11-Database HADR (1)
11-Database HADR (1)
Information Management
Agenda
■ HADR: Concepts and Capabilities
■ Requirements
■ Configuration
■ Reads on Standby
■ Takeover Operation
■ Multiple-Standby Overview
HADR Concept
■ HADR is a database replication feature that provides a high availability solution for
both partial and complete site failures.
■ HADR is based on a pair (primary and standby) of databases. In case of failure, the
standby database can take over the workload
– Primary
• Handles all client connections and processes transactions
• Continuously ships transaction logs to the standby over the network
– Standby
• Kept in sync with primary by applying received transaction logs
Network Connection
tx tx
tx tx
HADR
Keeps the two
servers in sync
HADR Capabilities
■ High Availability
– Automatic Failover with Tivoli System Automation
– Automatic Client Reroute
■ Reads-on Standby
– Offloading read transactions from the primary server to standby servers
■ Multiple Standby City A Read / Write
session 1
– Local standby for high availability
– Remote standby for disaster recovery Server 1
City B Read-only
session 5
Database
Primary Read / Write
session 2
HADR
Read-only A
session 4 ns
tio
s ac
an
Tr
Transactions
Server 3
Standby Server 2
Database
HADR Standby Read--only
A session 3
Database
HADR
A
Benefits of HADR
HADR Scope
Server 1 Server 2
Primary Standby
TCP/IP
HADR
Database A HADR Database A
Database C
Database B
Database D
Standby
Primary
TCP/IP
Database E HADR Database E
HADR
Super Asynchronous
Synchronous
Log Log
8 © 2012 IBM Corporation
Information Management
HADR Requirements
Server 1 Server 2
■ Both primary and standby systems must have similar
hardware and software configuration
■ Hardware
– Server: same vendor and architecture
– Memory: identical amounts of memory to support replayed buffer pool operations
– Network: a TCP/IP network between the HADR systems, connected over a high-
speed, high-capacity network
• Recommendation: an extra network to separate internal HADR traffic from
workload / client traffic
■ Software
– OS: identical version including patch level
– DB2: identical bit size (32 or 64) and version
• Supports rolling upgrades
■ Database Configuration
– Not supported in a partitioned database environment
– Primary and standby databases must have the same database name
– Table spaces must be identical on the primary and standby databases
3. db2 update db cfg for hadr_db using 4. db2 update db cfg for hadr_db using
HADR_LOCAL_HOST host_a HADR_LOCAL_HOST host_b
HADR_REMOTE_HOST host_b HADR_REMOTE_HOST host_a
HADR_LOCAL_SVC svc_a HADR_LOCAL_SVC svc_b
HADR_REMOTE_SVC svc_b HADR_REMOTE_SVC svc_a
HADR_REMOTE_INST inst_b HADR_REMOTE_INST inst_a
HADR_TIMEOUT 120 HADR_TIMEOUT 120
HADR_SYNCMODE ASYNC HADR_SYNCMODE ASYNC
6. db2 start hadr on database hadr_db 5. db2 start hadr on database hadr_db as
as primary secondary
■ By Force
– 1. Standby sends a notice asking the primary to shut itself down
– 2. Standby does NOT wait for any acknowledgement from the primary to confirm
that it has received the takeover notification or that it has shut down (must be
within peer window)
– 3. Standby stops receiving logs from the primary, finishes replaying the logs it has
already received, and then becomes a primary.
2 - Standby does NOT wait for any acknowledgement from the primary to confirm that
it has received the takeover notification or that it has shut down (must be within
peer window)
3 - Standby stops receiving logs from the primary, finishes replaying the logs it has
already received, and then becomes a primary.
Note: The option “by force peer window only” only succeeds within the peer window
Original Original
Primary Standby
© 2012 IBM Corporation
Information Management
Primary
Automatic Reconfiguration
■ Reconfiguration after HADR service is started
– Values for hadr_remote_host, hadr_remote_inst, and
hadr_remote_svc configuration parameters are automatically reset when
HADR starts if you did not correctly set them.
■ Both types of takeover are supported in multiple standby mode, and any of the
standby databases can take over as the primary.
SU
Principal standby PE
RA Auxiliary standby
SY
Hostname: host2 NC Hostname: host4
Port: 40 Port: 42
Instance name: dbinst2 Instance name: dbinst4
City A City B
© 2012 IBM Corporation
Information Management
Hadr_remote_svc 40 10 10 10
Hadr_local_svc 10 40 41 42
Hadr_syncmode
Effective N/A sync superasync superasync
Hadr_syncmode
© 2012 IBM Corporation
Information Management
Initial Setup
■ Step 1: Create a backup image
– On host1 (primary)
■ The following are not required to be set in a multiple standby environment as they
will be automatically set
– hadr_remote_host
– hadr_remote_svc
– hadr_remote_inst
Initial Setup
■ On host1 (the primary) ■ On host3 (auxiliary standby)
DB2 "UPDATE DB CFG FOR hadr_db USING DB2 "UPDATE DB CFG FOR hadr_db USING
HADR_TARGET_LIST HADR_TARGET_LIST
host2:40|host3:41|host4:42 host1:10|host2:40|host4:42
HADR_REMOTE_HOST host2 HADR_REMOTE_HOST host1
HADR_REMOTE_SVC 40 HADR_REMOTE_SVC 10
HADR_LOCAL_HOST host1 HADR_LOCAL_HOST host3
HADR_LOCAL_SVC 10 HADR_LOCAL_SVC 41
HADR_SYNCMODE sync HADR_SYNCMODE superasync
HADR_REMOTE_INST db2inst2" HADR_REMOTE_INST db2inst1“
Starting HADR
■ The DBA starts the standby databases first, by issuing the following command on
each of host2, host3, and host 4
SYNC
SU
Principal standby PE
RA Auxiliary standby
SY
Hostname: host2 NC Hostname: host4
Port: 42
Port: 40 Instance name: dbinst4
Instance name: dbinst2
TAKEOVER
City A City B
SYNC
SUPERASYNC
City A City B
Hadr_remote_svc 40 10 40 40
Hadr_local_svc 10 40 41 42
Hadr_syncmode
Effective sync N/A superasync superasync
Hadr_syncmode
takeover
Primary Auxiliary standby
SUPERASYNC
Host name: host1
Hostname: host3
Port: 10
Port: 41
Instance name: dbinst1
Instance name: dbinst3
SYNC
SU
Principal standby PE
RA Auxiliary standby
SY
Hostname: host2 NC Hostname: host4
Port: 40 Port: 42
Instance name: dbinst2 Instance name: dbinst4
City A City B
© 2012 IBM Corporation
Information Management
Primary
Host name: host1 Hostname: host3
Port: 10 Port: 41
Instance name: dbinst3
Instance name: dbinst1
SUPERASYNC
Auxiliary
standby
Hostname: host2 Hostname: host4
Port: 42
Port: 40 Instance name: dbinst4
Instance name: dbinst2
City A City B
© 2012 IBM Corporation
Information Management
Hadr_remote_svc 40 10 42 41
Hadr_local_svc 10 40 41 42
Hadr_syncmode
Effective N/A sync n/a superasync
Hadr_syncmode
© 2012 IBM Corporation
Information Management
Primary
Host name: host1
Hostname: host3
Port: 10
Port: 41
Instance name: dbinst1
Instance name: dbinst3
SUPERASYNC
Y NC
R AS
UPE
S
Principal standby Auxiliary
Hostname: host2 standby Hostname: host4
Port: 40 Port: 42
Instance name: dbinst2 Instance name: dbinst4
City A City B
© 2012 IBM Corporation
Information Management
Hadr_remote_svc 40 41 40 41
Hadr_local_svc 10 40 41 42
Hadr_syncmode
Effective N/A superasync n/a superasync
Hadr_syncmode
© 2012 IBM Corporation
Information Management
Auxiliary standby
SUPERA Primary
S YNC
Host name: host1
Hostname: host3
Port: 10
Port: 41
Instance name: dbinst1
Instance name: dbinst3
SUPERASYNC
Y NC
R AS
UPE
S
Principal standby Auxiliary
Hostname: host2 Standby Hostname: host4
Port: 40 Port: 42
Instance name: dbinst2 Instance name: dbinst4
City A City B
© 2012 IBM Corporation
Information Management
Hadr_remote_svc 41 41 40 41
Hadr_local_svc 10 40 41 42
Hadr_syncmode
Effective superasync superasync n/a superasync
Hadr_syncmode
© 2012 IBM Corporation
Information Management
Monitoring HADR
■ There are a number of methods to monitor the status of HADR databases:
– db2pd utility and GET SNAPSHOT FOR DATABASE command
• From the primary = information about the primary and all standbys
• From a standby = information about that standby and the primary
• db2pd has been changed to display one entry for each primary-standby pair
Summary
■ HADR solution is based on a pair (primary and standby) of databases. In
case of failure, the standby database can take over the workload
■ DB2 10 introduces
– HADR Multiple-Standby improves your ability to protect your data while
still keeping it highly available.
– HADR log spooling allows the standby to spool log records arriving from
the primary
• This decouples log replay on the standby from receiving of the log data
from the primary
– HADR Delayed Replay can allow a standby database to intentionally
remain far behind the primary at all times
• Very useful to prevent data loss due to errant transactions
Questions?
E-mail: [email protected]
Subject: “DB2 10 Bootcamp”
Information Management