GBase8C 主备切换

1、以操作系统gbase登录数据库任意节点,执行如下命令,查看主备情况
[gbase@c2 ~]$ gs_om -t status --detail
[  CMServer State   ]

node      node_ip         instance                              state
-----------------------------------------------------------------------
1  c1.com 192.168.0.66    1    /opt/huawei/install/cm/cm_server Primary
2  c2.com 192.168.0.67    2    /opt/huawei/install/cm/cm_server Standby

[   Cluster State   ]

cluster_state   : Normal
redistributing  : No
balanced        : Yes
current_az      : AZ_ALL

[  Datanode State   ]

node      node_ip         instance                         state
----------------------------------------------------------------------------
1  c1.com 192.168.0.66    6001 /dbdata/gbase/install/data/dn P Primary Normal
2  c2.com 192.168.0.67    6002 /dbdata/gbase/install/data/dn S Standby Normal
2、以操作系统用户gbase登录准备切换为主节点的备节点,执行如下命令。

gs_ctl switchover -D /dbdata/gbase/install/data/dn

[gbase@c2 ~]$ gs_ctl switchover -D  /dbdata/gbase/install/data/dn
[2023-04-26 16:33:59.839][45360][][gs_ctl]: gs_ctl switchover ,datadir is /opt/huawei/install/data/dn
[2023-04-26 16:33:59.839][45360][][gs_ctl]: switchover term (1)
[2023-04-26 16:33:59.845][45360][][gs_ctl]: waiting for server to switchover........
[2023-04-26 16:34:04.909][45360][][gs_ctl]: done
[2023-04-26 16:34:04.909][45360][][gs_ctl]: switchover completed (/opt/huawei/install/data/dn)
/dbdata/gbase/install/data/dn 为备数据库节点的数据目录。

须知: 对于同一数据库,上一次主备切换未完成,不能执行下一次切换。当业务正在操作时,发起switchover,可能主机的线程无法停止导致switchover显示超时,实际后台仍然在运行,等主机线程停止后,switchover即可完成。比如在主机删除一个大的分区表时,可能无法响应switchover发起的信号。
主机故障时,可以在备机执行如下命令。

gs_ctl failover -D /dbdata/gbase/install/data/dn
3、switchover或failover成功后,执行如下命令记录当前主备机器信息。
### gs_om -t refreshconf
[gbase@c2 ~]$ gs_om -t refreshconf
Generating dynamic configuration file for all nodes.
Successfully generated dynamic configuration file.
4、查看状态
[gbase@c2 ~]$ gs_om -t status --detail
[  CMServer State   ]

node      node_ip         instance                              state
-----------------------------------------------------------------------
1  c1.com 192.168.0.66    1   /dbdata/gbase/install/data/dn Primary
2  c2.com 192.168.0.67    2   /dbdata/gbase/install/data/dn Standby

[   Cluster State   ]

cluster_state   : Normal
redistributing  : No
balanced        : No
current_az      : AZ_ALL

[  Datanode State   ]

node      node_ip         instance                         state
----------------------------------------------------------------------------
1  c1.com 192.168.0.66    6001 /dbdata/gbase/install/data/dn P Standby Normal
2  c2.com 192.168.0.67    6002 /dbdata/gbase/install/data/dn S Primary Normal

  • 4
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值