HANA数据 HA集群手工切换方法

8 篇文章 0 订阅
2 篇文章 0 订阅

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

  1. Set the maintenance meta attribute of the multi-state resource for SAP HANA.

    # crm resource maintenance msl_SAPHana_HA1_HDB10 on

  2. 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

  1. 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”.

  2. 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参数,有可能会切换不过来,记得先进入维护)模式

  3. 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

  4. 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

  1. 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

  2. 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.

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您好!如果您想要在MyBatis中配置HANA数据源,您可以按照以下步骤进行操作: 1. 首先,确保您的项目中已经引入了MyBatis和HANA数据库的依赖项。 2. 在您的项目配置文件(比如application.properties或者application.yml)中,添加HANA数据库的连接信息,例如: ``` spring.datasource.url=jdbc:sap://localhost:30015/your_hana_database spring.datasource.username=your_username spring.datasource.password=your_password spring.datasource.driver-class-name=com.sap.db.jdbc.Driver ``` 这里的`your_hana_database`是您的HANA数据库的地址,`your_username`和`your_password`是您的HANA数据库的用户名和密码。根据实际情况进行修改。 3. 在MyBatis的配置文件(比如mybatis-config.xml)中,配置HANA数据源的信息,例如: ```xml <configuration> <environments default="development"> <environment id="development"> <transactionManager type="JDBC"/> <dataSource type="POOLED"> <property name="driver" value="com.sap.db.jdbc.Driver"/> <property name="url" value="jdbc:sap://localhost:30015/your_hana_database"/> <property name="username" value="your_username"/> <property name="password" value="your_password"/> </dataSource> </environment> </environments> <mappers> <!-- 添加您的Mapper配置 --> </mappers> </configuration> ``` 这里的配置与上一步中的配置相同,只是格式稍有不同。 4. 在您的Mapper接口中定义SQL语句,并使用`@Mapper`注解标记该接口。 ```java @Mapper public interface YourMapper { // 添加您的SQL语句定义 } ``` 至此,您已经成功配置了HANA数据源在MyBatis中。您可以根据实际需求,使用MyBatis的API来操作HANA数据库。希望对您有帮助!如果您有任何其他问题,请随时提问。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值