sr_scripts HANA SR configure tool v2.4
Rebuild by LiGuangTao lightpea@163.com)
The sr_* scripts provide a rough idea, how to use hdbnsutil for
system replication. Some aspects are outside of these scripts,
most importantly, how the primary system is shut down in case of
a takeover. A solution has to make sure that the "old primary"
system is not availble for clients when the sr_takeover command
is triggered.
Prerequisite:
-) The scripts require to be executed by <sid>adm
-) <sid>adm user has to be able to ssh to the other system
(both directions). For the demo case it is best without
password. To achieve this, you can use a private key without
password. E.g., do as <sid>adm
ssh-keygen -t rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
scp ~/.ssh/* <other-host>:<user-home>/.ssh/
-) You have installed two HANA instances following the system
replication requirements, i.e., same SID, instance-ID and
number of worker/standby nodes (see Admin guide for details)
-) Make sure you have enabled the backups on primary site
(this is generally required for system replication)
Preparation:
-) copy all sr_*.sh, helper.sh and settings.sh to a folder on
both systems (the nodes running the master name servers) of
both HANA instances
-) Adopt the values in settings.sh to your setup (on both HANA
instances)
With HANA 1.0 SPS07, it seems the hosts provided should only be the
host names, not fully qualified host names.
-) For a scale out: run the scripts (hdbnsutil commands) only
on the server which is acting as master name server, which
is not necessarily the first node, e.g., after a host
auto-failover of the first-node. You have to change the
settings.sh accordingly.
Exemplarily Usage:
ENABLE SYSTEM REPLICATION
################################################################
1) sr_enable
Pre-condition: the to be primary host (host A) runs in
SR mode: none you can check with hdbnsutil -sr_state)
Action: on the to be primary host (host A), run sr_enable.
Post-condition: host A is enabled for system replication
2) sr_register
Pre-condition: the to be secondary host (host B) run in
SR mode: none (after a fail back it may also be in mode
primary, see step XXXXXXXXXXXXXXXXXXXXXXXXX),
the secondary host (host B) is shut down (sr_register
will ask if HANA on host B should be shut down)
Action: run sr_register on host B. If HANA is still running,
the script will ask if HANA on host B should be shut down.
After sr_register, HANA on host B will be started and will
hence start to sync with host A
Post-condition: host B is secondary and starts to sync with
host A
TAKEOVER
################################################################
3) sr_takeover
Pre-condition: secondary (host B) is running and in sync
with the primary (host A).
Action: on the secondary, run sr_takeover. It will ask if
the primary should be shut down.
NOTE: for real scenarios, this has to be solved outside of
such scripts or HANA
Post-condition: host B is now primary and starts up, i.e.,
loads the last save point and starts to replay logs. host A
is still configured to be primary and hence must not take
any SQL connection
(RE)ENABLE SYSTEM REPLICATION
################################################################
4) sr_register
Pre-condition: primary (host B) is running, host A is in
sr mode primary but shutdown, e.g., due to disaster,
maintainance, etc.
Action: execute sr_register on host A. It will register host A
as secondary at host B (which is primary)
Post-condition: host A is starting up and syncs with host B.
A is secondary, B is primary
FAIL BACK
################################################################
5) sr_takeover
Pre-condition: secondary (host A) is running and in sync
with the primary (host B)
Action: on the secondary, run sr_takeover. It will ask if
the primary should be shut down.
NOTE: for real scenarios, this has to be solved outside of
such scripts or HANA
Post-condition: host A is now primary and starts up, i.e.,
loads the last save point and starts to replay logs. host B
is still configured to be primary and hence must not take
any SQL connection
(RE-RE)ENABLE SYSTEM REPLICATION
################################################################
6) sr_register
Pre-condition: primary (host A) is running, host B is in
sr mode primary but shutdown, e.g., due to disaster,
maintainance, etc.
Action: execute sr_register on host B. It will register host B
as secondary at host A
Post-condition: host B is starting up and syncs with host A.
B is secondary, A is primary
DISABLE SYSTEM REPLICATION
################################################################
7) sr_unregister
Pre-condition: primary and secondary hosts are both running,
secondary is in sync with primary.
Action: execute sr_unregister, this will
a) check which host is primary and which secondary
b) shutdown HANA on the secondary
c) execute sr_unregister on secondary (after HANA is shutdown)
d) shutdown HANA on the primary
e) execute sr_disable on primary (after HANA is shutdown)
f) start HANA on both hosts
Post-condition: both host A and host B are up and running,
both are in SR mode: none
SET VIP ON THE PRIMARY HOST
################################################################
8) sr_vip
Pre-condition: primary and secondary hosts are both running,
Action: execute sr_vip on PRIMARY HOST ,this will
a) set the VIP on the PRIMARY HOST
CLEAN UP REPLICATION PARAMETER IN GLOBAL.INI
################################################################
9) sr_cleanup
Pre-condition: primary and secondary hosts are both running,
Action: execute sr_clean on any HOST ,this will
a) clean up the replication parameter on the node
################################################################
add systemReplication info at sr_state outputing results