DB2 HADR Setup
Create database on both database servers
$ db2 create database HADRTEST
Configuration setting on both databases
1. Check/Update /etc/hosts file
Make sure following entries exists on both the nodes
9.1.2.3 hadrnode01
9.1.2.4 hadrnode02
2. Check/Update /etc/services file
Make sure following entries exists on both the nodes
DB2_HADR_PORT 55555/tcp
Db2c_db2inst1 50000/tcp
3. Enable HADR on databases
hadrnode01
$ db2 update db cfg for HADRTEST using LOGINDEXBUILD ON
$ db2 update db cfg for HADRTEST using INDEXREC RESTART
$ db2 update db cfg for HADRTEST using LOGARCHMETH1 LOGRETAIN
$ db2 backup database HADRTEST to C:\BACKUP
$ db2 update db cfg for HADRTEST using HADR_LOCAL_HOST 9.1.2.3
$ db2 update db cfg for HADRTEST using HADR_LOCAL_SVC 55555
$ db2 update db cfg for HADRTEST using HADR_REMOTE_HOST 9.1.2.4
$ db2 update db cfg for HADRTEST using HADR_REMOTE_SVC 55555
$ db2 update db cfg for HADRTEST using HADR_REMOTE_INST DB2
$ db2 update db cfg for HADRTEST using HADR_TIMEOUT 120
$ db2 update db cfg for HADRTEST using HADR_SYNCMODE NEARSYNC
$ db2 backup database HADRTEST to C:\BACKUP
FTP the backup image (from the primary machine) to the STANDBY MACHINE
hadrnode02
$ db2 restore database HADRTEST from C:\BACKUP
$ db2 update db cfg for HADRTEST using HADR_LOCAL_HOST 9.1.2.4
$ db2 update db cfg for HADRTEST using HADR_LOCAL_SVC 55555
$ db2 update db cfg for HADRTEST using HADR_REMOTE_HOST 9.1.2.3
$ db2 update db cfg for HADRTEST using HADR_REMOTE_SVC 55555
$ db2 update db cfg for HADRTEST using HADR_REMOTE_INST DB2
$ db2 start hadr on database HADRTEST as standby
hadrnode01
$ db2 start hadr on database HADRTEST as primary
--Verifying HADR is up and running
db2pd -db HADRTEST -hadr
Steps on switching roles (PRIMARY/STANDBY) between the two
machine (hadrnode01 and hadrnode02)
1. ON PRIMARY (hadrnode01):
machine (hadrnode01 and hadrnode02)
1. ON PRIMARY (hadrnode01):
db2 connect to HADRTEST
2. ON PRIMARY (hadrnode01):
2. ON PRIMARY (hadrnode01):
db2 "create table tab1 (col1 int)"
3. ON PRIMARY (hadrnode01):
3. ON PRIMARY (hadrnode01):
db2 "insert into tab1 values (1)" -insert 10 rows
4. ON PRIMARY (hadrnode01): power down the Primary
4. ON PRIMARY (hadrnode01): power down the Primary
db2stop force
5. ON STANDBY (hadrnode02):
5. ON STANDBY (hadrnode02):
db2 takeover hadr on database HADRTEST by force
6. The STANDBY instance on hadrnode02 (DB2) is now the primary
7. ON hadrnode02:
6. The STANDBY instance on hadrnode02 (DB2) is now the primary
7. ON hadrnode02:
db2pd -db HADRTEST -hadr -(the ROLE should state: PRIMARY)
8. ON hadrnode02:
8. ON hadrnode02:
db2 connect to HADRTEST
9. ON hadrnode02:
9. ON hadrnode02:
db2 "select * from tab1" -You should see the 20 rows inserted
10. ON hadrnode02:
10. ON hadrnode02:
db2 "create table tab2 (col1 int)"
11. ON hadrnode02:
11. ON hadrnode02:
db2 "insert into tab2 values (1)" -insert about 10 rows
12. ON hadrnode01:
12. ON hadrnode01:
db2 start hadr on database HADRTEST as standby
13. ON hadrnode01:
13. ON hadrnode01:
db2pd -db HADRTEST -hadr -(the ROLE should state: STANDBY)
14. on hadrnode01:
14. on hadrnode01:
db2 takeover hadr on database HADRTEST
15. on hadrnode01:
15. on hadrnode01:
db2pd -db HADRTEST -hadr -(the ROLE should state: PRIMARY)
16. ON hadrnode01:
16. ON hadrnode01:
db2 "select * from tab2" -you should be able to see the 20 rows inserted
17. on hadrnode02:
17. on hadrnode02:
db2pd -db HADRTEST -hadr -(the ROLE should state; STANDBY)
Note:
1. Hostname of the HADR pair cannot be the same on both the servers.
2. The instance name and the underlying userid on UNIX systems can be different. Make sure to update the correct name of the instance for the db cfg parameter HADR_REMOTE_INST to the correct value.
References : http://www-01.ibm.com/support/docview.wss?uid=swg21410648, HADR with TSA using db2haicu
Note:
1. Hostname of the HADR pair cannot be the same on both the servers.
2. The instance name and the underlying userid on UNIX systems can be different. Make sure to update the correct name of the instance for the db cfg parameter HADR_REMOTE_INST to the correct value.
References : http://www-01.ibm.com/support/docview.wss?uid=swg21410648, HADR with TSA using db2haicu
No comments:
Post a Comment