IBM DB2 comes and integrates a multitude of high-availability solutions, that can employ and increase the availability of databases. There are software high availability solutions, such as SQL Replication, Q Replication, HADR, DB2 ACS, and IBM TSA, and hardware-based solutions, such as IBM PPRC, HACMP, FlashCopy, or hybrid such as the new clustering solution provided by DB2 pureScale technology, covered in Chapter 14, IBM pureScale Technology and DB2. Obviously, we can choose to implement one solution or use a virtually unlimited number of combinations to ensure that we are highly protected from any type of disaster. In the following recipes, we will cover how to set up and DB2 fault monitor as high availability solutions as a high availability solution.
HADR is a high availability software solution provided by IBM for DB2 database protection in the case of disaster or critical database failure. HADR is an abbreviation for High Availability Disaster Recovery. The technology itself can be classified as a replication solution. Basically, this technology replicates data by sending and replaying logs from a source database to a destination database. The source database, by convention, is called the primary database; the destination database is called the standby database
Some important benefits of HADR:
Some restrictions with using HADR:
Operations replicated using HADR:
Operations that do not replicate using HADR:
Setting up HADR is straightforward. You can use a variety of methods to set up HADR, using the command line or Control Center, and IBM Optim Database Administrator HADR setup wizards. In the following recipe, we will set up HADR using the command line.
In this recipe, nodedb21 will be used for the initial primary database, and nodedb22 for the initial standby database. We use the term initially, because in the following recipes, we will initiate takeover and takeover by force operations, and the databases will exchange and change their roles. All operations will be conducted on the non-partitioned NAV database, under instance db2inst1 on nodedb21, and db2inst1 on nodedb22.
To set up a HADR configuration, we will use the following steps:
Install IBM DB2 9.7 Enterprise Server Edition in location /opt/ibm/db2/V9.7_01, on nodedb22; create users db2inst1 and db2fenc1, and instance db2inst1, during installation.
[root@nodedb22 ~]# mkdir -p /data/db2/db2inst1/nav
[root@nodedb22 ~]#
[root@nodedb22 ~]# mkdir -p /data/db2/db2inst1/logarchives
[root@nodedb22 ~]#
[root@nodedb21 ~]# mkdir -p /data/db2/db2inst1/logarchives
[root@nodedb22 ~]#
[root@nodedb21 ~]# mkdir -p /data/db2/db2inst1/backup
[root@nodedb21 ~]#
[root@nodedb21 ~]# mkdir -p /data/db2/db2inst1/backup
[root@nodedb21 ~]#
[root@nodedb21 ~]# mkdir -p /data/db2/db2inst1/mirrorlogs
[root@nodedb21 ~]#
[root@nodedb22 ~]# mkdir -p /data/db2/db2inst1/mirrorlogs
[root@nodedb22~]#
This is just an example; usually, the mirror logs should be stored in a safe location. If it is possible use an NFS mount exported from another server.
[root@nodedb21 ~]# chown –R db2inst1:db2iadm1 /data/db2/db2inst1
[root@nodedb21 ~]#
[root@nodedb22 ~]# chown –R db2inst1:db2iadm1 /data/db2/db2inst1
[root@nodedb22 ~]#
[db2inst1@nodedb21 ~]$ db2 “CONNECT TO NAV”
Database Connection Information
Database server = DB2/LINUXX8664 9.7.4
SQL authorization ID = DB2INST1
Local database alias = NAV
[db2inst1@nodedb21 ~]$ db2 “QUIESCE DATABASE IMMEDIATE”
DB20000I The QUIESCE DATABASE command completed successfully.
[db2inst1@nodedb21 ~]$
[db2inst1@nodedb21 ~]$ db2 “UPDATE DB CFG FOR NAV USING
logarchmeth1 ‘DISK:/data/db2/db2inst1/logarchives'”
DB20000I The UPDATE DATABASE CONFIGURATION command completed
successfully.
[db2inst1@nodedb21 ~]$
[db2inst1@nodedb21 ~]$ db2 “UPDATE DB CFG FOR NAV USING
LOGPRIMARY 20″
DB20000I The UPDATE DATABASE CONFIGURATION command completed
successfully.
[db2inst1@nodedb21 ~]$
[db2inst1@nodedb21 ~]$ db2 “UPDATE DB CFG FOR NAV USING
LOGSECOND 5″
DB20000I The UPDATE DATABASE CONFIGURATION command completed
successfully.
[db2inst1@nodedb21 ~]$
[db2inst1@nodedb21 ~]$ db2 “UPDATE DB CFG FOR NAV USING
LOGFILSIZ 2048 “
DB20000I The UPDATE DATABASE CONFIGURATION command completed
successfully.
[db2inst1@nodedb21
[db2inst1@nodedb21 ~]$ db2 “UPDATE DATABASE CONFIGURATION USING
MIRRORLOGPATH /data/db2/db2inst1/mirrorlogfiles”
DB20000I The UPDATE DATABASE CONFIGURATION command completed
successfully.
[db2inst1@nodedb21 ~]$
[db2inst1@nodedb21 ~]$ db2 “UPDATE DB CFG FOR NAV USING
LOGBUFSZ 1024 “
DB20000I The UPDATE DATABASE CONFIGURATION command completed
successfully.
db2inst1@nodedb21 ~]$
[db2inst1@nodedb21 ~]$ db2 “UNQUIESCE DATABASE”
DB20000I The UNQUIESCE DATABASE command completed successfully.
[db2inst1@nodedb21 ~]$
[db2inst1@nodedb21 ~]$ db2 “UPDATE DATABASE CONFIGURATION FOR NAV
USING LOGINDEXBUILD ON “
DB20000I The UPDATE DATABASE CONFIGURATION command completed
successfully.
[db2inst1@nodedb21 ~]$
LOGBUFSZ should be correlated with network tuning; try to set TCP tunables (receive and send buffer) to appropriate values.
[db2inst1@nodedb21 ~]$ db2 “UPDATE DATABASE CONFIGURATION FOR NAV
USING INDEXREC RESTART”
DB20000I The UPDATE DATABASE CONFIGURATION command completed
successfully.
[db2inst1@nodedb21 ~]$
[db2inst1@nodedb21 ~]$ db2 terminate
DB20000I The TERMINATE command completed successfully.
[db2inst1@nodedb21 ~]$ db2 “BACKUP DATABASE NAV TO “/data/backup”
COMPRESS”
Backup successful. The timestamp for this backup image is :
20110707150659
[db2inst1@nodedb21 ~]$
[db2inst1@nodedb21 ~]$ scp /data/db2/db2inst1/backup/
NAV.0.db2inst1.NODE0000.CATN0000.
20110707150659.001 nodedb22:/data/db2/db2inst1/backup
db2inst1@nodedb22’s password:
NAV.0.db2inst1.NODE0000.CATN0000.20110707150659.001
[db2inst1@nodedb21 ~]$
[db2inst1@nodedb22 ~]$ db2 “RESTORE DATABASE NAV FROM /data/db2/
db2inst1/backup TAKEN AT 20110707150659 REPLACE
HISTORY FILE”
DB20000I The RESTORE DATABASE command completed successfully.
[db2inst1@nodedb22 ~]$
DB2_HADR_NAV1 55006/tcp
DB2_HADR_NAV2 55007/tcp
[db2inst1@nodedb21 ~]$ db2 “UPDATE DATABASE CONFIGURATION
FOR NAV USING HADR_LOCAL_HOST nodedb21″
DB20000I The UPDATE DATABASE CONFIGURATION command
completed successfully.
[db2inst1@nodedb21 ~]$
DB2_HADR_NAV1 55006/tcp
DB2_HADR_NAV2 55007/tcp
I remember deciding to pursue my first IT certification, the CompTIA A+. I had signed…
Key takeaways The transformer architecture has proved to be revolutionary in outperforming the classical RNN…
Once we learn how to deploy an Ubuntu server, how to manage users, and how…
Key-takeaways: Clean code isn’t just a nice thing to have or a luxury in software projects; it's a necessity. If we…
While developing a web application, or setting dynamic pages and meta tags we need to deal with…
Software architecture is one of the most discussed topics in the software industry today, and…