一区二区三区日韩精品-日韩经典一区二区三区-五月激情综合丁香婷婷-欧美精品中文字幕专区

分享

MySQL+MHA+keepalive+vip 安裝配置

 財商能力 2014-02-14

在mysql的復(fù)制,當主服務(wù)崩潰了,利用mha實現(xiàn)主服務(wù)自動切換,并能使其他從服務(wù)切換到新的主機。下面是部署步驟

(1)準備三機器:主服務(wù) 192.168.8.120,備主 192.168.8.121 ,從服務(wù)和管理節(jié)點 192.168.8.122

(2)修改各臺主機名 如 管理節(jié)點192.168.8.122

 cat /etc/hosts

[root@centos3 mha]# more /etc/hosts
127.0.0.1   localhost
192.168.8.120 centos1
192.168.8.121 centos2
192.168.8.122 centos3

(3)數(shù)據(jù)節(jié)點

安裝mha4mysql-node-0.53.tar.gz  mha4mysql-manager-0.53.tar.gz,由于mha4mysql-node 依賴 perl-DBD-MySQL, mha4mysql-manager依賴 perl-Config-Tiny perl-Params-Validate perl-Log-Dispatch perl-Parallel-ForkManager 。所以現(xiàn)在這些依賴包。實驗使用yum 安裝。

對三臺mariadb數(shù)據(jù)節(jié)點只需安裝mha4mysql-node-0.53.tar.gz ,本文沒有寫mariadb的安裝以及復(fù)制。

[root@centos1mha]# rpm -ivh http://dl./pub/epel/5/i386/epel-release-5-4.noarch.rpm

[root@centos1mha]# yum -y install perl-DBD-MySQL  ncftp

[root@centos1mha]# tar -zxf mha4mysql-node-0.53.tar.gz

[root@centos1mha]# cd mha4mysql-node-0.53

[root@centos1mha]#  perl Makefile.PL   

[root@centos1mha]# make && make install 

(4)管理節(jié)點

[root@sh-gs-dbmg0227 ~]#  rpm -ivh http://dl./pub/epel/5/i386/epel-release-5-4.noarch.rpm 

//這個是centos5.x 如果是6.x rpm -ivh http://dl./pub/epel/6/i386/epel-release-6-8.noarch.rpm 

[root@centos3 mha]# yum -y install perl-DBD-MySQL  ncftp

[root@centos3 mha]# tar -zxf mha4mysql-node-0.53.tar.gz 

[root@centos3 mha]# cd mha4mysql-node-0.53

[root@centos3 mha]# perl Makefile.PL   

[root@centos3 mha]# make && make install 

[root@centos3 mha]#  yum -y install perl-Config-Tiny perl-Params-Validate perl-Log-Dispatch perl-Parallel-ForkManager perl-Config-IniFiles

[root@centos3 mha]# tar -zxf mha4mysql-manager-0.53.tar.gz

[root@centos3 mha]# perl Makefile.PL

如果在該過程中出現(xiàn)下面錯誤
Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: inc /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at inc/Module/Install/Can.pm line 6.
解決方法:
 yum install perl-CPAN 

[root@centos3 mha]# make && make install 

[root@centos3 mha]# mkdir /etc/masterha

[root@centos3 mha]# mkdir -p /master/app1
[root@centos3 mha]# mkdir -p /scripts

[root@centos3 mha]# cp samples/conf/* /etc/masterha/

[root@centos3 mha]# cp samples/scripts/*  /scripts

配置管理節(jié)點

[root@centos3 mha]# more  /etc/masterha/masterha_default.cnf
[server default]
user=root
password=123456
ssh_user=root
repl_user=repl
repl_password=qwert
master_binlog_dir= /app/mysql
remote_workdir=/app/mha
secondary_check_script= masterha_secondary_check -s 192.168.12.234 -s 192.168.12.232
ping_interval=1
master_ip_failover_script=/scripts/master_ip_failover
#shutdown_script=/scripts/power_manager
report_script= /scripts/send_report
master_ip_online_change_script= /scripts/master_ip_online_change

[root@centos3 mha]# more  /etc/masterha/app1.cnf

[server default]
manager_workdir=/app/mha
manager_log=/app/mha/manager.log

[server1]
hostname=192.168.8.120
candidate_master=1

[server2]
hostname=192.168.8.121
candidate_master=1

[server3]
hostname=192.168.8.122
no_master=1

(5)在mysql 添加用戶,復(fù)制設(shè)置

mysql 主節(jié)點

grant replication slave  on *.* to  identified by 'qwert';

grant  all on *.* to  identified by '123456';

備主節(jié)點

grant replication slave on *.* to  identified by 'qwert';

grant  all on *.* to  identified by '123456';

set read_only=1
set relay_log_purge=0

從節(jié)點

 grant  all on *.* to  identified by '123456';

set read_only=1
set relay_log_purge=0

(6)配置ssh

[[root@centos3~# ssh-keygen -t rsa 

[root@centos3 ~]# ssh-copy-id -i .ssh/id_rsa.pub root@192.168.8.120

[root@centos3~]# ssh-copy-id -i .ssh/id_rsa.pub root@192.168.8.121 

[root@centos1 ~]# ssh-keygen -t rsa

[root@centos1 ~]# ssh-copy-id -i .ssh/id_rsa.pub root@192.168.8.121

[root@centos1 ~]# ssh-copy-id -i .ssh/id_rsa.pub root@192.168.8.122

[root@centos2 ~]# ssh-keygen -t rsa 

[root@centos2 ~]# ssh-copy-id -i .ssh/id_rsa.pub root@192.168.8.120

[root@centos2 ~]#  ssh-copy-id -i .ssh/id_rsa.pub root@192.168.8.122

(7)測試ssh

 [root@centos3 mha]#  masterha_check_ssh --global_conf=/etc/masterha/masterha_default.cnf  --conf=/etc/masterha/app1.cnf
Sat Aug 10 06:15:39 2013 - [info] Reading default configuratoins from /etc/masterha/masterha_default.cnf..
Sat Aug 10 06:15:39 2013 - [info] Reading application default configurations from /etc/masterha/app1.cnf..
Sat Aug 10 06:15:39 2013 - [info] Reading server configurations from /etc/masterha/app1.cnf..
Sat Aug 10 06:15:39 2013 - [info] Starting SSH connection tests..
Sat Aug 10 06:15:42 2013 - [debug]
Sat Aug 10 06:15:39 2013 - [debug]  Connecting via SSH from root@192.168.8.120(192.168.8.120:22) to root@192.168.8.121(192.168.8.121:22)..
Sat Aug 10 06:15:41 2013 - [debug]   ok.
Sat Aug 10 06:15:41 2013 - [debug]  Connecting via SSH from root@192.168.8.120(192.168.8.120:22) to root@192.168.8.122(192.168.8.122:22)..
Sat Aug 10 06:15:42 2013 - [debug]   ok.
Sat Aug 10 06:15:43 2013 - [debug]
Sat Aug 10 06:15:40 2013 - [debug]  Connecting via SSH from root@192.168.8.121(192.168.8.121:22) to root@192.168.8.120(192.168.8.120:22)..
Sat Aug 10 06:15:41 2013 - [debug]   ok.
Sat Aug 10 06:15:41 2013 - [debug]  Connecting via SSH from root@192.168.8.121(192.168.8.121:22) to root@192.168.8.122(192.168.8.122:22)..
Sat Aug 10 06:15:43 2013 - [debug]   ok.
Sat Aug 10 06:15:44 2013 - [debug]
Sat Aug 10 06:15:40 2013 - [debug]  Connecting via SSH from root@192.168.8.122(192.168.8.122:22) to root@192.168.8.120(192.168.8.120:22)..
Sat Aug 10 06:15:42 2013 - [debug]   ok.
Sat Aug 10 06:15:42 2013 - [debug]  Connecting via SSH from root@192.168.8.122(192.168.8.122:22) to root@192.168.8.121(192.168.8.121:22)..
Sat Aug 10 06:15:44 2013 - [debug]   ok.
Sat Aug 10 06:15:44 2013 - [info] All SSH connection tests passed successfully.

(8)測試復(fù)制

[root@centos3 mha]#  masterha_check_repl --global_conf=/etc/masterha/masterha_default.cnf  --conf=/etc/masterha/app1.cnf
Sat Aug 10 06:26:13 2013 - [info] Reading default configuratoins from /etc/masterha/masterha_default.cnf..
Sat Aug 10 06:26:13 2013 - [info] Reading application default configurations from /etc/masterha/app1.cnf..
Sat Aug 10 06:26:13 2013 - [info] Reading server configurations from /etc/masterha/app1.cnf..
Sat Aug 10 06:26:13 2013 - [info] MHA::MasterMonitor version 0.53.
Sat Aug 10 06:26:13 2013 - [info] Dead Servers:
Sat Aug 10 06:26:13 2013 - [info] Alive Servers:
Sat Aug 10 06:26:13 2013 - [info]   192.168.8.120(192.168.8.120:3306)
Sat Aug 10 06:26:13 2013 - [info]   192.168.8.121(192.168.8.121:3306)
Sat Aug 10 06:26:13 2013 - [info]   192.168.8.122(192.168.8.122:3306)
Sat Aug 10 06:26:13 2013 - [info] Alive Slaves:
Sat Aug 10 06:26:13 2013 - [info]   192.168.8.121(192.168.8.121:3306)  Version=5.5.29-log (oldest major version between slaves) log-bin:enabled
Sat Aug 10 06:26:13 2013 - [info]     Replicating from 192.168.8.120(192.168.8.120:3306)
Sat Aug 10 06:26:13 2013 - [info]     Primary candidate for the new Master (candidate_master is set)
Sat Aug 10 06:26:13 2013 - [info]   192.168.8.122(192.168.8.122:3306)  Version=5.5.29-log (oldest major version between slaves) log-bin:enabled
Sat Aug 10 06:26:13 2013 - [info]     Replicating from 192.168.8.120(192.168.8.120:3306)
Sat Aug 10 06:26:13 2013 - [info]     Not candidate for the new Master (no_master is set)
Sat Aug 10 06:26:13 2013 - [info] Current Alive Master: 192.168.8.120(192.168.8.120:3306)
Sat Aug 10 06:26:13 2013 - [info] Checking slave configurations..
Sat Aug 10 06:26:13 2013 - [info] Checking replication filtering settings..
Sat Aug 10 06:26:13 2013 - [info]  binlog_do_db= , binlog_ignore_db=
Sat Aug 10 06:26:13 2013 - [info]  Replication filtering check ok.
Sat Aug 10 06:26:13 2013 - [info] Starting SSH connection tests..
Sat Aug 10 06:26:17 2013 - [info] All SSH connection tests passed successfully.
Sat Aug 10 06:26:17 2013 - [info] Checking MHA Node version..
Sat Aug 10 06:26:18 2013 - [info]  Version check ok.
Sat Aug 10 06:26:18 2013 - [info] Checking SSH publickey authentication settings on the current master..
Sat Aug 10 06:26:18 2013 - [info] HealthCheck: SSH to 192.168.8.120 is reachable.
Sat Aug 10 06:26:18 2013 - [info] Master MHA Node version is 0.53.
Sat Aug 10 06:26:18 2013 - [info] Checking recovery script configurations on the current master..
Sat Aug 10 06:26:18 2013 - [info]   Executing command: save_binary_logs --command=test --start_pos=4 --binlog_dir=/app/mysql --output_file=/app/mha/save_binary_logs_test --manager_version=0.53 --start_file=mysql-bin.000010
Sat Aug 10 06:26:18 2013 - [info]   Connecting to root@192.168.8.120(192.168.8.120)..
  Creating /app/mha if not exists..    ok.
  Checking output directory is accessible or not..
   ok.
  Binlog found at /app/mysql, up to mysql-bin.000010
Sat Aug 10 06:26:18 2013 - [info] Master setting check done.
Sat Aug 10 06:26:18 2013 - [info] Checking SSH publickey authentication and checking recovery script configurations on all alive slave servers..
Sat Aug 10 06:26:18 2013 - [info]   Executing command : apply_diff_relay_logs --command=test --slave_user=root --slave_host=192.168.8.121 --slave_ip=192.168.8.121 --slave_port=3306 --workdir=/app/mha --target_version=5.5.29-log --manager_version=0.53 --relay_log_info=/app/mysql/relay-log.info  --relay_dir=/app/mysql/  --slave_pass=xxx
Sat Aug 10 06:26:18 2013 - [info]   Connecting to root@192.168.8.121(192.168.8.121:22)..
  Checking slave recovery environment settings..
    Opening /app/mysql/relay-log.info ... ok.
    Relay log found at /app/mysql, up to mysql-relay-bin.000004
    Temporary relay log file is /app/mysql/mysql-relay-bin.000004
    Testing mysql connection and privileges.. done.
    Testing mysqlbinlog output.. done.
    Cleaning up test file(s).. done.
Sat Aug 10 06:26:19 2013 - [info]   Executing command : apply_diff_relay_logs --command=test --slave_user=root --slave_host=192.168.8.122 --slave_ip=192.168.8.122 --slave_port=3306 --workdir=/app/mha --target_version=5.5.29-log --manager_version=0.53 --relay_log_info=/app/mysql/relay-log.info  --relay_dir=/app/mysql/  --slave_pass=xxx
Sat Aug 10 06:26:19 2013 - [info]   Connecting to root@192.168.8.122(192.168.8.122:22)..
  Checking slave recovery environment settings..
    Opening /app/mysql/relay-log.info ... ok.
    Relay log found at /app/mysql, up to mysql-relay-bin.000004
    Temporary relay log file is /app/mysql/mysql-relay-bin.000004
    Testing mysql connection and privileges.. done.
    Testing mysqlbinlog output.. done.
    Cleaning up test file(s).. done.
Sat Aug 10 06:26:20 2013 - [info] Slaves settings check done.
Sat Aug 10 06:26:20 2013 - [info]
192.168.8.120 (current master)
 +--192.168.8.121
 +--192.168.8.122

Sat Aug 10 06:26:20 2013 - [info] Checking replication health on 192.168.8.121..
Sat Aug 10 06:26:20 2013 - [info]  ok.
Sat Aug 10 06:26:20 2013 - [info] Checking replication health on 192.168.8.122..
Sat Aug 10 06:26:20 2013 - [info]  ok.
Sat Aug 10 06:26:20 2013 - [info] Checking master_ip_failover_script status:
Sat Aug 10 06:26:20 2013 - [info]   /scripts/master_ip_failover --command=status --ssh_user=root --orig_master_host=192.168.8.120 --orig_master_ip=192.168.8.120 --orig_master_port=3306
Sat Aug 10 06:26:20 2013 - [info]  OK.
Sat Aug 10 06:26:20 2013 - [warning] shutdown_script is not defined.
Sat Aug 10 06:26:20 2013 - [info] Got exit code 0 (Not master dead).

MySQL Replication Health is OK.

(9)啟動management

[root@centos3 mysql]# nohup masterha_manager  --global-conf=/etc/masterha/masterha_default.cnf  --conf=/etc/masterha/app1.cnf

Sat Aug 10 06:29:36 2013 - [info] MHA::MasterMonitor version 0.53.
Sat Aug 10 06:29:37 2013 - [info] Dead Servers:
Sat Aug 10 06:29:37 2013 - [info] Alive Servers:
Sat Aug 10 06:29:37 2013 - [info]   192.168.8.120(192.168.8.120:3306)
Sat Aug 10 06:29:37 2013 - [info]   192.168.8.121(192.168.8.121:3306)
Sat Aug 10 06:29:37 2013 - [info]   192.168.8.122(192.168.8.122:3306)
Sat Aug 10 06:29:37 2013 - [info] Alive Slaves:
Sat Aug 10 06:29:37 2013 - [info]   192.168.8.121(192.168.8.121:3306)  Version=5.5.29-log (oldest major version between slaves) log-bin:enabled
Sat Aug 10 06:29:37 2013 - [info]     Replicating from 192.168.8.120(192.168.8.120:3306)
Sat Aug 10 06:29:37 2013 - [info]     Primary candidate for the new Master (candidate_master is set)
Sat Aug 10 06:29:37 2013 - [info]   192.168.8.122(192.168.8.122:3306)  Version=5.5.29-log (oldest major version between slaves) log-bin:enabled
Sat Aug 10 06:29:37 2013 - [info]     Replicating from 192.168.8.120(192.168.8.120:3306)
Sat Aug 10 06:29:37 2013 - [info]     Not candidate for the new Master (no_master is set)
Sat Aug 10 06:29:37 2013 - [info] Current Alive Master: 192.168.8.120(192.168.8.120:3306)
Sat Aug 10 06:29:37 2013 - [info] Checking slave configurations..
Sat Aug 10 06:29:37 2013 - [info] Checking replication filtering settings..
Sat Aug 10 06:29:37 2013 - [info]  binlog_do_db= , binlog_ignore_db=
Sat Aug 10 06:29:37 2013 - [info]  Replication filtering check ok.
Sat Aug 10 06:29:37 2013 - [info] Starting SSH connection tests..
Sat Aug 10 06:29:40 2013 - [info] All SSH connection tests passed successfully.
Sat Aug 10 06:29:40 2013 - [info] Checking MHA Node version..
Sat Aug 10 06:29:41 2013 - [info]  Version check ok.
Sat Aug 10 06:29:41 2013 - [info] Checking SSH publickey authentication settings on the current master..
Sat Aug 10 06:29:42 2013 - [info] HealthCheck: SSH to 192.168.8.120 is reachable.
Sat Aug 10 06:29:42 2013 - [info] Master MHA Node version is 0.53.
Sat Aug 10 06:29:42 2013 - [info] Checking recovery script configurations on the current master..
Sat Aug 10 06:29:42 2013 - [info]   Executing command: save_binary_logs --command=test --start_pos=4 --binlog_dir=/app/mysql --output_file=/app/mha/save_binary_logs_test --manager_version=0.53 --start_file=mysql-bin.000010
Sat Aug 10 06:29:42 2013 - [info]   Connecting to root@192.168.8.120(192.168.8.120)..
  Creating /app/mha if not exists..    ok.
  Checking output directory is accessible or not..
   ok.
  Binlog found at /app/mysql, up to mysql-bin.000010
Sat Aug 10 06:29:42 2013 - [info] Master setting check done.
Sat Aug 10 06:29:42 2013 - [info] Checking SSH publickey authentication and checking recovery script configurations on all alive slave servers..
Sat Aug 10 06:29:42 2013 - [info]   Executing command : apply_diff_relay_logs --command=test --slave_user=root --slave_host=192.168.8.121 --slave_ip=192.168.8.121 --slave_port=3306 --workdir=/app/mha --target_version=5.5.29-log --manager_version=0.53 --relay_log_info=/app/mysql/relay-log.info  --relay_dir=/app/mysql/  --slave_pass=xxx
Sat Aug 10 06:29:42 2013 - [info]   Connecting to root@192.168.8.121(192.168.8.121:22)..
  Checking slave recovery environment settings..
    Opening /app/mysql/relay-log.info ... ok.
    Relay log found at /app/mysql, up to mysql-relay-bin.000004
    Temporary relay log file is /app/mysql/mysql-relay-bin.000004
    Testing mysql connection and privileges.. done.
    Testing mysqlbinlog output.. done.
    Cleaning up test file(s).. done.
Sat Aug 10 06:29:43 2013 - [info]   Executing command : apply_diff_relay_logs --command=test --slave_user=root --slave_host=192.168.8.122 --slave_ip=192.168.8.122 --slave_port=3306 --workdir=/app/mha --target_version=5.5.29-log --manager_version=0.53 --relay_log_info=/app/mysql/relay-log.info  --relay_dir=/app/mysql/  --slave_pass=xxx
Sat Aug 10 06:29:43 2013 - [info]   Connecting to root@192.168.8.122(192.168.8.122:22)..
  Checking slave recovery environment settings..
    Opening /app/mysql/relay-log.info ... ok.
    Relay log found at /app/mysql, up to mysql-relay-bin.000004
    Temporary relay log file is /app/mysql/mysql-relay-bin.000004
    Testing mysql connection and privileges.. done.
    Testing mysqlbinlog output.. done.
    Cleaning up test file(s).. done.
Sat Aug 10 06:29:43 2013 - [info] Slaves settings check done.
Sat Aug 10 06:29:43 2013 - [info]
192.168.8.120 (current master)
 +--192.168.8.121
 +--192.168.8.122

Sat Aug 10 06:29:43 2013 - [info] Checking master_ip_failover_script status:
Sat Aug 10 06:29:43 2013 - [info]   /scripts/master_ip_failover --command=status --ssh_user=root --orig_master_host=192.168.8.120 --orig_master_ip=192.168.8.120 --orig_master_port=3306
Sat Aug 10 06:29:44 2013 - [info]  OK.
Sat Aug 10 06:29:44 2013 - [warning] shutdown_script is not defined.
Sat Aug 10 06:29:44 2013 - [info] Set master ping interval 1 seconds.
Sat Aug 10 06:29:44 2013 - [info] Set secondary check script: masterha_secondary_check -s 192.168.8.121 -s 192.168.8.122
Sat Aug 10 06:29:44 2013 - [info] Starting ping health check on 192.168.8.120(192.168.8.120:3306)..
Sat Aug 10 06:29:44 2013 - [info] Ping(SELECT) succeeded, waiting until MySQL doesn't respond..

[root@sh-gs-dbmg0227 /]# masterha_check_status --conf=/etc/masterha/app1.cnf

app1 (pid:7127) is running(0:PING_OK), master:192.168.8.121
(10)在備節(jié)點,從節(jié)點 執(zhí)行定期刪除中繼日志

00 00 * * * /usr/local/bin/purge_relay_logs –user=root –password=123456 –disable_relay_log_purge >> /masterha/purge_relay_logs.log 2>&1

(11)測試 關(guān)閉mysql主服務(wù)服務(wù),主機宕機。主服務(wù)是否自動切換。

Sat Aug 10 06:29:36 2013 - [info] MHA::MasterMonitor version 0.53.
Sat Aug 10 06:29:37 2013 - [info] Dead Servers:
Sat Aug 10 06:29:37 2013 - [info] Alive Servers:
Sat Aug 10 06:29:37 2013 - [info]   192.168.8.120(192.168.8.120:3306)
Sat Aug 10 06:29:37 2013 - [info]   192.168.8.121(192.168.8.121:3306)
Sat Aug 10 06:29:37 2013 - [info]   192.168.8.122(192.168.8.122:3306)
Sat Aug 10 06:29:37 2013 - [info] Alive Slaves:
Sat Aug 10 06:29:37 2013 - [info]   192.168.8.121(192.168.8.121:3306)  Version=5.5.29-log (oldest major version between slaves) log-bin:enabled
Sat Aug 10 06:29:37 2013 - [info]     Replicating from 192.168.8.120(192.168.8.120:3306)
Sat Aug 10 06:29:37 2013 - [info]     Primary candidate for the new Master (candidate_master is set)
Sat Aug 10 06:29:37 2013 - [info]   192.168.8.122(192.168.8.122:3306)  Version=5.5.29-log (oldest major version between slaves) log-bin:enabled
Sat Aug 10 06:29:37 2013 - [info]     Replicating from 192.168.8.120(192.168.8.120:3306)
Sat Aug 10 06:29:37 2013 - [info]     Not candidate for the new Master (no_master is set)
Sat Aug 10 06:29:37 2013 - [info] Current Alive Master: 192.168.8.120(192.168.8.120:3306)
Sat Aug 10 06:29:37 2013 - [info] Checking slave configurations..
Sat Aug 10 06:29:37 2013 - [info] Checking replication filtering settings..
Sat Aug 10 06:29:37 2013 - [info]  binlog_do_db= , binlog_ignore_db=
Sat Aug 10 06:29:37 2013 - [info]  Replication filtering check ok.
Sat Aug 10 06:29:37 2013 - [info] Starting SSH connection tests..
Sat Aug 10 06:29:40 2013 - [info] All SSH connection tests passed successfully.
Sat Aug 10 06:29:40 2013 - [info] Checking MHA Node version..
Sat Aug 10 06:29:41 2013 - [info]  Version check ok.
Sat Aug 10 06:29:41 2013 - [info] Checking SSH publickey authentication settings on the current master..
Sat Aug 10 06:29:42 2013 - [info] HealthCheck: SSH to 192.168.8.120 is reachable.
Sat Aug 10 06:29:42 2013 - [info] Master MHA Node version is 0.53.
Sat Aug 10 06:29:42 2013 - [info] Checking recovery script configurations on the current master..
Sat Aug 10 06:29:42 2013 - [info]   Executing command: save_binary_logs --command=test --start_pos=4 --binlog_dir=/app/mysql --output_file=/app/mha/save_binary_logs_test --manager_version=0.53 --start_file=mysql-bin.000010
Sat Aug 10 06:29:42 2013 - [info]   Connecting to root@192.168.8.120(192.168.8.120)..
  Creating /app/mha if not exists..    ok.
  Checking output directory is accessible or not..
   ok.
  Binlog found at /app/mysql, up to mysql-bin.000010
Sat Aug 10 06:29:42 2013 - [info] Master setting check done.
Sat Aug 10 06:29:42 2013 - [info] Checking SSH publickey authentication and checking recovery script configurations on all alive slave servers..
Sat Aug 10 06:29:42 2013 - [info]   Executing command : apply_diff_relay_logs --command=test --slave_user=root --slave_host=192.168.8.121 --slave_ip=192.168.8.121 --slave_port=3306 --workdir=/app/mha --target_version=5.5.29-log --manager_version=0.53 --relay_log_info=/app/mysql/relay-log.info  --relay_dir=/app/mysql/  --slave_pass=xxx
Sat Aug 10 06:29:42 2013 - [info]   Connecting to root@192.168.8.121(192.168.8.121:22)..
  Checking slave recovery environment settings..
    Opening /app/mysql/relay-log.info ... ok.
    Relay log found at /app/mysql, up to mysql-relay-bin.000004
    Temporary relay log file is /app/mysql/mysql-relay-bin.000004
    Testing mysql connection and privileges.. done.
    Testing mysqlbinlog output.. done.
    Cleaning up test file(s).. done.
Sat Aug 10 06:29:43 2013 - [info]   Executing command : apply_diff_relay_logs --command=test --slave_user=root --slave_host=192.168.8.122 --slave_ip=192.168.8.122 --slave_port=3306 --workdir=/app/mha --target_version=5.5.29-log --manager_version=0.53 --relay_log_info=/app/mysql/relay-log.info  --relay_dir=/app/mysql/  --slave_pass=xxx
Sat Aug 10 06:29:43 2013 - [info]   Connecting to root@192.168.8.122(192.168.8.122:22)..
  Checking slave recovery environment settings..
    Opening /app/mysql/relay-log.info ... ok.
    Relay log found at /app/mysql, up to mysql-relay-bin.000004
    Temporary relay log file is /app/mysql/mysql-relay-bin.000004
    Testing mysql connection and privileges.. done.
    Testing mysqlbinlog output.. done.
    Cleaning up test file(s).. done.
Sat Aug 10 06:29:43 2013 - [info] Slaves settings check done.
Sat Aug 10 06:29:43 2013 - [info]
192.168.8.120 (current master)
 +--192.168.8.121
 +--192.168.8.122

Sat Aug 10 06:29:43 2013 - [info] Checking master_ip_failover_script status:
Sat Aug 10 06:29:43 2013 - [info]   /scripts/master_ip_failover --command=status --ssh_user=root --orig_master_host=192.168.8.120 --orig_master_ip=192.168.8.120 --orig_master_port=3306
Sat Aug 10 06:29:44 2013 - [info]  OK.
Sat Aug 10 06:29:44 2013 - [warning] shutdown_script is not defined.
Sat Aug 10 06:29:44 2013 - [info] Set master ping interval 1 seconds.
Sat Aug 10 06:29:44 2013 - [info] Set secondary check script: masterha_secondary_check -s 192.168.8.121 -s 192.168.8.122
Sat Aug 10 06:29:44 2013 - [info] Starting ping health check on 192.168.8.120(192.168.8.120:3306)..
Sat Aug 10 06:29:44 2013 - [info] Ping(SELECT) succeeded, waiting until MySQL doesn't respond..
Sat Aug 10 06:31:27 2013 - [warning] Got error on MySQL select ping: 2006 (MySQL server has gone away)
Sat Aug 10 06:31:27 2013 - [info] Executing seconary network check script: masterha_secondary_check -s 192.168.8.121 -s 192.168.8.122  --user=root  --master_host=192.168.8.120  --master_ip=192.168.8.120  --master_port=3306
Sat Aug 10 06:31:27 2013 - [info] Executing SSH check script: save_binary_logs --command=test --start_pos=4 --binlog_dir=/app/mysql --output_file=/app/mha/save_binary_logs_test --manager_version=0.53 --binlog_prefix=mysql-bin
Sat Aug 10 06:31:28 2013 - [info] HealthCheck: SSH to 192.168.8.120 is reachable.
Sat Aug 10 06:31:28 2013 - [warning] Got error on MySQL connect: 2013 (Lost connection to MySQL server at 'reading initial communication packet', system error: 111)
Sat Aug 10 06:31:28 2013 - [warning] Connection failed 1 time(s)..
Monitoring server 192.168.8.121 is reachable, Master is not reachable from 192.168.8.121. OK.
Monitoring server 192.168.8.122 is reachable, Master is not reachable from 192.168.8.122. OK.
Sat Aug 10 06:31:29 2013 - [info] Master is not reachable from all other monitoring servers. Failover should start.
Sat Aug 10 06:31:29 2013 - [warning] Got error on MySQL connect: 2013 (Lost connection to MySQL server at 'reading initial communication packet', system error: 111)
Sat Aug 10 06:31:29 2013 - [warning] Connection failed 2 time(s)..
Sat Aug 10 06:31:30 2013 - [warning] Got error on MySQL connect: 2013 (Lost connection to MySQL server at 'reading initial communication packet', system error: 111)
Sat Aug 10 06:31:30 2013 - [warning] Connection failed 3 time(s)..
Sat Aug 10 06:31:30 2013 - [warning] Master is not reachable from health checker!
Sat Aug 10 06:31:30 2013 - [warning] Master 192.168.8.120(192.168.8.120:3306) is not reachable!
Sat Aug 10 06:31:30 2013 - [warning] SSH is reachable.
Sat Aug 10 06:31:30 2013 - [info] Connecting to a master server failed. Reading configuration file /etc/masterha/masterha_default.cnf and /etc/masterha/app1.cnf again, and trying to connect to all servers to check server status..
Sat Aug 10 06:31:30 2013 - [info] Reading default configuratoins from /etc/masterha/masterha_default.cnf..
Sat Aug 10 06:31:30 2013 - [info] Reading application default configurations from /etc/masterha/app1.cnf..
Sat Aug 10 06:31:30 2013 - [info] Reading server configurations from /etc/masterha/app1.cnf..
Sat Aug 10 06:31:30 2013 - [info] Dead Servers:
Sat Aug 10 06:31:30 2013 - [info]   192.168.8.120(192.168.8.120:3306)
Sat Aug 10 06:31:30 2013 - [info] Alive Servers:
Sat Aug 10 06:31:30 2013 - [info]   192.168.8.121(192.168.8.121:3306)
Sat Aug 10 06:31:30 2013 - [info]   192.168.8.122(192.168.8.122:3306)
Sat Aug 10 06:31:30 2013 - [info] Alive Slaves:
Sat Aug 10 06:31:30 2013 - [info]   192.168.8.121(192.168.8.121:3306)  Version=5.5.29-log (oldest major version between slaves) log-bin:enabled
Sat Aug 10 06:31:30 2013 - [info]     Replicating from 192.168.8.120(192.168.8.120:3306)
Sat Aug 10 06:31:30 2013 - [info]     Primary candidate for the new Master (candidate_master is set)
Sat Aug 10 06:31:30 2013 - [info]   192.168.8.122(192.168.8.122:3306)  Version=5.5.29-log (oldest major version between slaves) log-bin:enabled
Sat Aug 10 06:31:30 2013 - [info]     Replicating from 192.168.8.120(192.168.8.120:3306)
Sat Aug 10 06:31:30 2013 - [info]     Not candidate for the new Master (no_master is set)
Sat Aug 10 06:31:30 2013 - [info] Checking slave configurations..
Sat Aug 10 06:31:30 2013 - [info] Checking replication filtering settings..
Sat Aug 10 06:31:30 2013 - [info]  Replication filtering check ok.
Sat Aug 10 06:31:30 2013 - [info] Master is down!
Sat Aug 10 06:31:30 2013 - [info] Terminating monitoring script.
Sat Aug 10 06:31:30 2013 - [info] Got exit code 20 (Master dead).
Sat Aug 10 06:31:30 2013 - [info] MHA::MasterFailover version 0.53.
Sat Aug 10 06:31:30 2013 - [info] Starting master failover.
Sat Aug 10 06:31:30 2013 - [info]
Sat Aug 10 06:31:30 2013 - [info] * Phase 1: Configuration Check Phase..
Sat Aug 10 06:31:30 2013 - [info]
Sat Aug 10 06:31:30 2013 - [info] Dead Servers:
Sat Aug 10 06:31:30 2013 - [info]   192.168.8.120(192.168.8.120:3306)
Sat Aug 10 06:31:30 2013 - [info] Checking master reachability via mysql(double check)..
Sat Aug 10 06:31:30 2013 - [info]  ok.
Sat Aug 10 06:31:30 2013 - [info] Alive Servers:
Sat Aug 10 06:31:30 2013 - [info]   192.168.8.121(192.168.8.121:3306)
Sat Aug 10 06:31:30 2013 - [info]   192.168.8.122(192.168.8.122:3306)
Sat Aug 10 06:31:30 2013 - [info] Alive Slaves:
Sat Aug 10 06:31:30 2013 - [info]   192.168.8.121(192.168.8.121:3306)  Version=5.5.29-log (oldest major version between slaves) log-bin:enabled
Sat Aug 10 06:31:30 2013 - [info]     Replicating from 192.168.8.120(192.168.8.120:3306)
Sat Aug 10 06:31:30 2013 - [info]     Primary candidate for the new Master (candidate_master is set)
Sat Aug 10 06:31:30 2013 - [info]   192.168.8.122(192.168.8.122:3306)  Version=5.5.29-log (oldest major version between slaves) log-bin:enabled
Sat Aug 10 06:31:30 2013 - [info]     Replicating from 192.168.8.120(192.168.8.120:3306)
Sat Aug 10 06:31:30 2013 - [info]     Not candidate for the new Master (no_master is set)
Sat Aug 10 06:31:30 2013 - [info] ** Phase 1: Configuration Check Phase completed.
Sat Aug 10 06:31:30 2013 - [info]
Sat Aug 10 06:31:30 2013 - [info] * Phase 2: Dead Master Shutdown Phase..
Sat Aug 10 06:31:30 2013 - [info]
Sat Aug 10 06:31:30 2013 - [info] Forcing shutdown so that applications never connect to the current master..
Sat Aug 10 06:31:30 2013 - [info] Executing master IP deactivatation script:
Sat Aug 10 06:31:30 2013 - [info]   /scripts/master_ip_failover --orig_master_host=192.168.8.120 --orig_master_ip=192.168.8.120 --orig_master_port=3306 --command=stopssh --ssh_user=root 
Sat Aug 10 06:31:31 2013 - [info]  done.
Sat Aug 10 06:31:31 2013 - [warning] shutdown_script is not set. Skipping explicit shutting down of the dead master.
Sat Aug 10 06:31:31 2013 - [info] * Phase 2: Dead Master Shutdown Phase completed.
Sat Aug 10 06:31:31 2013 - [info]
Sat Aug 10 06:31:31 2013 - [info] * Phase 3: Master Recovery Phase..
Sat Aug 10 06:31:31 2013 - [info]
Sat Aug 10 06:31:31 2013 - [info] * Phase 3.1: Getting Latest Slaves Phase..
Sat Aug 10 06:31:31 2013 - [info]
Sat Aug 10 06:31:31 2013 - [info] The latest binary log file/position on all slaves is mysql-bin.000010:107
Sat Aug 10 06:31:31 2013 - [info] Latest slaves (Slaves that received relay log files to the latest):
Sat Aug 10 06:31:31 2013 - [info]   192.168.8.121(192.168.8.121:3306)  Version=5.5.29-log (oldest major version between slaves) log-bin:enabled
Sat Aug 10 06:31:31 2013 - [info]     Replicating from 192.168.8.120(192.168.8.120:3306)
Sat Aug 10 06:31:31 2013 - [info]     Primary candidate for the new Master (candidate_master is set)
Sat Aug 10 06:31:31 2013 - [info]   192.168.8.122(192.168.8.122:3306)  Version=5.5.29-log (oldest major version between slaves) log-bin:enabled
Sat Aug 10 06:31:31 2013 - [info]     Replicating from 192.168.8.120(192.168.8.120:3306)
Sat Aug 10 06:31:31 2013 - [info]     Not candidate for the new Master (no_master is set)
Sat Aug 10 06:31:31 2013 - [info] The oldest binary log file/position on all slaves is mysql-bin.000010:107
Sat Aug 10 06:31:31 2013 - [info] Oldest slaves:
Sat Aug 10 06:31:31 2013 - [info]   192.168.8.121(192.168.8.121:3306)  Version=5.5.29-log (oldest major version between slaves) log-bin:enabled
Sat Aug 10 06:31:31 2013 - [info]     Replicating from 192.168.8.120(192.168.8.120:3306)
Sat Aug 10 06:31:31 2013 - [info]     Primary candidate for the new Master (candidate_master is set)
Sat Aug 10 06:31:31 2013 - [info]   192.168.8.122(192.168.8.122:3306)  Version=5.5.29-log (oldest major version between slaves) log-bin:enabled
Sat Aug 10 06:31:31 2013 - [info]     Replicating from 192.168.8.120(192.168.8.120:3306)
Sat Aug 10 06:31:31 2013 - [info]     Not candidate for the new Master (no_master is set)
Sat Aug 10 06:31:31 2013 - [info]
Sat Aug 10 06:31:31 2013 - [info] * Phase 3.2: Saving Dead Master's Binlog Phase..
Sat Aug 10 06:31:31 2013 - [info]
Sat Aug 10 06:31:31 2013 - [info] Fetching dead master's binary logs..
Sat Aug 10 06:31:31 2013 - [info] Executing command on the dead master 192.168.8.120(192.168.8.120:3306): save_binary_logs --command=save --start_file=mysql-bin.000010  --start_pos=107 --binlog_dir=/app/mysql --output_file=/app/mha/saved_master_binlog_from_192.168.8.120_3306_20130810063130.binlog --handle_raw_binlog=1 --disable_log_bin=0 --manager_version=0.53
  Creating /app/mha if not exists..    ok.
 Concat binary/relay logs from mysql-bin.000010 pos 107 to mysql-bin.000010 EOF into /app/mha/saved_master_binlog_from_192.168.8.120_3306_20130810063130.binlog ..
  Dumping binlog format description event, from position 0 to 107.. ok.
  Dumping effective binlog data from /app/mysql/mysql-bin.000010 position 107 to tail(126).. ok.
 Concat succeeded.
Sat Aug 10 06:31:32 2013 - [info] scp from root@192.168.8.120:/app/mha/saved_master_binlog_from_192.168.8.120_3306_20130810063130.binlog to local:/app/mha/saved_master_binlog_from_192.168.8.120_3306_20130810063130.binlog succeeded.
Sat Aug 10 06:31:32 2013 - [info] HealthCheck: SSH to 192.168.8.121 is reachable.
Sat Aug 10 06:31:33 2013 - [info] HealthCheck: SSH to 192.168.8.122 is reachable.
Sat Aug 10 06:31:33 2013 - [info]
Sat Aug 10 06:31:33 2013 - [info] * Phase 3.3: Determining New Master Phase..
Sat Aug 10 06:31:33 2013 - [info]
Sat Aug 10 06:31:33 2013 - [info] Finding the latest slave that has all relay logs for recovering other slaves..
Sat Aug 10 06:31:33 2013 - [info] All slaves received relay logs to the same position. No need to resync each other.
Sat Aug 10 06:31:33 2013 - [info] Searching new master from slaves..
Sat Aug 10 06:31:33 2013 - [info]  Candidate masters from the configuration file:
Sat Aug 10 06:31:33 2013 - [info]   192.168.8.121(192.168.8.121:3306)  Version=5.5.29-log (oldest major version between slaves) log-bin:enabled
Sat Aug 10 06:31:33 2013 - [info]     Replicating from 192.168.8.120(192.168.8.120:3306)
Sat Aug 10 06:31:33 2013 - [info]     Primary candidate for the new Master (candidate_master is set)
Sat Aug 10 06:31:33 2013 - [info]  Non-candidate masters:
Sat Aug 10 06:31:33 2013 - [info]   192.168.8.122(192.168.8.122:3306)  Version=5.5.29-log (oldest major version between slaves) log-bin:enabled
Sat Aug 10 06:31:33 2013 - [info]     Replicating from 192.168.8.120(192.168.8.120:3306)
Sat Aug 10 06:31:33 2013 - [info]     Not candidate for the new Master (no_master is set)
Sat Aug 10 06:31:33 2013 - [info]  Searching from candidate_master slaves which have received the latest relay log events..
Sat Aug 10 06:31:33 2013 - [info] New master is 192.168.8.121(192.168.8.121:3306)
Sat Aug 10 06:31:33 2013 - [info] Starting master failover..
Sat Aug 10 06:31:33 2013 - [info]
From:
192.168.8.120 (current master)
 +--192.168.8.121
 +--192.168.8.122

To:
192.168.8.121 (new master)
 +--192.168.8.122
Sat Aug 10 06:31:33 2013 - [info]
Sat Aug 10 06:31:33 2013 - [info] * Phase 3.3: New Master Diff Log Generation Phase..
Sat Aug 10 06:31:33 2013 - [info]
Sat Aug 10 06:31:33 2013 - [info]  This server has all relay logs. No need to generate diff files from the latest slave.
Sat Aug 10 06:31:33 2013 - [info] Sending binlog..
Sat Aug 10 06:31:34 2013 - [info] scp from local:/app/mha/saved_master_binlog_from_192.168.8.120_3306_20130810063130.binlog to root@192.168.8.121:/app/mha/saved_master_binlog_from_192.168.8.120_3306_20130810063130.binlog succeeded.
Sat Aug 10 06:31:34 2013 - [info]
Sat Aug 10 06:31:34 2013 - [info] * Phase 3.4: Master Log Apply Phase..
Sat Aug 10 06:31:34 2013 - [info]
Sat Aug 10 06:31:34 2013 - [info] *NOTICE: If any error happens from this phase, manual recovery is needed.
Sat Aug 10 06:31:34 2013 - [info] Starting recovery on 192.168.8.121(192.168.8.121:3306)..
Sat Aug 10 06:31:34 2013 - [info]  Generating diffs succeeded.
Sat Aug 10 06:31:34 2013 - [info] Waiting until all relay logs are applied.
Sat Aug 10 06:31:34 2013 - [info]  done.
Sat Aug 10 06:31:34 2013 - [info] Getting slave status..
Sat Aug 10 06:31:34 2013 - [info] This slave(192.168.8.121)'s Exec_Master_Log_Pos equals to Read_Master_Log_Pos(mysql-bin.000010:107). No need to recover from Exec_Master_Log_Pos.
Sat Aug 10 06:31:34 2013 - [info] Connecting to the target slave host 192.168.8.121, running recover script..
Sat Aug 10 06:31:34 2013 - [info] Executing command: apply_diff_relay_logs --command=apply --slave_user=root --slave_host=192.168.8.121 --slave_ip=192.168.8.121  --slave_port=3306 --apply_files=/app/mha/saved_master_binlog_from_192.168.8.120_3306_20130810063130.binlog --workdir=/app/mha --target_version=5.5.29-log --timestamp=20130810063130 --handle_raw_binlog=1 --disable_log_bin=0 --manager_version=0.53 --slave_pass=xxx
Sat Aug 10 06:31:35 2013 - [info]
Applying differential binary/relay log files /app/mha/saved_master_binlog_from_192.168.8.120_3306_20130810063130.binlog on 192.168.8.121:3306. This may take long time...
Applying log files succeeded.
Sat Aug 10 06:31:35 2013 - [info]  All relay logs were successfully applied.
Sat Aug 10 06:31:35 2013 - [info] Getting new master's binlog name and position..
Sat Aug 10 06:31:35 2013 - [info]  mysql-bin.000008:107
Sat Aug 10 06:31:35 2013 - [info]  All other slaves should start replication from here. Statement should be: CHANGE MASTER TO MASTER_HOST='192.168.8.121', MASTER_PORT=3306, MASTER_LOG_FILE='mysql-bin.000008', MASTER_LOG_POS=107, MASTER_USER='repl', MASTER_PASSWORD='xxx';
Sat Aug 10 06:31:35 2013 - [info] Executing master IP activate script:
Sat Aug 10 06:31:35 2013 - [info]   /scripts/master_ip_failover --command=start --ssh_user=root --orig_master_host=192.168.8.120 --orig_master_ip=192.168.8.120 --orig_master_port=3306 --new_master_host=192.168.8.121 --new_master_ip=192.168.8.121 --new_master_port=3306 
Can't call method "prepare" on an undefined value at /usr/local/share/perl5/MHA/DBHelper.pm line 335.
Sat Aug 10 06:31:35 2013 - [error][/usr/local/share/perl5/MHA/MasterFailover.pm, ln1259]  Failed to activate master IP address for 192.168.8.121 with return code 10:0
Sat Aug 10 06:31:35 2013 - [warning] Proceeding.
Sat Aug 10 06:31:35 2013 - [info] Setting read_only=0 on 192.168.8.121(192.168.8.121:3306)..
Sat Aug 10 06:31:35 2013 - [info]  ok.
Sat Aug 10 06:31:35 2013 - [info] ** Finished master recovery successfully.
Sat Aug 10 06:31:35 2013 - [info] * Phase 3: Master Recovery Phase completed.
Sat Aug 10 06:31:35 2013 - [info]
Sat Aug 10 06:31:35 2013 - [info] * Phase 4: Slaves Recovery Phase..
Sat Aug 10 06:31:35 2013 - [info]
Sat Aug 10 06:31:35 2013 - [info] * Phase 4.1: Starting Parallel Slave Diff Log Generation Phase..
Sat Aug 10 06:31:35 2013 - [info]
Sat Aug 10 06:31:35 2013 - [info] -- Slave diff file generation on host 192.168.8.122(192.168.8.122:3306) started, pid: 11342. Check tmp log /app/mha/192.168.8.122_3306_20130810063130.log if it takes time..
Sat Aug 10 06:31:35 2013 - [info]
Sat Aug 10 06:31:35 2013 - [info] Log messages from 192.168.8.122 ...
Sat Aug 10 06:31:35 2013 - [info]
Sat Aug 10 06:31:35 2013 - [info]  This server has all relay logs. No need to generate diff files from the latest slave.
Sat Aug 10 06:31:35 2013 - [info] End of log messages from 192.168.8.122.
Sat Aug 10 06:31:35 2013 - [info] -- 192.168.8.122(192.168.8.122:3306) has the latest relay log events.
Sat Aug 10 06:31:35 2013 - [info] Generating relay diff files from the latest slave succeeded.
Sat Aug 10 06:31:35 2013 - [info]
Sat Aug 10 06:31:35 2013 - [info] * Phase 4.2: Starting Parallel Slave Log Apply Phase..
Sat Aug 10 06:31:35 2013 - [info]
Sat Aug 10 06:31:35 2013 - [info] -- Slave recovery on host 192.168.8.122(192.168.8.122:3306) started, pid: 11344. Check tmp log /app/mha/192.168.8.122_3306_20130810063130.log if it takes time..
Sat Aug 10 06:31:36 2013 - [info]
Sat Aug 10 06:31:36 2013 - [info] Log messages from 192.168.8.122 ...
Sat Aug 10 06:31:36 2013 - [info]
Sat Aug 10 06:31:35 2013 - [info] Sending binlog..
Sat Aug 10 06:31:35 2013 - [info] scp from local:/app/mha/saved_master_binlog_from_192.168.8.120_3306_20130810063130.binlog to root@192.168.8.122:/app/mha/saved_master_binlog_from_192.168.8.120_3306_20130810063130.binlog succeeded.
Sat Aug 10 06:31:35 2013 - [info] Starting recovery on 192.168.8.122(192.168.8.122:3306)..
Sat Aug 10 06:31:35 2013 - [info]  Generating diffs succeeded.
Sat Aug 10 06:31:35 2013 - [info] Waiting until all relay logs are applied.
Sat Aug 10 06:31:35 2013 - [info]  done.
Sat Aug 10 06:31:35 2013 - [info] Getting slave status..
Sat Aug 10 06:31:35 2013 - [info] This slave(192.168.8.122)'s Exec_Master_Log_Pos equals to Read_Master_Log_Pos(mysql-bin.000010:107). No need to recover from Exec_Master_Log_Pos.
Sat Aug 10 06:31:35 2013 - [info] Connecting to the target slave host 192.168.8.122, running recover script..
Sat Aug 10 06:31:35 2013 - [info] Executing command: apply_diff_relay_logs --command=apply --slave_user=root --slave_host=192.168.8.122 --slave_ip=192.168.8.122  --slave_port=3306 --apply_files=/app/mha/saved_master_binlog_from_192.168.8.120_3306_20130810063130.binlog --workdir=/app/mha --target_version=5.5.29-log --timestamp=20130810063130 --handle_raw_binlog=1 --disable_log_bin=0 --manager_version=0.53 --slave_pass=xxx
Sat Aug 10 06:31:36 2013 - [info]
Applying differential binary/relay log files /app/mha/saved_master_binlog_from_192.168.8.120_3306_20130810063130.binlog on 192.168.8.122:3306. This may take long time...
Applying log files succeeded.
Sat Aug 10 06:31:36 2013 - [info]  All relay logs were successfully applied.
Sat Aug 10 06:31:36 2013 - [info]  Resetting slave 192.168.8.122(192.168.8.122:3306) and starting replication from the new master 192.168.8.121(192.168.8.121:3306)..
Sat Aug 10 06:31:36 2013 - [info]  Executed CHANGE MASTER.
Sat Aug 10 06:31:36 2013 - [info]  Slave started.
Sat Aug 10 06:31:36 2013 - [info] End of log messages from 192.168.8.122.
Sat Aug 10 06:31:36 2013 - [info] -- Slave recovery on host 192.168.8.122(192.168.8.122:3306) succeeded.
Sat Aug 10 06:31:36 2013 - [info] All new slave servers recovered successfully.
Sat Aug 10 06:31:36 2013 - [info]
Sat Aug 10 06:31:36 2013 - [info] * Phase 5: New master cleanup phease..
Sat Aug 10 06:31:36 2013 - [info]
Sat Aug 10 06:31:36 2013 - [info] Resetting slave info on the new master..
Sat Aug 10 06:31:36 2013 - [info]  192.168.8.121: Resetting slave info succeeded.
Sat Aug 10 06:31:36 2013 - [info] Master failover to 192.168.8.121(192.168.8.121:3306) completed successfully.
Sat Aug 10 06:31:36 2013 - [info]

----- Failover Report -----

app1: MySQL Master failover 192.168.8.120 to 192.168.8.121 succeeded

Master 192.168.8.120 is down!

Check MHA Manager logs at centos3:/app/mha/manager.log for details.

Started automated(non-interactive) failover.
Invalidated master IP address on 192.168.8.120.
The latest slave 192.168.8.121(192.168.8.121:3306) has all relay logs for recovery.
Selected 192.168.8.121 as a new master.
192.168.8.121: OK: Applying all logs succeeded.
Failed to activate master IP address for 192.168.8.121 with return code 10:0
192.168.8.122: This host has the latest relay log events.
Generating relay diff files from the latest slave succeeded.
192.168.8.122: OK: Applying all logs succeeded. Slave started, replicating from 192.168.8.121.
192.168.8.121: Resetting slave info succeeded.
Master failover to 192.168.8.121(192.168.8.121:3306) completed successfully.
Sat Aug 10 06:31:36 2013 - [info] Sending mail..

以上是mha成功進行主從切換

(11)主從安裝keepalived ,實現(xiàn)虛擬ip漂移

[root@centos1 src]# tar -zxf keepalived-1.2.2.tar.gz

[root@centos1 src]# cd keepalived-1.2.2

[root@centos1 keepalived-1.2.2]# ./configure

[root@centos1 keepalived-1.2.2]# make && make install

[root@centos1 keepalived-1.2.2]# mkdir /etc/keepalived

[root@centos1 keepalived-1.2.2]# cp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/

[root@centos1 keepalived-1.2.2]# cp /usr/local/etc/rc.d/init.d/keepalived /etc/init.d/

[root@centos1 keepalived-1.2.2]# cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/

(12)主從配置keepalived ,主從的priority設(shè)置不同,權(quán)重的為主狀態(tài)

[root@centos1 keepalived-1.2.2]# more /etc/keepalived/keepalived.conf
! Configuration File for keepalived

global_defs {

   router_id mha
}

vrrp_script check_run {
    script "/root/check_mysql.sh"
    interval 1
}
vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
   
  track_script {
         check_run
     }

   virtual_ipaddress {
        192.168.8.123
      
    }
}

[root@centos1 ~] vi check_mysql.sh

#!/bin/bash
MYSQL=/usr/local/mysql/bin/mysql
MYSQL_HOST=127.0.0.1
MYSQL_USER=root
MYSQL_PASSWORD=
CHECK_TIME=3
#mysql  is working MYSQL_OK is 1 , mysql down MYSQL_OK is 0
MYSQL_OK=1
function check_mysql_helth (){
$MYSQL -h $MYSQL_HOST -u $MYSQL_USER -e "show status;" >/dev/null 2>&1
if [ $? = 0 ] ;then
     MYSQL_OK=1
else
     MYSQL_OK=0
fi
     return $MYSQL_OK
}
while [ $CHECK_TIME -ne 0 ]
do
     let "CHECK_TIME -= 1"
     check_mysql_helth
if [ $MYSQL_OK = 1 ] ; then
     CHECK_TIME=0
     exit 0
fi

if [ $MYSQL_OK -eq 0 ] &&  [ $CHECK_TIME -eq 0 ]
then
     pkill keepalived
exit 1
fi
sleep 1
done

此腳本不能檢測MySQL 正常運行,不能正常,就關(guān)閉keepalived,釋放虛擬IP.

在發(fā)現(xiàn)主庫down,根據(jù)輸出日志信息,mha做一下操作
1:發(fā)現(xiàn)主庫不可用,masterha_secondary_check 和save_binary_logs 兩腳本檢測從庫是否可達,檢測主庫binlog 是否可用。并發(fā)出failover 信號。
2:檢查主庫server1,三次不可通后確認無法使用,確定server1 的mysql 不可用,但主機ssh 可達。
3:開始Dead Master Shutdown Phase 階段,調(diào)用master_ip_failover 腳本.
4:開啟master_recovry_phase,找到所有slaves 己讀到的binlog 位置,若生產(chǎn)環(huán)境下從庫讀取不一致,則以最新的為準從dead_master 上獲取最新的binlog。將dead_master存在但未同步到從上的binlog 保存下來
5:開始Determining New Master Phase 段段,尋找備用master,原則為設(shè)置candidate_master, 擁有最新的binlog。標記為no_master 的server永不會設(shè)為備主。然后開始failover,mysql 架構(gòu)由120( 主庫) ,121(備主),122為 從庫。
6:開始New Master Diff Log Generation Phase 階段,應(yīng)用差異日志到新主庫。確定新主當前的master_log_file,master_log_pos。
7:應(yīng)用差異日志到所有從庫,應(yīng)用完成后,關(guān)閉新主server2 的read_only 選項,對應(yīng)用可讀可寫。
8:在所有從庫上執(zhí)行change master。清除新主庫的slave 信息,reset slave,完成failover。
9:最后調(diào)用send_report 腳本,發(fā)送報警短信或是郵件通知dba.


 

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多

    久久经典一区二区三区| 国产精品涩涩成人一区二区三区| 我的性感妹妹在线观看| 正在播放国产又粗又长| 黄片免费播放一区二区| 午夜资源在线观看免费高清| 精品国模一区二区三区欧美| 久久这里只有精品中文字幕| 国产又粗又硬又长又爽的剧情| 东北女人的逼操的舒服吗| 日韩欧美一区二区久久婷婷| 老外那个很粗大做起来很爽| 91香蕉国产观看免费人人| 精品久久少妇激情视频| 久久久精品日韩欧美丰满| 亚洲中文字幕日韩在线| 欧美午夜一级特黄大片| 欧美日韩一级黄片免费观看| 性欧美唯美尤物另类视频| 国产精品福利一二三区| 少妇在线一区二区三区| 久热在线视频这里只有精品| 中文字幕日韩一区二区不卡| 国产成人精品综合久久久看| 亚洲第一区二区三区女厕偷拍| 国产日韩欧美在线亚洲| 又黄又色又爽又免费的视频| 国产精品内射婷婷一级二级| 欧美尤物在线视频91| 欧美激情床戏一区二区三| 欧美成人高清在线播放| 国产性情片一区二区三区| 91精品国产综合久久精品| 精品人妻一区二区三区四区久久| 日韩欧美综合在线播放| 黑人巨大精品欧美一区二区区| 字幕日本欧美一区二区| 99久久国产精品成人观看| 国产精品视频久久一区| 久久机热频这里只精品| 丰满少妇高潮一区二区|