MHA 在过去几年一直用的比较火,特别是在在传统复制的那个年代。至从有了GTID好像我们也可以把MHA给忘记了,但是很多企业现在还是在用的比较多。每个公司的MHA玩法也不太一样,但是本质都是差不多了。下面我就带大家简单快速的搭建一个MHA玩一下,看看MHA是怎么玩的。如果要深入的了解MHA我建议去github里面看看一些官方的文档或者别人的一些博客,google一下或者bing一下就能找到了。我也不去重复的写了。
 
MHA 搭建全过程                                                             
 
有时候yum localinstall 安装不了原因,可能是上面的几个包没有安装
安装完成以后可以使用如下的管理工具:
#rpm -ql mha4mysql-manager-0.56-0.el6.noarch
/usr/bin/masterha_check_repl
/usr/bin/masterha_check_ssh
/usr/bin/masterha_check_status
/usr/bin/masterha_conf_host
/usr/bin/masterha_manager
/usr/bin/masterha_master_monitor
/usr/bin/masterha_master_switch
/usr/bin/masterha_secondary_check
/usr/bin/masterha_stop
/usr/share/man/man1/masterha_check_repl.1.gz
/usr/share/man/man1/masterha_check_ssh.1.gz
/usr/share/man/man1/masterha_check_status.1.gz
/usr/share/man/man1/masterha_conf_host.1.gz
/usr/share/man/man1/masterha_manager.1.gz
/usr/share/man/man1/masterha_master_monitor.1.gz
 
 环境准备:
首先我们需要准备一下3台机器
 master 192.168.5.100     端口3310
 slave1:192.168.5.101    端口3310
 slave2:192.168.5.102     端口3310
 vip 192.168.5.99
 
 关闭防火墙的和SELINUX
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
 
 
1:master 的搭建过程
实例初始化:
/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql_3310/my_3310.cnf --initialize-insecure
启动实例
/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql_3310/my_3310.cnf &
 2:创建复制用的账号
#mysql>CREATE USER rpl@'192.168.5.%';
#mysql>GRANT REPLICATION SLAVE ON *.* TO  'rpl'@'192.168.5.%'  identified by '123456';
 
搭建主从环境:
 change master  to master_host='192.168.5.100',master_port=3310, master_user='rpl', master_password='',master_auto_position=1;
3台机器之间建立机器信任机制建立
 
 使用 ssh-keygen 生成key
 
# ssh-keygen 一路回车就行了。最后会在~/,ssh 下面产生:id_rsa id_rsa.pub 两个文件。
 
生成信任文件:
#cd ~/.ssh/
#cat id_rsa.pub>authorized_keys  ## 每个机器都需要执行下
#chmod 600 *
保留.ssh 下面只有id_rsa,id_rsa.pub 其他文件可以删或是备份移走。
把文件分发到其它三台机器上(需要输出密码)
#cd ~
#scp -r .ssh 192.168.5.102
#scp   -r   .ssh  192.168.5.103
这样就完成了3台机器的ssh信任
 
 
配置文件:
[server default]
log_level=debug    ### 开启debug的模式
manager_log=/etc/masterha/app1.log
manager_workdir=/etc/masterha/app1
master_binlog_dir=/data/mysql/mysql_3310/logs
master_ip_failover_script=/etc/masterha/master_ip_failover
master_ip_online_change_script=/etc/masterha/master_ip_failover
password=123456
ping_interval=1
remote_workdir=/etc/masterha/app1
repl_password=123456
repl_user=rpl
ssh_user=root
user=root
 
[server1]
candidate_master=1
hostname=node1
port=3310
 
 
[server2]
candidate_master=1
hostname=node2
port=3310
 
[server3]
hostname=node3
port=3310
  
 
1.检查SSH配置
 
#masterha_check_ssh --conf=/etc/masterha/app1.conf
 
以下是我们能看到的返回信息:
 
#masterha_check_ssh --conf=/etc/masterha/app1.conf
Wed Nov  1 01:56:31 2017 - [info] Reading default configuration from /etc/masterha_default.cnf..
Wed Nov  1 01:56:31 2017 - [info] Reading application default configuration from /etc/masterha/app1.conf..
Wed Nov  1 01:56:31 2017 - [info] Reading server configuration from /etc/masterha/app1.conf..
Wed Nov  1 01:56:31 2017 - [info] Starting SSH connection tests..
Wed Nov  1 01:56:32 2017 - [debug]
Wed Nov  1 01:56:31 2017 - [debug]  Connecting via SSH from root@192.168.5.102(192.168.5.102:22) to root@192.168.5.103(192.168.5.103:22)..
Wed Nov  1 01:56:32 2017 - [debug]   ok.
Wed Nov  1 01:56:32 2017 - [debug]
Wed Nov  1 01:56:32 2017 - [debug]  Connecting via SSH from root@192.168.5.103(192.168.5.103:22) to root@192.168.5.102(192.168.5.102:22)..
Wed Nov  1 01:56:32 2017 - [debug]   ok.
Wed Nov  1 01:56:32 2017 - [info] All SSH connection tests passed successfully.
  1. 检查 主从复制是不是正常:masterha_check_repl --conf=/etc/masterha/app1.conf
        以下是我们如果正常,我们会看到一下的内容提示:
# masterha_check_repl --conf=/etc/masterha/app1.conf
Wed Nov  1 01:37:46 2017 - [info] Reading default configuration from /etc/masterha_default.cnf..
Wed Nov  1 01:37:46 2017 - [info] Reading application default configuration from /etc/masterha/app1.conf..
Wed Nov  1 01:37:46 2017 - [info] Reading server configuration from /etc/masterha/app1.conf..
Wed Nov  1 01:37:46 2017 - [info] MHA::MasterMonitor version 0.56.
Wed Nov  1 01:37:47 2017 - [info] GTID failover mode = 1
Wed Nov  1 01:37:47 2017 - [info] Dead Servers:
Wed Nov  1 01:37:47 2017 - [info] Alive Servers:
Wed Nov  1 01:37:47 2017 - [info]   192.168.5.102(192.168.5.102:3310)
Wed Nov  1 01:37:47 2017 - [info]   192.168.5.103(192.168.5.103:3310)
Wed Nov  1 01:37:47 2017 - [info] Alive Slaves:
Wed Nov  1 01:37:47 2017 - [info]   192.168.5.103(192.168.5.103:3310)  Version=5.7.19-17-29.22-log (oldest major version between slaves) log-bin:enabled
Wed Nov  1 01:37:47 2017 - [info]     GTID ON
Wed Nov  1 01:37:47 2017 - [info]     Replicating from 192.168.5.102(192.168.5.102:3310)
Wed Nov  1 01:37:47 2017 - [info]     Primary candidate for the new Master (candidate_master is set)
Wed Nov  1 01:37:47 2017 - [info] Current Alive Master: 192.168.5.102(192.168.5.102:3310)
Wed Nov  1 01:37:47 2017 - [info] Checking slave configurations..
Wed Nov  1 01:37:47 2017 - [info]  read_only=1 is not set on slave 192.168.5.103(192.168.5.103:3310).
Wed Nov  1 01:37:47 2017 - [info] Checking replication filtering settings..
Wed Nov  1 01:37:47 2017 - [info]  binlog_do_db= , binlog_ignore_db=
Wed Nov  1 01:37:47 2017 - [info]  Replication filtering check ok.
Wed Nov  1 01:37:47 2017 - [info] GTID (with auto-pos) is supported. Skipping all SSH and Node package checking.
Wed Nov  1 01:37:47 2017 - [info] Checking SSH publickey authentication settings on the current master..
Wed Nov  1 01:37:47 2017 - [info] HealthCheck: SSH to 192.168.5.102 is reachable.
Wed Nov  1 01:37:47 2017 - [info]
192.168.5.102(192.168.5.102:3310) (current master)
+--192.168.5.103(192.168.5.103:3310)
Wed Nov  1 01:37:47 2017 - [info] Checking replication health on 192.168.5.103..
Wed Nov  1 01:37:47 2017 - [info]  ok.
Wed Nov  1 01:37:47 2017 - [info] Checking master_ip_failover_script status:
Wed Nov  1 01:37:47 2017 - [info]   /etc/masterha/master_ip_failover --command=status --ssh_user=root --orig_master_host=192.168.5.102 --orig_master_ip=192.168.5.102 --orig_master_port=3310
Wed Nov  1 01:37:47 2017 - [info]  OK.
Wed Nov  1 01:37:47 2017 - [warning] shutdown_script is not defined.
Wed Nov  1 01:37:47 2017 - [info] Got exit code 0 (Not master dead).
MySQL Replication Health is OK.
 3 检查MHA Manager的状态 #masterha_check_status --conf=/etc/masterha/app1.conf
      以下是我们返回的信息:
#masterha_check_status --conf=/etc/masterha/app1.conf
app1 is stopped(2:NOT_RUNNING).
4 启动mha 监控服务:nohup masterha_manager --conf=/etc/masterha/app1.conf --remove_dead_master_conf --ignore_last_failover < /dev/null > /etc/masterha/app1/manager.log 2>&1 &
 
启动后的结果大概是这样的
#nohup masterha_manager --conf=/etc/masterha/app1.conf --remove_dead_master_conf --ignore_last_failover < /dev/null > /etc/masterha/app1/manager.log 2>&1 &
[1] 9440
 
 这个可以查看一下我们的进程:
#ps aux | grep master
root      1108  0.0  0.1  89544  2148 ?        Ss   Oct30   0:00 /usr/libexec/postfix/master -w
root      9440  2.0  1.0 287396 20200 pts/5    S    01:42   0:00 perl /usr/bin/masterha_manager --conf=/etc/masterha/app1.conf --remove_dead_master_conf --ignore_last_failover
root      9463  0.0  0.0 112660   976 pts/5    R+   01:42   0:00 grep --color=auto master
 
 
 
5:关闭MHA Manage监控   masterha_stop --conf=/etc/masterha/app1.conf
 
 
 
手动切换命令:masterha_master_switch --conf=/etc/masterha/app1.conf --master_state=alive --new_master_host=192.168.5.102 --orig_master_is_new_slave --running_updates_limit=10000 --interactive=0
 
#masterha_master_switch --conf=/etc/masterha/app1.conf --master_state=alive --new_master_host=192.168.5.102 --orig_master_is_new_slave --running_updates_limit=10000 --interactive=0
Wed Nov  1 04:40:30 2017 - [info] MHA::MasterRotate version 0.56.
Wed Nov  1 04:40:30 2017 - [info] Starting online master switch..
Wed Nov  1 04:40:30 2017 - [info]
Wed Nov  1 04:40:30 2017 - [info] * Phase 1: Configuration Check Phase..
Wed Nov  1 04:40:30 2017 - [info]
Wed Nov  1 04:40:30 2017 - [info] Reading default configuration from /etc/masterha_default.cnf..
Wed Nov  1 04:40:30 2017 - [info] Reading application default configuration from /etc/masterha/app1.conf..
Wed Nov  1 04:40:30 2017 - [info] Reading server configuration from /etc/masterha/app1.conf..
Wed Nov  1 04:40:30 2017 - [info] GTID failover mode = 1
Wed Nov  1 04:40:30 2017 - [info] Current Alive Master: 192.168.5.100(192.168.5.100:3310)
Wed Nov  1 04:40:30 2017 - [info] Alive Slaves:
Wed Nov  1 04:40:30 2017 - [info]   192.168.5.102(192.168.5.102:3310)  Version=5.7.19-log (oldest major version between slaves) log-bin:enabled
Wed Nov  1 04:40:30 2017 - [info]     GTID ON
Wed Nov  1 04:40:30 2017 - [info]     Replicating from 192.168.5.100(192.168.5.100:3310)
Wed Nov  1 04:40:30 2017 - [info]     Primary candidate for the new Master (candidate_master is set)
Wed Nov  1 04:40:30 2017 - [info]   192.168.5.103(192.168.5.103:3310)  Version=5.7.19-17-29.22-log (oldest major version between slaves) log-bin:enabled
Wed Nov  1 04:40:30 2017 - [info]     GTID ON
Wed Nov  1 04:40:30 2017 - [info]     Replicating from 192.168.5.100(192.168.5.100:3310)
Wed Nov  1 04:40:30 2017 - [info]     Primary candidate for the new Master (candidate_master is set)
Wed Nov  1 04:40:30 2017 - [info] Executing FLUSH NO_WRITE_TO_BINLOG TABLES. This may take long time..
Wed Nov  1 04:40:30 2017 - [info]  ok.
Wed Nov  1 04:40:30 2017 - [info] Checking MHA is not monitoring or doing failover..
Wed Nov  1 04:40:30 2017 - [error][/usr/share/perl5/vendor_perl/MHA/MasterRotate.pm, ln142] Getting advisory lock failed on the current master. MHA Monitor runs on the current master. Stop MHA Manager/Monitor and try again.
Wed Nov  1 04:40:30 2017 - [error][/usr/share/perl5/vendor_perl/MHA/ManagerUtil.pm, ln177] Got ERROR:  at /usr/bin/masterha_master_switch line 53.
 
       [root@node1 05:57:52 /etc/masterha/app1]
#masterha_master_switch --conf=/etc/masterha/app1.conf --master_state=alive --new_master_host=node2  --running_updates_limit=10000 --interactive=0
Thu Nov  2 05:58:52 2017 - [info] MHA::MasterRotate version 0.56.
Thu Nov  2 05:58:52 2017 - [info] Starting online master switch..
Thu Nov  2 05:58:52 2017 - [info]
Thu Nov  2 05:58:52 2017 - [info] * Phase 1: Configuration Check Phase..
Thu Nov  2 05:58:52 2017 - [info]
Thu Nov  2 05:58:52 2017 - [info] Reading default configuration from /etc/masterha_default.cnf..
Thu Nov  2 05:58:52 2017 - [info] Reading application default configuration from /etc/masterha/app1.conf..
Thu Nov  2 05:58:52 2017 - [info] Reading server configuration from /etc/masterha/app1.conf..
Thu Nov  2 05:58:52 2017 - [info] GTID failover mode = 1
Thu Nov  2 05:58:52 2017 - [info] Current Alive Master: 192.168.5.100(192.168.5.100:3310)
Thu Nov  2 05:58:52 2017 - [info] Alive Slaves:
Thu Nov  2 05:58:52 2017 - [info]   192.168.5.102(192.168.5.102:3310)  Version=5.7.19-log (oldest major version between slaves) log-bin:enabled
Thu Nov  2 05:58:52 2017 - [info]     GTID ON
Thu Nov  2 05:58:52 2017 - [info]     Replicating from 192.168.5.100(192.168.5.100:3310)
Thu Nov  2 05:58:52 2017 - [info]     Primary candidate for the new Master (candidate_master is set)
Thu Nov  2 05:58:52 2017 - [info] Executing FLUSH NO_WRITE_TO_BINLOG TABLES. This may take long time..
Thu Nov  2 05:58:52 2017 - [info]  ok.
Thu Nov  2 05:58:52 2017 - [info] Checking MHA is not monitoring or doing failover..
Thu Nov  2 05:58:52 2017 - [info] Checking replication health on 192.168.5.102..
Thu Nov  2 05:58:52 2017 - [info]  ok.
Thu Nov  2 05:58:52 2017 - [error][/usr/share/perl5/vendor_perl/MHA/ServerManager.pm, ln1218] node2 is not alive!
Thu Nov  2 05:58:52 2017 - [error][/usr/share/perl5/vendor_perl/MHA/MasterRotate.pm, ln232] Failed to get new master!
Thu Nov  2 05:58:52 2017 - [error][/usr/share/perl5/vendor_perl/MHA/ManagerUtil.pm, ln177] Got ERROR:  at /usr/bin/masterha_master_switch line 53.
[root@node1 05:58:52 /etc/masterha/app1]
#masterha_master_switch --conf=/etc/masterha/app1.conf --master_state=alive --new_master_host=node2  
Thu Nov  2 05:59:00 2017 - [info] MHA::MasterRotate version 0.56.
Thu Nov  2 05:59:00 2017 - [info] Starting online master switch..
Thu Nov  2 05:59:00 2017 - [info]
Thu Nov  2 05:59:00 2017 - [info] * Phase 1: Configuration Check Phase..
Thu Nov  2 05:59:00 2017 - [info]
Thu Nov  2 05:59:00 2017 - [info] Reading default configuration from /etc/masterha_default.cnf..
Thu Nov  2 05:59:00 2017 - [info] Reading application default configuration from /etc/masterha/app1.conf..
Thu Nov  2 05:59:00 2017 - [info] Reading server configuration from /etc/masterha/app1.conf..
Thu Nov  2 05:59:00 2017 - [info] GTID failover mode = 1
Thu Nov  2 05:59:00 2017 - [info] Current Alive Master: 192.168.5.100(192.168.5.100:3310)
Thu Nov  2 05:59:00 2017 - [info] Alive Slaves:
Thu Nov  2 05:59:00 2017 - [info]   192.168.5.102(192.168.5.102:3310)  Version=5.7.19-log (oldest major version between slaves) log-bin:enabled
Thu Nov  2 05:59:00 2017 - [info]     GTID ON
Thu Nov  2 05:59:00 2017 - [info]     Replicating from 192.168.5.100(192.168.5.100:3310)
Thu Nov  2 05:59:00 2017 - [info]     Primary candidate for the new Master (candidate_master is set)
It is better to execute FLUSH NO_WRITE_TO_BINLOG TABLES on the master before switching. Is it ok to execute on 192.168.5.100(192.168.5.100:3310)? (YES/no): yes
Thu Nov  2 05:59:03 2017 - [info] Executing FLUSH NO_WRITE_TO_BINLOG TABLES. This may take long time..
Thu Nov  2 05:59:03 2017 - [info]  ok.
Thu Nov  2 05:59:03 2017 - [info] Checking MHA is not monitoring or doing failover..
Thu Nov  2 05:59:03 2017 - [info] Checking replication health on 192.168.5.102..
Thu Nov  2 05:59:03 2017 - [info]  ok.
Thu Nov  2 05:59:03 2017 - [error][/usr/share/perl5/vendor_perl/MHA/ServerManager.pm, ln1218] node2 is not alive!
Thu Nov  2 05:59:03 2017 - [error][/usr/share/perl5/vendor_perl/MHA/MasterRotate.pm, ln232] Failed to get new master!
Thu Nov  2 05:59:03 2017 - [error][/usr/share/perl5/vendor_perl/MHA/ManagerUtil.pm, ln177] Got ERROR:  at /usr/bin/masterha_master_switch line 53.
[root@node1 05:59:03 /etc/masterha/app1]
#masterha_master_switch --conf=/etc/masterha/app1.conf --master_state=alive
Thu Nov  2 05:59:26 2017 - [info] MHA::MasterRotate version 0.56.
Thu Nov  2 05:59:26 2017 - [info] Starting online master switch..
Thu Nov  2 05:59:26 2017 - [info]
Thu Nov  2 05:59:26 2017 - [info] * Phase 1: Configuration Check Phase..
Thu Nov  2 05:59:26 2017 - [info]
Thu Nov  2 05:59:26 2017 - [info] Reading default configuration from /etc/masterha_default.cnf..
Thu Nov  2 05:59:26 2017 - [info] Reading application default configuration from /etc/masterha/app1.conf..
Thu Nov  2 05:59:26 2017 - [info] Reading server configuration from /etc/masterha/app1.conf..
Thu Nov  2 05:59:26 2017 - [info] GTID failover mode = 1
Thu Nov  2 05:59:26 2017 - [info] Current Alive Master: 192.168.5.100(192.168.5.100:3310)
Thu Nov  2 05:59:26 2017 - [info] Alive Slaves:
Thu Nov  2 05:59:26 2017 - [info]   192.168.5.102(192.168.5.102:3310)  Version=5.7.19-log (oldest major version between slaves) log-bin:enabled
Thu Nov  2 05:59:26 2017 - [info]     GTID ON
Thu Nov  2 05:59:26 2017 - [info]     Replicating from 192.168.5.100(192.168.5.100:3310)
Thu Nov  2 05:59:26 2017 - [info]     Primary candidate for the new Master (candidate_master is set)
It is better to execute FLUSH NO_WRITE_TO_BINLOG TABLES on the master before switching. Is it ok to execute on 192.168.5.100(192.168.5.100:3310)? (YES/no): yes
Thu Nov  2 05:59:28 2017 - [info] Executing FLUSH NO_WRITE_TO_BINLOG TABLES. This may take long time..
Thu Nov  2 05:59:28 2017 - [info]  ok.
Thu Nov  2 05:59:28 2017 - [info] Checking MHA is not monitoring or doing failover..
Thu Nov  2 05:59:28 2017 - [info] Checking replication health on 192.168.5.102..
Thu Nov  2 05:59:28 2017 - [info]  ok.
Thu Nov  2 05:59:28 2017 - [info] Searching new master from slaves..
Thu Nov  2 05:59:28 2017 - [info]  Candidate masters from the configuration file:
Thu Nov  2 05:59:28 2017 - [info]   192.168.5.100(192.168.5.100:3310)  Version=5.7.19-log log-bin:enabled
Thu Nov  2 05:59:28 2017 - [info]     GTID ON
Thu Nov  2 05:59:28 2017 - [info]   192.168.5.102(192.168.5.102:3310)  Version=5.7.19-log (oldest major version between slaves) log-bin:enabled
Thu Nov  2 05:59:28 2017 - [info]     GTID ON
Thu Nov  2 05:59:28 2017 - [info]     Replicating from 192.168.5.100(192.168.5.100:3310)
Thu Nov  2 05:59:28 2017 - [info]     Primary candidate for the new Master (candidate_master is set)
Thu Nov  2 05:59:28 2017 - [info]  Non-candidate masters:
Thu Nov  2 05:59:28 2017 - [info]  Searching from candidate_master slaves which have received the latest relay log events..
Thu Nov  2 05:59:28 2017 - [info]
From:
192.168.5.100(192.168.5.100:3310) (current master)
+--192.168.5.102(192.168.5.102:3310)
To:
192.168.5.102(192.168.5.102:3310) (new master)
Starting master switch from 192.168.5.100(192.168.5.100:3310) to 192.168.5.102(192.168.5.102:3310)? (yes/NO): yes
Thu Nov  2 05:59:30 2017 - [info] Checking whether 192.168.5.102(192.168.5.102:3310) is ok for the new master..
Thu Nov  2 05:59:30 2017 - [info]  ok.
Thu Nov  2 05:59:30 2017 - [info] ** Phase 1: Configuration Check Phase completed.
Thu Nov  2 05:59:30 2017 - [info]
Thu Nov  2 05:59:30 2017 - [info] * Phase 2: Rejecting updates Phase..
Thu Nov  2 05:59:30 2017 - [info]
master_ip_online_change_script is not defined. If you do not disable writes on the current master manually, applications keep writing on the current master. Is it ok to proceed? (yes/NO): yes
Thu Nov  2 05:59:33 2017 - [info] Locking all tables on the orig master to reject updates from everybody (including root):
Thu Nov  2 05:59:33 2017 - [info] Executing FLUSH TABLES WITH READ LOCK..
Thu Nov  2 05:59:33 2017 - [info]  ok.
Thu Nov  2 05:59:33 2017 - [info] Orig master binlog:pos is mysql-bin.000013:190.
Thu Nov  2 05:59:33 2017 - [info]  Waiting to execute all relay logs on 192.168.5.102(192.168.5.102:3310)..
Thu Nov  2 05:59:33 2017 - [info]  master_pos_wait(mysql-bin.000013:190) completed on 192.168.5.102(192.168.5.102:3310). Executed 0 events.
Thu Nov  2 05:59:33 2017 - [info]   done.
Thu Nov  2 05:59:33 2017 - [info] Getting new master's binlog name and position..
Thu Nov  2 05:59:33 2017 - [info]  mysql-bin.000011:1167
Thu Nov  2 05:59:33 2017 - [info]  All other slaves should start replication from here. Statement should be: CHANGE MASTER TO MASTER_HOST='192.168.5.102', MASTER_PORT=3310, MASTER_AUTO_POSITION=1, MASTER_USER='rpl', MASTER_PASSWORD='xxx';
Thu Nov  2 05:59:33 2017 - [info]
Thu Nov  2 05:59:33 2017 - [info] * Switching slaves in parallel..
Thu Nov  2 05:59:33 2017 - [info]
Thu Nov  2 05:59:33 2017 - [info] Unlocking all tables on the orig master:
Thu Nov  2 05:59:33 2017 - [info] Executing UNLOCK TABLES..
Thu Nov  2 05:59:33 2017 - [info]  ok.
Thu Nov  2 05:59:33 2017 - [info] All new slave servers switched successfully.
Thu Nov  2 05:59:33 2017 - [info]
Thu Nov  2 05:59:33 2017 - [info] * Phase 5: New master cleanup phase..
Thu Nov  2 05:59:33 2017 - [info]
Thu Nov  2 05:59:33 2017 - [info]  192.168.5.102: Resetting slave info succeeded.
Thu Nov  2 05:59:33 2017 - [info] Switching master to 192.168.5.102(192.168.5.102:3310) completed successfully.
[root@node1 05:59:33 /etc/masterha/app1]
 
几个脚本的:注意脚本的里面有些地方是自己需要去修改的,比如vip
1.绑定 vip的 shell 脚本(当然,也可以自己手动的去绑定或者删除)
vip="192.168.5.99/24"   #####注意我们的子网掩码还是需要加上的
/sbin/ip addr add $vip dev enp0s8
 
2.删除vip 的shell 脚本
vip="192.168.1.99"
/sbin/ip addr del $vip dev enp0s8
 
手动切换的时候:
手动failover,这种场景意味着在业务上没有启用MHA自动切换功能,当主服务器故障时,人工手动调用MHA来进行故障切换操作,具体命令如下:
注意:如果,MHA manager检测到没有dead的server,将报错,并结束failover: 

MHA 安装与简单使用的更多相关文章

  1. mha安装使用手册

    mha安装使用手册 注:目前mha最新的版本代码已经不放到google code网站了,而是放在github上,最新的版本为0.57,github链接如下: mha manager:https://g ...

  2. (转)python requests的安装与简单运用

    requests是python的一个HTTP客户端库,跟urllib,urllib2类似,那为什么要用requests而不用urllib2呢?官方文档中是这样说明的: python的标准库urllib ...

  3. MongoDB在Windows下安装、Shell客户端的使用、Bson扩充的数据类型、MongoVUE可视化工具安装和简单使用、Robomongo可视化工具(2)

    一.Windows 下载安装 1.去http://www.mongodb.org/downloads下载,mongodb默认安装在C:\Program Files\MongoDB目录下,到F:\Off ...

  4. python requests的安装与简单运用

    requests是python的一个HTTP客户端库,跟urllib,urllib2类似,那为什么要用requests而不用urllib2呢?官方文档中是这样说明的: python的标准库urllib ...

  5. memcache的windows下的安装和简单使用

    原文:memcache的windows下的安装和简单使用 memcache是为了解决网站访问量大,数据库压力倍增的解决方案之一,由于其简单实用,很多站点现在都在使用memcache,但是memcach ...

  6. 【RabbitMQ】RabbitMQ在Windows的安装和简单的使用

    版本说明 使用当前版本:3.5.4 安装与启动 在官网上下载其Server二进制安装包,在Windows上的安装时简单的,与一般软件没什么区别. 安装前会提示你,还需要安装Erlang,并打开下载页面 ...

  7. Thrift的安装和简单演示样例

    本文仅仅是简单的解说Thrift开源框架的安装和简单使用演示样例.对于具体的解说,后面在进行阐述. Thrift简述                                           ...

  8. libmemcached安装及简单例子

    libmemcached安装及简单例子 1.下载安装libmemcached  $ wget http://launchpad.net/libmemcached/1.0/0.44/+download/ ...

  9. [hadoop系列]Pig的安装和简单演示样例

    inkfish原创,请勿商业性质转载,转载请注明来源(http://blog.csdn.net/inkfish ).(来源:http://blog.csdn.net/inkfish) Pig是Yaho ...

随机推荐

  1. 通过返回动态改变textview和imageview

    //获取并显示优惠券ID Intent intent = getIntent(); awardID=(TextView)findViewById(R.id.awardID); String id = ...

  2. js常见算法(一)

    1.每个单词手字母大写 var capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperCase( ...

  3. 去除IE10自带的清除按钮

    最近在工作中碰到了一个问题,原本在IE8,IE9下正常的input表单,在IE10下会出现清除按钮,即表单右侧会出现一个可以清除该表单内容的小叉.由于之前一直没有兼容过IE10,所以我专门搜了下原因. ...

  4. android studio运行的时候出现Unable to obtain debug bridge错误的解决办法

    先贴上我百度的: 首先利用win+R,输入cmd,并且输入命令好来到:cd D:\Android\sdk\platform-tools\(这个是我的adb.exe目录,你的可以自行搜索)然后输入:ad ...

  5. WordPress文章页添加展开/收缩功能

    很多时候我们在WordPress上发布一些文章的时候里面都包含了很多的代码,我一般又不喜欢把代码压缩起来而喜欢让代码格式化显示,但是格式化显示通常会让文章内容看起来很多,不便于访问者浏览,所以今天就介 ...

  6. iOS 组件化的几篇文章

    随着工程的成长,开发人员的增多,合理的模块划分及低耦合的重要性显得愈发重要.最近在思考这方面的问题,也读了不少通过组件化解耦的文章,这里记录一下. 前 5 篇文章有些关联,建议阅读顺序,1.3.2.4 ...

  7. 第一把机械键盘 ikbc C-87

    终于入了机械键盘,ikbc C-87黑色红轴. 原本上周五晚上就到了,但是那个键盘有几个键弹起后弹簧会持续响,敲了一会,实在不能忍受,就申请换货了.新换的键盘今天终于到了,没有了之前的问题,但是几乎每 ...

  8. Java值传递和引用传递

    Java总是在讨论是传递还是引用传递,Java没有像C语言那样拥有指针,在看到引用传递和值传递很多的解释之后,更相信引用传递和值传递归根到底都是值传递,只不过引用传递的时候看上去很高大上,其实是把变量 ...

  9. Python之sqlite3

    Python sqlite3数据库是一款非常小巧的内置模块,它使用一个文件存储整个数据库,操作十分方便,相比其他大型数据库来说,确实有些差距.但是在性能表现上并不逊色,麻雀虽小,五脏俱全,sqlite ...

  10. window平台写的shell脚步在Linux不识别

    ---恢复内容开始--- 出现的问题是 写的shell脚步在Linux执行的时候不被识别 解决方案: 1.确保用户对文件有读写及执行权限 oracle@linux-106:~/RMAN/bin> ...