Skip to main content

WSO2 AS worker/manager cluster with WSO2 ELB

This blog describes how to setup WSO2 Application Server worker/manager cluster with WSO2 Elastic Load Balancer.

WSO2 Elastic Load Balancer - 2.1.0
WSO2 Application Server - 5.2.1

1. Deployment Diagram


2. Configure the load balancer


1. Unzip the WSO2 ELB

2. Setting up the load balancing configuration
Edit “<ELB_HOME>/repository/conf/loadbalancer.conf” file


appserver {
       domains   {          
           wso2.as.domain {
               tenant_range    *;
group_mgt_port 4500;
      worker {
          hosts as.wso2.com;
      }   
mgt {
    hosts mgt.as.wso2.com;
}   
           }
       }
}


3. Setting up the cluster configurations
Edit “<ELB_HOME>/repository/conf/axis2/axis2.xml” file as follows


<clustering class="org.wso2.carbon.core.clustering.hazelcast.HazelcastClusteringAgent" enable="true">
<parameter name="membershipScheme">wka</parameter>
<parameter name="domain">wso2.carbon.lb.domain</parameter>
<parameter name="localMemberHost">127.0.0.1</parameter>
<parameter name="localMemberPort">4000</parameter>

4. Configuring the ELB to listen on default ports
Edit “<ELB_HOME>/repository/conf/axis2/axis2.xml” file as follows


<transportReceiver name="http" class="org.apache.synapse.transport.passthru.PassThroughHttpListener">
     <parameter name="port">80</parameter>
</transportReceiver>
<transportReceiver name="https" class="org.apache.synapse.transport.passthru.PassThroughHttpSSLListener">
       <parameter name="port" locked="false">443</parameter>
</transportReceiver>


5. Mapping the host names to the IP
Update the “/etc/hosts” file

<IP-of-worker>    as.wso2.com
<IP-of-manager>    mgt.as.wso2.com


3. Configure the manager node


1. Unzip the WSO2 AS

2. Setting up the cluster configurations
Edit “<AS_HOME>/repository/conf/axis2/axis2.xml” file as follows


<clustering class="org.wso2.carbon.core.clustering.hazelcast.HazelcastClusteringAgent" enable="true">
<parameter name="membershipScheme">wka</parameter>
<parameter name="domain">wso2.as.domain</parameter>
<parameter name="localMemberHost">mgt.as.wso2.com</parameter>
<parameter name="localMemberPort">4100</parameter>

*** Specify this node belongs to the management sub domain
<parameter name="properties">
<property name="backendServerURL" value="https://${hostName}:${httpsPort}/services/"/>
          <property name="mgtConsoleURL" value="https://${hostName}:${httpsPort}/"/>
          <property name="subDomain" value="mgt"/>
</parameter>

*** Specify the well known member
<members>
   <member>
         <hostName>127.0.0.1</hostName>
         <port>4500</port>        
   </member>
</members>

3. Configuring the port offset and host name
Edit “<AS_HOME>/repository/conf/carbon.xml” file as follows

<Offset>1</Offset>
<HostName>as.wso2.com</HostName>
<MgtHostName>mgt.as.wso2.org</MgtHostName>


4. Configure the HTTP/HTTPS proxy ports to communicate through the load balancer
Edit “<AS_HOME>/repository/conf/tomcat/catalina-server.xml” file as follows


<Connector  protocol="org.apache.coyote.http11.Http11NioProtocol"
               port="9763"
               proxyPort="80"

<Connector  protocol="org.apache.coyote.http11.Http11NioProtocol"
               port="9443"
               proxyPort="443"


4. Configure the worker node


1. Unzip the WSO2 AS

2. Setting up the cluster configurations
Edit “<AS_HOME>/repository/conf/axis2/axis2.xml” file as follows


<clustering class="org.wso2.carbon.core.clustering.hazelcast.HazelcastClusteringAgent" enable="true">
<parameter name="membershipScheme">wka</parameter>
<parameter name="domain">wso2.as.domain</parameter>
<parameter name="localMemberHost">as.wso2.com</parameter>
<parameter name="localMemberPort">4200</parameter>
*** Specify this node belongs to the management sub domain
<parameter name="properties">
<property name="backendServerURL" value="https://${hostName}:${httpsPort}/services/"/>
          <property name="mgtConsoleURL" value="https://${hostName}:${httpsPort}/"/>
          <property name="subDomain" value="worker"/>
</parameter>

*** Specify the well known member
<members>
   <member>
         <hostName>127.0.0.1</hostName>
         <port>4500</port>        
   </member>
</members>

3. Configuring the port offset and host name
Edit “<AS_HOME>/repository/conf/carbon.xml” file as follows

<Offset>2</Offset>
<HostName>as.wso2.com</HostName>

4. Configure the HTTP/HTTPS proxy ports to communicate through the load balancer
Edit “<AS_HOME>/repository/conf/tomcat/catalina-server.xml” file as follows

<Connector  protocol="org.apache.coyote.http11.Http11NioProtocol"
               port="9763"
               proxyPort="80"

<Connector  protocol="org.apache.coyote.http11.Http11NioProtocol"
               port="9443"
               proxyPort="443"


5. Create the worker2 node
Get a copy of worker1 node and change the following

<parameter name="localMemberPort">4300</parameter>
<Offset>3</Offset>


5. Testing the cluster


1. Start the ELB
sudo <ELB_HOME>/bin/wso2server.sh

2. Start the manager node
sudo <AS_HOME>/bin/wso2server.sh

3. Start the worker1 and worker2 nodes
sudo <AS_HOME>/bin/wso2server.sh -DworkerNode=true

4. Check member joined messages in all consoles

5. Access management console https://mgt.as.wso2.com/carbon

6. Test load distribution - create jaggery app to log a message - http://as.wso2.com/sample





Comments

Popular posts from this blog

Create Application in WSO2 App Cloud via REST API

This blog post gives you some examples on how to use createApplication REST API correctly in WSO2 App Cloud  https://docs.wso2.com/display/AppCloud/Published+APIs Before invoke createApplication API, you need to login to the WSO2 App Cloud and get the session cookie. curl -c cookies -v -k -X POST -k https://apps.cloud.wso2.com/appmgt/site/blocks/user/login/ajax/login.jag -d 'action=login&userName=amalka.wso2.com@<tenant>&password=<password>’ This are some basic example to create applications in WSO2 App Cloud. Create application via upload from file system curl -v -k -b cookies -X POST https://apps.cloud.wso2.com/appmgt/site/blocks/application/application.jag -F action=createApplication -F applicationName=SampleFile -F applicationDescription=desc -F runtime=1 -F appTypeName=war -F applicationRevision=1.0.0 -F uploadedFileName=sample.war -F runtimeProperties=[] -F tags=[]  -F fileupload=@/home/amalka/Downloads/sample.war -F isFileAttached=t...

Send email via WSO2 ESB with several attachments

WSO2 ESB Mail transport allows you to send a email only with 1 attachment. If you want to send number of attachments here's the solution. Scenario: Here I want to extract some content from the input message and attach to the email as two different attachment. Solution:  You can achieve this requirement using Gmail connector. Steps:  Add the Gmail connector to the ESB and enable it. You can download the esb connector here https://storepreview.wso2.com/store/assets/esbconnector/a1fba975-89fb-4bb0-a1b9-9f9d061fb31c Add it to the ESB and enable it https://docs.wso2.com/display/ESB481/Managing+Connectors+in+Your+ESB+Instance Gmail connector documentation https://docs.wso2.com/display/ESBCONNECTORS/Gmail+Connector Setup the scenario: split the input message and send it with an email using two different attachments. Input message I used <email>         <username>sender@gmail.com<...

How to generate random unique number in SOAP UI request

eg 1: ${=System.currentTimeMillis() + ((int)(Math.random()*10000))} eg 2: ${=java.util.UUID.randomUUID()} ${=java.util.UUID.randomUUID()} ${=System.currentTimeMillis() + ((int)(Math.random()*10000))} - See more at: http://tryitnw.blogspot.com/2014/03/generating-random-unique-number-in-soap.html#sthash.m2S4tUFu.dpuf ${=System.currentTimeMillis() + ((int)(Math.random()*10000))} - See more at: http://tryitnw.blogspot.com/2014/03/generating-random-unique-number-in-soap.html#sthash.m2S4tUFu.dpuf ${=System.currentTimeMillis() + ((int)(Math.random()*10000))} - See more at: http://tryitnw.blogspot.com/2014/03/generating-random-unique-number-in-soap.html#sthash.m2S4tUFu.dpuf