mysql mha vip 不漂移_MHA集群(gtid复制)和vip漂移

本篇博客详细介绍了如何配置MySQL MHA(Master High Availability)集群,采用GTID(Global Transaction Identifier)进行主从同步,以及避免VIP(Virtual IP)漂移的方法。通过四台服务器的分配,展示了从主从搭建到半同步复制、GTID模式开启的步骤,并通过SSH连接测试和MHA健康检查验证了配置的正确性。此外,还讨论了使用MHA自带脚本实现VIP漂移的测试过程。
摘要由CSDN通过智能技术生成

在上一片博客中,讲述了怎么去配置MHA架构!这片博客不再细说,只说明其中MySQL主从搭建,这里使用的是gtid加上半同步复制!

上一片博客中,把MySQL主从的搭建由filename和pos的过程改变为如下的基于gtid的过程就可以,因此不再详细说明,只展示gtid的搭建!

四台服务器分配如下:

MHA管理节点: 10.0.102.214

MySQL主节点:   10.0.102.204

MySQL从节点1:  10.0.102.179 【这个节点可以作为备用的主】

MySQL从节点2: 10.0.102.221

搭建基于gtid的数据库复制!

第一步:保证三个服务器的数据是一致的【处于一致的状态】

第二步:在主上和备用的主上创建复制账户,用户名和密码要保持一致!

第三步:开启gtid,加载半同步复制的插件!

三台服务器中配置文件加入以下参照:

plugin_dir=/usr/local/mysql/lib/plugin/ #因为这里MySQL5.7是源码安装的位置,若是使用rpm包安装,则注意更改位置plugin_load=semisync_master.so #这两个插件尽量在每个服务器都安装吧

plugin_load=semisync_slave.so

gtid-mode=on #开启gtid

enforce-gtid-consistency #确保gtid全局的一致性

log-bin=character_set_server=utf8 #设置字符集

log_slave_updates #gtid复制时,一定要开启

设置完配置文件之后,重启服务器,然后再从上执行以下命令!

mysql> change master to master_host="10.0.102.204", master_user="repl",master_password="123456",master_auto_position = 1;

Query OK,0 rows affected, 2 warnings (0.09sec)

mysql>start slave;

Query OK,0 rows affected (0.01 sec)

若上面没有报错,则使用show slave status查看复制的状态!

检查MHA的状态

ssh状态检查:

8f900a89c6347c561fdf2122f13be562.png

961ddebeb323a10fe0623af514929fc1.png

[root@test3 ~]# masterha_check_ssh --conf=/etc/masterha/app1.cnf

Sun Dec 9 11:42:50 2018 - [warning] Global configuration file /etc/masterha_default.cnf notfound. Skipping.

SunDec 9 11:42:50 2018 - [info] Reading application default configuration from /etc/masterha/app1.cnf..

SunDec 9 11:42:50 2018 - [info] Reading server configuration from /etc/masterha/app1.cnf..

SunDec 9 11:42:50 2018 - [info]Starting SSH connection tests..

SunDec 9 11:42:51 2018 - [debug]SunDec 9 11:42:50 2018 - [debug] Connecting via SSH from root@10.0.102.204(10.0.102.204:22) to root@10.0.102.179(10.0.102.179:22)..

SunDec 9 11:42:51 2018 - [debug]ok.

SunDec 9 11:42:51 2018 - [debug] Connecting via SSH from root@10.0.102.204(10.0.102.204:22) to root@10.0.102.221(10.0.102.221:22)..

SunDec 9 11:42:51 2018 - [debug]ok.

SunDec 9 11:42:51 2018 - [debug]SunDec 9 11:42:51 2018 - [debug] Connecting via SSH from root@10.0.102.179(10.0.102.179:22) to root@10.0.102.204(10.0.102.204:22)..

SunDec 9 11:42:51 2018 - [debug]ok.

SunDec 9 11:42:51 2018 - [debug] Connecting via SSH from root@10.0.102.179(10.0.102.179:22) to root@10.0.102.221(10.0.102.221:22)..

SunDec 9 11:42:51 2018 - [debug]ok.

SunDec 9 11:42:52 2018 - [debug]SunDec 9 11:42:51 2018 - [debug] Connecting via SSH from root@10.0.102.221(10.0.102.221:22) to root@10.0.102.204(10.0.102.204:22)..

SunDec 9 11:42:52 2018 - [debug]ok.

SunDec 9 11:42:52 2018 - [debug] Connecting via SSH from root@10.0.102.221(10.0.102.221:22) to root@10.0.102.179(10.0.102.179:22)..

SunDec 9 11:42:52 2018 - [debug]ok.

SunDec 9 11:42:52 2018 - [info] All SSH connection tests passed successfully.

masterha_check_ssh --conf=/etc/masterha/app1.cnf

961ddebeb323a10fe0623af514929fc1.png

[root@test3 ~]# masterha_check_ssh --conf=/etc/masterha/app1.cnf

Sun Dec 9 11:42:50 2018 - [warning] Global configuration file /etc/masterha_default.cnf notfound. Skipping.

SunDec 9 11:42:50 2018 - [info] Reading application default configuration from /etc/masterha/app1.cnf..

SunDec 9 11:42:50 2018 - [info] Reading server configuration from /etc/masterha/app1.cnf..

SunDec 9 11:42:50 2018 - [info]Starting SSH connection tests..

SunDec 9 11:42:51 2018 - [debug]SunDec 9 11:42:50 2018 - [debug] Connecting via SSH from root@10.0.102.204(10.0.102.204:22) to root@10.0.102.179(10.0.102.179:22)..

SunDec 9 11:42:51 2018 - [debug]ok.

SunDec 9 11:42:51 2018 - [debug] Connecting via SSH from root@10.0.102.204(10.0.102.204:22) to root@10.0.102.221(10.0.102.221:22)..

SunDec 9 11:42:51 2018 - [debug]ok.

SunDec 9 11:42:51 2018 - [debug]SunDec 9 11:42:51 2018 - [debug] Connecting via SSH from root@10.0.102.179(10.0.102.179:22) to root@10.0.102.204(10.0.102.204:22)..

SunDec 9 11:42:51 2018 - [debug]ok.

SunDec 9 11:42:51 2018 - [debug] Connecting via SSH from root@10.0.102.179(10.0.102.179:22) to root@10.0.102.221(10.0.102.221:22)..

SunDec 9 11:42:51 2018 - [debug]ok.

SunDec 9 11:42:52 2018 - [debug]SunDec 9 11:42:51 2018 - [debug] Connecting via SSH from root@10.0.102.221(10.0.102.221:22) to root@10.0.102.204(10.0.102.204:22)..

SunDec 9 11:42:52 2018 - [debug]ok.

SunDec 9 11:42:52 2018 - [debug] Connecting via SSH from root@10.0.102.221(10.0.102.221:22) to root@10.0.102.179(10.0.102.179:22)..

SunDec 9 11:42:52 2018 - [debug]ok.

SunDec 9 11:42:52 2018 - [info] AllSSH connection tests passed successfully.[root@test3 ~]# masterha_check_repl --conf=/etc/masterha/app1.cnf

Sun Dec 9 11:43:39 2018 - [warning] Global configuration file /etc/masterha_default.cnf notfound. Skipping.

SunDec 9 11:43:39 2018 - [info] Reading application default configuration from /etc/masterha/app1.cnf..

SunDec 9 11:43:39 2018 - [info] Reading server configuration from /etc/masterha/app1.cnf..

SunDec 9 11:43:39 2018 - [info] MHA::MasterMonitor version 0.56.

SunDec 9 11:43:39 2018 - [info] GTID failover mode = 1SunDec 9 11:43:39 2018 - [info]Dead Servers:

SunDec 9 11:43:39 2018 - [info]Alive Servers:

SunDec 9 11:43:39 2018 - [info] 10.0.102.204(10.0.102.204:3

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值