Categories
Technology

JDBC Mount setup for WSO2 Registry

All WSO2 products are shipped with a built-in registry, supported by the H2 Database packaged with the product. Though it’s sufficient for many applications, its not recommended for Enterprise integration applications and Production environments.

 

In our case the ESB registry is mounted with WSO2 Governance Registry (GREG). The below steps can be used to change the ATOM based registry mount (default) with JDBC based mount.

The following example was implemented on the systems which had deployed resources and services, servicing other applications.

GREG

1. In GREG, replace WSO2_CARBON_DB in master-datasources.xml with JDBC details.

<datasource>
   <name>WSO2_CARBON_DB</name>
   <description>The datasource used for registry and user manager</description>
   <jndiConfig>
        <name>jdbc/WSO2CarbonDB</name>
   </jndiConfig>
   <definition type="RDBMS">
       <configuration>
           <url>jdbc:oracle:thin:@172.17.0.2:1521:XE</url>
           <username>USER</username>
           <password>USER1234</password>
           <driverClassName>oracle.jdbc.driver.OracleDriver</driverClassName>
           <maxActive>50</maxActive>
           <maxWait>60000</maxWait>
           <testOnBorrow>true</testOnBorrow>
           <validationQuery>SELECT 1</validationQuery>
           <validationInterval>30000</validationInterval>
        </configuration>
   </definition>
</datasource>

2. As we used a ORACLE Database, copy the driver ojdbc6.jar to the following path
<PRODUCT_HOME>/repository/components/lib/

3. Back up the .CAR files and configurations and packages

4. The following command will create the necessary tables on the target Datasource configured in the above step.


sh wso2server.sh -Dsetup

Validate the following

1. Tables and DB objects are created in the DB
2. Whether data is populated
3. Old resource content are also available
4. Existing CAR files got deployed successfully

Console:

ESB Console

 

User management

1. Existing user got updated in DB
2. Create a new user and the same should be populated in the DB

 

In ESB 4.9.0

1. Update the datasources XML

<PRODUCT_HOME>/repository/conf/datasource/master-datasources.xml

Add the following configuration
<datasource>
   <name>WSO2_CARBON_DB_GREG</name>
   <description>The datasource used for registry and user manager</description>
   <jndiConfig>
        <name>jdbc/WSO2CarbonDB_GREG</name>
   </jndiConfig>
   <definition type="RDBMS">
       <configuration>           <url>jdbc:oracle:thin:@172.17.0.2:1521:XE</url>           <username>USER</username>
           <password>USER1234</password>           <driverClassName>oracle.jdbc.driver.OracleDriver</driverClassName>           <maxActive>50</maxActive>
           <maxWait>60000</maxWait>           <testOnBorrow>true</testOnBorrow>
           <validationQuery>SELECT 1</validationQuery>           <validationInterval>30000</validationInterval>
        </configuration>
   </definition>
</datasource>

2. Update the registry configuration

<PRODUCT_ HOME>/repository/conf/registry.xml

<dbConfig name="remote_registry">      <dataSource>jdbc/WSO2CarbonDB_GREG</dataSource>
</dbConfig>

— Specify the remote Governance Registry instance —

<remoteInstance url="https://172.17.0.6:9443/registry">
    <id>instanceid</id>
    <dbConfig>remote_registry</dbConfig>
    <cacheId>USER@jdbc:oracle:thin:@172.17.0.2:1521:XE</cacheId>
    <readOnly>false</readOnly>
    <enableCache>false</enableCache>
    <registryRoot>/</registryRoot>
</remoteInstance>

Mount configuration

<mount path="/_system/governance" overwrite="true">        <instanceId>governanceRegistryInstance</instanceId>        <targetPath>/_system/governance</targetPath>    
</mount>

2. Copy the JDBC driver – ojdbc6.jar to /repository/components/lib/

3. Restart ESB

Validate the following

1. Logs have the successful mounting of remote registry

Registry logs

 

References:

https://docs.wso2.com/display/ESB490/Remote+Instance+and+Mount+Configuration+Details
https://docs.wso2.com/display/ESB490/Governance+Partition+in+a+Remote+Registry