[root@wallet01 ~]# vi /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.1.201 wallet01 192.168.1.202 wallet02 192.168.1.203 wallet03 192.168.1.204 wallet04 [root@wallet01 ~]# scp /etc/hosts 192.168.1.202:/etc [root@wallet01 ~]# scp /etc/hosts 192.168.1.203:/etc [root@wallet01 ~]# scp /etc/hosts 192.168.1.204:/etc [root@wallet01 ~]# /sbin/ifconfig eth0:1 192.168.1.200/24 [root@wallet01 ~]# mysql -uroot -pabcd.1234 mysql> grant all on *.* to 'mha'@'%' identified by 'mha'; Query OK, 0 rows affected (0.04 sec) mysql> flush privileges; Query OK, 0 rows affected (0.14 sec) mysql> show master status; +------------------+-----------+--------------+------------------+-------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +------------------+-----------+--------------+------------------+-------------------+ | mysql-bin.000245 | 104390591 | | | | +------------------+-----------+--------------+------------------+-------------------+ 1 row in set (0.00 sec) [root@wallet02 ~]# mysql -uroot -pabcd.1234 mysql> show slave status\G; *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 192.168.1.201 Master_User: repl Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000245 Read_Master_Log_Pos: 104399339 Relay_Log_File: relay-bin.000004 Relay_Log_Pos: 14828467 Relay_Master_Log_File: mysql-bin.000245 Slave_IO_Running: Yes Slave_SQL_Running: Yes [root@wallet03 ~]# mysql -uroot -pabcd.1234 mysql> show slave status\G; *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 192.168.1.201 Master_User: repl Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000245 Read_Master_Log_Pos: 104410355 Relay_Log_File: relay-bin.000004 Relay_Log_Pos: 14834299 Relay_Master_Log_File: mysql-bin.000245 Slave_IO_Running: Yes Slave_SQL_Running: Yes [root@wallet01 ~]# vi /etc/my.cnf [mysqld] relay_log_purge = 0 [root@wallet02 ~]# vi /etc/my.cnf [mysqld] relay_log_purge = 0 read_only = 1 [root@wallet03 ~]# vi /etc/my.cnf [mysqld] relay_log_purge = 0 read_only = 1 [root@wallet01 ~]# ssh-keygen [root@wallet01 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@wallet02 [root@wallet01 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@wallet03 [root@wallet01 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@wallet04 [root@wallet02 ~]# ssh-keygen [root@wallet02 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@wallet01 [root@wallet02 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@wallet03 [root@wallet02 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@wallet04 [root@wallet03 ~]# ssh-keygen [root@wallet03 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@wallet01 [root@wallet03 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@wallet02 [root@wallet03 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@wallet04 [root@wallet04 ~]# ssh-keygen [root@wallet04 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@wallet01 [root@wallet04 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@wallet02 [root@wallet04 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@wallet03 [root@wallet01 ~]# ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql [root@wallet01 ~]# ln -s /usr/local/mysql/bin/mysqlbinlog /usr/local/bin/mysqlbinlog [root@wallet02 ~]# ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql [root@wallet02 ~]# ln -s /usr/local/mysql/bin/mysqlbinlog /usr/local/bin/mysqlbinlog [root@wallet03 ~]# ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql [root@wallet03 ~]# ln -s /usr/local/mysql/bin/mysqlbinlog /usr/local/bin/mysqlbinlog [root@wallet04 ~]# ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql [root@wallet04 ~]# ln -s /usr/local/mysql/bin/mysqlbinlog /usr/local/bin/mysqlbinlog [root@wallet01 ~]# yum install -y perl-DBD-MySQL perl-CPAN perl-Config-Tiny perl-Log-Dispatch perl-Time-HiRes perl-Parallel-ForkManager [root@wallet01 ~]# tar zxvf mha4mysql-node-0.56.tar.gz [root@wallet01 ~]# cd mha4mysql-node-0.56 [root@wallet01 mha4mysql-node-0.56]# perl Makefile [root@wallet01 mha4mysql-node-0.56]# make && make install [root@wallet02 ~]# yum install -y perl-DBD-MySQL perl-CPAN perl-Config-Tiny perl-Log-Dispatch perl-Time-HiRes perl-Parallel-ForkManager [root@wallet02 ~]# tar zxvf mha4mysql-node-0.56.tar.gz [root@wallet02 ~]# cd mha4mysql-node-0.56 [root@wallet02 mha4mysql-node-0.56]# perl Makefile [root@wallet02 mha4mysql-node-0.56]# make && make install [root@wallet03 ~]# yum install -y perl-DBD-MySQL perl-CPAN perl-Config-Tiny perl-Log-Dispatch perl-Time-HiRes perl-Parallel-ForkManager [root@wallet03 ~]# tar zxvf mha4mysql-node-0.56.tar.gz [root@wallet03 ~]# cd mha4mysql-node-0.56 [root@wallet03 mha4mysql-node-0.56]# perl Makefile [root@wallet03 mha4mysql-node-0.56]# make && make install [root@wallet04 ~]# yum install -y perl-DBD-MySQL perl-CPAN perl-Config-Tiny perl-Log-Dispatch perl-Time-HiRes perl-Parallel-ForkManager [root@wallet04 ~]# tar zxvf mha4mysql-node-0.56.tar.gz [root@wallet04 ~]# cd mha4mysql-node-0.56 [root@wallet04 mha4mysql-node-0.56]# perl Makefile [root@wallet04 mha4mysql-node-0.56]# make && make install [root@wallet04 ~]# tar zxvf mha4mysql-manager-0.56.tar.gz [root@wallet04 ~]# cd mha4mysql-manager-0.56 [root@wallet04 mha4mysql-manager-0.56]# perl Makefile.PL [root@wallet04 mha4mysql-manager-0.56]# make && make install [root@wallet04 mha4mysql-manager-0.56]# cp samples/scripts/* /usr/local/bin [root@wallet04 ~]# mkdir -p /usr/local/mha [root@wallet04 ~]# mkdir -p /etc/mha [root@wallet04 ~]# vim /etc/mha/mha.conf [server default] user=mha password=mha repl_user=repl repl_password=repl ssh_user=root ping_interval=1 ping_type=CONNECT manager_workdir=/usr/local/mha manager_log=/usr/local/mha/manager.log master_ip_failover_script=/usr/local/bin/master_ip_failover master_ip_online_change_script=/usr/local/bin/master_ip_online_change [server1] hostname=wallet01 ip=192.168.1.201 ssh_port=22 master_binlog_dir=/usr/local/mysql/data candidate_master=1 port=3306 [server2] hostname=wallet02 ip=192.168.1.202 ssh_port=22 master_binlog_dir=/usr/local/mysql/data candidate_master=1 port=3306 [server3] hostname=wallet03 ip=192.168.1.203 ssh_port=22 master_binlog_dir=/usr/local/mysql/data candidate_master=1 port=3306 [root@wallet04 ~]# vi /usr/local/bin/master_ip_failover #!/usr/bin/env perl # Copyright (C) 2011 DeNA Co.,Ltd. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ## Note: This is a sample script and is not complete. Modify the script based on your environment. use strict; use warnings FATAL => 'all'; use Getopt::Long; my ( $command, $ssh_user, $orig_master_host, $orig_master_ip, $orig_master_port, $new_master_host, $new_master_ip, $new_master_port ); my $vip = '192.168.1.200/24'; # Virtual IP my $gateway = '192.168.1.1'; #Gateway IP my $interface = 'eth0'; my $key = "1"; my $ssh_start_vip = "/sbin/ifconfig $interface:$key $vip;/sbin/arping -I $interface -c 3 -s $vip $gateway >/dev/null 2>&1"; my $ssh_stop_vip = "/sbin/ifconfig $interface:$key down"; GetOptions( 'command=s' => \$command, 'ssh_user=s' => \$ssh_user, 'orig_master_host=s' => \$orig_master_host, 'orig_master_ip=s' => \$orig_master_ip, 'orig_master_port=i' => \$orig_master_port, 'new_master_host=s' => \$new_master_host, 'new_master_ip=s' => \$new_master_ip, 'new_master_port=i' => \$new_master_port, ); exit &main(); sub main { print "\n\nIN SCRIPT TEST====$ssh_stop_vip==$ssh_start_vip===\n\n"; if ( $command eq "stop" || $command eq "stopssh" ) { # $orig_master_host, $orig_master_ip, $orig_master_port are passed. # If you manage master ip address at global catalog database, # invalidate orig_master_ip here. my $exit_code = 1; eval { print "Disabling the VIP on old master: $orig_master_host \n"; &stop_vip(); $exit_code = 0; }; if ($@) { warn "Got Error: $@\n"; exit $exit_code; } exit $exit_code; } elsif ( $command eq "start" ) { # all arguments are passed. # If you manage master ip address at global catalog database, # activate new_master_ip here. # You can also grant write access (create user, set read_only=0, etc) here. my $exit_code = 10; eval { print "Enabling the VIP - $vip on the new master - $new_master_host \n"; &start_vip(); $exit_code = 0; }; if ($@) { warn $@; exit $exit_code; } exit $exit_code; } elsif ( $command eq "status" ) { print "Checking the Status of the script.. OK \n"; `ssh $ssh_user\@$orig_master_host \" $ssh_start_vip \"`; exit 0; } else { &usage(); exit 1; } } # A simple system call that enable the VIP on the new master sub start_vip() { `ssh $ssh_user\@$new_master_host \" $ssh_start_vip \"`; } # A simple system call that disable the VIP on the old_master sub stop_vip() { `ssh $ssh_user\@$orig_master_host \" $ssh_stop_vip \"`; } sub usage { print "Usage: master_ip_failover --command=start|stop|stopssh|status --orig_master_host=host --orig_master_ip=ip --orig_master_port=port --new_master_host=host --new_master_ip=ip --new_master_port=port\n"; } [root@wallet04 ~]# /usr/local/bin/masterha_check_ssh --conf=/etc/mha/mha.conf Wed Feb 20 15:45:05 2019 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping. Wed Feb 20 15:45:05 2019 - [info] Reading application default configuration from /etc/mha/mha.conf.. Wed Feb 20 15:45:05 2019 - [info] Reading server configuration from /etc/mha/mha.conf.. Wed Feb 20 15:45:05 2019 - [info] Starting SSH connection tests.. Wed Feb 20 15:45:05 2019 - [debug] Wed Feb 20 15:45:05 2019 - [debug] Connecting via SSH from root@wallet01(192.168.1.201:22) to root@wallet02(192.168.1.202:22).. Wed Feb 20 15:45:05 2019 - [debug] ok. Wed Feb 20 15:45:05 2019 - [debug] Connecting via SSH from root@wallet01(192.168.1.201:22) to root@wallet03(192.168.1.203:22).. Wed Feb 20 15:45:05 2019 - [debug] ok. Wed Feb 20 15:45:06 2019 - [debug] Wed Feb 20 15:45:05 2019 - [debug] Connecting via SSH from root@wallet02(192.168.1.202:22) to root@wallet01(192.168.1.201:22).. Wed Feb 20 15:45:05 2019 - [debug] ok. Wed Feb 20 15:45:05 2019 - [debug] Connecting via SSH from root@wallet02(192.168.1.202:22) to root@wallet03(192.168.1.203:22).. Wed Feb 20 15:45:05 2019 - [debug] ok. Wed Feb 20 15:45:06 2019 - [debug] Wed Feb 20 15:45:06 2019 - [debug] Connecting via SSH from root@wallet03(192.168.1.203:22) to root@wallet01(192.168.1.201:22).. Wed Feb 20 15:45:06 2019 - [debug] ok. Wed Feb 20 15:45:06 2019 - [debug] Connecting via SSH from root@wallet03(192.168.1.203:22) to root@wallet02(192.168.1.202:22).. Wed Feb 20 15:45:06 2019 - [debug] ok. Wed Feb 20 15:45:06 2019 - [info] All SSH connection tests passed successfully. [root@wallet04 ~]# /usr/local/bin/masterha_check_repl --conf=/etc/mha/mha.conf Wed Feb 20 15:45:22 2019 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping. Wed Feb 20 15:45:22 2019 - [info] Reading application default configuration from /etc/mha/mha.conf.. Wed Feb 20 15:45:22 2019 - [info] Reading server configuration from /etc/mha/mha.conf.. Wed Feb 20 15:45:22 2019 - [info] MHA::MasterMonitor version 0.56. Wed Feb 20 15:45:23 2019 - [info] GTID failover mode = 0 Wed Feb 20 15:45:23 2019 - [info] Dead Servers: Wed Feb 20 15:45:23 2019 - [info] Alive Servers: Wed Feb 20 15:45:23 2019 - [info] wallet01(192.168.1.201:3306) Wed Feb 20 15:45:23 2019 - [info] wallet02(192.168.1.202:3306) Wed Feb 20 15:45:23 2019 - [info] wallet03(192.168.1.203:3306) Wed Feb 20 15:45:23 2019 - [info] Alive Slaves: Wed Feb 20 15:45:23 2019 - [info] wallet02(192.168.1.202:3306) Version=5.6.43-log (oldest major version between slaves) log-bin:enabled Wed Feb 20 15:45:23 2019 - [info] Replicating from 192.168.1.201(192.168.1.201:3306) Wed Feb 20 15:45:23 2019 - [info] Primary candidate for the new Master (candidate_master is set) Wed Feb 20 15:45:23 2019 - [info] wallet03(192.168.1.203:3306) Version=5.6.43-log (oldest major version between slaves) log-bin:enabled Wed Feb 20 15:45:23 2019 - [info] Replicating from 192.168.1.201(192.168.1.201:3306) Wed Feb 20 15:45:23 2019 - [info] Primary candidate for the new Master (candidate_master is set) Wed Feb 20 15:45:23 2019 - [info] Current Alive Master: wallet01(192.168.1.201:3306) Wed Feb 20 15:45:23 2019 - [info] Checking slave configurations.. Wed Feb 20 15:45:23 2019 - [info] Checking replication filtering settings.. Wed Feb 20 15:45:23 2019 - [info] binlog_do_db= , binlog_ignore_db= Wed Feb 20 15:45:23 2019 - [info] Replication filtering check ok. Wed Feb 20 15:45:23 2019 - [info] GTID (with auto-pos) is not supported Wed Feb 20 15:45:23 2019 - [info] Starting SSH connection tests.. Wed Feb 20 15:45:24 2019 - [info] All SSH connection tests passed successfully. Wed Feb 20 15:45:24 2019 - [info] Checking MHA Node version.. Wed Feb 20 15:45:24 2019 - [info] Version check ok. Wed Feb 20 15:45:24 2019 - [info] Checking SSH publickey authentication settings on the current master.. Wed Feb 20 15:45:25 2019 - [info] HealthCheck: SSH to wallet01 is reachable. Wed Feb 20 15:45:25 2019 - [info] Master MHA Node version is 0.56. Wed Feb 20 15:45:25 2019 - [info] Checking recovery script configurations on wallet01(192.168.1.201:3306).. Wed Feb 20 15:45:25 2019 - [info] Executing command: save_binary_logs --command=test --start_pos=4 --binlog_dir=/usr/local/mysql/data --output_file=/var/tmp/save_binary_logs_test --manager_version=0.56 --start_file=mysql-bin.000245 Wed Feb 20 15:45:25 2019 - [info] Connecting to [email protected](wallet01:22).. Creating /var/tmp if not exists.. ok. Checking output directory is accessible or not.. ok. Binlog found at /usr/local/mysql/data, up to mysql-bin.000245 Wed Feb 20 15:45:25 2019 - [info] Binlog setting check done. Wed Feb 20 15:45:25 2019 - [info] Checking SSH publickey authentication and checking recovery script configurations on all alive slave servers.. Wed Feb 20 15:45:25 2019 - [info] Executing command : apply_diff_relay_logs --command=test --slave_user='mha' --slave_host=wallet02 --slave_ip=192.168.1.202 --slave_port=3306 --workdir=/var/tmp --target_version=5.6.43-log --manager_version=0.56 --relay_dir=/usr/local/mysql/data --current_relay_log=relay-bin.000004 --slave_pass=xxx Wed Feb 20 15:45:25 2019 - [info] Connecting to [email protected](wallet02:22).. Checking slave recovery environment settings.. Relay log found at /usr/local/mysql/data, up to relay-bin.000004 Temporary relay log file is /usr/local/mysql/data/relay-bin.000004 Testing mysql connection and privileges..Warning: Using a password on the command line interface can be insecure. done. Testing mysqlbinlog output.. done. Cleaning up test file(s).. done. Wed Feb 20 15:45:25 2019 - [info] Executing command : apply_diff_relay_logs --command=test --slave_user='mha' --slave_host=wallet03 --slave_ip=192.168.1.203 --slave_port=3306 --workdir=/var/tmp --target_version=5.6.43-log --manager_version=0.56 --relay_dir=/usr/local/mysql/data --current_relay_log=relay-bin.000004 --slave_pass=xxx Wed Feb 20 15:45:25 2019 - [info] Connecting to [email protected](wallet03:22).. Checking slave recovery environment settings.. Relay log found at /usr/local/mysql/data, up to relay-bin.000004 Temporary relay log file is /usr/local/mysql/data/relay-bin.000004 Testing mysql connection and privileges..Warning: Using a password on the command line interface can be insecure. done. Testing mysqlbinlog output.. done. Cleaning up test file(s).. done. Wed Feb 20 15:45:26 2019 - [info] Slaves settings check done. Wed Feb 20 15:45:26 2019 - [info] wallet01(192.168.1.201:3306) (current master) +--wallet02(192.168.1.202:3306) +--wallet03(192.168.1.203:3306) Wed Feb 20 15:45:26 2019 - [info] Checking replication health on wallet02.. Wed Feb 20 15:45:26 2019 - [info] ok. Wed Feb 20 15:45:26 2019 - [info] Checking replication health on wallet03.. Wed Feb 20 15:45:26 2019 - [info] ok. Wed Feb 20 15:45:26 2019 - [info] Checking master_ip_failover_script status: Wed Feb 20 15:45:26 2019 - [info] /usr/local/bin/master_ip_failover --command=status --ssh_user=root --orig_master_host=wallet01 --orig_master_ip=192.168.1.201 --orig_master_port=3306 IN SCRIPT TEST====/sbin/ifconfig eth0:1 down==/sbin/ifconfig eth0:1 192.168.1.200/24;/sbin/arping -I eth0 -c 3 -s 192.168.1.200/24 192.168.1.1 >/dev/null 2>&1=== Checking the Status of the script.. OK Wed Feb 20 15:45:26 2019 - [info] OK. Wed Feb 20 15:45:26 2019 - [warning] shutdown_script is not defined. Wed Feb 20 15:45:26 2019 - [info] Got exit code 0 (Not master dead). MySQL Replication Health is OK. [root@wallet04 ~]# nohup /usr/local/bin/masterha_manager --conf=/etc/mha/mha.conf > /var/log/masterhamanager.log < /dev/null 2>&1 & [root@wallet04 ~]# /usr/local/bin/masterha_check_status --conf=/etc/mha/mha.conf mha (pid:14002) is running(0:PING_OK), master:wallet01 [root@wallet04 ~]# cat /var/log/masterhamanager.log Wed Feb 20 17:06:54 2019 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping. Wed Feb 20 17:06:54 2019 - [info] Reading application default configuration from /etc/mha/mha.conf.. Wed Feb 20 17:06:54 2019 - [info] Reading server configuration from /etc/mha/mha.conf..
关闭wallet01之前: wallet01:master wallet02:wallet01的第一个slave wallet03:wallet01的第二个slave [root@wallet01 ~]# ip addr 2: eth0:mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 08:00:27:46:e9:d6 brd ff:ff:ff:ff:ff:ff inet 192.168.1.201/24 brd 192.168.1.255 scope global eth0 inet 192.168.1.200/24 brd 192.168.1.255 scope global secondary eth0:1 关闭wallet01之后: wallet02被提升为新的master wallet03成为wallet02的第一个slave [root@wallet01 ~]# service mysqld stop Shutting down MySQL..... [ OK ] [root@wallet01 ~]# ip addr 2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 08:00:27:46:e9:d6 brd ff:ff:ff:ff:ff:ff inet 192.168.1.201/24 brd 192.168.1.255 scope global eth0 [root@wallet02 ~]# ip addr 2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 08:00:27:7b:14:12 brd ff:ff:ff:ff:ff:ff inet 192.168.1.202/24 brd 192.168.1.255 scope global eth0 inet 192.168.1.200/24 brd 192.168.1.255 scope global secondary eth0:1 [root@wallet02 ~]# mysql -uroot -pabcd.1234 mysql> show master status; +------------------+----------+--------------+------------------+-------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +------------------+----------+--------------+------------------+-------------------+ | mysql-bin.000005 | 120 | | | | +------------------+----------+--------------+------------------+-------------------+ 1 row in set (0.00 sec) [root@wallet03 ~]# mysql -uroot -pabcd.1234 mysql> show slave status\G; *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 192.168.1.202 Master_User: repl Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000005 Read_Master_Log_Pos: 120 Relay_Log_File: relay-bin.000002 Relay_Log_Pos: 283 Relay_Master_Log_File: mysql-bin.000005 Slave_IO_Running: Yes Slave_SQL_Running: Yes
恢复wallet01之后: wallet02:master wallet03:wallet02的第一个slave wallet01:wallet02的第二个slave [root@wallet04 ~]# grep -i 'change' /usr/local/mha/manager.log Tue Mar 13 15:34:53 2018 - [info] All other slaves should start replication from here. Statement should be: CHANGE MASTER TO MASTER_HOST='amb02 or 192.168.1.202', MASTER_PORT=3306, MASTER_LOG_FILE='mysql-bin.000005', MASTER_LOG_POS=120, MASTER_USER='repl', MASTER_PASSWORD='xxx'; Tue Mar 13 15:34:53 2018 - [info] Executed CHANGE MASTER. [root@wallet04 ~]# cd /usr/local/mha/ [root@wallet04 mha]# rm -rf mha.failover.complete [root@wallet01 ~]# service mysqld start Starting MySQL. [ OK ] [root@wallet01 ~]# mysql -uroot -pabcd.1234 mysql> stop slave; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> reset slave all; Query OK, 0 rows affected (0.00 sec) mysql> CHANGE MASTER TO MASTER_HOST='192.168.1.202', MASTER_PORT=3306, MASTER_LOG_FILE='mysql-bin.000005', MASTER_LOG_POS=120, MASTER_USER='repl', MASTER_PASSWORD='repl'; Query OK, 0 rows affected, 2 warnings (0.06 sec) mysql> start slave; Query OK, 0 rows affected (0.05 sec) mysql> show slave status\G; *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 192.168.1.202 Master_User: repl Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000005 Read_Master_Log_Pos: 120 Relay_Log_File: relay-bin.000002 Relay_Log_Pos: 283 Relay_Master_Log_File: mysql-bin.000005 Slave_IO_Running: Yes Slave_SQL_Running: Yes [root@wallet04 ~]# /usr/local/bin/masterha_check_ssh --conf=/etc/mha/mha.conf [root@wallet04 ~]# /usr/local/bin/masterha_check_repl --conf=/etc/mha/mha.conf [root@wallet04 ~]# nohup /usr/local/bin/masterha_manager --conf=/etc/mha/mha.conf > /var/log/masterhamanager.log < /dev/null 2>&1 & [root@wallet04 ~]# /usr/local/bin/masterha_check_status --conf=/etc/mha/mha.conf mha (pid:1921) is running(0:PING_OK), master:192.168.1.202