Create a Multi Data Source for a RAC Database

Use the model Yaml templates to create a multi data source for an Oracle Real Application Cluster (RAC) database with WebLogic Enterprise Edition.

Following is an example of model Yaml template for app deployment with multi data source (RAC as infra DB with WebLogic Enterprise Edition) properties:

Note:

The template files are located at /u01/shared/scripts/pipeline/templates on the administration host.
resources:
  JDBCSystemResource:
    'db1-hellods':
      Target: '@@ENV:RESOURCE_PREFIX@@-cluster'
      JdbcResource:
        JDBCDataSourceParams:
          GlobalTransactionsProtocol: None
          JNDIName: [ 'jdbc/db1-hellods' ]
        JDBCDriverParams:
          DriverName: oracle.jdbc.OracleDriver
          URL: '@@SECRET:@@ENV:DOMAIN_UID@@-db1datasource-secret:url@@'
          PasswordEncrypted: '@@SECRET:@@ENV:DOMAIN_UID@@-db1datasource-secret:password@@'
          Properties:
            user:
              Value:
        JDBCConnectionPoolParams:
          StatementCacheSize: 0
          TestTableName: SQL ISVALID
          InitialCapacity: 1
          MaxCapacity: 1
    'db2-hellods':
      Target: '@@ENV:RESOURCE_PREFIX@@-cluster'
      JdbcResource:
        JDBCDataSourceParams:
          GlobalTransactionsProtocol: None
          JNDIName: [ 'jdbc/db2-hellods' ]
        JDBCDriverParams:
          DriverName: oracle.jdbc.OracleDriver
          URL: '@@SECRET:@@ENV:DOMAIN_UID@@-db2datasource-secret:url@@'
          PasswordEncrypted: '@@SECRET:@@ENV:DOMAIN_UID@@-db2datasource-secret:password@@'
          Properties:
            user:
              Value:
        JDBCConnectionPoolParams:
          StatementCacheSize: 0
          TestTableName: SQL ISVALID
          InitialCapacity: 1
          MaxCapacity: 1
    'hellods':
       Target: '@@ENV:RESOURCE_PREFIX@@-cluster'
       JdbcResource:
         DatasourceType: MDS
         JDBCDataSourceParams:
           AlgorithmType: 'Load-Balancing'
           DataSourceList: [ 'db1-hellods','db2-hellods' ]
           JNDIName: [ jdbc/hellods ]

You must set up the database to create a schema user before you create the data source. See Prerequisites to Create a Data Source.

  1. Update the schema user that you created in the Properties section in the model Yaml template.

    See Prerequisites to Create a Data Source.

    For example:

    Properties:
      user:
        Value: <schema user>
      
  2. Create the data source secrets in the model Yaml file as follows:
    1. Open an SSH connection to the domain's Administration Server node as the opc user.
      ssh -i <path_to_private_key> opc@<node_public_ip>
    2. Go to u01/shared/helper-scripts location and obtain the connect string for each node using the following commands:
      ./url.sh
      URL1 = jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=<host_name>)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=<service_name>)(INSTANCE_NAME=<instance1_name>)))
      URL2 = jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=<host_name>)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=<service_name>)(INSTANCE_NAME=<instance2_name>))
      
    3. Create <domain_uid>-db1datasource-secret/<domain_uid>-db2datasource-secret<domain_uid>-datasource-secret with password and url using the kubectl commands.
      kubectl create secret generic <domain_name>-db1datasource-secret --from-literal=password=<password>
      --from-literal=url='jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)
      HOST=<host1_name>)(PORT=1521))CONNECT_DATA=(SERVICE_NAME=<service_name>)(INSTANCE_NAME=<instance_name>)))'
      -n <resource_prefix>-domain-ns
      
      kubectl create secret generic <domain_name>-db2datasource-secret --from-literal=password=<password>
      --from-literal=url='jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)
      HOST=<host2_name)(PORT=1521))CONNECT_DATA=(SERVICE_NAME=<service_name>)(INSTANCE_NAME=<instance_name>)))'
      -n <resource_prefix>-domain-ns