Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2794612
  • 博文数量: 423
  • 博客积分: 7770
  • 博客等级: 少将
  • 技术积分: 4766
  • 用 户 组: 普通用户
  • 注册时间: 2006-11-09 11:58
个人简介

Oracle/DB2/Postgresql/Mysql/Hadoop/Greenplum/Postgres-xl/Mongodb

文章分类

全部博文(423)

文章存档

2019年(3)

2018年(6)

2017年(27)

2016年(23)

2015年(30)

2014年(16)

2013年(31)

2012年(73)

2011年(45)

2010年(14)

2009年(30)

2008年(30)

2007年(63)

2006年(32)

分类: DB2/Informix

2014-12-29 18:34:17

Question

You plan to setup High Availability Data Replication between two DB2 databases and need step by step instructions

Answer

These instructions allow you to setup HADR for DB2 on a Windows environment. However the same commands can be used for Linux and UNIX by simply changing the "D:\" to a valid path.


ON THE PRIMARY: 
                                                                         
1. Create sample db using the db2sampl command.

  db2sampl

2. Enable it for log archiving.

   1.  For db2 version 9.5 and 9.7
  db2 update db cfg for using LOGARCHMETH1 LOGRETAIN
  
Above command will enable to database for log archiving and keep the logs in the same active log directory. This will also place the db in backup pending state.

3. Take an offline backup.
   db2 "backup database "

4. Setting up HADR cfg parameters on Primary database.

   db2 update db cfg for using HADR_LOCAL_HOST
   db2 update db cfg for using HADR_LOCAL_SVC
   db2 update db cfg for using HADR_REMOTE_HOST
   db2 update db cfg for using HADR_REMOTE_SVC
   db2 update db cfg for using HADR_REMOTE_INST
   db2 update db cfg for using LOGINDEXBUILD ON

5. Take an offline backup to be used for setting HADR.

   db2 "backup database "



ON THE STANDBY MACHINE:

Ensure both the servers are on the same db2level so that a mismatch situation does not occur. Run "db2level" command on both the servers to check whether they are on the same DB2 Version and Fix Pack. 

6. FTP the backup image (from the primary machine) to the STANDBY MACHINE

7. db2 "restore database DBNAME"

8. Setting up HADR cfg parameters on standby database.

   db2 update db cfg for using HADR_LOCAL_HOST
   db2 update db cfg for using HADR_LOCAL_SVC
   db2 update db cfg for using HADR_REMOTE_HOST
   db2 update db cfg for using HADR_REMOTE_SVC
   db2 update db cfg for using HADR_REMOTE_INST
   

9. db2 start hadr on database as standby

 

ON THE PRIMARY MACHINE:

10. Starting up HADR on the primary server

   db2 start hadr on database as primary

   --Verifing HADR is up and running
   db2pd -db -hadr

==================================================================

Here's the steps on switching roles (PRIMARY/STANDBY) between the two     
machine (CM01 and CM11).

1. ON PRIMARY (CM01): db2 connect to
2. ON PRIMARY (CM01): db2 "create table tab1 (col1 int)"
3. ON PRIMARY (CM01): db2 "insert into tab1 values (1)" -insert 20 rows
4. ON PRIMARY (CM01): power down the Primary --> db2stop force
5. ON STANDBY (CM11): db2 takeover hadr on database by force
6. The STANDBY instance on CM11 (DB2) is now the primary
7. ON CM11: db2pd -db -hadr (the ROLE should state: PRIMARY)
8. ON CM11: db2 connect to
9. ON CM11: db2 "select * from tab1" -You should see the 20 rows inserted
10. ON CM11: db2 "create table tab2 (col1 int)"
11. ON CM11 db2 "insert into tab2 values (1)" -insert about 20 rows
12. ON CM01: db2 start hadr on database as standby
13. ON CM01: db2pd -db -hadr (the ROLE should state: STANDBY)
14. on CM01: db2 takeover hadr on database
15. on CM01: db2pd -db -hadr (the ROLE should state: PRIMARY)
16. ON CM01: db2 "select * from tab2" -you should be able to see the 20 rows inserted
17. on CM11: db2pd -db -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.


Rate this page:

(0 users)Average rating

Document information


More support for:

DB2 for Linux, UNIX and Windows

Software version:

9.1, 9.5, 9.7

Operating system(s):

AIX, HP-UX, Linux, Solaris, Windows

Reference #:

1410648

Modified date:

2013-01-31

Translate my page

阅读(2776) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~