Db2

 View Only
  • 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
    ------------------------------

    #Db2


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

    IBM Champion
    Posted Fri October 25, 2019 08:56 AM
    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 Mon October 28, 2019 09:32 AM
    Edited by System Fri January 20, 2023 04:50 PM
    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

    IBM Champion
    Posted Mon October 28, 2019 11:22 AM
    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 Mon October 28, 2019 11:37 AM
    Thanks Markus. I will give it a try once I find machines to try on. Thanks again

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



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

    Posted Tue November 17, 2020 01:40 PM

    Hi,

    just pulled the latest db2 image (currently 11.5.4.0) and tried to start two node in HADR on the same host following the hints describe on dockerHub.

    So, I'm struggling to do this because of db2_setup_hadr.sh failure : Invalid HADR setup option(s) specified.
    However, the run command is the same as in the dockerHub docs (using podman instead of docker) and while inspecting the setup shell files inside /var/db2_setup/lib I noticed this:

    setup_db2_instance.sh:
    .....
    if ! setup_hadr ${HADR_ROLE_FOR_SETUP?} ${DB2INSTANCE?} ${db_name_for_hadr?} ; then
    echo "(!!!) There was a failure during HADR setup... "
    fi
    ....

    setup_hadr.sh:
    ...
    while test $# -gt 0; do
    case $1 in
    -primary) current_node="primary"
    ;;
    -standby) current_node="standby"
    ;;
    -remote) shift; remote_host=$1
    ;;
    -use_backup) standby_init_method="backup"
    ;;
    -use_snapshot) standby_init_method="snapshot"
    ;;
    -reinit) reinit_hadr=true
    ;;
    -database) shift; database=$1
    ;;
    -instance) shift; instance=$1
    ;;
    *)
    logger_error "Invalid HADR setup option(s) specified."
    logger_error "${HADR_SETUP_USAGE?}" && exit ${FALSE}
    ;;
    esac
    shift
    done

    in fact the usage printed is the following:

    ################################################################################

    * Usage: docker exec -it Db2wh setup_hadr [ -primary | -standby ]
    -remote <hostname>:<IP address> [ -use_backup | -use_snapshot ] -reinit

    I've checked that ${HADR_ROLE_FOR_SETUP?} is set to values in PRIMARY or STANDBY and so it seems that the command called by setup_db2_instance.sh is not correct. Am I right or is there something I'm missing?

    I'm just trying to find a reason why the HADR doesn't work in a basic settings like mine....

    Thanks for your help.
    Francesco



    ------------------------------
    FRANCESCO PROIETTI
    ------------------------------