step-by-step guide on configuring db2 hadr replication

Source: 192.168.91.59
Destination: 192.168.91.11
DB name: CMSDB
DB2 version: 9.7.0.7

# as db2inst1 on primary, make sure LOGARCHMETH1 is set

db2 get db cfg for cmsdb | grep LOGARCHMETH1

# Setting up HADR cfg parameters on Primary database.

db2 update db cfg for CMSDB using HADR_LOCAL_HOST 192.168.91.59
db2 update db cfg for CMSDB using HADR_LOCAL_SVC 51012
db2 update db cfg for CMSDB using HADR_REMOTE_HOST 192.168.91.11
db2 update db cfg for CMSDB using HADR_REMOTE_SVC 51013
db2 update db cfg for CMSDB using HADR_REMOTE_INST db2inst1
db2 update db cfg for CMSDB using LOGINDEXBUILD ON
db2 UPDATE DB CFG FOR CMSDB USING HADR_TIMEOUT 120
db2 UPDATE DB CFG FOR CMSDB USING HADR_SYNCMODE NEARSYNC
db2 terminate

# Take an offline backup to be used for setting HADR

db2 backup db cmsdb compress

# SCP backup file to standby

# as db2inst1 on standby database

db2 "restore db cmsdb redirect"
db2pd -d cmsdb -tables
db2 restore db cmsdb continue

# make sure status is roll forward-pending

db2 rollforward db cmsdb query status

# Setting up HADR cfg parameters on standby database

db2 update db cfg for CMSDB using HADR_LOCAL_HOST 192.168.91.11
db2 update db cfg for CMSDB using HADR_LOCAL_SVC 51013
db2 update db cfg for CMSDB using HADR_REMOTE_HOST 192.168.91.59
db2 update db cfg for CMSDB using HADR_REMOTE_SVC 51012
db2 update db cfg for CMSDB using HADR_REMOTE_INST db2inst1
db2 UPDATE DB CFG FOR CMSDB USING HADR_TIMEOUT 120
db2 UPDATE DB CFG FOR CMSDB USING HADR_SYNCMODE NEARSYNC
db2 terminate

# as db2inst1 on primary
# HADR primary database will break the HADR connection if logging on the primary database
# has been blocked for the specified number of seconds in peer state

db2set DB2_HADR_PEER_WAIT_LIMIT=30

# Setting up reads on standby

db2set DB2_HADR_ROS=ON
db2stop
db2start

# both on primary and standby database

db2 UPDATE DATABASE CFG FOR CMSDB USING AUTO_MAINT OFF AUTO_RUNSTATS OFF

# create archive log directory on standby

mkdir -p /home/db2inst1/db2archlog/db2inst1/CMSDB/NODE0000/C0000018

# start hadr on standby

db2 start hadr on database CMSDB as standby

# Starting up HADR on the primary server

db2 start hadr on database CMSDB as primary

#Verifing HADR is up and running

db2pd -db CMSDB -hadr

# as db2inst1 on primary db

db2 connect to cmsdb
db2 "create table db2inst1.testrep(id bigint)"

Reference:

http://www-01.ibm.com/support/docview.wss?uid=swg21410648
Step by Step Procedure to set up HADR replication between DB2 databases

http://www.ibm.com/developerworks/data/library/techarticle/dm-1205hadrstandby/
Get the most from the DB2 HADR standby database

https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/DB2HADR/page/HADR%20Tutorial
DB2 HADR Tutorial

http://www-01.ibm.com/support/docview.wss?uid=swg21694894
How to resolve SQL1768N reason code 5 “Invalid service name for the hadr_local_svc configuration parameter.”

Leave a comment