Tuesday, July 6, 2010

Making the resources of a WSO2 ESB READ-WRITE node available in the READ-ONLY node of a cluster

If you have a cluster of WSO2 ESB nodes and if you need to make the resources of the READ_WRITE node available on the READ-ONLY nodes all you have to do is set up a property in the carbon.xml. For the WSO2 ESB instances to be in a cluster, you need to have a WSO2 Governance Registry instance as well since in 3.0.x family, the resource that are created in WSO2 ESB are saved to a configuration/governance registry. In order to witness this, following steps should be followed.

Step 1 - Setting up the governance and configuration registry instances

a) Download the latest WSO2 Governance Registry distribution from here.

b) Extract the downloaded WSO2 Governance Registry distribution to two separate directories.
E.g.: - Extract the distribution to a folder named config-reg and gov-reg

c) Change the http/https ports (of the mgt-transports.xml) of these two instances so that it is possible for you to start the two registry instances on the same machine.

E.g. :- Assume that the ports were configured as below
Governance registry
- HTTP port - 9763
- HTTPS port - 9443
Configuration registry
- HTTP port - 9764
- HTTPS port - 9444


d) Change the registry.xml files of the governance and configuration registries as follows to connect to an external database (Let us assume that the two registry instances will be connected to two separate MySQL databases)

i) Add the following dbConfig to the registry.xml of the governance registry instance (gov-reg)

<dbconfig name="gov_registry">
<url>jdbc:mysql://localhost:3306/reg_gov_db</url>
<username>wso2</username>
<password>wso2</password>
<drivername>com.mysql.jdbc.Driver</drivername>
<maxactive>50</maxactive>
<maxwait>60000</maxwait>
<minidle>5</minidle>
</dbconfig>


ii) Add the following two dbConfig configurations to the registry.xml of the configuration registry instance (config-reg)

<dbconfig name="config_registry">
<url>jdbc:mysql://10.100.1.153:3306/reg_config_db</url>
<username>wso2</username>
<password>wso2</password>
<drivername>com.mysql.jdbc.Driver</drivername>
<maxactive>50</maxactive>
<maxwait>60000</maxwait>
<minidle>5</minidle>
</dbconfig>

<dbconfig name="gov_registry">
<url>jdbc:mysql://localhost:3306/reg_gov_db</url>
<username>wso2</username>
<password>wso2</password>
<drivername>com.mysql.jdbc.Driver</drivername>
<maxactive>50</maxactive>
<maxwait>60000</maxwait>
<minidle>5</minidle>
</dbconfig>


iii) In addition to the above add the following configuration to the registry.xml of the configuration registry (config-reg). This configuration will be used to mount the governance registry instance to this particular configuration registry instance.

<remoteinstance url="">:9443/gov/registry">
<id>gov_reg</id>
<dbconfig>gov_registry</dbconfig>
<readonly>false</readonly>
<registryroot>/</registryroot>
</remoteinstance>

<mount path="/_system/governance" overwrite="true">
<instanceid>gov_reg</instanceid>
<targetpath>/_system/governance</targetpath>
</mount>

e) Once the above configration are done, start the governance registry instance and the configuration registry instances

Step 2 - Setting up the WSO2 ESB READ-WRITE instance

a) Download the latest WSO2 ESB instance from here and extract it to a folder of your choice.
E.g. - Extract the distribution to a folder named esb-rw

b) Change the ports of the WSO2 ESB instance

E.g. :- Assume that the ports were configured as below
- HTTP port - 9761
- HTTPS port - 9441


c) Leave the default dbConfig section as it is and add the following to the registry.xml file.

<dbconfig name="config_registry">
<url>jdbc:mysql://localhost:3306/reg_config_db</url>
<username>wso2</username>
<password>wso2</password>
<drivername>com.mysql.jdbc.Driver</drivername>
<maxactive>50</maxactive>
<maxwait>60000</maxwait>
<minidle>5</minidle>
</dbconfig>

<dbconfig name="gov_registry">
<url>jdbc:mysql://localhost:3306/reg_gov_db</url>
<username>wso2</username>
<password>wso2</password>
<drivername>com.mysql.jdbc.Driver</drivername>
<maxactive>50</maxactive>
<maxwait>60000</maxwait>
<minidle>5</minidle>
</dbconfig>


d) Additionally, add the following configuration to the registry.xml inorder to mount the governance and configuration registries to the WSO2 ESB READ-WRITE instance

<remoteinstance url="https://localhost:9444/config/registry">
<id>config_reg</id>
<dbconfig>config_registry</dbconfig>
<readonly>false</readonly>
<registryroot>/</registryroot>
</remoteinstance>

<mount path="/_system/governance" overwrite="true">
<instanceid>gov_reg</instanceid>
<targetpath>/_system/governance</targetpath>
</mount>

<mount path="/_system/config" overwrite="true">
<instanceid>config_reg</instanceid>
<targetpath>/_system/nodes</targetpath>
</mount>

<remoteinstance url="https://localhost:9443/gov/registry">
<id>gov_reg</id>
<dbconfig>gov_registry</dbconfig>
<readonly>false</readonly>
<registryroot>/</registryroot>
</remoteinstance>


e) Next, enable clustering by uncommenting the following section of the axis2.xml

<clustering class="org.apache.axis2.clustering.tribes.TribesClusteringAgent" enable="true">
:
:
</clustering>


Step 3 - Setting up the WSO2 ESB READ-ONLY instance

a) Extract the downloaded WSO2 ESB instance to another folder of your choice.
E.g. - Extract the distribution to a folder named esb-ro

b) Change the ports of the WSO2 ESB instance

E.g. :- Assume that the ports were configured as below
- HTTP port - 9762
- HTTPS port - 9443

c) Leave the default dbConfig section as it is and add the following to the registry.xml file.

<dbconfig name="config_registry">
<url>jdbc:mysql://localhost:3306/reg_config_db</url>
<username>wso2</username>
<password>wso2</password>
<drivername>com.mysql.jdbc.Driver</drivername>
<maxactive>50</maxactive>
<maxwait>60000</maxwait>
<minidle>5</minidle>
</dbconfig>

<dbconfig name="gov_registry">
<url>jdbc:mysql://localhost:3306/reg_gov_db</url>
<username>wso2</username>
<password>wso2</password>
<drivername>com.mysql.jdbc.Driver</drivername>
<maxactive>50</maxactive>
<maxwait>60000</maxwait>
<minidle>5</minidle>
</dbconfig>


d) Additionally, add the following configuration to the registry.xml inorder to mount the governance and configuration registries to the WSO2 ESB READ-WRITE instance

<remoteinstance url="https://localhost:9444/config/registry">
<id>config_reg</id>
<dbconfig>config_registry</dbconfig>
<readonly>true</readonly>
<registryroot>/</registryroot>
</remoteinstance>

<mount path="/_system/governance" overwrite="true">
<instanceid>gov_reg</instanceid>
<targetpath>/_system/governance</targetpath>
</mount>

<mount path="/_system/config" overwrite="true">
<instanceid>config_reg</instanceid>
<targetpath>/_system/nodes</targetpath>
</mount>

<remoteinstance url="https://localhost:9443/gov/registry">
<id>gov_reg</id>
<dbconfig>gov_registry</dbconfig>
<readonly>true</readonly>
<registryroot>/</registryroot>
</remoteinstance>


e) Next, enable clustering by uncommenting the following section of the axis2.xml (This is required ONLY in a state-full setup)

<clustering class="org.apache.axis2.clustering.tribes.TribesClusteringAgent" enable="true">
:
:
</clustering>


f) Inorder for the resources that are in the READ-WRITE instance to be available in the READ-ONLY node, the following configuration should be added to the carbon.xml

<mediationconfig>
<loadfromregistry>true</loadfromregistry>
</mediationconfig>


Step 4 - Creating resources in the READ-WRITE instance

Once the configuration are properly done, start the READ-WRITE WSO2 ESB instance.

user@user-laptop:~/opt/esbrw/wso2esb-3.0.0/bin $ sh ./wso2server.sh


Now create some resources (Sequences, Endpoints, Proxy Services,etc) by logging into the Management Console

Step 5 - Witnessing the resources of the READ-WRITE instance in the READ-ONLY node

Finally, start the READ-ONLY instance and you will see the resources that were created through the READ-WRITE available through the READ-ONLY node

user@user-laptop:~/opt/esbr0/wso2esb-3.0.0/bin $ sh ./wso2server.sh

2 comments:

Unknown said...

Hi, thanks for this great article.
Is it possible to add those resources (Sequences, Endpoints, Proxy Services,etc) to GREG instead of ESB. And allow the ESB to read form the GREG.
Thanks

Evanthika said...

Hi,

Yes. This is possible. Once you have mounted your ESB instance to G-Reg correctly, you should be able to access the resources which you upload to G-Reg through ESB. However, you can do this with resources such as Sequences and Endpoints only.

Regards,
Evanthika