Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Oracle Real Application Clusters (RAC) is an option for the Oracle Database for clustering and high availability in Oracle database environments. In the Oracle RAC environment, some of the commands used in oracle.sql are considered inefficient. Therefore, the product has a separate SQL script oracle_rac.sql for Oracle RAC. The Oracle RAC-friendly script is located in the dbscripts folder together with other .sql scripts.

Info

To test products on Oracle RAC, rename oracle_rac.sql to oracle.sql before running -Dsetup.

The following sections describe how to replace the default H2 databases with Oracle RAC:

Table of Contents
maxLevel3
styleborder:1locationtopseparatorpipe

Creating the database

Follow the steps below to set up an Oracle RAC database:

Setting up the database user

...

Create a database user and grant privileges to the user as shown below:

Code Block
languagepowershell
Create user USER_NAME identified by PASSWORD account unlock;
grant connect to USER_NAME;
grant create session, dba to USER_NAME;
commit;

...

Copying the JDBC driver

Copy the Oracle JDBC libraries (for example, the <ORACLE_HOME>/jdbc/lib/ojdbc14.jar file) to the <PRODUCT_HOME>/repository/components/lib/ directory. 

Info

Remove the old database driver from the <PRODUCT_HOME>/repository/components/dropins/ directory when you upgrade the database driver.

Creating the database tables

Create the database tables either manually by running a script or automatically by using a startup parameter as described below.

Using a script

You can create database tables manually by logging in to the created database and executing the following script in SQL*Plus:

...

  • To create tables for the registry and user manager database, run the below command:

    Code Block
    languagepowershell
    SQL> @$<PRODUCT_HOME>/dbscripts/oracle.sql
  • To create tables for the  identity database, run the below command:

    Code Block
    languagepowershell
    SQL> @$<PRODUCT_HOME>/dbscripts/identity/oracle.sql
  • To create tables for the  storage database, run the below command:

    Code Block
    languagepowershell
    SQL> @$<PRODUCT_HOME>/dbscripts/storage/oracle.sql

...

$ ./${PRODUCT_HOME}/bin/wso2server.sh
Using a startup parameter

You can create database tables automatically when starting the product for the first time by using the -Dsetup parameter as follows:

When starting the product for the first time, use the following commands to create the database tables:

  • For Windows users:
    $PRODUCT_HOME/bin/wso2server.bat -Dsetup
  • For Linux Users
    $ ./${PRODUCT_HOME}/bin/wso2server.sh -Dsetup

Creating a datasource for the database

After creating the database, you create a datasource to point to it in the following files:

...

Edit the default database configuration defined in the  master-datasources.xml file located in the <PRODUCT_HOME>/repository/conf/datasources/ directory as follows. The database configurations in both registry.xml and user-mgt.xml refer to this data source.

Info

Replace these settings with your own custom values:

Code Block
languagexml
<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:@(DESCRIPTION=(LOAD_BALANCE=on)
   			       (ADDRESS=(PROTOCOL=TCP)(HOST=racnode1) (PORT=1521))
   			       (ADDRESS=(PROTOCOL=TCP)(HOST=racnode2) (PORT=1521))
   			       (CONNECT_DATA=(SERVICE_NAME=rac)))</url>
            <username>regadmin</username>
            <password>regadmin</password>
            <driverClassName>oracle.jdbc.driver.OracleDriver</driverClassName>
            <maxActive>80</maxActive>
            <maxWait>60000</maxWait>
            <minIdle>5</minIdle>
            <testOnBorrow>true</testOnBorrow>
            <validationQuery>SELECT 1 FROM DUAL</validationQuery>
            <validationInterval>30000</validationInterval>
          </configuration>
     </definition>
</datasource>

The database configuration options

  • url - The URL of the database.
  • username - The name of the database user.
  • password - The password of the database user.
  • driverClassName  - The class name of the database driver.
  • maxActive - The maximum number of active connections that can be allocated from this pool at the same time, or enter a negative value for no limit.
  • maxWait - The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception. You can enter zero or a negative value to wait indefinitely.
  • minIdle - The minimum number of active connections that can remain idle in the pool without extra ones being created, or enter zero to create none.
  • testOnBorrow - Whether objects will be validated before being borrowed from the pool. If the object fails to validate, it will be dropped from the pool, and another attempt will be made to borrow another. 
  • validationQuery - The SQL query that will be used to validate connections from this pool before returning them to the caller.
  • validationInterval - Whether to avoid excess validation and only run validation at this frequency (time in milliseconds) at most. If a connection is due for validation, but it has been validated previously within this interval, it will not be validated again. 

    Info

    For more information on other parameters that can be defined in the master-datasources.xml file, see Tomcat JDBC Connection Pool.

...

Replace the default values in the datasource configurations of the following files with your custom values accordingly, to point to the created registry and user manager, identity and storage databases.

...

Include Page
shared:Setting up Oracle RAC (V1)
shared:Setting up Oracle RAC (V1)