DB2 High Availability Disaster Recovery(HADR) is similar like oracle DataGurd.It's easy to configure and maintenance.You can learn how to configure it from this article.I have two nodes:syb02 and syb05.They are running redhat linux 6.3 and syb02 as the primary node,syb05 as the standby node.The DB2 version is V97fp7 for linux x86_64.I just show you using command-line to setup HADR.Also you can use the DB2 control center to  configure it.Following table is my environment:

Fast Track To DB2 V9.7 High Availability Disaster Recovery _DB2

1.Set the required database configuration parameters

  1. [abcinst@syb02 ~]$ db2 update db cfg for abcdb using logretain on  
  2. [abcinst@syb02 ~]$ db2 update db cfg for abcdb using trackmod on  
  3. [abcinst@syb02 ~]$ db2 update db cfg for abcdb using logindexbuild on 
  4. [abcinst@syb02 ~]$ db2 update db cfg for abcdb using indexrec restart 

2.Back up abcdb on the primary by running the following command

  1. [abcinst@syb02 ~]$ db2 backup db abcdb to /share/db2/backup/ 
  2. Backup successful. The timestamp for this backup p_w_picpath is : 20130409194052 

3.Move a copy of the backup to the standby server

4.Restore the database on standby server

  1. [abcinst@syb05 ~]$ db2 restore db abcdb from /share/db2/backup taken at 20130409194052 replace history file 

Notice:After restore to standby server,you mustn't run rollforward command.

5.Configure databases for ACR(optional)

  1. On primary server: 
  2. [abcinst@syb02 ~]$ db2 update alternate server for db abcdb using hostname 172.16.255.35 port 50000 
  3. On standby server: 
  4. [abcinst@syb05 ~]$ db2 update alternate server for db abcdb using hostname 172.16.255.32 port 50000 

6.Append following line into /etc/services

  1. [root@syb02 ~]# tail -2 /etc/services  
  2. DB2_HADR_1      55001/tcp 
  3. DB2_HADR_2      55002/tcp 

7.Update the HADR database configuration parameters on the primary database

  1. [abcinst@syb02 ~]$ db2 update db cfg for abcdb using HADR_LOCAL_HOST 172.16.255.32 
  2. [abcinst@syb02 ~]$ db2 update db cfg for abcdb using HADR_LOCAL_SVC DB2_HADR_1 
  3. [abcinst@syb02 ~]$ db2 update db cfg for abcdb using HADR_REMOTE_HOST 172.16.255.35 
  4. [abcinst@syb02 ~]$ db2 update db cfg for abcdb using HADR_REMOTE_SVC DB2_HADR_2 
  5. [abcinst@syb02 ~]$ db2 update db cfg for abcdb using HADR_REMOTE_INST abcinst 
  6. [abcinst@syb02 ~]$ db2 update db cfg for abcdb using HADR_SYNCMODE SYNC 
  7. [abcinst@syb02 ~]$ db2 update db cfg for abcdb using HADR_TIMEOUT 120 
  8. [abcinst@syb02 ~]$ db2 connect to abcdb 
  9. [abcinst@syb02 ~]$ db2 quiesce db immediate force connections 
  10. [abcinst@syb02 ~]$ db2 unquiesce db 
  11. [abcinst@syb02 ~]$ db2 connect reset 

8.Update the HADR database configuration parameters on the standby database

  1. [abcinst@syb05 ~]$ db2 update db cfg for abcdb using HADR_LOCAL_HOST 172.16.255.35 
  2. [abcinst@syb05 ~]$ db2 update db cfg for abcdb using HADR_LOCAL_SVC DB2_HADR_2 
  3. [abcinst@syb05 ~]$ db2 update db cfg for abcdb using HADR_REMOTE_HOST 172.16.255.32 
  4. [abcinst@syb05 ~]$ db2 update db cfg for abcdb using HADR_REMOTE_SVC DB2_HADR_1 
  5. [abcinst@syb05 ~]$ db2 update db cfg for abcdb using HADR_REMOTE_INST abcinst 
  6. [abcinst@syb05 ~]$ db2 update db cfg for abcdb using HADR_SYNCMODE SYNC 
  7. [abcinst@syb05 ~]$ db2 update db cfg for abcdb using HADR_TIMEOUT 120 

9.Optional

If you want to use the reads on standby feature, you must set the corresponding registry variables on the standby server by running the following commands:

  1. [abcinst@syb05 ~]$ db2set DB2_HADR_ROS=ON 
  2. [abcinst@syb05 ~]$ db2set DB2_STANDBY_ISO=UR 

10.Start the standby database first by the following commands on SYB05

  1. [abcinst@syb05 ~]$ db2 deactivate db abcdb 
  2. [abcinst@syb05 ~]$ db2 start hadr on db abcdb as standby 
  3. SQL1766W  The command completed successfully. However, LOGINDEXBUILD was not enabled before HADR was started. 

11.Start HADR on the primary database on SYB02

  1. [abcinst@syb02 ~]$ db2 deactivate db abcdb 
  2. [abcinst@syb02 ~]$ db2 start hadr on db abcdb as primary 

Testing the HADR

1.Connect to primary database do following steps

Create a table:SYB_DATABASEINF

  1. [abcinst@syb02 ~]$ db2 connect to abcdb 
  2. [abcinst@syb02 ~]$ db2 "create table SYB_DATABASEINF ( 
  3. hostname                        char(18)                         not null  , 
  4. accesstime                      char(20)                         not null  , 
  5. dbname                          char(20)                         not null  , 
  6. dbsize                          float(16)                        not null  , 
  7. datafree                        float(16)                        not null  , 
  8. logsize                         float(16)                        not null  , 
  9. logfree                         float(16)                        not null 
  10. in tbs01" 

Import data into SYB_DATABASEINF from textfile:

  1. [abcinst@syb02 ~]$ db2 "import from /mnt/iq2/SYB_DATABASEINF.txt of del insert into SYB_DATABASEINF"  
  2. [abcinst@syb02 ~]$ db2 "select count(*) from SYB_DATABASEINF" 
  3.  
  4. 1           
  5. ----------- 
  6.     1973065 

2.Switch roles of the databases

On standby server,running takeover command:

  1. [abcinst@syb05 ~]$ db2 takeover hadr on db abcdb 

After switch,the syb02 become to standby role and the syb05 become to primary role.

3.Checking all of the roles status

On new primary server:

  1. [abcinst@syb05 ~]$ db2 get snapshot for db on abcdb |grep -B 15 "Log gap running average(bytes)" 
  2.  
  3. HADR Status 
  4.   Role                   = Primary 
  5.   State                  = Peer 
  6.   Synchronization mode   = Sync 
  7.   Connection status      = Connected, 04/10/2013 15:08:57.689470 
  8.   Heartbeats missed      = 0 
  9.   Local host             = 172.16.255.35 
  10.   Local service          = DB2_HADR_2 
  11.   Remote host            = 172.16.255.32 
  12.   Remote service         = DB2_HADR_1 
  13.   Remote instance        = abcinst 
  14.   timeout(seconds)       = 120 
  15.   Primary log position(file, page, LSN) = S0000048.LOG, 8448, 000000004F8289F1 
  16.   Standby log position(file, page, LSN) = S0000048.LOG, 8448, 000000004F8289F1 
  17.   Log gap running average(bytes) = 0 

On new standby server:

  1. [abcinst@syb02 ~]$ db2 get snapshot for db on abcdb |grep -B 15 "Log gap running average(bytes)" 
  2.  
  3. HADR Status 
  4.   Role                   = Standby 
  5.   State                  = Peer 
  6.   Synchronization mode   = Sync 
  7.   Connection status      = Connected, 04/09/2013 23:08:45.964717 
  8.   Heartbeats missed      = 0 
  9.   Local host             = 172.16.255.32 
  10.   Local service          = DB2_HADR_1 
  11.   Remote host            = 172.16.255.35 
  12.   Remote service         = DB2_HADR_2 
  13.   Remote instance        = abcinst 
  14.   timeout(seconds)       = 120 
  15.   Primary log position(file, page, LSN) = S0000048.LOG, 8448, 000000004F8289F1 
  16.   Standby log position(file, page, LSN) = S0000048.LOG, 8448, 000000004F8289F1 
  17.   Log gap running average(bytes) = 0 

4.Connect to the new primary server and query the total number of SYB_DATABASEINF table

  1. [abcinst@syb05 ~]$ connect to abcdb 
  2.    Database Connection Information 
  3.  
  4.  Database server        = DB2/LINUXX8664 9.7.7 
  5.  SQL authorization ID   = ABCINST 
  6.  Local database alias   = ABCDB 
  7. [abcinst@syb05 ~]$ db2 "select count(*) from SYB_DATABASEINF" 
  8.  
  9. 1           
  10. ----------- 
  11.     1973065 

That's all for Fast Track To DB2 High Availability Disaster Recovery,for more information from here