Db2 On Premise and Cloud

Expand all | Collapse all

How to setup HADR on an already existing dockers

  • 1.  How to setup HADR on an already existing dockers

    Posted Mon September 30, 2019 08:46 AM

    Hi
    I have 2 DB2 dockers on 2 different machines that are deployed automatically as part of Commerce deployment. I wanted to setup HADR between these 2 dockers.
    I followed some of the steps in this link https://hub.docker.com/r/ibmcom/db2 without pulling ibmcom/db2 docker image.
    I did the following:

    docker  stop  mydb2docker
    docker  commit  mydb2docker  newdb2docker
    docker run --name node1 --privileged --ipc=host -p 50000 -p 55000 -e LICENSE=accept -e DB2INST1_PASSWORD=<password> -e HADR_ENABLED=true -e ETCD_ENDPOINT=IP1:PORT1,IP2:PORT2,IP3:PORT3 -v /home/db2server_fs/database:/database -v /nfs/shared:/hadr newdb2docker
    I didn't see anything happen. I was able to access the docker and db2 started successfully
    I then went ahead and setup the hadr as we do for on-prem (set all hadr db cfg, backed up and restored the db, ... ). The setup failed at the command "db2 start hadr on database mall as standby" with error
    SQL1768N Unable to start HADR. Reason code = "4".

    Is there a way to setup HADR without pulling Db2 Developer-C and changing the license.



    ------------------------------
    Noureddine Brahimi
    ------------------------------


  • 2.  RE: How to setup HADR on an already existing dockers

    Posted 21 days ago
    Hi,
    what did you set for HADR_LOCAL_HOST (and for remote as well)? As RC4 means it cant resolve its hostname. 
    Be sure to set correct hostnames in the db cfg and that the names can be resolved (in docker: either use /etc/hosts or use dns given by docker using a user defined bridge network).


    ------------------------------
    Markus Fraune
    ------------------------------



  • 3.  RE: How to setup HADR on an already existing dockers

    Posted 18 days ago
    Edited by Noureddine Brahimi 18 days ago
    Actually, I gave up and used db2 on prem. Wasn't able to set hadr between the db2 containers
    For hadr_local_host, it's either the primary db's host or the standby db's host, depends where you run the command
    db2 update db cfg for mall using hadr_local_<host>

    ------------------------------
    Noureddine Brahimi
    ------------------------------



  • 4.  RE: How to setup HADR on an already existing dockers

    Posted 18 days ago
    Hi,

    hadr on docker works the same as on a "normal" system. the difference within docker is that name resolving does only work for the container name, not for the hostname. so either try to use the container name of the primary and secondary container or insert the internal IP address of those containers of their network. if you forwarded the hadr listener port (-p option during docker run command) you could use the docker hostname/ip with the opened port instead. 

    if you follow these steps it should work out of the box (change passwords):
    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 idug2019

    •create hadr node1 (primary)
    docker run -itd --name db2srv_hadr_node1 --privileged
      --
    ipc=host -p 50000 -p 55000 -e LICENSE=accept
      -
    e DB2INST1_PASSWORD=itgain -v db2srv_empty_hadr_h1:/database
      -v db2srv_empty_hadr_share:/
    hadr -e DBNAME=EMPTHADR
      -
    e HADR_ENABLED=true -h db2srv_hadr_node1 --network=idug2019   ibmcom/db2


      create hadr node 2 (standby)
    docker run -itd --name db2srv_hadr_node2 --privileged
      --
    ipc=host -p 50000 -p 55000 -e LICENSE=accept
      -
    e DB2INST1_PASSWORD=itgain -v db2srv_empty_hadr_h2:/database
      -v db2srv_empty_hadr_share:/
    hadr -e DBNAME=EMPTHADR
      -
    e HADR_ENABLED=true -h db2srv_hadr_node2 --network=idug2019   ibmcom/db2

    check for log entries:
    docker logs -f db2srv_hadr_node1
    docker logs -f db2srv_hadr_node2


    ------------------------------
    Markus Fraune
    ------------------------------



  • 5.  RE: How to setup HADR on an already existing dockers

    Posted 18 days ago
    Thanks Markus. I will give it a try once I find machines to try on. Thanks again

    ------------------------------
    Noureddine Brahimi
    ------------------------------