【MySQL】通过signal18 replication manage实现数据库高可用集群
2021/6/11 19:25:06
本文主要是介绍【MySQL】通过signal18 replication manage实现数据库高可用集群,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
[root@wallet03 ~]# vim /etc/yum.repos.d/signal18.repo
[signal18]
name=Signal18 repositories
baseurl=http://repo.signal18.io/centos/2.1/$releasever/$basearch/
gpgcheck=0
enabled=1
[root@wallet03 ~]# yum install -y replication-manager-osc
[root@wallet03 ~]# vim /etc/replication-manager/cluster.d/cluster1.toml
db-servers-hosts = "192.168.40.201:3306,192.168.40.202:3306"
db-servers-prefered-master = "192.168.40.201:3306"
db-servers-credential = "root:abcd.1234"
db-servers-connect-timeout = 2
replication-credential = "repl:repl"
failover-mode = "automatic"
failover-pre-script = "/usr/local/bin/vip-down.sh" #在failover之前执行的脚本,删除vip
failover-post-script = "/usr/local/bin/vip-up.sh" #在failover之后执行的脚本,增加vip
failover-falsepositive-ping-counter = 5 ##在N次检测失败后执行failover
failover-limit = 0 ##如果已经执行N次failover则取消failover
failover-time-limit = 0 ##如果在N秒内执行过failover则取消failover
failover-max-slave-delay = 30 #当复制延迟大于N秒则取消failover
[root@wallet03 ~]# vim /usr/local/bin/vip-down.sh
#!/bin/bash
orig_master=$1
new_master=$2
old_port=$3
new_port=$4
interface=ens192
vip=192.168.40.100
ssh_user='root'
ssh_options=''
ssh=$(which ssh)
ip2util=$(which ip)
cmd_vip_del="sudo -n $ip2util address del ${vip}/32 dev ${interface}"
cmd_vip_chk="$ip2util address show dev ${interface} to ${vip%/*}/32"
$ssh ${ssh_options} -tt ${ssh_user}@${orig_master} \
"[ -n \"\$(${cmd_vip_chk})\" ] && ${cmd_vip_del} && || [ -z \"\$(${cmd_vip_chk})\" ]"
[root@wallet03 ~]# vim /usr/local/bin/vip-up.sh
#!/bin/bash
orig_master=$1
new_master=$2
old_port=$3
new_port=$4
interface=ens192
vip=192.168.40.100
ssh_user='root'
ssh_options=''
ssh=$(which ssh)
arping=$(which arping)
ip2util=$(which ip)
cmd_vip_add="$ip2util address add ${vip} dev ${interface}"
cmd_vip_chk="$ip2util address show dev ${interface} to ${vip%/*}/32"
cmd_arp_fix="$arping -c 1 -I ${interface} ${vip%/*}"
cmd_local_arp_fix=`ip neigh flush dev ${interface}`
$ssh ${ssh_options} -tt ${ssh_user}@${new_master} \
"[ -z \"\$(${cmd_vip_chk})\" ] && ${cmd_vip_add} && ${cmd_arp_fix} || [ -n \"\$(${cmd_vip_chk})\" ]"
[root@wallet03 ~]# systemctl start replication-manager
这篇关于【MySQL】通过signal18 replication manage实现数据库高可用集群的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-20部署MySQL集群入门:新手必读指南
- 2024-11-20部署MySQL集群教程:初学者指南
- 2024-11-20部署MySQL集群项目实战:新手教程
- 2024-11-20部署MySQL集群资料:新手入门教程
- 2024-11-20MySQL集群部署教程:入门级详解
- 2024-11-20MySQL集群教程:入门与实践指南
- 2024-11-20部署MySQL集群教程:新手入门指南
- 2024-11-20MySQL读写分离教程:轻松入门
- 2024-11-20部署MySQL集群入门:一步一步搭建你的数据库集群
- 2024-11-19部署MySQL集群学习:入门教程