Setting up DB2 HADR
These days databases are an important part of running the business, hence the availability of the database is astronomicallycritical. Â Its really important that critical database needs to have high availability at all times.IBM added HADR to DB2 few years back, it stands for High Availability Disaster Recovery. HADR provides failover capability should the primary database server fails. Â If the primary server fails, the workload is transferred over to the secondary server. HADR is not automatic failover, so don’t get confused with DB2 on Cluster Server .
In a HADR setup there is a primary server which is online and can accept connections from applications and then there is a secondary server which plays the log and keep the data in sync with the primary server.
Below are the tasks I did to setup DB2 HADR :
Tasks |
Server |
|
Server names |
Tom |
Jerry |
 |
 |
 |
OS |
Redhat Linux |
Redhat Linux |
DB2 edition |
V9.7 ESE |
V9.7 ESE |
IP address |
192.168.110.10 |
192.168.110.11 |
Instance |
db2inst1 |
db2inst1 |
Database |
CARTOON |
 |
 |
 |
 |
Backup database |
BACKUP DATABASE CARTOON TO /bkup |
 |
ftp/sftp |
ftp the backup file from Tom to Jerry |
 |
Update primary database for automatic client reroute; |
UPDATE ALTERNATE SERVER FOR DATABASE cartoons USING HOSTNAME jerry PORT 60000; |
 |
Update HADR configuration parameters for primary database |
UPDATE DB CFG FOR cartoons USING LOGINDEXBUILD ON ; |
 |
Restore database |
 |
RESTORE DATABASE cartoons FROM /db2bkup TAKEN AT 20110411090137 REPLACE HISTORY FILE WITHOUT PROMPTING; |
Update standby database for automatic client reroute; |
 |
UPDATE ALTERNATE SERVER FOR DATABASE cartoons USING HOSTNAME tom PORT 60000; |
Update HADR configuration parameters for standby database; |
 |
UPDATE DB CFG FOR cartoons USING LOGINDEXBUILD ON ; |
Start HADR on standby database |
 |
START HADR ON DATABASE cartoons AS STANDBY; |
Start HADR on primary database |
ATTACH TO “db2inst1”; |
 |
 |
 |
 |
Verify HADR status |
db2pd -hadr -d    >>> should say Primary Peer |
db2pd -hadr -d    >>> should say Standby Peer |
Manual takeover |
 |
takeover hadr on database cartoons |
Verify HADR status |
db2pd -hadr -d    >>> should say Standby Peer |
db2pd -hadr -d    >>> should say Primary Peer |
Â
Try it out and let me know how it goes ? Â As always use your best judgement when you try this on your system.