Configuring a Db2 HA external database

You can configure your Operational Decision Manager instance to connect to a Db2® database server in High Availability (HA) mode.

About this task

Operational Decision Manager supports High Availability connections to Db2.

Note: You are responsible for the backup and recovery process.

To configure a Db2 server in HA, you need to create a data source secret. You must then set the externalCustomDatabase parameters in the odm_configuration section of your custom resource file.

Procedure

  1. Create an XML file to configure the Decision Center data source.

    Name the file datasource-dc.xml.

    The following example shows a configuration file for Db2 in HA.

    <server>
          <fileset id="DBLibFileset" dir="/config/resources" includes="*.jar" />
          <library id="DBLib" filesetRef="DBLibFileset" />
          <dataSource id="jdbc/ilogDataSource" jndiName="jdbc/ilogDataSource" isolationLevel="TRANSACTION_READ_COMMITTED" statementCacheSize="30">
            <jdbcDriver libraryRef="DB2Lib" />
                <properties.db2.jcc 
                   databaseName="ODMDB"
                   serverName="mydbserver.mycompany.com"
                   portNumber="50001" 
                   user="db2user" 
                   password="db2password" 
                   sslConnection="true" 
                   sslTrustStoreLocation="/config/security/truststore.jks" 
                   sslTrustStorePassword="<YOUR_TRUSTSTORE_PASSWORD>" 
                   clientRerouteAlternateServerName="alternatedbserver.mycompany.com" 
                   clientRerouteAlternatePortNumber="50001" 
                   maxRetriesForClientReroute="3" 
                   retryIntervalForClientReroute="15s" 
                   enableSeamlessFailover="1" />
            <jdbcDriver javax.sql.ConnectionPoolDataSource="com.ibm.db2.jcc.DB2ConnectionPoolDataSource"
              libraryRef="DBLib" />
            <connectionManager agedTimeout="120" 
              connectionTimeout="30" maxIdleTime="90" maxPoolSize="50" 
              minPoolSize="5" purgePolicy="FailingConnectionOnly" reapTime="60"/>
        </dataSource>
    </server>
    The YOUR_TRUSTSTORE_PASSWORD variable is the password that is stored in the secret referenced by the odm_configuration.dba.passwordSecretRef parameter in the CR. To maintain compatibility with the previous release, use changeit, which was the default value. See the reference manual for more details.
  2. Create an XML file to configure the Decision Server data source.

    Name the file datasource-ds.xml.

    The following example shows a configuration file for Db2 in HA.

    <server>
           <fileset id="DBLibFileset" dir="/config/resources" includes="*.jar" />
          <library id="DBLib" filesetRef="DBLibFileset" />
          <dataSource id="jdbc/resdatasource" jndiName="jdbc/resdatasource" isolationLevel="TRANSACTION_READ_COMMITTED" statementCacheSize="30"> 
            <jdbcDriver libraryRef="DB2Lib" />
                <properties.db2.jcc 
                   databaseName="ODMDB" 
                   serverName="mydbserver.mycompany.com" 
                   portNumber="50001" 
                   user="db2inst1" 
                   password="Psiadmin1" 
                   sslConnection="true" 
                   sslTrustStoreLocation="/config/security/truststore.jks" 
                   sslTrustStorePassword="<YOUR_TRUSTSTORE_PASSWORD>" 
                   clientRerouteAlternateServerName="alternatedbserver.mycompany.com"  
                   clientRerouteAlternatePortNumber="50001" 
                   maxRetriesForClientReroute="3" 
                   retryIntervalForClientReroute="15s" 
                   enableSeamlessFailover="1" />
            <jdbcDriver javax.sql.ConnectionPoolDataSource="com.ibm.db2.jcc.DB2ConnectionPoolDataSource"
              libraryRef="DBLib" />
            <connectionManager agedTimeout="120" 
              connectionTimeout="30" maxIdleTime="90" maxPoolSize="50" 
              minPoolSize="5" purgePolicy="FailingConnectionOnly" reapTime="60"/>
        </dataSource>
    </server>
  3. Create a secret from the two XML files.
    Use the kubectl create secret command to create a secret. The following example creates customdatasource-secret.
    kubectl create secret generic customdatasource-secret --from-file datasource-ds.xml --from-file datasource-dc.xml
  4. Create a secret to store the certificate to connect to Db2.
    Use the kubectl create secret command to create a secret. For example,
    kubectl create secret generic ibm-dba-odm-db2-cacert --from-file=tls.crt=./db2-ssl-cert.pem

    When you configure Operational Decision Manager, use the custom parameters for the secret that you created.

    In a custom resource descriptor with the Cloud Pak operator, use the following YAML:

    spec:
      odm_configuration:
        customization: 
           trusted_certificate_list: 
            - ibm-dba-odm-db2-cacert
        externalCustomDatabase:
          datasourceRef: customdatasource-secret