Db2

Db2

Connect with Db2, Informix, Netezza, open source, and other data experts to gain value from your data, share insights, and solve problems.

 View Only
  • 1.  Need help to set up HADR on DB2 v11.5 in docker

    Posted Tue October 11, 2022 10:29 AM
    Hi
    I deployed two DB2 containers on Docker, followed the steps on the topic [ Running DB2 HADR ] in this cite: Docker Hub.
    The following is the actual command I did:
    • Create Volume for /database on node1
    docker volume create db2srv_empty_hadr_h1
    • Create Volume for /database on node2
    docker volume create db2srv_empty_hadr_h2
    • Create volume for /hadr
    docker volume create db2srv_empty_hadr_share
    • Create network to enable dns hostname/containernameresolving
    docker network create -d bridge idug


    • Run DB2 container
    docker run -itd --name db2srv_hadr_node1 --privileged \
    --ipc=host -p 50000 -p 55000 -e LICENSE=accept \
    -e -e DB2INST1_PASSWORD=db2inst1 -v db2srv_empty_hadr_h1:/database \
    -v db2srv_empty_hadr_share:/hadr -e DBNAME=EMPTHADR \
    -e ETCD_ENDPOINT=xxx:2379,xxx:2379,xxx:2379
    -e HADR_ENABLED=true -h db2srv_hadr_node1 --network=idug ibmcom/db2

    docker run -itd --name db2srv_hadr_node2 --privileged \
    --ipc=host -p 50000 -p 55000 -e LICENSE=accept \
    -e DB2INST1_PASSWORD=db2inst1 -v db2srv_empty_hadr_h2:/database \
    -v db2srv_empty_hadr_share:/hadr -e DBNAME=EMPTHADR \
    -e ETCD_ENDPOINT=xxx:2379,xxx:2379,xxx:2379
    -e HADR_ENABLED=true -h db2srv_hadr_node2 --network=idug ibmcom/db2

    I found that HADR was set up successfully by checking the HADR status:



    However, the automated failover didn't work. When I stop the primary node, the standby node just disconnected from the primary node.
    I checked the governor config file in primary node:

     
    I found the error during the governor setup.


    Could you help me to setup ETCD in HADR or how to solve the problem in the picture?
    Thank you very much!

    ------------------------------
    xiaomin wang
    ------------------------------

    #Db2


  • 2.  RE: Need help to set up HADR on DB2 v11.5 in docker

    Posted Wed October 12, 2022 01:39 AM
    HADR does not provide an automatic failover. For that you need TSA MP or pacemaker.

    ------------------------------
    Ferdinand Prahst
    ------------------------------



  • 3.  RE: Need help to set up HADR on DB2 v11.5 in docker

    Posted Thu October 13, 2022 12:24 PM
    Hi Ferdinand, thank you for your reply. 
    I followed the tutorial in docker hub: https://hub.docker.com/r/ibmcom/db2 to set up DB2 HADR in docker environment.
    As mentioned in docker hub, 'In the event we lose the primary container, providing the ETCD_ENDPOINT ensures that the takeover will happen automatically, and the standby container will pick up the workload'.
    I found that there was a component called governor in the db2 image which used ETCD to realize automated failover.
    The current problem is I cannot run the governor program, when I run: python governor.py, the following error shows:




    ------------------------------
    xiaomin wang
    ------------------------------



  • 4.  RE: Need help to set up HADR on DB2 v11.5 in docker

    Posted Thu October 13, 2022 10:49 AM
    As Ferdinand mentioned, automatic failover from primary server to standby server does not happen automatically. If you manually issue a takeover command (db2 "takeover database <dbname>") on the standby server, the database should cleanly move from primary database server to standby database server.

    If you are looking to make this an automated process where a problem is determined and failover to standby automatically happens you will need to configure an additional project. If you are working with Db2 11.5, I would recommend configuring Corosync Pacemaker which is open source and replacing TSAMP. A good resource for this was a free ebook published by Triton Consulting which you can find at this blog - Automating HADR Failovers with Pacemaker



    ------------------------------
    Michael Krafick
    ------------------------------



  • 5.  RE: Need help to set up HADR on DB2 v11.5 in docker

    Posted Thu October 13, 2022 12:41 PM
    Hi Michael, thank you for your reply.
    I have tried to conduct the failover manually with the command which you mentioned, it succeed.
    In the blog you recommended,  Pacemaker can only used in on-premises deployments and non-container cloud environments.
    I want to deploy DB2 in docker or K8s with HADR and automated failover feature, so I wonder if the Pacemaker can meet the requirement.


    ------------------------------
    xiaomin wang
    ------------------------------



  • 6.  RE: Need help to set up HADR on DB2 v11.5 in docker

    Posted Tue October 18, 2022 08:58 PM
    Hi Xiao Min
    I got dev team confirmation that Pacemaker is not supported in the Docker environment now.  If you have customers that are asking for this feature, pls provide us the details thus we can bring it back to dev team to prioritize. Thanks!


    ------------------------------
    Su Li Hou
    ------------------------------



  • 7.  RE: Need help to set up HADR on DB2 v11.5 in docker

    Posted Wed October 19, 2022 10:39 AM
    Su Li Ho, I can provide some feedback for the dev team. I do see some value in getting Pacemaker to work with Db2 in a managed container environment. 

    In most cases, our large and critical Db2 databases would be in a more traditional configuration. They would be "servers" in a HADR pair within an Amazon EC2 instance. This lends itself to being monitored by Pacemaker without a problem.

    However, we are starting to look at Db2 Community Edition for microservice backend databases. They are often smaller and are spun up in a managed K8's environment through an automated process. They are smaller but can be important where automated HADR failover could be useful. Being able to spin up all environments from Dev to Prod as a managed container would be useful logistically, and having automatic HADR failover via Pacemaker is a good production support feature.

    At first I didn't see why you would want Pacemaker to support HADR in a docker container configuration. But it would actually address some logistical problems we have when we have to build 3/4 of our environments in containers and 1/4 in EC2.


    ------------------------------
    -----------------
    Michael Krafick (Twitter: @mkrafick)
    IBM Champion for Data and AI
    ------------------------------



  • 8.  RE: Need help to set up HADR on DB2 v11.5 in docker

    Posted Wed October 19, 2022 10:21 AM
    Containerization/K8's is really built around things being ethereal, not permanent. So recovering from something is often more about blowing away the container and spinning it back up than the traditional way of failing over or recovering from backup. However, I have learned that relational databases tend to break a lot of the thinking/approach done with containerization. Pacemaker and Db2 are also relatively new with true support not happening until 11.5 and some features I would have thought necessary not happening until the latest fixpack release. TSAMP was well established (and in my opinion temperamental as hell), Pacemaker and Db2 are still learning to work with each other. But what I see is already impressive and a little more solid than TSAMP. If you see a business case for Pacemaker working with HADR in containers, give the feedback here and open a IBM Aha Idea (RFE). Matter of fact, I'll respond to Su Li Hou's answer with some of my own feedback.

    In our specific shop, we keep lower environments in K8's managed containers. We still run regular maintenance on them and recovery is often a redeployment of the container (which picks up the persistent data volume) or even a restore of the database if really needed. However, we keep production environments in Amazon EC2 instances configured with an HA pair and Pacemaker. We keep the build in a Cloudformation template in a Github Repo that can be spun up via a create-stack command.

    ------------------------------
    -----------------
    Michael Krafick (Twitter: @mkrafick)
    IBM Champion for Data and AI
    ------------------------------