...
Download and install MySQL Server.
Download the MySQL JDBC driver.
Unzip the downloaded MySQL driver zipped archive, and copy the MySQL JDBC driver JAR (
mysql-connector-java-x.x.xx-bin.jar
) into the<PRODUCT_HOME>/repository/components/lib
directory of both the manager and worker nodes.- Define the host name for configuring permissions for the new database by opening the
/etc/hosts
file and adding the following line:<MYSQL-DB-SERVER-IP> carbondb.mysql-wso2.com
Info You would do this step only if your database is not on your local machine and on a separate server.
- Enter the following command in a terminal/command window, where
username
is the username you want to use to access the databases:mysql -u username -p
- When prompted, specify the password that will be used to access the databases with the username you specified.
Create the databases using the following commands, where
<PRODUCT_HOME>
is the path to any of the product instances you installed, andusername
andpassword
are the same as those you specified in the previous steps:
Configure the data sources for both nodes so that they point to the respective databases.Code Block language none mysql> create database WSO2_USER_DB; mysql> use WSO2_USER_DB; mysql> source <PRODUCT_HOME>/dbscripts/mysql.sql; mysql> grant all on WSO2_USER_DB.* TO regadmin@"carbondb.mysql-wso2.com" identified by "regadmin"; mysql> create database REGISTRY_DB; mysql> use REGISTRY_DB; mysql> source <PRODUCT_HOME>/dbscripts/mysql.sql; mysql> grant all on REGISTRY_DB.* TO regadmin@"carbondb.mysql-wso2.com" identified by "regadmin"; mysql> create database REGISTRY_LOCAL1; mysql> use REGISTRY_LOCAL1; mysql> source <PRODUCT_HOME>/dbscripts/mysql.sql; mysql> grant all on REGISTRY_LOCAL1.* TO regadmin@"carbondb.mysql-wso2.com" identified by "regadmin"; mysql> create database REGISTRY_LOCAL2; mysql> use REGISTRY_LOCAL2; mysql> source <PRODUCT_HOME>/dbscripts/mysql.sql; mysql> grant all on REGISTRY_LOCAL2.* TO regadmin@"carbondb.mysql-wso2.com" identified by "regadmin";
Configuring the manager node
Note |
---|
You do not have to do these configurations if you are not including the manager node in your cluster. This is the case in clustering deployment pattern 3. |
On the manager node, open
<PRODUCT_HOME>/repository/conf/datasources/master-datasource.xml
and configure the data sources to point to theREGISTRY_LOCAL1
,WSO2_REGISTRY_DB
, andWSO2_USER_DB
databases as follows (change the username, password, and database URL as needed for your environment):Code Block language html/xml <datasources-configuration xmlns:svns="http://org.wso2.securevault/configuration"> <providers> <provider>org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader</provider> </providers> <datasources> <datasource> <name>REGISTRY_LOCAL1</name> <description>The datasource used for registry- local</description> <jndiConfig> <name>jdbc/WSO2CarbonDB</name> </jndiConfig> <definition type="RDBMS"> <configuration> <url>jdbc:mysql://carbondb.mysql-wso2.com:3306/REGISTRY_LOCAL1?autoReconnect=true</url> <username>regadmin</username> <password>regadmin</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> <datasource> <name>REGISTRY_DB</name> <description>The datasource used for registry- config/governance</description> <jndiConfig> <name>jdbc/WSO2RegistryDB</name> </jndiConfig> <definition type="RDBMS"> <configuration> <url>jdbc:mysql://carbondb.mysql-wso2.com:3306/REGISTRY_DB?autoReconnect=true</url> <username>regadmin</username> <password>regadmin</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> <datasource> <name>WSO2_USER_DB</name> <description>The datasource used for registry and user manager</description> <jndiConfig> <name>jdbc/WSO2UMDB</name> </jndiConfig> <definition type="RDBMS"> <configuration> <url>jdbc:mysql://carbondb.mysql-wso2.com:3306/WSO2_USER_DB</url> <username>regadmin</username> <password>regadmin</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> </datasources> </datasources-configuration>
Info Make sure to replace
username
andpassword
with your MySQL database username and password.- Repeat this configuration on the worker node, this time configuring the local registry to point to
REGISTRY_LOCAL2
To configure the datasource, update the
dataSource
property found in<PRODUCT_HOME>/repository/conf/user-mgt.xml
of the manager node as shown below:
<datasources-configuration xmlns:svns="http://org.wso2.securevault/configuration"> <providers> <provider>org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader</provider> </providers> <datasources> <datasource> <name>REGISTRY_LOCAL2</name> <description>The datasource used for registry- local</description> <jndiConfig> <name>jdbc/WSO2CarbonDB</name> </jndiConfig> <definition type="RDBMS"> <configuration> <url>jdbc:mysql://carbondb.mysql-wso2.com:3306/REGISTRY_LOCAL2?autoReconnect=true</url> <username>regadmin</username> <password>regadmin</password> <driverClassName>com.mysql.jdbc.Driver</driverClassName> <maxActive>50</maxActive> <maxWait>60000</maxWait> <testOnBorrow>true</testOnBorrow> <validationQuery>SELECT 1</validationQuery>Code Block language html/xml <Property name="dataSource">jdbc/WSO2UMDB</Property>
Configure the shared registry database and mounting details in
<PRODUCT_HOME>/
repository/conf/registry.xml
of the manager node as shown below:Code Block language html/xml <dbConfig name="sharedregistry"> <dataSource>jdbc/WSO2RegistryDB</dataSource> </dbConfig> <remoteInstance url="https://localhost:9443/registry"> <id>instanceid</id> <dbConfig>sharedregistry</dbConfig> <readOnly>false</readOnly> <enableCache>true</enableCache> <registryRoot>/</registryRoot> <cacheId>REGISTRY_DB@jdbc:mysql://carbondb.mysql-wso2.com:3306/REGISTRY_LOCAL1?autoReconnect=true</cacheId> </remoteInstance> <mount path="/_system/config" overwrite="true"> <instanceId>instanceid</instanceId> <targetPath>/_system/asNodes</targetPath> </mount> <mount path="/_system/governance" overwrite="true"> <instanceId>instanceid</instanceId> <targetPath>/_system/governance</targetPath> </mount>
The following are some key points to note when adding these configurations:
- The registry
mount path
is used to identify the type of registry. For example, ”/_system/config
” refers to configuration registry and "/_system/governance
" refers to the governance registry. - This configuration enables you to identify the data source you configured in the master-datasources.xml file using the
dbConfig
entry and we give a unique name to refer to that datasource entry which is “sharedregistry
”. - The
remoteInstance
section refers to an external registry mount. We can specify the read-only/read-write nature of this instance as well as caching configurations and the registry root location. In case of a worker node thereadOnly
property should betrue
and in case of a manager node, this property should be set tofalse
. - Additionally we need to specify
cacheId
for caching to function properly in the clustered environment. Note thatcacheId
is same as the JDBC connection URL to our registry database. This value is thecacheId
of the remote instance. Here thecacheId
should be in the format of $database_username@$database_url, where $database_username is the username of the remote instance database and $database_url is the remote instance database URL. ThiscacheID
is used to identify the cache it should look for when caching is enabled. In this case, the database we should connect to is WSO2CARBON_DB. - You need to define a unique name “id” for each remote instance which is then referred from mount configurations. In the above example, the unique id for the remote instance is
instanceId
. - In each of the mounting configurations, we specify the actual mount path and target mount path. The
targetPath
can be any meaningful name. In this instance it is/_system/asNodes
.
- The registry
Configuring the worker node
On the worker node, open
<PRODUCT_HOME>/repository/conf/datasources/master-datasource.xml
and configure the data sources to point to theREGISTRY_LOCAL2
,WSO2_REGISTRY_DB
, andWSO2_USER_DB
databases as follows (change the username, password, and database URL as needed for your environment):Code Block language html/xml <datasources-configuration xmlns:svns="http://org.wso2.securevault/configuration"> <providers> <provider>org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader</provider> </providers> <datasources> <datasource> <name>REGISTRY_LOCAL2</name>
...
<description>The datasource used for registry- local</description>
...
<jndiConfig>
...
...
<name>jdbc/WSO2CarbonDB</name>
...
</jndiConfig>
...
...
<definition type="RDBMS">
...
...
...
...
...
...
<configuration>
...
...
<url>jdbc:mysql://carbondb.mysql-wso2.com:3306/REGISTRY_LOCAL2?autoReconnect=true</url>
...
<username>regadmin</username>
...
...
<password>regadmin</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>
...
...
<datasource>
...
<name>REGISTRY_DB</name> <description>The datasource used for registry-
...
config/governance</
...
description>
...
<jndiConfig>
...
<name>jdbc/WSO2RegistryDB</name>
...
</jndiConfig>
...
<definition type="RDBMS">
...
...
...
...
...
...
...
...
<configuration>
...
...
<url>jdbc:mysql://carbondb.mysql-wso2.com:3306/REGISTRY_DB?autoReconnect=true</url>
...
...
<username>regadmin</username>
...
...
<password>regadmin</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>
...
...
<datasource>
...
<name>WSO2_USER_DB</name> <description>The datasource used
...
for registry and user manager</description> <jndiConfig>
...
...
<name>jdbc/WSO2UMDB</name> </
...
Info |
---|
Make sure to replace |
...
To configure the datasource, update the dataSource
property found in <PRODUCT_HOME>/repository/conf/user-mgt.xml
of the manager node as shown below:
Code Block | ||
---|---|---|
| ||
<Property name="dataSource">jdbc/WSO2UMDB</Property> |
...
Configure the shared registry database and mounting details in <PRODUCT_HOME>/
repository/conf/registry.xml
of the manager node as shown below:
Code Block | ||
---|---|---|
| ||
<dbConfig name="sharedregistry">
<dataSource>jdbc/WSO2RegistryDB</dataSource>
</dbConfig>
<remoteInstance url="https://localhost:9443/registry">
<id>instanceid</id>
<dbConfig>sharedregistry</dbConfig>
<readOnly>false</readOnly>
<enableCache>true</enableCache>
<registryRoot>/</registryRoot>
<cacheId>REGISTRY_DB@jdbc:mysql://carbondb.mysql-wso2.com:3306/REGISTRY_LOCAL1?autoReconnect=true</cacheId>
</remoteInstance>
<mount path="/_system/config" overwrite="true">
<instanceId>instanceid</instanceId>
<targetPath>/_system/asNodes</targetPath>
</mount>
<mount path="/_system/governance" overwrite="true">
<instanceId>instanceid</instanceId>
<targetPath>/_system/governance</targetPath>
</mount> |
The following are some key points to note when adding these configurations:
- The registry
mount path
is used to identify the type of registry. For example, ”/_system/config
” refers to configuration registry and "/_system/governance
" refers to the governance registry. - This configuration enables you to identify the data source you configured in the master-datasources.xml file using the
dbConfig
entry and we give a unique name to refer to that datasource entry which is “sharedregistry
”. - The
remoteInstance
section refers to an external registry mount. We can specify the read-only/read-write nature of this instance as well as caching configurations and the registry root location. In case of a worker node thereadOnly
property should betrue
and in case of a manager node, this property should be set tofalse
. - Additionally we need to specify
cacheId
for caching to function properly in the clustered environment. Note thatcacheId
is same as the JDBC connection URL to our registry database. This value is thecacheId
of the remote instance. Here thecacheId
should be in the format of $database_username@$database_url, where $database_username is the username of the remote instance database and $database_url is the remote instance database URL. ThiscacheID
is used to identify the cache it should look for when caching is enabled. In this case, the database we should connect to is WSO2CARBON_DB. - You need to define a unique name “id” for each remote instance which is then referred from mount configurations. In the above example, the unique id for the remote instance is
instanceId
. In each of the mounting configurations, we specify the actual mount path and target mount path. The jndiConfig> <definition type="RDBMS"> <configuration> <url>jdbc:mysql://carbondb.mysql-wso2.com:3306/WSO2_USER_DB</url> <username>regadmin</username> <password>regadmin</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> </datasources> </datasources-configuration>
Info Make sure to replace
username
andpassword
with your MySQL database username and password.
targetPath
can be any meaningful name. In this instance it is /_system/asNodes
Now your database is set up. The next step is to configure the manager and worker node.
...