双活方案_MySQL高可用及双活解决方案(下)

本文介绍了Arksentinel如何支持MySQL双活解决方案,强调了根据节点间距离调整切换优先级的机制,并详细说明了如何配置VIP切换脚本,包括故障切换和手动运维切换时的接口调用。此外,还提到了switch_config表的创建,用于设置不同的切换方式如VIP、Arkproxy和域名。
摘要由CSDN通过智能技术生成
1f87f6c25110534e4eb74fa29aa7f689.png

扩展功能

Arksentinel 支持节点按照距离远近来调整切换优先级,哨兵切换节点时首先对比数据同步情况(主从架构,Galera,MGR默认一致),然后根据节点间距离进行优先排序(两个节点配置的address_num绝对值),距离越近优先级越高.

此外,用户可以在切换时配置调用脚本,进行proxy,vip或者域名等操作(当前提供两种切换方式:基于vip和基于Arkproxy,如果用户想要基于其他方式或者无法通过ifconfig进行vip绑定解绑则需要自己编写)

目前拓展功能只支持手动配置对应架构的数据库表.

基于VIP切换测试

初始化测试环境

  • 搭建主从架构集群如下
f58335fec3705c4677e701c5408facdc.png
  • 配置切换脚本路径

// 登录哨兵配置库,设置切换脚本,在执行故障切换时会调用failover,手动维护操作时调用switchover

// 用户可以根据下面的接口定义编写符合自己场景的切换脚本

update sentinel_config set switchover_script='./switchover',failover_script='./failover';

// 哨兵故障切换时调用接口如下

-namespace string

cluster namespace: a name to mysql cluster (default "namespace")

-newip string

instance ip which replace old one (default "10.0.0.90")

-newport int

instance port which replace old one (default 3306)

-oldip string

instance ip which can`t work well (default "10.0.0.89")

-oldport int

instance port which can`t work well (default 3306)

-role string

instance role: master standby statistic (default "standby")

-type string

sentinel type:Base, MasterSlave, GaleraCluster, Arkgate, ETL (default "Base")

// 哨兵手动运维切换时调用接口如下

-namespace string

cluster namespace: a name to mysql cluster (default "namespace")

-op string

operation type:MarkNormal, MarkMaintain, AddNode, DelNode, Promotion, ForceMaintain (default "MarkNormal")

-opip string

operation instance ip (default "10.0.0.89")

-opport int

operation instance port (default 3306)

-replaceip string

old master ip when Promotion operation (default "10.0.0.90")

-replaceport int

old master port when Promotion operation (default 3306)

-role string

instance role: master standby statistic (default "standby")

-type string

sentinel type:Base, MasterSlave, GaleraCluster, Arkgate, ETL (default "Base")

  • 设置切换配置

// 在ark_sentinel中添加 switch_config表

CREATE TABLE `switch_config` (

`id` int(11) NOT NULL AUTO_INCREMENT,

`namespace` varchar(100) NOT NULL COMMENT '集群标志名称',

`switch_type` enum('vip','arkproxy','domain') NOT NULL DEFAULT 'arkproxy' COMMENT '切换方式,分别为虚拟ip,arkproxy,域名',

`config` json DEFAULT NULL COMMENT '不同切换方式对应不同的配置参数',

`update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

`create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,

PRIMARY KEY (`id`),

UNIQUE KEY `uniq_namespace` (`namespace`)

) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4

// failover脚本使用ssh登录旧节点 执行 ifconfig down(失败的话则忽略,避免机器down掉影响流程)

// 然后登录新节点执行ifconfig up, 最后在新节点执行arping更新

// 因此需要配置ssh,网卡等信息

insert switch_config values(null,'ms_demo1','vip','{"ssh_config": {"nic": "enp0s3

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值