MHA(Master High Availability)目前在MySQL高可用方面是一个相对成熟的解决方案,它由日本DeNA公司youshimaton(现就职于Facebook公司)开发,是一套优秀的作为MySQL高可用性环境下==故障切换和主从提升==的高可用软件。在MySQL故障切换过程中,MHA能做到在0~30秒之内自动完成数据库的故障切换操作,并且在进行故障切换的过程中,MHA能在==较大程度==上保证数据的一致性,以达到真正意义上的高可用。
[admin@mgr ~]$ masterha_check_ssh --conf=/etc/mha/app1.conf Sat Apr 1122:23:592020 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping. Sat Apr 1122:23:592020 - [info] Reading application default configuration from /etc/mha/app1.conf.. Sat Apr 1122:23:592020 - [info] Reading server configuration from /etc/mha/app1.conf.. Sat Apr 1122:23:592020 - [info] Starting SSH connection tests.. Sat Apr 1122:24:002020 - [debug] Sat Apr 1122:23:592020 - [debug] Connecting via SSH from admin@10.1.1.10(10.1.1.10:22) to admin@10.1.1.20(10.1.1.20:22).. Warning: Permanently added '10.1.1.20' (ECDSA) to the list of known hosts. Sat Apr 1122:23:592020 - [debug] ok. Sat Apr 1122:23:592020 - [debug] Connecting via SSH from admin@10.1.1.10(10.1.1.10:22) to admin@10.1.1.30(10.1.1.30:22).. Warning: Permanently added '10.1.1.30' (ECDSA) to the list of known hosts. Sat Apr 1122:23:592020 - [debug] ok. Sat Apr 1122:24:002020 - [debug] Sat Apr 1122:23:592020 - [debug] Connecting via SSH from admin@10.1.1.20(10.1.1.20:22) to admin@10.1.1.10(10.1.1.10:22).. Sat Apr 1122:24:002020 - [debug] ok. Sat Apr 1122:24:002020 - [debug] Connecting via SSH from admin@10.1.1.20(10.1.1.20:22) to admin@10.1.1.30(10.1.1.30:22).. Warning: Permanently added '10.1.1.30' (ECDSA) to the list of known hosts. Sat Apr 1122:24:002020 - [debug] ok. Sat Apr 1122:24:012020 - [debug] Sat Apr 1122:24:002020 - [debug] Connecting via SSH from admin@10.1.1.30(10.1.1.30:22) to admin@10.1.1.10(10.1.1.10:22).. Sat Apr 1122:24:002020 - [debug] ok. Sat Apr 1122:24:002020 - [debug] Connecting via SSH from admin@10.1.1.30(10.1.1.30:22) to admin@10.1.1.20(10.1.1.20:22).. Sat Apr 1122:24:002020 - [debug] ok. Sat Apr 1122:24:012020 - [info] All SSH connection tests passed successfully. [admin@mgr ~]$ 以上信息说明ok
[admin@mgr ~]$ masterha_check_repl --conf=/etc/mha/app1.conf Sat Apr 1122:35:442020 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping. Sat Apr 1122:35:442020 - [info] Reading application default configuration from /etc/mha/app1.conf.. Sat Apr 1122:35:442020 - [info] Reading server configuration from /etc/mha/app1.conf.. Sat Apr 1122:35:442020 - [info] MHA::MasterMonitor version 0.57. Sat Apr 1122:35:452020 - [info] GTID failover mode = 1 Sat Apr 1122:35:452020 - [info] Dead Servers: Sat Apr 1122:35:452020 - [info] Alive Servers: Sat Apr 1122:35:452020 - [info] 10.1.1.10(10.1.1.10:3307) Sat Apr 1122:35:452020 - [info] 10.1.1.20(10.1.1.20:3307) Sat Apr 1122:35:452020 - [info] 10.1.1.30(10.1.1.30:3307) Sat Apr 1122:35:452020 - [info] Alive Slaves: Sat Apr 1122:35:452020 - [info] 10.1.1.20(10.1.1.20:3307) Version=5.7.25-log (oldest major version between slaves) log-bin:enabled Sat Apr 1122:35:452020 - [info] GTID ON Sat Apr 1122:35:452020 - [info] Replicating from 10.1.1.10(10.1.1.10:3307) Sat Apr 1122:35:452020 - [info] Primary candidate for the new Master (candidate_master is set) Sat Apr 1122:35:452020 - [info] 10.1.1.30(10.1.1.30:3307) Version=5.7.25-log (oldest major version between slaves) log-bin:enabled Sat Apr 1122:35:452020 - [info] GTID ON Sat Apr 1122:35:452020 - [info] Replicating from 10.1.1.10(10.1.1.10:3307) Sat Apr 1122:35:452020 - [info] Primary candidate for the new Master (candidate_master is set) Sat Apr 1122:35:452020 - [info] Current Alive Master: 10.1.1.10(10.1.1.10:3307) Sat Apr 1122:35:452020 - [info] Checking slave configurations.. Sat Apr 1122:35:452020 - [info] Checking replication filtering settings.. Sat Apr 1122:35:452020 - [info] binlog_do_db= , binlog_ignore_db= Sat Apr 1122:35:452020 - [info] Replication filtering check ok. Sat Apr 1122:35:452020 - [info] GTID (with auto-pos) is supported. Skipping all SSH and Node package checking. Sat Apr 1122:35:452020 - [info] Checking SSH publickey authentication settings on the current master.. Sat Apr 1122:35:452020 - [info] HealthCheck: SSH to 10.1.1.10 is reachable. Sat Apr 1122:35:452020 - [info] 10.1.1.10(10.1.1.10:3307) (current master) +--10.1.1.20(10.1.1.20:3307) +--10.1.1.30(10.1.1.30:3307)
Sat Apr 1122:35:452020 - [info] Checking replication health on 10.1.1.20.. Sat Apr 1122:35:452020 - [info] ok. Sat Apr 1122:35:452020 - [info] Checking replication health on 10.1.1.30.. Sat Apr 1122:35:452020 - [info] ok. Sat Apr 1122:35:452020 - [info] Checking master_ip_failover_script status: Sat Apr 1122:35:452020 - [info] /etc/mha/master_ip_failover.sh 10.1.1.1001--command=status --ssh_user=admin --orig_master_host=10.1.1.10--orig_master_ip=10.1.1.10--orig_master_port=3307 Checking the Status of the script.. OK Sat Apr 1122:35:452020 - [info] OK. Sat Apr 1122:35:452020 - [warning] shutdown_script is not defined. Sat Apr 1122:35:452020 - [info] Got exit code 0 (Not master dead).