Creating HADR services for a multiple cluster topology

You can create HADR services and network policies for a multiple cluster topology.

About this task

The examples in this procedure are for an HADR setup with a primary and two standby databases. The primary and principal standby are in cluster1, and the auxiliary standby is in cluster2.

Procedure

  1. Generate the HADR service definitions and network policies 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 your configuration.
    oc exec -it c- db2oltp-primary -db2u-0 -- create_hadr_services --db-role primary --primary-name db2oltp-primary --standby-name db2oltp-standby --aux1-name db2oltp-aux --primary-ext-host api.cluster1.ibm.com --standby-ext-host api.cluster1.ibm.com --aux1-ext-host api.cluster2.ibm.com | sed '/selector:/a\ \ \ \ type: engine'
    
    apiVersion: v1
    kind: Service
    metadata:
      name: c-db2oltp-primary-hadr-svc
    spec:
      selector:
        app: db2oltp-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: NodePort
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: c-db2oltp-primary-hadr-svc-ext
    spec:
      type: ExternalName
      externalName: api.cluster1.ibm.com
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: c-db2oltp-standby-hadr-svc-ext
    spec:
      type: ExternalName
      externalName: api.cluster1.ibm.com
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: c-db2oltp-aux-hadr-svc-ext
    spec:
      type: ExternalName
      externalName: api.cluster2.ibm.com
    ---
    
  2. Switch to the namespace 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- db2oltp-primary-db2u-0 -- create_hadr_services --db-role primary --primary-name db2oltp-primary --standby-name db2oltp-standby --aux1-name db2oltp-aux --primary-ext-host api.cluster1.ibm.com --standby-ext-host api.cluster1.ibm.com --aux1-ext-host api.cluster2.ibm.com | oc apply -f -
    
  3. Verify that the services were created:
    • One NodePort service that matches the Db2 or Db2 Warehouse deployment
    • Multiple ExternalName services – one for each database in the HADR configuration
    oc get svc | grep hadr-svc
    
    

    Example output:

    
    c-db2oltp-aux-hadr-svc-ext       ExternalName   <none>     api.cluster2.ibm.com   <none>   9s
    c-db2oltp-primary-hadr-svc        NodePort       172.30.77.20     <none>   60006:32457/TCP,60007:31243/TCP,60008:30374/TCP,60009:30977/TCP   2m15s
    c-db2oltp-primary-hadr-svc-ext    ExternalName   <none>  api.cluster1.ibm.com   <none>    9s
    c-db2oltp-standby-hadr-svc-ext    ExternalName   <none>     api.cluster1.ibm.com   <none>
    
  4. Verify that the network policy was created in the same OpenShift project as the Db2® deployment:
    oc get networkpolicy | grep hadr-ext
    

    Example output:

    c-db2oltp-primary-hadr-ext     formation_id=db2oltp-primary,type=engine         25s
  5. Repeat steps 1 through 4. Use environment variables for namespace.

    Run this command for the standby database:

    oc project ${NAMESPACE_STANDBY}
    

    Run this comment for the auxiliary database:

    
    oc project ${NAMESPACE_AUX}