9.1.1 Configuring HADR on a primary/standby database

You can configure HADR using the command-line processor (CLP), the Set Up High Availability disaster recovery (HADR) wizard in Control Center, or by the corresponding application programming interfaces (APIs). Use the following procedure to configure primary and standby databases for High Availability disaster recovery using the CLP:

1.xxxx

Enable log archiving. Configure other DB2 parameters on the primary database:

(P) $ db2 update db configuration for rmall using LOGRETAIN RECOVERY
(P) $ db2 update db configuration for rmall using LOGINDEXBUILD ON
(P) $ db2 update db configuration for rmall using INDEXREC RESTART
(P) $ db2 update db configuration for rmall using NEWLOGPATH 
"/db2log/"

Note: We highly recommended that you use the NEWLOGPATH configuration parameter to put database logs on a separate device from the database once the database is created. This protects your database from media failure where the logs are stored, and improves the overall performance of database system.

2.xxxx

Perform the command in Example 9-1 to restore the database in standby.

Example 9-1 Restore database in standby

(S) $ db2 restore db rmall replace history file

3.xxxx

Configure HADR and client reroute on the primary database. As primary instance owner, set HADR-related parameters for the primary database, as shown in Example 9-2.

Example 9-2 primary database parameter configuration

(P) $ db2 update db configuration for rmall using HADR_LOCAL_HOST rayden2 
(P) $ db2 update db configuration for rmall using HADR_LOCAL_SVC 18819 
(P) $ db2 update db configuration for rmall using HADR_REMOTE_HOST salmon
(P) $ db2 update db configuration for rmall using HADR_REMOTE_SVC 18820
(P) $ db2 update db configuration for rmall using HADR_REMOTE_INST db2inst1
(P) $ db2 update db configuration for rmall using HADR_SYNCMODE NEARSYNC

Note: The configuration for this article uses the NEARSYNC synchronization mode. Transaction response time is shorter with NEARSYNC than with the other synchronous modes. However, protection against data loss is greater with other synchronization modes.

4.xxxx

Configure HADR and client reroute on the standby database. As the standby instance owner, set HADR-related parameters for the standby database as shown in Example 9-3.

Example 9-3 standby database parameter configuration

(S) $ db2 update db configuration for rmall using HADR_LOCAL_HOST salmonsalmon 
(S) $ db2 update db configuration for rmall using HADR_LOCAL_SVC 18820 
(S) $ db2 update db configuration for rmall using HADR_REMOTE_HOST rayden2
(S) $ db2 update db configuration for rmall using HADR_REMOTE_SVC 18819
(S) $ db2 update db configuration for rmall using HADR_REMOTE_INST db2inst1
(S) $ db2 update db configuration for rmall using HADR_SYNCMODE NEARSYNC

5.xxxx

Start HADR. You can use the commands shown in Example 9-4

Example 9-4 Start HADR

(S) $ db2 start hadr on db rmall as standby
(P) $ db2 start hadr on db rmall as primary

Note: IBM recommends starting HADR on the standby server before you start HADR on a primary database server. When you start HADR on a primary database server, the database server waits up to HADR_TIMEOUT seconds for a standby database server to connect to it. If there is still no standby database server connected after HADR_TIMEOUT seconds have passed, the HADR start on the primary database server fails.

6.xxxx

Verify that HADR has been successfully configured:
Review the db2diag.log on both the primary and the standby database server to see whether HADR is configured correctly.
Examine the HADR status from a snapshot of both the primary database and the standby database. Figure 9-1 and Figure 9-2 show the HADR section returned by the GET SNAPSHOT command.

Figure 9-1 HADR standby server status

Figure 9-2 HADR primary server status
Check the DB2 log to see whether you can see the records shown in Example 9-5 (for the primary database) and Example 9-6 (for the standby database).

Example 9-5 DB2 log from the primary database

2007-07-03-21.26.46.707671-240 I61036A394         LEVEL: Warning
PID     : 565478               TID  : 1           PROC : db2agent (RMALL) 0
INSTANCE: db2inst1 NODE : 000         DB   : RMALL
APPHDL  : 0-28                 APPID: *LOCAL.db2inst1.070704012646
FUNCTION: DB2 UDB, High Availability Disaster Recovery, hdrEduStartup, probe:21151
MESSAGE : Info: HADR Startup has begun.

2007-07-03-21.26.46.789144-240 E61431A333         LEVEL: Event
PID     : 618662               TID  : 1           PROC : db2hadrp (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL   
FUNCTION: DB2 UDB, High Availability Disaster Recovery, hdrSetHdrState, probe:10000
CHANGE  : HADR state set to None (was None)

2007-07-03-21.26.46.825540-240 E61765A335         LEVEL: Event
PID     : 618662               TID  : 1           PROC : db2hadrp (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL   
FUNCTION: DB2 UDB, High Availability Disaster Recovery, hdrSetHdrState, probe:10000
CHANGE  : HADR state set to P-Boot (was None)

2007-07-03-21.26.46.848887-240 I62101A317         LEVEL: Warning
PID     : 618662               TID  : 1           PROC : db2hadrp (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL   
FUNCTION: DB2 UDB, High Availability Disaster Recovery, hdrEduP, probe:20301
MESSAGE : Info: Primary Started.

2007-07-03-21.26.47.452229-240 E62419A353         LEVEL: Event
PID     : 618662               TID  : 1           PROC : db2hadrp (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL   
FUNCTION: DB2 UDB, High Availability Disaster Recovery, hdrSetHdrState, probe:10000
CHANGE  : HADR state set to P-RemoteCatchupPending (was P-Boot)

2007-07-03-21.26.47.462966-240 I62773A398         LEVEL: Warning
PID     : 565478               TID  : 1           PROC : db2agent (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL
APPHDL  : 0-28                 APPID: *LOCAL.db2inst1.070704012646
FUNCTION: DB2 UDB, High Availability Disaster Recovery, hdrEduStartup, probe:21152
MESSAGE : Info: HADR Startup has completed.

2007-07-03-21.26.47.664441-240 E63172A362         LEVEL: Event
PID     : 618662               TID  : 1           PROC : db2hadrp (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL   
FUNCTION: DB2 UDB, High Availability Disaster Recovery, hdrSetHdrState, probe:10000
CHANGE  : HADR state set to P-RemoteCatchup (was P-RemoteCatchupPending)

2007-07-03-21.26.47.671841-240 I63535A336         LEVEL: Warning
PID     : 618662               TID  : 1           PROC : db2hadrp (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL   
FUNCTION: DB2 UDB, High Availability Disaster Recovery, hdrEduP, probe:20445
MESSAGE : remote catchup starts at 000000002A89500C

2007-07-03-21.26.47.769458-240 I63872A353         LEVEL: Warning
PID     : 618662               TID  : 1           PROC : db2hadrp (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL   
FUNCTION: DB2 UDB, High Availability Disaster Recovery, hdrTransitionPtoNPeer, probe:10645
MESSAGE : near peer catchup starts at 000000002B751D8B

2007-07-03-21.26.48.379809-240 E64226A352         LEVEL: Event
PID     : 618662               TID  : 1           PROC : db2hadrp (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL   
FUNCTION: DB2 UDB, High Availability Disaster Recovery, hdrSetHdrState, probe:10000
CHANGE  : HADR state set to P-NearlyPeer (was P-RemoteCatchup)

2007-07-03-21.26.48.389134-240 E64579A343         LEVEL: Event
PID     : 618662               TID  : 1           PROC : db2hadrp (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL   
FUNCTION: DB2 UDB, High Availability Disaster Recovery, hdrSetHdrState, probe:10000
CHANGE  : HADR state set to P-Peer (was P-NearlyPeer)

Example 9-6 DB2 log from the standby database

2007-07-03-21.17.04.600117-240 I568803A394        LEVEL: Warning
PID     : 24210                TID  : 1           PROC : db2agent (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL
APPHDL  : 0-120                APPID: *LOCAL.db2inst1.070704011702
FUNCTION: DB2 UDB, High Availability Disaster Recovery, hdrEduStartup, probe:21151
MESSAGE : Info: HADR Startup has begun.

2007-07-03-21.17.04.615717-240 E569198A333        LEVEL: Event
PID     : 15422                TID  : 1           PROC : db2hadrs (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL   
FUNCTION: DB2 UDB, High Availability Disaster Recovery, hdrSetHdrState, probe:10000
CHANGE  : HADR state set to None (was None)

2007-07-03-21.17.04.629921-240 E569532A335        LEVEL: Event
PID     : 15422                TID  : 1           PROC : db2hadrs (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL   
FUNCTION: DB2 UDB, High Availability Disaster Recovery, hdrSetHdrState, probe:10000
CHANGE  : HADR state set to S-Boot (was None)

2007-07-03-21.17.04.630221-240 I569868A338        LEVEL: Warning
PID     : 15422                TID  : 1           PROC : db2hadrs (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL   
FUNCTION: DB2 UDB, High Availability Disaster Recovery, hdrStartReplayMaster, probe:21251
MESSAGE : Info: Replaymaster Starting...

2007-07-03-21.17.04.637393-240 I570207A343        LEVEL: Warning
PID     : 30050                TID  : 1           PROC : db2agnti (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL
APPHDL  : 0-121
FUNCTION: DB2 UDB, High Availability Disaster Recovery, hdrEduStartup, probe:21151
MESSAGE : Info: HADR Startup has begun.

2007-07-03-21.17.04.715572-240 I570551A330        LEVEL: Warning
PID     : 30050                TID  : 1           PROC : db2agnti (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL
APPHDL  : 0-121
FUNCTION: DB2 UDB, recovery manager, sqlpReplayMaster, probe:300
MESSAGE : Starting Replay Master on standby.

2007-07-03-21.17.04.715934-240 I570882A340        LEVEL: Warning
PID     : 15422                TID  : 1           PROC : db2hadrs (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL   
FUNCTION: DB2 UDB, High Availability Disaster Recovery, hdrStartReplayMaster, probe:21252
MESSAGE : Info: Replaymaster request done.

2007-07-03-21.17.04.716189-240 E571223A345        LEVEL: Event
PID     : 15422                TID  : 1           PROC : db2hadrs (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL   
FUNCTION: DB2 UDB, High Availability Disaster Recovery, hdrSetHdrState, probe:10000
CHANGE  : HADR state set to S-LocalCatchup (was S-Boot)

2007-07-03-21.17.04.716451-240 I571569A317        LEVEL: Warning
PID     : 15422                TID  : 1           PROC : db2hadrs (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL   
FUNCTION: DB2 UDB, High Availability Disaster Recovery, hdrEduS, probe:20341
MESSAGE : Info: Standby Started.

2007-07-03-21.17.04.719812-240 E571887A346        LEVEL: Warning
PID     : 30050                TID  : 1           PROC : db2agnti (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL
APPHDL  : 0-121
FUNCTION: DB2 UDB, recovery manager, sqlpReplayMaster, probe:920
MESSAGE : ADM1602W  Rollforward recovery has been initiated.

2007-07-03-21.17.04.721055-240 E572234A389        LEVEL: Warning
PID     : 30050                TID  : 1           PROC : db2agnti (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL
APPHDL  : 0-121
FUNCTION: DB2 UDB, recovery manager, sqlpReplayMaster, probe:1740
MESSAGE : ADM1603I  DB2 is invoking the forward phase of the database 
          rollforward recovery.

2007-07-03-21.17.04.721383-240 I572624A420        LEVEL: Warning
PID     : 30050                TID  : 1           PROC : db2agnti (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL
APPHDL  : 0-121
FUNCTION: DB2 UDB, recovery manager, sqlpForwardRecovery, probe:720
DATA #1 : String, 103 bytes
Invoking database rollforward forward recovery,
lowtranlsn 000000002A89529F minbufflsn 000000002A0F44C0

2007-07-03-21.17.04.725989-240 I573045A358        LEVEL: Warning
PID     : 30050                TID  : 1           PROC : db2agnti (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL
APPHDL  : 0-121
FUNCTION: DB2 UDB, recovery manager, sqlprecm, probe:2000
MESSAGE : Using parallel recovery with 3 agents 9 QSets 27 queues and 16 chunks

2007-07-03-21.17.04.716208-240 I573404A398        LEVEL: Warning
PID     : 24210                TID  : 1           PROC : db2agent (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL
APPHDL  : 0-120                APPID: *LOCAL.db2inst1.070704011702
FUNCTION: DB2 UDB, High Availability Disaster Recovery, hdrEduStartup, probe:21152
MESSAGE : Info: HADR Startup has completed.

2007-07-03-21.17.05.775420-240 I573803A320        LEVEL: Warning
PID     : 41284                TID  : 1           PROC : db2shred (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL
APPHDL  : 0-121
FUNCTION: DB2 UDB, recovery manager, sqlpshrEdu, probe:18300
MESSAGE : Maxing hdrLCUEndLsnRequested

2007-07-03-21.17.05.819612-240 E574124A361        LEVEL: Event
PID     : 15422                TID  : 1           PROC : db2hadrs (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL   
FUNCTION: DB2 UDB, High Availability Disaster Recovery, hdrSetHdrState, probe:10000
CHANGE  : HADR state set to S-RemoteCatchupPending (was S-LocalCatchup)

2007-07-03-21.17.22.845448-240 E574486A369        LEVEL: Event
PID     : 15422                TID  : 1           PROC : db2hadrs (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL   
FUNCTION: DB2 UDB, High Availability Disaster Recovery, hdrSetHdrState, probe:10000
CHANGE  : HADR state set to S-RemoteCatchupPending (was S-RemoteCatchupPending)

2007-07-03-21.17.22.872810-240 E574856A362        LEVEL: Event
PID     : 15422                TID  : 1           PROC : db2hadrs (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL   
FUNCTION: DB2 UDB, High Availability Disaster Recovery, hdrSetHdrState, probe:10000
CHANGE  : HADR state set to S-RemoteCatchup (was S-RemoteCatchupPending)

2007-07-03-21.17.22.873088-240 I575219A335        LEVEL: Warning
PID     : 15422                TID  : 1           PROC : db2hadrs (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL   
FUNCTION: DB2 UDB, High Availability Disaster Recovery, hdrSPrepareLogWrite, probe:10260
MESSAGE : RCUStartLsn 000000002A89539A

2007-07-03-21.17.23.712898-240 E575555A352        LEVEL: Event
PID     : 15422                TID  : 1           PROC : db2hadrs (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL   
FUNCTION: DB2 UDB, High Availability Disaster Recovery, hdrSetHdrState, probe:10000
CHANGE  : HADR state set to S-NearlyPeer (was S-RemoteCatchup)

2007-07-03-21.17.23.782792-240 E575908A343        LEVEL: Event
PID     : 15422                TID  : 1           PROC : db2hadrs (RMALL) 0
INSTANCE: db2inst1             NODE : 000         DB   : RMALL   
FUNCTION: DB2 UDB, High Availability Disaster Recovery, hdrSetHdrState, probe:10000
CHANGE  : HADR state set to S-Peer (was S-NearlyPeer)

xxxx