Page tree
Skip to end of metadata
Go to start of metadata

Purpose

The purpose of this document is to provide the steps which we could use to build DB2 LUW HADR on existing DB2 database.

Step1:

Add the IP addresses to the hostname mappings in the /etc/hosts file of each database server (Primary and Standby) like the following:

In current database server (CNPVG1121):
# cat /etc/hosts
10.58.132.239 CNPVG1121.apj.global.corp.sap CNPVG1121
10.58.132.190 CNPVG1122.apj.global.corp.sap CNPVG1122

In new added database server (CNPVG1122):
# cat /etc/hosts
10.58.132.190 CNPVG1122.apj.global.corp.sap CNPVG1122
10.58.132.239 CNPVG1121.apj.global.corp.sap CNPVG1121

Step 2:

Find and record uid number and gid number of following users on current database host:

CNPVG1121:/ # id db2adh uid=1002(db2adh) gid=1002(dbadhadm) groups=1000(sapinst),1002(dbadhadm)
CNPVG1121:/ # id adhadm uid=1001(adhadm) gid=1001(sapsys) groups=1000(sapinst),1003(dbadhctl),1001(sapsys)
CNPVG1121:/ # id sapadh uid=1003(sapadh) gid=1005(dbadhmon) groups=16(dialout),33(video),1005(dbadhmon)

Step 3: 

The directories /sapmnt/<SID>/exe, /sapmnt/<SID>/profile and /sapmnt/<SID>/global from Central Instance are needed to be mounted on the new database (standby) host:
Add following entries in /etc/exports of Central Instance:
/sapmnt/<SID>>/exe <new db host ip> (rw,no_root_squash,async,insecure,no_subtree_check)
/sapmnt/<SID>/global <new db host ip> (rw,no_root_squash,async,insecure,no_subtree_check)
/sapmnt/<SID>/profile <new db host ip> (rw,no_root_squash,async,insecure,no_subtree_check)
and then run:
# exportfs –a
Add following entries in /etc/fstab of new db host (Standby Database):
<Central Instance IP>:/sapmnt/<SID>/exe /sapmnt/<SID>/exe nfs defaults 0 0 <Central Instance IP>:/sapmnt/<SID>/global /sapmnt/<SID>/global nfs defaults 0 0 <Central Instance IP>:/sapmnt/<SID>/profile /sapmnt/<SID>/profile nfs defaults 0 0
and then run:
# mount –a

Step 4:

Backup the database of current existing system like the following:
db2 backup db ADH online to /db2/ADH/backup Backup successful.
The timestamp for this backup image is: 20150412162558

Step 5:

Start the installation of standby database from SWPM like the following: 

Choose the system copy method:

Input the user id number, group id number with the same values according to the values we got in Section 2

Choose HADR as cluster type:

Input HADR log shipping ports:

 

restore the database with previous backup of original database at the step when SWPM ask to restore database for homogeneous system copy, after restore we need to cancel the SWPM:

Step 6:

Restore the database during system copy
Specify the new added database to use the same log archive directory of current database:

Add following entry in /etc/exports of current db host(Primary database):
/db2/ADH/log_archive CNPVG1122(rw,no_root_squash,async,insecure,no_subtree_check)
then run: # exportfs –a
Add following entry in /etc/fstab of new added db host:
CNPVG1121:/db2/ADH/log_archive /db2/ADH/log_archive nfs defaults 0 0
then run: # mount –a
Specify the log archive directory on new added database: db2 update db cfg for ADH using LOGARCHMETH1 DISK:/db2/ADH/log_archive
Copy the online backup of current database into ‘/db2/<SID>/backup’ of new db host and restore the database:
db2 restore db ADH from /db2/ADH/backup DB20000I  The RESTORE DATABASE command completed successfully.
The new restored database should be in rollforward pending status like the following:
db2 get db cfg for ADH|grep Rollforward Rollforward pending                                     = DATABASE

Step 7: 

Configure the HADR
Checking in two database servers with ‘cat /etc/services | grep -i <SID>’ to ensure the following ports should be same both in current and in new created db host:
In current database server (Primary): # cat /etc/services | grep -i ADH
sapmsADH 3601/tcp # SAP System Message Server Port
sapdb2ADH 5919/tcp # SAP DB2 Communication Port
ADH_HADR_1 5951/tcp
ADH_HADR_2 5952/tcp
DB2_db2adh 5915/tcp
DB2_db2adh_1 5916/tcp
DB2_db2adh_2 5917/tcp
DB2_db2adh_END 5918/tcp


In new created db host (Standby): # cat /etc/services | grep -i ADH

sapmsADH 3601/tcp # SAP System Message Server Port
sapdb2ADH 5919/tcp # SAP DB2 Communication Port
ADH_HADR_1 5951/tcp
ADH_HADR_2 5952/tcp
DB2_db2adh 5915/tcp
DB2_db2adh_1 5916/tcp
DB2_db2adh_2 5917/tcp
DB2_db2adh_END 5918/tcp


and then configure HADR like the followings:
in current database (Primary):

db2 UPDATE DB CFG FOR ADH USING HADR_LOCAL_HOST CNPVG1121 10.58.132.239
db2 UPDATE DB CFG FOR ADH USING HADR_LOCAL_SVC ADH_HADR_1
db2 UPDATE DB CFG FOR ADH USING HADR_REMOTE_HOST CNPVG1122 10.58.132.190
db2 UPDATE DB CFG FOR ADH USING HADR_REMOTE_SVC ADH_HADR_2
db2 UPDATE DB CFG FOR ADH USING HADR_REMOTE_INST db2adh
db2 UPDATE DB CFG FOR ADH USING HADR_TIMEOUT 120
db2 UPDATE DB CFG FOR ADH USING HADR_SYNCMODE NEARSYNC
db2 UPDATE DB CFG FOR ADH USING HADR_SPOOL_LIMIT 1000
db2 UPDATE DB CFG FOR ADH USING HADR_PEER_WINDOW 240
db2 UPDATE DB CFG FOR ADH USING indexrec RESTART logindexbuild ON
in new crated database (Standby):

db2 UPDATE DB CFG FOR ADH USING HADR_LOCAL_HOST CNPVG1122
db2 UPDATE DB CFG FOR ADH USING HADR_LOCAL_SVC ADH_HADR_2
db2 UPDATE DB CFG FOR ADH USING HADR_REMOTE_HOST CNPVG1121
db2 UPDATE DB CFG FOR ADH USING HADR_REMOTE_SVC ADH_HADR_1
db2 UPDATE DB CFG FOR ADH USING HADR_REMOTE_INST db2adh
db2 UPDATE DB CFG FOR ADH USING HADR_TIMEOUT 120
db2 UPDATE DB CFG FOR ADH USING HADR_SYNCMODE NEARSYNC
db2 UPDATE DB CFG FOR ADH USING HADR_SPOOL_LIMIT 1000
db2 UPDATE DB CFG FOR ADH USING HADR_PEER_WINDOW 240
db2 UPDATE DB CFG FOR ADH USING indexrec RESTART logindexbuild ON

Step 8:

Start Hadr:
start new created database as standby database firstly:
CNPVG1122:db2adh 51> db2 deactivate db adh
DB20000I The DEACTIVATE DATABASE command completed successfully.

CNPVG1122:db2adh 52> db2 start hadr on db adh as standby
DB20000I  The START HADR ON DATABASE command completed successfully.

Then start the original database as Primary database:
CNPVG1121:db2adh 55> db2 deactivate db adh
DB20000I  The DEACTIVATE DATABASE command completed successfully.

CNPVG1121:db2adh 55> db2 start hadr on db adh as primary
DB20000I  The START HADR ON DATABASE command completed successfully.

Then the HADR database will be built successfully, we can use following command to check the current status of Primary and Standby databases with db2<sid>:

db2pd -d <SID> -hadr

 

Related Documents and Links:

- System requirements for HADR
http://www-01.ibm.com/support/knowledgecenter/SSEPGG_10.1.0/com.ibm.db2.luw.admin.ha.doc/doc/c0011759.html?lang=en         
- Introduction about the setup of HADR
http://www-01.ibm.com/support/knowledgecenter/SSEPGG_10.1.0/com.ibm.db2.luw.admin.ha.doc/doc/t0011725.html?lang=en

Installation Guide of SAP NetWeaver on UNIX: IBM DB2 for Linux, UNIX, and Windows (Valid for SAP NetWeaver 7.1 to 7.4 SR1)
Installation Guide of IBM DB2 High Availability Solution: IBM Tivoli System Automation for Multiplatforms

Related SAP Notes:

Note 1555903: DB6: Supported DB2 Database Features
Note 1700631: DB6: Using DB2 10.1 with SAP Applications
Note 1612105: DB6: FAQ for DB2 High Availability Disaster Recovery (HADR)

__________________________________________________________________________________________________________

Use this structure to help you compose your contributions for WIKI and at the same time will ensure spelling and grammar.

 

  • No labels