MHA(Master High Availability)目前在MySQL高可用方面是一个相对成熟的解决方案,它由日本DeNA公司youshimaton(现就职于Facebook公司)开发,是一套优秀的作为MySQL高可用性环境下故障切换和主从提升的高可用软件。在MySQL故障切换过程中,MHA能做到在0~30秒之内自动完成数据库的故障切换操作,并且在进行故障切换的过程中,MHA能在最大程度上保证数据的一致性,以达到真正意义上的高可用。
MariaDB [test_repl]> grant all privileges on *.* to 'mha'@'mysql_a' identified by '222222'; MariaDB [test_repl]> grant all privileges on *.* to 'mha'@'mysql_b' identified by '222222'; MariaDB [test_repl]> grant all privileges on *.* to 'mha'@'mysql_c' identified by '222222'; MariaDB [test_repl]> grant all privileges on *.* to 'mha'@'vm02' identified by '222222';
修改mysql参数
在2台slave上修改
1 2
mysql -e 'set global read_only=1' mysql -uroot -pffffff -e 'show slave status\G'|egrep 'Slave_IO|Slave_SQL'
# yum install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker perl-DBD-MySQL [root@mysql_a mha4mysql-node-0.56]# ansible mysql -a 'perl Makefile.PL chdir=/usr/local/src/mha4mysql-node-0.56/' [root@mysql_a mha4mysql-node-0.56]# ansible mysql -a 'make chdir=/usr/local/src/mha4mysql-node-0.56/' [root@mysql_a mha4mysql-node-0.56]# ansible mysql -a 'make install chdir=/usr/local/src/mha4mysql-node-0.56/'
[root@vm02 ~]# masterha_check_ssh --conf=/etc/mastermha/app1.cnf Wed Aug 2 17:12:59 2017 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping. Wed Aug 2 17:12:59 2017 - [info] Reading application default configurations from /etc/mastermha/app1.cnf.. Wed Aug 2 17:12:59 2017 - [info] Reading server configurations from /etc/mastermha/app1.cnf.. Wed Aug 2 17:12:59 2017 - [info] Starting SSH connection tests.. Wed Aug 2 17:13:00 2017 - [debug] Wed Aug 2 17:13:00 2017 - [debug] Connecting via SSH from root@mysql_a(192.168.6.126:22) to root@mysql_b(192.168.6.127:22).. Wed Aug 2 17:13:00 2017 - [debug] ok. Wed Aug 2 17:13:00 2017 - [debug] Connecting via SSH from root@mysql_a(192.168.6.126:22) to root@mysql_c(192.168.6.128:22).. Wed Aug 2 17:13:00 2017 - [debug] ok. Wed Aug 2 17:13:01 2017 - [debug] Wed Aug 2 17:13:00 2017 - [debug] Connecting via SSH from root@mysql_b(192.168.6.127:22) to root@mysql_a(192.168.6.126:22).. Wed Aug 2 17:13:00 2017 - [debug] ok. Wed Aug 2 17:13:00 2017 - [debug] Connecting via SSH from root@mysql_b(192.168.6.127:22) to root@mysql_c(192.168.6.128:22).. Wed Aug 2 17:13:00 2017 - [debug] ok. Wed Aug 2 17:13:01 2017 - [debug] Wed Aug 2 17:13:01 2017 - [debug] Connecting via SSH from root@mysql_c(192.168.6.128:22) to root@mysql_a(192.168.6.126:22).. Wed Aug 2 17:13:01 2017 - [debug] ok. Wed Aug 2 17:13:01 2017 - [debug] Connecting via SSH from root@mysql_c(192.168.6.128:22) to root@mysql_b(192.168.6.127:22).. Wed Aug 2 17:13:01 2017 - [debug] ok. Wed Aug 2 17:13:01 2017 - [info] All SSH connection tests passed successfully.
Thu Aug 3 17:10:16 2017 - [info] MHA::MasterMonitor version 0.56. Thu Aug 3 17:10:18 2017 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln401] Error happend on checking configurations. Use of uninitialized value in string eq at /usr/local/share/perl5/MHA/Server.pm line 236. Thu Aug 3 17:10:18 2017 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln500] Error happened on monitoring servers. Thu Aug 3 17:10:18 2017 - [info] Got exit code 1 (Not master dead).