====== DB2 High Availability Data Replication - Setup ======
===== PRIMARY NODE =====
**1. Identify or create database for HADR**
db2 create database ... or db2sampl
**2. Configure DB for log archiving**
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. Configure HADR DB 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
**4. Take an offline backup to be used for HADR configuration**
db2 "backup database [to '/path/to/backup'|use TSM]"
**5. Transfer the backup image to the Standby node or grant access to Standby TSM node**
===== STANDBY NODE =====
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. Restore the database from backup image (disk or TSM)**
db2 "restore database DBNAME [from '/path/to/backup'|use TSM] taken at "
**7. Configure HADR DB parameters on Standby DB**
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
**8. Start HADR on Standby DB**
db2 start hadr on database as standby
===== PRIMARY NODE =====
**9. Start HADR on Primary DB**
db2 start hadr on database as primary
**10. Check HADR is up and running**
db2pd -db -hadr
Hostname of the HADR pair cannot be the same on both the servers.
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.