Monday, August 8, 2016

How to Mount and Share Registry Between WSO2 Servers.

Most of the WSO2 products have embedded registry to that product which store data and persisting configuration. The Registry space provided to each product contains three major partitions.

  • Local Repository : Contains system configuration and runtime data that is local to the single instance of a product. This partition is not to be shared with multiple servers and can be browsed under /_system/local in the registry browser.
  • Configuration Repository : Contains product specific configuration. This partition can be shared across multiple instances of the same product and can be browsed under /_system/config in the registry browser.
  • Governance Repository :  Contains data and configuration shared across the platform. This partition can be made use of by multiple instances of various Carbon based products and can be can be browsed under /_system/governance in the registry browser.
We can mount registry between WSO2 carbon servers. Here I'm going to explain using WSO2 App Manager and WSO2 Identity Server.
  1. Create new database called APPM_REG_DB in MYSQL server
  2. Create tables inside the created database by executing the script in <APPM_HOME>/dbscripts/mysql.sql
  3. If App Manager and Identity Server are running on the same machine, follow this step.
  4. Set Offset value to 1 in /repository/conf/carbon.xml.
       
       <Offset>1</Offset>  
       
    
  5. Specify the datasource definition like below in the <APPM_HOME>/repository/conf/datasources/master-datasources.xml to connect early created APPM_REG_DB database to mount registry.
  6.    
       <datasource>   
         <name>WSO2REG_DB</name>   
         <description>The datasource used for registry database</description>   
         <jndiConfig>   
           <name>jdbc/WSO2REG_DB</name>   
         </jndiConfig>   
         <definition type="RDBMS">   
           <configuration>   
             <url>jdbc:mysql://localhost:3306/APPM_REG_DB</url>   
             <username>username</username>   
             <password>password</password>   
             <driverClassName>com.mysql.jdbc.Driver</driverClassName>   
             <maxActive>50</maxActive>   
             <maxWait>60000</maxWait>   
             <testOnBorrow>true</testOnBorrow>   
             <validationQuery>SELECT 1</validationQuery>   
             <validationInterval>30000</validationInterval>   
           </configuration>   
         </definition>   
       </datasource>  
       
    
  7. Add the same datasource configuration to <IS_HOME>/repository/conf/datasources/master-datasources.xml.
  8. Copy the database driver to both <IS_HOME>/repository/components/lib and <AppM_HOME>/repository/components/lib directories.
  9. Create the registry mounts by inserting the following sections to both <APPM_HOME>/repository/conf/registry.xml and <IS_HOME>/repository/conf/registry.xml file. Remember to not to replace the existing <dbConfig name="wso2registry">. Just add below configuration to the existing configuration.
  10.    
       <dbConfig name="govregistry">  
         <dataSource>jdbc/WSO2REG_DB</dataSource>  
       </dbConfig>  
        
       <remoteInstance url="https://localhost">    
         <id>gov</id>  
         <dbConfig>govregistry</dbConfig>  
         <readOnly>false</readOnly>  
         <enableCache>true</enableCache>  
         <registryRoot>/</registryRoot>  
       </remoteInstance>  
        
       <mount path="/_system/governance" overwrite="true">  
         <instanceId>gov</instanceId>  
         <targetPath>/_system/governance</targetPath>  
       </mount>  
        
       <mount path="/_system/config" overwrite="true">  
         <instanceId>gov</instanceId>  
         <targetPath>/_system/config</targetPath>  
       </mount>  
       
    
  11. Restart both server.
  12. That's all. Now both servers should see the same configs and governance registries.
  13. To confirm everything was successful, go to Home > Resources > Browse from management console. You can see "config" and "governance" repositories with an arrow as in below image.

No comments:

Post a Comment