Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Mount WSO2 products to a remote WSO2 Governance Registry instance(MsSQL 2012)

DZone's Guide to

Mount WSO2 products to a remote WSO2 Governance Registry instance(MsSQL 2012)

· Cloud Zone
Free Resource

Download this eBook outlining the critical components of success for SaaS companies - and the new rules you need to play by.  Brought to you in partnership with NuoDB.

In this post we are going to mount wso2 products into a remote governance registry. In the default scenario wso2 governance registry is pointed to a local h2 database.

First lets configure the governance registry instance to point to the MsSQL data source.
  • Download WSO2 Governance Registry product and extract the product.
  • Go to /repository/conf/datasources  and open master-datasources.xml
  • Then change the following entries in the WSO2CARBON data source.
    <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:sqlserver://127.0.0.1:1433;databaseName=REMOTEDB</url>
                        <username>sa</username>
                        <password>pass#word2</password>
                        <driverClassName>com.microsoft.sqlserver.jdbc.SQLServerDriver</driverClassName>
                        <maxActive>50</maxActive>
                        <maxWait>60000</maxWait>
                        <testOnBorrow>true</testOnBorrow>
                        <validationQuery>SELECT 1</validationQuery>
                        <validationInterval>30000</validationInterval>
                    </configuration>
                </definition>
    </datasource>
  • Fill the url, username, password according to your MsSQL Instance.
  • Log into the MSSQL 2012 Management studio and create a database called REMOTEDB
  • Then move to the /repository/components/lib folder in the extracted greg product folder and copy the downloaded MsSQL JDBC Connector. You can download the sqljdbc driver from this link. Download
  • Then Start the WSO2 governance product with the -Dsetup option. (-Dsetup option will populate the new schemas in the newly pointed MsSQL REMOTEDB)
    D:\blog\wso2greg-4.6.0\bin>wso2server.bat -Dsetup

 Now lets mount a WSO2 product to this remote registry. 

  • Let's use WSO2 API Manager for this example post. First Download the product and extract it to your hard drive.
  • Go to /repository/conf/datasources folder and open the master-datasources.xml file
  • Then add a new data source as follows. For the demonstration purpose lets name the new datasource as WSO2_CARBON_DB2.
    <datasource>
                <name>WSO2_CARBON_DB2</name>
                <description>The datasource used for registry and user manager</description>
                <jndiConfig>
                    <name>jdbc/WSO2CarbonDB2</name>
                </jndiConfig>
                <definition type="RDBMS">
                    <configuration>
                        <url>jdbc:sqlserver://127.0.0.1:1433;databaseName=REMOTEDB</url>
                        <username>sa</username>
                        <password>pass#word2</password>
                        <driverClassName>com.microsoft.sqlserver.jdbc.SQLServerDriver</driverClassName>
                        <maxActive>50</maxActive>
                        <maxWait>60000</maxWait>
                        <testOnBorrow>true</testOnBorrow>
                        <validationQuery>SELECT 1</validationQuery>
                        <validationInterval>30000</validationInterval>
                    </configuration>
                </definition>
    </datasource>
  • Note that this datasource is a completely new entry and let the default config reamins as it is.
  • Now as we did in WSO2 governance product copy the saljdbc driver to the /repository/components/lib folder
  • No open up the /repository/conf registry.xml file in the WSO2 API Manager product and do the following changes.
  •  Add a new dbConfig as follows
    <dbConfig name="remoteRegistry">
           <dataSource>jdbc/WSO2CarbonDB2</dataSource>
    </dbConfig>
  • Note that the dataSource is set to the jndiConfig name which we used in the new datasource defined in the API Manager's master-datasources.xml
  • Now find the following configuration, uncomment it and change it to the following config values.
    <remoteInstance url="https://localhost:9443/registry">
            <id>apimanager</id>
            <dbConfig>remoteRegistry</dbConfig>
            <readOnly>false</readOnly>
            <enableCache>true</enableCache>
            <registryRoot>/</registryRoot>
    </remoteInstance>
  • Note that the dbConfig name is set to the newly added dbConfig name, which is "remoteRegistry" in this example. Give a unique id value.
  • Then we set the remote mounted path using the following configuration.
    <mount path="/_system/config" overwrite="true">
            <instanceId>apimanager</instanceId>
            <targetPath>/_system/amnode</targetPath>
    </mount>
  • This configuration is comment by default and you have to uncomment and provide the relevant values. Note that the instanceID value is same as the id value in remoteInstance configuration.
  • The target path is set to /_system/amnode if you are using several API Manager nodes you can set all to the same path. If it is a different product it is recommend to use a different path for example ESB node path would be /_system/esbnode
  • /_system/config is the path which the product is going to be mounted.
  • Now finally if you have followed the above steps correctly start the API Manager with some port Offset if the product is running in the same machine.
    D:\blog\wso2am-1.6.0\bin>wso2server.bat -DportOffset=100
    
  • Now log into the API Manager Web UI using the following URL https://192.168.1.2:9543/carbon/
  • If you browse the resource can see the remotely mounted /_system/config registry.
API Manager Resource view
That's it for now. Feel free to shore your thoughts about the post. :)


Learn how moving from a traditional, on-premises delivery model to a cloud-based, software-as-a-service (SaaS) strategy is a high-stakes, bet-the-company game for independent software vendors. Brought to you in partnership with NuoDB.

Topics:

Published at DZone with permission of Aruna Karunarathna, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}