Configuring a custom external database
You can customize your Operational Decision Manager instance by configuring an external database. IBM Db2® and PostgreSQL drivers are provided.
About this task
ODM for production supports database connections to custom external databases, for example Oracle.
https://github.com/icp4a/cert-kubernetes/tree/19.0.3/ODM/configuration/custom-external-database.
Procedure
-
Create an XML file to configure the Decision Center datasource.
Name the file datasource-dc.xml.
The following example shows a configuration file for Oracle.
<server> <!-- Declare the jar files for Oracle access through JDBC. --> <library id="OracleLib"> <fileset dir="/drivers" includes="ojdbc*.jar"/> </library> <!-- Declare the database --> <dataSource jndiName="jdbc/ilogDataSource" isolationLevel="TRANSACTION_READ_COMMITTED" statementCacheSize="150"> <connectionManager maxPoolSize="25" minPoolSize="10" connectionTimout="10s" agedTimeout="30m"/> <jdbcDriver libraryRef="OracleLib"/> <properties.oracle driverType="thin" databaseName="xe" serverName="oracleServerName" portNumber="1521" user="system" password="oracle"/> </dataSource> </server>Note: The /drivers path must not be modified. The path locates a directory in the container. To copy a driver to the /drivers directory, use the following command.kubectl cp ojdbc8-12.x.x.x.jar namespace/instance-name-odm-decisioncenter-XXXXXX:/drivers/ -
Create an XML file to configure the Decision Server datasource.
Name the file datasource-ds.xml.
The following example shows a configuration file for Oracle.
<server> <!-- Declare the jar files for Oracle access through JDBC. --> <library id="OracleLib"> <fileset dir="/drivers" includes="ojdbc*.jar"/> </library> <!-- Declare the database --> <dataSource jndiName="jdbc/resdatasource"> <jdbcDriver libraryRef="OracleLib"/> <properties.oracle driverType="thin" databaseName="xe" serverName="oracleServerName" portNumber="1521" user="system" password="oracle"/> </dataSource> </server> -
Create a secret from the two XML files.
Use the
kubectl create secretcommand to create a secret. The following example creates the secret customdatasource-secret.kubectl create secret generic customdatasource-secret --from-file datasource-ds.xml --from-file datasource-dc.xml -
Create a Persistent Volume Claim (PVC) to host the JDBC Oracle driver.
The following YAML file (driver-pvc.yaml) defines the PVC customdatasource-pvc.
kind: PersistentVolumeClaim apiVersion: v1 metadata: name: customdatasource-pvc spec: accessModes: - ReadWriteOnce resources: requests: storage: 1GiThe following command creates the PVC.
kubectl create -f driver-pvc.yaml -
When you deploy Operational Decision
Manager, use the custom
parameters for the secret and PVC you created.
For 19.0.2
externalCustomDatabase.datasourceRef=customdatasource-secret externalCustomDatabase.driverPvc=customdatasource-pvcNew in 19.0.3 In a custom resource descriptor with the Cloud Pak operator, use the following YAML:
externalCustomDatabase: datasourceRef: customdatasource-secret driverPvc: customdatasource-pvcThe YAML file is applied to the operator by running the
kubectl applycommand. You run the command only when you are done configuring your ODM customizations and all of the other components that you want to deploy or update.kubectl apply -f custom_resources.yaml -
Push the JDBC driver in the PVC by running a
kubectl cpcommand.- Get the name of the pod for the ODM instance by using the command
kubectl get pods | grep instance-name.The command returns a list of pods.
- Check that the Oracle database is up and running.
- Add the Oracle JDBC driver to a pod with the following
command.
kubectl cp ojdbc8-12.x.x.x.jar namespace/instance-name-odm-decisioncenter-XXXXXX:/drivers/
- Get the name of the pod for the ODM instance by using the command
-
Restart all the pods by using the
kubectl delete podcommand.kubectl delete pod instance-name-odm-decisioncenter-XXXXXX \ kubectl delete pod instance-name-odm-decisionserverconsole-XXXXXX \ kubectl delete pod instance-name-odm-decisionserverruntime-XXXXXX \ kubectl delete pod instance-name-odm-decisionrunner-XXXXXX