Creating Db2 Warehouse HADR services for a single cluster topology

You can create HADR services and network policies for a single cluster topology, whether databases are in a single project or multiple OpenShift® projects.

About this task

If your configuration includes only the primary database and a single standby database (no auxiliary standbys) in the same OpenShift project, you might want to use the HADR API instead of the HADR scripts.

Procedure

  1. Generate the HADR service and network policy definitions using the create_hadr_services script on the primary database pod.
    Ports are always set up for primary and three standby databases, regardless of the configuration.
    oc exec -it c-db2wh-primary-db2u-0 -- create_hadr_services --db-role primary --primary-name db2wh-primary --standby-name db2wh-standby --aux1-name db2wh-aux
    
    apiVersion: v1
    kind: Service
    metadata:
      name: c-db2wh-primary-hadr-svc
    spec:
      selector:
        app: db2wh-primary
        type: engine
      ports:
        - name: db2u-hadrp
          port: 60006
          targetPort: 60006
        - name: db2u-hadrs
          port: 60007
          targetPort: 60007
        - name: db2u-hadra1
          port: 60008
          targetPort: 60008
        - name: db2u-hadra2
          port: 60009
          targetPort: 60009
      type: ClusterIP
    ---
    
  2. Switch to the project that the primary database is in, and use the oc apply -f command directly on the output to create the k8s services and network policies:
    oc project ${NAMESPACE_PRIMARY}
    oc exec -it c-db2wh-primary-db2u-0 -- create_hadr_services --db-role primary --primary-name db2wh-primary --standby-name db2wh-standby --aux1-name db2wh-aux | oc apply -f -
  3. Verify that the service and network policy was created in the same OpenShift project as the Db2 Warehouse deployment:
    oc get svc | grep hadr-svc
    The following is an example of the returned output:
    c-db2wh-primary-hadr-svc    ClusterIP   172.30.77.20  <none>   60006/TCP,60007/TCP,60008/TCP,60009/TCP        26s
  4. Run the following command to verify that the network policy was created in the same OpenShift Container Platform project as the Db2 Warehouse deployment:
    oc get networkpolicy | grep hadr-ext
    The following is an example of the returned output:
    c-db2wh-primary-hadr-ext     formation_id=db2oltp-primary,type=engine         25s
  5. Repeat steps 1 to 4 for each standby database, ensuring that you use the appropriate value for --db-role and that you are in the project that corresponds to the database:
    oc project ${NAMESPACE_STANDBY}
    oc exec -it c-db2wh-standby-db2u-0 -- create_hadr_services --db-role standby --primary-name db2wh-primary --standby-name db2wh-standby --aux1-name db2wh-aux | oc apply -f -
    oc project ${NAMESPACE_AUX}
    oc exec -it c-db2wh-aux-db2u-0 -- create_hadr_services --db-role aux1 --primary-name db2wh-primary --standby-name db2wh-standby --aux1-name db2wh-aux | oc apply -f -