Configuring Db2 Community Edition on OCP

After installing Db2 Community Edition into an OpenShift cluster, you configure it to connect to the Agile Service Manager application discovery service.

Before you begin

Ensure you have installed Db2 Community Edition on OCP.

About this task

You first prepare the Db2 server, then configure the connection to the application discovery service on OCP.

After installation and configuration, you can verify that the application discovery service has been successfully configured with DB2 on OCP by checking the service status.

Procedure

Db2 server prerequisites

  1. Capture the primary storage and the database pods.
    Example of a primary storage pod:
    # kubectl get pod | grep pss
    fvt-topology-nasm-app-disco-pss-deployment-6c5b55594f-gbphr       1/2     Running     5          41m
    Example of the database pod:
    kubectl get pod | grep db2u-0
    Example system output:
    
    asm204-db2u-0   1/1   Running   0   27h
  2. Copy the create_db2_database.sh script from the primary storage pod to the OCP /tmp directory.
    Example:
    kubectl cp  fvt-topology-nasm-app-disco-pss-deployment-6c5b55594f-gbphr:/opt/IBM/taddm/utils/create_db2_database.sh /tmp/create_db2_database.sh
  3. Copy the create_db2_database.sh script from the previous step to the tmp directory in the database pod.
    Example:
    kubectl cp create_database.sh asm204-db2u-0:/tmp
  4. Enter the database pod and provide execute permissions to the script.
    Example:
    kubectl exec -it asm204-db2u-0 /bin/bash
    sudo chmod a+x /tmp/create_db2_database.sh
    
  5. Add 'archuser' Db2 user.
    oc rsh ${tools_pod} addLdapUser.py -u archuser -p archuser -r admin
    For more details, refer to Managing Db2 users with LDAP on a Red Hat OpenShift cluster
  6. As the db2inst1 user, create a database instance.
    Run the following command from the tmp directory. In the following example, the database is called 'taddm':
    ./create_db2_database.sh taddm
    
    Tip: If the system output consists of the following message, a database called 'taddm' already exists:
    DB2 version 1.5.4
    INFO: Database with same name taddm already exists.
    If this occurs, run the 'drop database' command, then recreate the 'taddm' database, as in the following example:
    db2 drop database taddm
    System output if successful:
    DB20000I  The DROP DATABASE command completed successfully.
    Rerun the following command:
    ./create_db2_database.sh taddm
    
  7. Confirm that the database has been created:
    db2 list database directory
    Example system output if the database exists:
    System Database Directory
    
    Number of entries in the directory = 1
    
    Database 1 entry:
    
     Database alias                       = TADDM
     Database name                        = TADDM
     Local database directory             = /mnt/blumeta0/db2/databases
     Database release level               = 15.00
     Comment                              =
     Directory entry type                 = Indirect
     Catalog database partition number    = 0
     Alternate server hostname            =
     Alternate server port number         =
    
    Test the database connection:
    db2 connect to TADDM user db2inst1 using db2inst1
    Example system output:
    Database Connection Information
    
     Database server        = DB2/LINUXX8664 11.5.4.0
     SQL authorization ID   = DB2INST1
     Local database alias   = TADDM
    
  8. Check that 'archuser' Db2 user can be connected to the TADDM database.
    oc exec -ti ${db2u_pod} bash
    su - db2inst1
    db2 connect to taddm user archuser using archuser
    Example system output:
    Database Connection Information
    
    Database server        = DB2/LINUXX8664 11.5.4.0
    SQL authorization ID   = ARCHUSER
    Local database alias   = TADDM
  9. Exit pod.

OCP application discovery server configuration

  1. On the OCP application discovery server, create a configuration file called db2-secret.yaml, as in the following example:
    apiVersion: v1
    kind: Secret
    metadata:
      name: db2-secret
      namespace: production
    data:
      DBARCHIVEUSER: YXJjaHVzZXI=
      DBUSER: ZGIyaW5zdDE=
      DB_ARCH_PASSWORD: YXJjaHVzZXI=
      DB_PASSWORD: ZGIyaW5zdDE=
    type: Opaque 
    
    Note: The values of the following parameters have to be base64 encoded:
    DBARCHIVEUSER
    Default value: archuser
    DBUSER
    Default value: db2inst1
    DB_ARCH_PASSWORD
    Default value: archuser
    DB_PASSWORD
    Default value: db2inst1
  2. Create a secret that stores DB details by running the following command:
    kubectl apply -f db2-secret.yaml
  3. Populate the database details in the Netcool Operations Insight on Red Hat OpenShift Operator properties.
    The following sample shows the database parameters to connect the application discovery service with the pre-configured database:
    appDisco:
      enabled: true
      dburl : 'db2hostname.com'
      dbsecret: 'db2-secret'
      secure: false
      certSecret: ''
    
    dburl
    The URL of the server on which DB2 is installed.
    For DB2 on OCP, the format of dburl is:
    <Service Name>.<Namespace Name>.svc.cluster.local
    Example:
    asm204-db2u.production.svc.cluster.local
    Run 'oc get svc' to obtain the service name, for example:
    oc get svc | grep asm204-db2u
    asm204-db2u
    ClusterIP   172.30.200.131   <none>
    50000/TCP,50001/TCP,25000/TCP,25001/TCP,25002/TCP,25003/TCP,25004/TCP,25005/TCP   27h
    
    dbsecret
    The name of the secret in the same namespace as the instance to be installed.
    It must contain the following keys:
    DBUSER
    The name of the DB2 user.
    DB_PASSWORD
    The password of the DB2 user.
    DBARCHIVEUSER
    The name of the DB2 archive user.
    DB_ARCH_PASSWORD
    The password of the DB2 archive user.
    secure
    'False' if the connection to DB2 is insecure.
    certSecret
    Applicable only if 'secure' property is 'true'.

What to do next

After the installation and configuration of the application discovery service and Db2, check the service status. Run the following command on the application discovery OCP server:
# kubectl exec -it <releasename>-topology-nasm-app-disco-pss-deployment-<pod-id> /opt/IBM/taddm/dist/bin/control status
The following example shows that the application discovery service has been successfully configured with Db2 on OCP:
kubectl exec -it appd204-topology-nasm-app-disco-pss-deployment-84dbdb89c9-sjk9m /opt/IBM/taddm/dist/bin/control status

Defaulting container name to pss.
Use 'kubectl describe pod/appd204-topology-nasm-app-disco-pss-deployment-84dbdb89c9-sjk9m -n production' to see all of the containers in this pod.
DbInit: Started
Liberty: Started
StorageService: Started

TADDM: Running