Professional Documents
Culture Documents
DB2 HADR Pacemaker Luis Garmendia
DB2 HADR Pacemaker Luis Garmendia
DB2 HADR Pacemaker Luis Garmendia
High availability
An outage is any disruption in the ability of the
database solution to serve user applications.
Unplanned outages
Examples of unplanned outages include:
• The failure of one component of the system, including
hardware or software failure.
• Invalid administrative or user application actions such
accidentally dropping a table that is needed for
business-critical transactions.
• Poor performance due to suboptimal configuration, or
inadequate hardware or software..
Indice
Introducción a HA Clusters
Pacemaker
Prerequisites and installation of Pacemaker
Db2cm. The db2 cluster management utility
Configuring a clustered environtment using
db2cm
Maintaining a Pacemaker cluster domain
References
High availability
Planned outages
• Upgrade. Upgrading your software or hardware
can sometimes require a partial or a full outage.
https://www.ibm.com/support/producthub/db2/docs/content/SSEPGG_11.5.
0/com.ibm.db2.luw.admin.ha.doc/doc/c0006354.html
High availability strategies
System monitoring
• Collecting statistics about the components of your
solution to facilitate workload balancing or detecting
that components have failed.
Load balancing
• Transferring some workload from an overloaded
component of your solution to another (Db2 purescale)
Maximizing performance
Minimizing the impact of maintenance
• (automated maintenance )
Database Logging
• Linear logging
High availability through
redundancy
Redundancy
Having secondary copies of each component.
At system level:
Uninterrupted or backup power supplies
Multiple network fibers between each component
Bonding or load balancing of network cards
Multiple hard drives in a redundant array
Clusters of CPUs
Db2 High Availability Disaster
Recover (HADR):
Redundancy
Db2 High Availability Disaster
Recover (HADR):
Redundancy
At database level having two databases
• A primary database that normally processes all or
most of the application workload;
• A secondary database (standby database) that can
take over the workload if the primary database fails
High availability through Failover
Failover
• Transferring all workload from a failed component of
your solution to a secondary component.
Idle Standby (HADR)
• A primary system processes all the workload while a
secondary or standby system is idle.
• In an high availability disaster recovery (HADR) setup,
you can have up to three standbys and you can
configure each standby to allow read-only workloads.
Heartbeat monitoring
To detect a failure on one machine in the cluster,
failover software can use heartbeat to confirm
availability.
Heartbeat monitoring involves system services
that maintain constant communication
between all the machines in a cluster.
If a heartbeat is not detected, failover to a
backup machine starts.
High availability through clustering
Corosync
Communication layer
Pacemaker utilizes the Corosync Cluster
Engine, an open source group communication
system software, to:
1. Provide a consistent view of cluster topology,
2. Ensure reliable messaging infrastructure so
that events are executed in the same order in
each node
3. To apply quorum constraints.
Pacemaker Resources
Constraints Examples
https://www.ibm.com/support/knowledgecenter/SSEPGG_11.5.0/com.ibm.db2.luw.admin.ha.doc/doc/c_pacemaker_base_component.html
Constraints Examples
https://www.ibm.com/support/knowledgecenter/SSEPGG_11.5.0/com.ibm.db2.luw.admin.ha.doc/doc/c_pacemaker_base_component.html
Constraints Examples
https://www.ibm.com/support/knowledgecenter/SSEPGG_11.5.0/com.ibm.db2.luw.admin.ha.doc/doc/c_pacemaker_base_component.html
Resource agents
A total of three resource agents are provided,
copied at
/usr/lib/ocf/resource.d/heartbeat
db2ethmon
The resource agent to monitor the defined
Ethernet network adapter.
This is at host level.
RA
Resource agents
db2inst
The resource agent to monitor, start, and stop
the Db2 member process.
This is at the Db2 instance level.
db2hadr
The resource agent to monitor, start, and stop
individual HADR-enabled databases.
This is at the Db2 database level.
RA
IP addresses
• An Internet Protocol address (IP address) is a
unique address on a network, for example:
129.30.180.16.
Subnet masks
• A network can be partitioned into multiple logical
subnets using subnet masks
• When you use db2cm to add an IP address to
your cluster domain, you have an option to
specify the subnet mask for the IP address.
RA
1) Connect to one of the Red Hat linux hosts, desde una terminal:
ssh inst491@10.250.0.1 Password: ibm2blue
ssh inst491@10.250.0.9 Password: ibm2blue
Db2 en: docker exec –it server /bin/bash
Correspondencia entre /home/inst491/hello-
docker/serverA/data y en docker /database
Db2cm en /home/inst491/hello-
docker/serverA/data/config/db2inst1/sqllib/adm
Pacemaker libraries en: /home/inst491/hello-
docker/serverA/data/tmp
su root Password: sinensia
Before Installing pacemaker
/etc/hosts
Add hosts short names pacemaker1 y pacemaker9 in /etc/hosts
(psswd de root: sinensia)
Before
After
:
Users and groupid
KornShell
In addition to packages reported by
the db2prereqcheck -l command, KornShell
(ksh) is required for the Db2 resource agents
for Pacemaker.
Cluster software
Db2 supports Pacemaker as an integrated
cluster manager solution.
However, this is only the case if
the Pacemaker and its software stack being
used are supplied by Db2 directly and
corresponds to a specific Db2 release and
configured using the new db2cm utility.
Prerequirites for an integrated
solution using Pacemaker
Db2 high availability disaster recovery
(HADR)
• Ensure that both HADR databases exist on
different systems.
• Ensure all HADR databases are started in their
respective primary and standby database roles,
and that all HADR primary-standby database
pairs are in peer state.
• Ensure that users are using one of the following
HADR synchronization modes: SYNC or
NEARSYNC.
Prerequirites for an integrated
solution using Pacemaker
Db2 high availability disaster recovery
(HADR)
• Configure hadr_peer_window for all HADR
databases to a value of at least 120 seconds.
• Disable the Db2 fault monitor.
Luís Garmendia
Download Pacemaker
1 As root on the first host, extract the tar file in the /tmp folder.
cd /tmp
tar -zxf
Db2_v11.5.4.0_Pacemaker_20200418_RHEL8.1_x86_64.tar.gz
2 Verify that the following packages are installed. The output may vary slightly
for different architectures and Linux distributions. All packages should include
the db2pcmk text in the output.
For example:
[root@ip-172-31-15-79 RPMS]# rpm -q corosync
corosync-3.0.3-1.db2pcmk.el8.x86_64
[root@ip-172-31-15-79 RPMS]# rpm -q pacemaker
pacemaker-2.0.2-1.db2pcmk.el8.x86_64
[root@ip-172-31-15-79 RPMS]# rpm -q crmsh
crmsh-4.1.0-0.db2pcmk.el8.noarch
Installing Pacemaker
1 As root on the first host, extract the tar file in the /tmp folder.
cd /tmp
tar -zxf
Db2_v11.5.4.0_Pacemaker_20200418_RHEL8.1_x86_64.tar.gz
Installing Pacemaker
https://www.ibm.com/support/pages/node/6327425
RA
Pacemaker Architecture
https://clusterlabs.org/pacemaker/doc/en-
US/Pacemaker/2.0/html/Pacemaker_Explained/_pacemaker_archite
cture.html
Luís Garmendia
Db2 cluster manager utility
db2cm
Db2 cluster manager utility (db2cm) is a utility
that you can use to configure and administer
your highly available databases in a clustered
environment with Pacemaker.
$INSTANCE/sqllib/adm/db2cm
Db2 cluster manager utility
db2cm
Db2cm command syntax
Db2 cluster manager utility
db2cm -create -cluster
Creates a new Pacemaker cluster domain with two hosts and
the public Ethernet resource.
The following parameters are mandatory:
-domain domain-name
Specifies the name of the Pacemaker domain
-host host-name
Specifies the name of the host. This is also used as a host in
the HADR cluster.
-publicEthernet public-Ethernet-device-name
Specifies the name of the public network adapter
Db2 cluster manager utility
db2cm -create -cluster
For example:
./db2cm -create -cluster -domain MyPCSDomain
-host host1 -publicEthernet eth0
-host host2 -publicEthernet eth2
db2cm –create -instance
3 Create the instance resource model by running the
following commands:
7 (Optional) Create the VIP resources for the newly created database.
Backup/Restore
Backup/Restore
2.Delete the current Pacemaker resources and cluster. Run the following
command:
db2cm -delete -cluster
3.Create the Tivoli SA MP resource model.
•If a backup of a previous Tivoli SA MP configuration is to be restored using
a db2haicu XML file, run the following command first on the standby
instance and then on the primary instance:
db2haicu -f exportedFile.xml
•To create the resource model from scratch, run the db2haicu on the
standby instance and follow the on-screen instructions
Luís Garmendia
Testing: Shut down standby
Testing: Shut down standby
Testing: Shut down standby
Restart standby
Restart standby
Testing: Shut down primary
Testing: Shut down primary
Testing: Shut down primary
Restart nodo1
Restart nodo1
Testing: Takeover
[db2inst2@dw_pacemaker_2]/home/db2inst2>db2 update
alternate server for database SAMPLE using hostname
192.168.56.249 port 51000
[
ALTERNATE SERVER
• DB2 Documentation
https://www.ibm.com/support/producthub/db2/docs/content/SSEPGG_11.5.0/com.ibm.db2.luw.admin.ha.doc
/doc/c_integrated_solution_pacemaker.html
https://www.ibm.com/support/producthub/db2/docs/content/SSEPGG_11.5.0/com.ibm.db2.luw.admin.ha.doc
/doc/c_pacemaker_intro.html
https://www.ibm.com/support/knowledgecenter/SSEPGG_11.5.0/com.ibm.db2.luw.wn.doc/doc/c_ha_enhance
ments_11-5-5.html
https://www.ibm.com/support/knowledgecenter/SSEPGG_11.5.0/com.ibm.db2.luw.admin.ha.doc/doc/r_maint
aining_cluster_domain.html
150
References
• DB2 Documentation
https://www.ibm.com/support/knowledgecenter/SSE
PGG_11.5.0/com.ibm.db2.luw.admin.ha.doc/doc/c_i
ntegrated_solution_pacemaker.html
https://www.ibm.com/support/knowledgecenter/SSE
PGG_11.5.0/com.ibm.db2.luw.admin.ha.doc/doc/c
_prereq_pacemaker.html
151
References
• Pacemaker Documentation
https://clusterlabs.org/pacemaker/doc/en-
US/Pacemaker/2.0/html/Pacemaker_Explained/_pac
emaker_architecture.html
152
References
https://access.redhat.com/articles/3172731
https://www.linuxjournal.com/content/ahead-pack-
pacemaker-high-availability-stack
https://www.ibm.com/support/pages/node/6359155
https://slideplayer.com/slide/8067194/
153
References
IBM support
https://www.ibm.com/support/pages/node/6327425
?mhsrc=ibmsearch_a&mhq=Pacemaker
https://www.ibm.com/support/pages/node/6330589
?mhsrc=ibmsearch_a&mhq=Pacemaker
154
References
Triton Consulting
https://www.triton.co.uk/automating-hadr-failovers-with-pacemaker/
E-book
https://marketing.triton.co.uk/acton/attachment/15128/f-0f9509bd-5858-4e0c-af2a-
3bde214d825e/1/-/-/-/-/DB2%20HADR%20Automation%20with%20Pacemaker.pdf
155