Running the HADR Simulator
About this task
The HADR Simulator is available as part of your Db2 installation sqllib\bin and sqllib\bin\samples. You can run the HADR Simulator (simhadr) for the following HADR configurations:
-
Single standby systems
-
Multiple standby systems
-
PureScale systems
Simulating Single Standby Database
To simulate a single standby database, run the HADR simulator as primary on the primary host
using the "-role primary"
option, and run "-role standby"
on the
standby host; starting either process first is acceptable.
The two processes will connect and start log shipping. To specify the length of the run, use
-n
(number of flushes) or -t
(number of seconds) on the primary
database.
You can also stop a run at any time by sending a "interrupt signal" (SIGINT
) to
the primary process. Both primary and standby databases will print performance statistics to
stdout
at the end of a run (including interrupted runs).
-lport
and -rport
options. For both
options, the host name and IP address (such as 1.2.3.4) are accepted.Example
When simulating a single standby database where the following is true:
- The primary host is
portland.ibm.com
, the HADR port is 4000 - The standby host is
sanfrancisco.ibm.com
, the HADR port is 5000 - The sync mode is
ASYNC
(default isNEARSYNC
) - The run length is 60 seconds (default is 4 seconds)
Run the following on the primary host portland.ibm.com
:
simhadr -lhost portland.ibm.com -lport 4000 -rhost sanfrancisco.ibm.com -rport 5000 -role primary -syncmode ASYNC -t 60
Run the following on the standby host sanfrancisco.ibm.com
:
simhadr -lhost sanfrancisco.ibm.com -lport 5000 -rhost portland.ibm.com -rport 4000 -role standby
Simulating Multiple Standby Databases
To simulate multiple standby databases, start multiple pairs of primary-standby concurrently, with all primary processes on the primary host. In Db2, each standby database is served by a dedicated thread in the primary database. To simulate this, we can run multiple copies of the simulator, one for each primary-standby pair.
In Db2, only one primary thread (listener thread) listens on the hadr_local_svc
port of the primary database; all standbys connect to this port. When running multiple copies of the
simulator, each needs to use a different hadr_local_svc
port on the primary host.
The standbys can have the same port because they run on different hosts.
After connection, the listener thread passes the connection over to the dedicated HADR thread. This is a common TCP server design.
Example
When simulating multiple standby databases where the following is true:
- The primary host is
portland.ibm.com
, the HADR port is 4000 and 4001 - The standby 1 host is
sanfrancisco.ibm.com
, the HADR port is 5000, and Sync mode isNEARSYNC
- The standby 2 host is
newyork.ibm.com
, the HADR port is 6000, and the Sync mode isSUPERASYNC
Run the following on the primary host portland.ibm.com
:
simhadr -lhost portland.ibm.com -lport 4000 -rhost sanfrancisco.ibm.com -rport 5000 -role primary -syncmode NEARSYNC -t 60
and
simhadr -lhost portland.ibm.com -lport 4001 -rhost newyork.ibm.com -rport 6000 -role primary -syncmode SUPERASYNC -t 60
Run the following on the standby 1 host sanfrancisco.ibm.com
:
simhadr -lhost sanfrancisco.ibm.com -lport 5000 -rhost portland.ibm.com -rport 4000 -role standby
Run the following on the standby 2 host newyork.ibm.com
:
simhadr -lhost newyork.ibm.com -lport 6000 -rhost portland.ibm.com -rport 4001 -role standby
newyork.ibm.com
connects to port 4001 on the primary
database.Simulating pureScale Systems
To simulate HADR on pureScale systems, start multiple pairs of primary-standby concurrently, with each primary processes on a pureScale member host and all standby processes on the standby replay member host.
In Db2, all primary members connect to the standby replay member, where a dedicated thread serves
each primary member, so only one hadr_local_svc
port is needed on the standby. To
run multiple copies of the simulator on the standby replay member host, each needs to use a
different hadr_local_svc
port on the standby. The primary hosts can use the same
hadr_local_svc
port.
Example
For a pureScale system where the following is true:
- The primary member 0 host is
portland_0.ibm.com
, the HADR port is 4000 - The primary member 1 host is
portland_1.ibm.com
, the HADR port is 4000 - The standby replay member host is
sanfrancisco.ibm.com
, the HADR port is 5000 and 5001. - Sync mode is
ASYNC
On primary member 0 host portland_0.ibm.com
, run
simhadr -lhost portland_0.ibm.com -lport 4000 -rhost sanfrancisco.ibm.com -rport 5000 -role primary -syncmode ASYNC -t 60
On primary member 1 host portland_1.ibm.com
, run
simhadr -lhost portland_1.ibm.com -lport 4000 -rhost sanfrancisco.ibm.com -rport 5001 -role primary -syncmode ASYNC -t 60
On standby replay host sanfrancisco.ibm.com
, run both of the following
simhadr -lhost sanfrancisco.ibm.com -lport 5000 -rhost portland_0.ibm.com -rport 4000 -role standby
simhadr -lhost sanfrancisco.ibm.com -lport 5001 -rhost portland_1.ibm.com -rport 4000 -role standby
OS and Endian Compatibility
While real HADR requires the primary and standby host machines to be of the same OS type and machine architecture, the HADR simulator has no requirement on OS type, or machine architecture. The primary and standbys can be on machines of different endian, this allows you to experiment on mixed platforms.