HANA手工切换 得进入维护模式执行
如何在备节点手动 takeover 数据库
须知
手动 takeover 的前提必须是只配置 System Replication,未配置 OS HAE 或 HAE 进入维护模式下执行,否则数据库会出现双主 (primary)的情况,导致 HAE 将数据库强制关闭。 在手动 takeover 数据库前,需要确保数据库同步完成,否则 takeover 失败。
步骤1
以 root 用户登录备节点服务器,然后执行 su- s00adm 命令切换到 HANA 数据库的用
s00adm 中的 s00 请使用实际数据库 SID 的小写替换。
步骤 2
执行 hdbnsutil -sr takeover 命令手动将备节点 takeover 为主节点。
步骤 3
参考 2.1.4.7 如何查看本机 HANA 数据库是主节点还是备节点,查看数据库状态。
若数据库模式(mode)变为 primary,说明切换完成。
Begin the maintenance
-
Set the maintenance meta attribute of the multi-state resource for SAP HANA.
# crm resource maintenance msl_SAPHana_HA1_HDB10 on
-
Wait, till the cluster is in idle (S_IDLE) state. Remark: cs_wait_for_idle is part of the ClusterTools2 package.
# cs_wait_for_idle -s 5
Cluster state: S_IDLE
Do the changes on the SAP workload
-
Before triggering the takeover, check that the system replication is in sync. Login on the primary.
# su - ha1adm
~> HDBSettings.sh systemReplicationStatus.py --sapcontrol=1 | egrep -i '(site|overall).*replication_status'
site/2/REPLICATION_STATUS=ACTIVE
overall_replication_status=ACTIVE
Check the site and overall replication status. In best both are “ACTIVE”.
-
It’s time to trigger the takeover in handshake mode. The primary suspends the transaction activity. Primary and secondary still communicate about the system replication status. They check, if the system replication is in sync. This means the last committed transaction is available on the secondary. The takeover is released. The former secondary gets the new primary. The former primary is still up but blocks all transactions. Login on the secondary.
# su - ha1adm
~> hdbnsutil -sr_takeover --suspendPrimary (可以不加--suspendPrimary参数,有可能会切换不过来,记得先进入维护)模式
-
Once the takeover is successful, register the old primary to get the new secondary. This blog documents that in the online mode. As an alternative first stop SAP HANA, register offline and start SAP HANA. Make sure to use the same site names as note down before (here WDF). Logon on the ‘old’ primary.
# su - ha1adm
~> hdbnsutil -sr_register \
--online \
--name=WDF \
--remoteHost=suse02 --remoteInstance=10 \
--replicationMode=sync --operationMode=logreplay
-
Repeat step 1. Check the replication status on the ‘new’ primary. Before we end the maintenance, the new SAP HANA instance pair should be both up-and-running. The system replication status must be ‘ACTIVE‘. The cluster should show no resource errors.
End the maintenance
-
Refresh the multi-state resource. The resource agent now detects the new system replication topology and adjusts the promotion scores.
# crm cluster refresh msl_SAPHana_HA1_HDB10
# cs_wait_for_idle -s 5
Cluster state: S_IDLE
-
End the maintenance. The resource agent sets the e.g. srHook attribute for the new primary site to ‘PRIM‘.
# crm resource maintenance msl_SAPHana_HA1_HDB10 off
Finally check the cluster is in normal operation, is in idle state and does not show resource errors.