DB2 HADR

So I have been struggling lately trying to figure out how to enable DB2 HADR (High Availability Disaster Recovery), and after several attempts, I manage to get it up and running and of course I documented the basic commands to get you started.

HADR Prerequisites

First of all make sure to respect the following rules:

  • Primary and standby machines MUST not have the same hostname
  • DB2 version and Fixpack MUST be the same on all machines use db2level to get DB2 installation information.
  • The OS version MUST be the same on all machines
  • The primary and standby machine(s) MUST have TCP/IP communication protocol enabled.

OK, once the above prerequisites are checked, we can start configuring DB2 HADR, in this example, our topology consists of two machines: Server1 and Server 2, Server1 will be the primary host and Server2 will be the standby one, both machines are using DB2 10.5 FP8, the database we are replicating called itimdb, I am assuming that the OS we’re using is Windows, so here is a table describing our current setup:

Server Server1 Server2
IP address 192.168.93.20 192.168.93.21
Instance name/port Db2admin/5002 Dbadmin/5002
Database name Itimdb itimdb
<Hadr service name>_<port> db2_hadr_1 60000/tcp db2_hadr_2 61000/tcp

HADR Setup

Specify the TCP/IP communication ports. On Windows, it is c:\windows\system32\drivers\etc\services, on Linux it is /etc/sevices.  Add two lines to the file on both systems to define the ports. The following lines are an example.

Each line specifies a connection service name, port number, and communications protocol. Make sure the port numbers are not used by other processes on the system, you can issue the command netstat -ato check if the ports are being used.

First, Link the primary database system to the standby database system by updating the following parameters:

The level of synchronization between the primary and standby database is determined by the synchronization mode parameter. By default, the mode is NEARSYNC. You can use the command to update it to a different mode.

READ ALSO  Microsoft is giving away ton of FREE BOOKS

Next, Create a folder e:\db2backup

Then, Back up the primary database.

Create a folder on the secondary server e:\db2backup

Transfer the backup image from the primary system to the standby system. Execute the following commands and restore the database on the standby system.

Link the standby database with the primary database system.

Next, Start the HADR on both databases. Start the standby system first:

Now start HADR on the primary database

To make sure that HADR is enabled on both machines, type the following command:

The output should be "CONNECTED", if not make sure you followed the steps as described above.

Last but not least, don’t forget to check IBM Knowledge Center for more information:

https://www.ibm.com/support/knowledgecenter/en/SSEPGG_10.5.0/com.ibm.db2.luw.admin.ha.doc/doc/c0006354.html

https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/DB2HADR/page/HADR%20Tutorial

The following two tabs change content below.
Ayoub Bahar, 25 years old, founder of this blog, I am passionate about coding, hacking, cracking and everything related to the new technologies. Follow me to get my latest articles.
Written by AYOUB BAHAR
Ayoub Bahar, 25 years old, founder of this blog, I am passionate about coding, hacking, cracking and everything related to the new technologies. Follow me to get my latest articles.