一.環(huán)境描述
讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來(lái)自于我們對(duì)這個(gè)行業(yè)的熱愛(ài)。我們立志把好的技術(shù)通過(guò)有效、簡(jiǎn)單的方式提供給客戶,將通過(guò)不懈努力成為客戶在信息化領(lǐng)域值得信任、有價(jià)值的長(zhǎng)期合作伙伴,公司提供的服務(wù)項(xiàng)目有:國(guó)際域名空間、虛擬主機(jī)、營(yíng)銷軟件、網(wǎng)站建設(shè)、鎮(zhèn)安網(wǎng)站維護(hù)、網(wǎng)站推廣。
操作系統(tǒng):RHEL 6.4
MySQL :5.6.27
角色 |
IP地址 |
主機(jī)名 |
Server ID |
類型 |
主庫(kù) |
192.168.222.156 |
oradb |
10 |
寫(xiě)入 |
備庫(kù)、MHA管理服務(wù)器 |
192.168.222.157 |
mysqldb2 |
11 |
讀、監(jiān)控集群組 |
二、部署MHA
1.主庫(kù)安裝 MHA NODE
1.1安裝需要的PERL模塊
yum -y install *zlib-dev*
install.sh
#!/bin/bash
wget http://xrl.us/cpanm --no-check-certificate
mv cpanm /usr/bin
chmod 755 /usr/bin/cpanm
cat >/root/list<<EOF
install DBD::mysql
EOF
for package in `cat /root/list`
do
cpanm $package
done
1.2安裝 MHA NODE
從 https://github.com/yoshinorim/mha4mysql-node下載最新版本的 mha4mysql-node源代碼(目前是 0.57版)
unzip mha4mysql-node-master.zip
cd mha4mysql-node-master
perl Makefile.PL
make
make install
2.備庫(kù)安裝 MHA Manager
2.1安裝需要的perl模塊
yum -y install *zlib-dev*
install.sh
#!/bin/bash
wget http://xrl.us/cpanm --no-check-certificate
mv cpanm /usr/bin
chmod 755 /usr/bin/cpanm
cat >/root/list<<EOF
install DBD::mysql
install Config::Tiny
install Log::Dispatch
install Parallel::ForkManager
install Time::HiRes
EOF
for package in `cat /root/list`
do
cpanm $package
done
2.2安裝MHA NODE
從 https://github.com/yoshinorim/mha4mysql-node下載最新版本的 mha4mysql-node源代碼(目前是 0.57版)
unzip mha4mysql-node-master.zip
cd mha4mysql-node-master
perl Makefile.PL
make
make install
2.3安裝 MHA Manager
從 https://github.com/yoshinorim/mha4mysql-manager下載最新版本的 mha4mysql-manager源代碼(目前是 0.57版)
unzip mha4mysql-manager-master.zip
cd mha4mysql-manager-master
perl Makefile.PL
make
make install
3.配置 SSH登錄無(wú)密碼驗(yàn)證
3.1主庫(kù)配置到 MHA manager節(jié)點(diǎn)(備庫(kù)節(jié)點(diǎn))SSH登錄無(wú)密碼驗(yàn)證
vi /etc/hosts
192.168.222.157 mysqldb2
192.168.222.156 oradb
ssh-keygen -t rsa
ssh-coyp-id -i /root/.ssh/id_rsa.pub root@192.168.222.157
ssh-coyp-id -i /root/.ssh/id_rsa.pub root@192.168.222.156
ssh root@192.168.222.156
ssh root@oradb
ssh root@192.168.222.157
ssh root@mysqldb2
3.2 MHA manager節(jié)點(diǎn)(備庫(kù)節(jié)點(diǎn))配置到主庫(kù)配置 SSH登錄無(wú)密碼驗(yàn)證
vi /etc/hosts
192.168.222.157 mysqldb2
192.168.222.156 oradb
ssh-keygen -t rsa
ssh-coyp-id -i /root/.ssh/id_rsa.pub root@192.168.222.157
ssh-coyp-id -i /root/.ssh/id_rsa.pub root@192.168.222.156
ssh root@192.168.222.156
ssh root@oradb
ssh root@192.168.222.157
ssh root@mysqldb2
4.搭建主從復(fù)制
4.1 修改主庫(kù)my.cnf配置服務(wù)器ID為10
vi /app/oracle/oradata2/mysql-5.6.27/my.cnf
[mysqld]
server_id = 10
4.1 修改備庫(kù)my.cnf配置
vi /usr/local/mysql/my.cnf
[mysqld]
server_id = 10
# slave config
log_bin=/usr/local/mysql/data/mysql-bin
relay_log=/usr/local/mysql/data/relay-bin
binlog_format=row
relay_log_purge=0
read_only=1
4.2 在主庫(kù)上備份
mysqldump --master-data=2 --single-transaction -R -A > all.sql
其中 --master-data=2代表備份時(shí)刻記錄 master的 Binlog位置和 Position,--single-transaction意思是獲取一致性快照, -R意思是備份相關(guān)的存儲(chǔ)過(guò)程
,-A代表備份所有的 schema。
4.3 在主庫(kù)上創(chuàng)建復(fù)制用戶和 MHA監(jiān)控用戶
mysql> grant replication slave on *.* to 'repl'@'192.168.222.%' identified by '123456';
mysql> grant all on *.* to 'root'@'192.168.222.%' identified by '123456'; /*MHA監(jiān)控用戶*/
4.4 查看主庫(kù)上備份時(shí)刻 Binlog的名稱和位置,MASTER_LOG和 MASTER_LOG_POS
head -n 30 all.sql|grep -i "CHANGE MASTER TO"
-- CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000068', MASTER_LOG_POS=325;
4.5 將備份復(fù)制到備庫(kù)
scp all.sql root@192.168.222.157:/root/olm
4.6 在備庫(kù)導(dǎo)入數(shù)據(jù)
mysql> source /root/olm/all.sql
mysql> flush privileges;
mysql>
change master to master_host='192.168.222.156',master_user='repl',master_password='123456',
master_port=3306,master_log_file='mysql-bin.000068',master_log_pos=325;
start slave;
--查看復(fù)制狀態(tài)
show slave status \G
5.配置MHA
5.1 創(chuàng)建 MHA工作目錄,并且創(chuàng)建相關(guān)配置文件
mkdir -p /etc/masterha
vi /etc/masterha/app1.cnf
[server default]
manager_log=/masterha/app1/app1.log
manager_workdir=/masterha/app1
master_binlog_dir=/app/oracle/oradata2/mysql-5.5.37/data
master_ip_failover_script=/usr/local/bin/master_ip_failover
master_ip_online_change_script=/usr/local/bin/master_ip_online_change
password=123456
ping_interval=1
remote_workdir=/tmp
repl_password=123456
repl_user=repl
secondary_check_script=/usr/local/bin/masterha_secondary_check -s mysqldb2 -s oradb --user=root --master_host=oradb --master_ip='192.168.222.156' --master_port=3306
shutdown_script=""
ssh_user=root
user=root
[server1]
hostname=192.168.222.156
port=3306
[server2]
candidate_master=1
check_repl_delay=0
hostname=192.168.222.157
port=3306
5.2 設(shè)置定期清理中繼日志的腳本
crontab -e
0 4 * * * /usr/local/bin/purge_relay_logs --user=root --password=123456 --disable_replay_log_purge --port=3306 --workdir=/usr/local/mysql/data --disable_relay_log_purge >> /usr/loca/masterha/log/purge_relay_logs.log 2>&1
5.2 編輯 /etc/bashrc文件,在文件末尾添加以下內(nèi)容,避免MHA執(zhí)行故障切換時(shí)無(wú)法找到 mysqlbinlog
PATH="$PATH:/usr/local/mysql/bin"
export PATH
5.3 檢查 SSH的配置
masterha_check_ssh --conf=/etc/masterha/app1.cnf
5.4 檢查MYSQL復(fù)制
masterha_check_repl --conf=/etc/masterha/app1.cnf
5.5 啟動(dòng) MHA Manger監(jiān)控
tail -f /masterha/app1/app1.log
--在另一個(gè)SSH窗口啟動(dòng) MHA Manger監(jiān)控。--remove_dead_master_conf該參數(shù)代表當(dāng)發(fā)生主從切換后,老的主庫(kù)的IP將會(huì)從配置文件中移除。
--ignore_last_failover 在缺省情況下,如果MHA檢測(cè)到連續(xù)發(fā)生宕機(jī),而且兩次宕機(jī)時(shí)間不足8小時(shí)的話,則不會(huì)進(jìn)行 Failover,之所以這樣限制
--是為了避免 ping-pong效應(yīng)。該參數(shù)代表忽悠上次 MHA觸發(fā)切換產(chǎn)生的文件,默認(rèn)情況下,MHA發(fā)生切換后將會(huì)在 /masterha/paa1下產(chǎn)生 app1.
--failover.complete文件,下次再次切換的時(shí)候如果發(fā)現(xiàn)目錄存在該文件將不允許觸發(fā)切換,除非在第一次切換后收到 rm -rf /masterha/paa1/app1. --failover.complete,出于方便考慮,我們每次啟動(dòng)MHA時(shí)會(huì)添加 --ignore_last_failover參數(shù)。
nohup masterha_manager --conf=/etc/masterha/app1.cnf --remove_dead_master_conf --ignore_last_failover< /dev/null >/masterha/app1/manager.log 2>&1 &
--查看 MHA Manager監(jiān)控是否正常
masterha_check_status --conf=/etc/masterha/app1.cnf
app1 (pid:4758) is running(0:PING_OK), master:192.168.222.156
--在默認(rèn)情況下,10秒內(nèi)狀態(tài)為10:INITIALIZING_MONITOR,當(dāng)狀態(tài)轉(zhuǎn)變?yōu)?:PING_OK后表明已經(jīng)開(kāi)啟了到 MASTER端的監(jiān)控。
關(guān)閉MHA的命令如下:
masterha_stop --conf=/etc/masterha/app1.cnf
6.配置 VIP
6.1 在主庫(kù)下載集群心跳軟件 keepalived,并進(jìn)行安裝
訪問(wèn) http://www.keepalived.org/software/ 下載 keepalived-1.2.18.tar.gz
tar vzxf keepalived-1.2.18.tar.gz
cd keepalived-1.2.18
./configure --prefix=/usr/local/keepalived
make
make install
cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/
cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
mkdir /etc/keepalived
cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
cp /usr/local/keepalived/sbin/keepalived /usr/sbin/
cd /etc/keepalived/
vi keepalived.conf
--下面是添加的配置
[root@oradb ~]# cat /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
acassen@firewall.loc
failover@firewall.loc
sysadmin@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id MySQL-ha
}
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 51
priority 150
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.222.158/24
}
}
service keepalived start
--是用 ip add命令可以看到 eth0上已經(jīng)綁定了虛擬IP 192.168.222.158,注意使用 ifconfig 是看不到虛擬IP的
[root@oradb ~]# ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:53:7e:f0 brd ff:ff:ff:ff:ff:ff
inet 192.168.222.156/24 brd 192.168.222.255 scope global eth0
inet 192.168.222.158/24 scope global secondary eth0
inet6 fe80::20c:29ff:fe53:7ef0/64 scope link
valid_lft forever preferred_lft forever
3: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:53:7e:fa brd ff:ff:ff:ff:ff:ff
inet 192.168.1.11/24 brd 192.168.1.255 scope global eth2
inet6 fe80::20c:29ff:fe53:7efa/64 scope link
valid_lft forever preferred_lft forever
6.2 在備庫(kù)下載集群心跳軟件 keepalived,并進(jìn)行安裝
訪問(wèn) http://www.keepalived.org/software/ 下載 keepalived-1.2.18.tar.gz
tar vzxf keepalived-1.2.18.tar.gz
cd keepalived-1.2.18
./configure --prefix=/usr/local/keepalived
make
make install
cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/
cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
mkdir /etc/keepalived
cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
cp /usr/local/keepalived/sbin/keepalived /usr/sbin/
cd /etc/keepalived/
vi keepalived.conf
--下面是添加的配置
! Configuration File for keepalived
global_defs {
notification_email {
acassen@firewall.loc
failover@firewall.loc
sysadmin@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id MySQL-ha
}
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 51
priority 120
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.222.158/24
}
}
service keepalived start
6.2 MHA引入 keepalived
在MHA監(jiān)控節(jié)點(diǎn)(備庫(kù))編輯 master_ip_failover腳本
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;
use MHA::DBHelper;
my (
$command, $ssh_user, $orig_master_host,
$orig_master_ip, $orig_master_port, $new_master_host,
$new_master_ip, $new_master_port, $new_master_user,
$new_master_password, $cmd
);
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,
'new_master_user=s' => \$new_master_user,
'new_master_password=s' => \$new_master_password,
);
exit &main();
sub main {
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 {
# updating global catalog, etc
$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 {
my $new_master_handler = new MHA::DBHelper();
# args: hostname, port, user, password, raise_error_or_not
$new_master_handler->connect( $new_master_ip, $new_master_port,
$new_master_user, $new_master_password, 1 );
## Set read_only=0 on the new master
$new_master_handler->disable_log_bin_local();
print "Set read_only=0 on the new master.\n";
$new_master_handler->disable_read_only();
## Creating an app user on the new master
print "Creating app user on the new master..\n";
#FIXME_xxx_create_user( $new_master_handler->{dbh} );
#$new_master_handler->enable_log_bin_local();
#$new_master_handler->disconnect();
## Update master ip on the catalog database, etc
#FIXME_xxx;
#$cmd = 'ssh root@192.168.222.156 \./lvs-admin stop';
#$cmd = 'ssh'.$ssh_user.'@'.$orig_master_ip.'\'./lvs-admin stop\'';
$cmd = 'ssh '.$ssh_user.'@'.$orig_master_ip.' \./lvs-admin stop';
system($cmd);
$exit_code = 0;
};
if ($@) {
warn $@;
# If you want to continue failover, exit 10.
exit $exit_code;
}
exit $exit_code;
}
elsif ( $command eq "status" ) {
# do nothing
exit 0;
}
else {
&usage();
exit 1;
}
}
sub usage {
"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";
}
在腳本中綠色背景的代碼是新增的,紅色背景的代碼是注釋的。
在主庫(kù)添加關(guān)閉 keepalived的腳本
vi /root/lvs-admin
case "$1" in
"stop")
echo;
echo "stop keepalived ......";
service keepalived stop
;;
"start")
echo;
echo "start keepalive ......";
service keepalived start
;;
*)
echo "please input you select!"
;;
esac
chmod 755 /root/lvs-admin
7.測(cè)試主庫(kù)故障MHA自動(dòng)把備庫(kù)提升為主庫(kù)并把虛擬IP漂移到新的主庫(kù)(原來(lái)的備庫(kù))
7.1在備庫(kù)停止復(fù)制默認(rèn)有二進(jìn)制日志沒(méi)傳到備庫(kù)
mysql> stop slave;
7.2 sysbench生成測(cè)試數(shù)據(jù),在主庫(kù)上的 sbtest庫(kù)下創(chuàng)建 sbtest表,共100萬(wàn)條數(shù)據(jù)
mysql> create database sbtest;
./sysbench --num-threads=4 --test=oltp --oltp-table-size=1000000 --oltp-read-only=off --init-rng=on --max-requests=0 \
--oltp-dist-type=uniform --max-time=1800 --mysql-user=root --db-driver=test --mysql-table-engine=innodb \
--oltp-test-mode=complex prepare
7.3 關(guān)閉主庫(kù) MHA會(huì)自動(dòng)把備份庫(kù)提升為新的主庫(kù),并把虛擬IP漂移到新的主庫(kù)(原來(lái)的備庫(kù))
--關(guān)閉主庫(kù)
mysqladmin -u root shutdown
--在MHA監(jiān)控節(jié)點(diǎn)(備庫(kù))實(shí)時(shí)查看MHA日志
tail -f /masterha/app1/app1.log
Thu Feb 2 23:53:06 2017 - [info] MHA::MasterMonitor version 0.57.
Thu Feb 2 23:53:07 2017 - [error][/usr/local/share/perl5/MHA/ServerManager.pm, ln671] Master 192.168.222.156:3306 from which slave 192.168.222.157(192.168.222.157:330
6) replicates is not defined in the configuration file!
Thu Feb 2 23:53:07 2017 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln427] Error happened on checking configurations. at /usr/local/share/perl5/MHA/Master
Monitor.pm line 329.
Thu Feb 2 23:53:07 2017 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln525] Error happened on monitoring servers.
Thu Feb 2 23:53:07 2017 - [info] Got exit code 1 (Not master dead).
Thu Feb 2 23:54:15 2017 - [info] MHA::MasterMonitor version 0.57.
Thu Feb 2 23:54:16 2017 - [error][/usr/local/share/perl5/MHA/ServerManager.pm, ln671] Master 192.168.222.156:3306 from which slave 192.168.222.157(192.168.222.157:330
6) replicates is not defined in the configuration file!
Thu Feb 2 23:54:16 2017 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln427] Error happened on checking configurations. at /usr/local/share/perl5/MHA/Master
Monitor.pm line 329.
Thu Feb 2 23:54:16 2017 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln525] Error happened on monitoring servers.
Thu Feb 2 23:54:16 2017 - [info] Got exit code 1 (Not master dead).
Thu Feb 2 23:58:13 2017 - [info] MHA::MasterMonitor version 0.57.
Thu Feb 2 23:58:14 2017 - [error][/usr/local/share/perl5/MHA/ServerManager.pm, ln671] Master 192.168.222.156:3306 from which slave 192.168.222.157(192.168.222.157:330
6) replicates is not defined in the configuration file!
Thu Feb 2 23:58:14 2017 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln427] Error happened on checking configurations. at /usr/local/share/perl5/MHA/Master
Monitor.pm line 329.
Thu Feb 2 23:58:14 2017 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln525] Error happened on monitoring servers.
Thu Feb 2 23:58:14 2017 - [info] Got exit code 1 (Not master dead).
Thu Feb 2 23:59:48 2017 - [info] MHA::MasterMonitor version 0.57.
Thu Feb 2 23:59:49 2017 - [error][/usr/local/share/perl5/MHA/ServerManager.pm, ln671] Master 192.168.222.156:3306 from which slave 192.168.222.157(192.168.222.157:330
6) replicates is not defined in the configuration file!
Thu Feb 2 23:59:49 2017 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln427] Error happened on checking configurations. at /usr/local/share/perl5/MHA/Master
Monitor.pm line 329.
Thu Feb 2 23:59:49 2017 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln525] Error happened on monitoring servers.
Thu Feb 2 23:59:49 2017 - [info] Got exit code 1 (Not master dead).
Fri Feb 3 00:04:10 2017 - [info] MHA::MasterMonitor version 0.57.
Fri Feb 3 00:04:11 2017 - [error][/usr/local/share/perl5/MHA/ServerManager.pm, ln671] Master 192.168.222.156:3306 from which slave 192.168.222.157(192.168.222.157:330
6) replicates is not defined in the configuration file!
Fri Feb 3 00:04:11 2017 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln427] Error happened on checking configurations. at /usr/local/share/perl5/MHA/Master
Monitor.pm line 329.
Fri Feb 3 00:04:11 2017 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln525] Error happened on monitoring servers.
Fri Feb 3 00:04:11 2017 - [info] Got exit code 1 (Not master dead).
Fri Feb 3 00:09:04 2017 - [info] MHA::MasterMonitor version 0.57.
Fri Feb 3 00:09:05 2017 - [error][/usr/local/share/perl5/MHA/ServerManager.pm, ln671] Master 192.168.222.156:3306 from which slave 192.168.222.157(192.168.222.157:330
6) replicates is not defined in the configuration file!
Fri Feb 3 00:09:05 2017 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln427] Error happened on checking configurations. at /usr/local/share/perl5/MHA/Master
Monitor.pm line 329.
Fri Feb 3 00:09:05 2017 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln525] Error happened on monitoring servers.
Fri Feb 3 00:09:05 2017 - [info] Got exit code 1 (Not master dead).
Fri Feb 3 00:13:13 2017 - [info] MHA::MasterMonitor version 0.57.
Fri Feb 3 00:13:14 2017 - [error][/usr/local/share/perl5/MHA/ServerManager.pm, ln671] Master 192.168.222.156:3306 from which slave 192.168.222.157(192.168.222.157:330
6) replicates is not defined in the configuration file!
Fri Feb 3 00:13:14 2017 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln427] Error happened on checking configurations. at /usr/local/share/perl5/MHA/Master
Monitor.pm line 329.
Fri Feb 3 00:13:14 2017 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln525] Error happened on monitoring servers.
Fri Feb 3 00:13:14 2017 - [info] Got exit code 1 (Not master dead).
Fri Feb 3 00:20:21 2017 - [info] MHA::MasterMonitor version 0.57.
Fri Feb 3 00:20:23 2017 - [error][/usr/local/share/perl5/MHA/ServerManager.pm, ln671] Master 192.168.222.156:3306 from which slave 192.168.222.157(192.168.222.157:330
6) replicates is not defined in the configuration file!
Fri Feb 3 00:20:23 2017 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln427] Error happened on checking configurations. at /usr/local/share/perl5/MHA/Master
Monitor.pm line 329.
Fri Feb 3 00:20:23 2017 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln525] Error happened on monitoring servers.
Fri Feb 3 00:20:23 2017 - [info] Got exit code 1 (Not master dead).
Fri Feb 3 00:21:54 2017 - [info] MHA::MasterMonitor version 0.57.
Fri Feb 3 00:21:55 2017 - [info] GTID failover mode = 0
Fri Feb 3 00:21:55 2017 - [info] Dead Servers:
Fri Feb 3 00:21:55 2017 - [info] Alive Servers:
Fri Feb 3 00:21:55 2017 - [info] 192.168.222.156(192.168.222.156:3306)
Fri Feb 3 00:21:55 2017 - [info] 192.168.222.157(192.168.222.157:3306)
Fri Feb 3 00:21:55 2017 - [info] Alive Slaves:
Fri Feb 3 00:21:55 2017 - [info] 192.168.222.157(192.168.222.157:3306) Version=5.6.27-log (oldest major version between slaves) log-bin:enabled
Fri Feb 3 00:21:55 2017 - [info] Replicating from 192.168.222.156(192.168.222.156:3306)
Fri Feb 3 00:21:55 2017 - [info] Primary candidate for the new Master (candidate_master is set)
Fri Feb 3 00:21:55 2017 - [info] Current Alive Master: 192.168.222.156(192.168.222.156:3306)
Fri Feb 3 00:21:55 2017 - [info] Checking slave configurations..
Fri Feb 3 00:21:55 2017 - [info] Checking replication filtering settings..
Fri Feb 3 00:21:55 2017 - [info] binlog_do_db= , binlog_ignore_db=
Fri Feb 3 00:21:55 2017 - [info] Replication filtering check ok.
Fri Feb 3 00:21:55 2017 - [info] GTID (with auto-pos) is not supported
Fri Feb 3 00:21:55 2017 - [info] Starting SSH connection tests..
Fri Feb 3 00:21:58 2017 - [info] All SSH connection tests passed successfully.
Fri Feb 3 00:21:58 2017 - [info] Checking MHA Node version..
Fri Feb 3 00:21:58 2017 - [info] Version check ok.
Fri Feb 3 00:21:58 2017 - [info] Checking SSH publickey authentication settings on the current master..
Fri Feb 3 00:21:59 2017 - [info] HealthCheck: SSH to 192.168.222.156 is reachable.
Fri Feb 3 00:21:59 2017 - [info] Master MHA Node version is 0.57.
Fri Feb 3 00:21:59 2017 - [info] Checking recovery script configurations on 192.168.222.156(192.168.222.156:3306)..
Fri Feb 3 00:21:59 2017 - [info] Executing command: save_binary_logs --command=test --start_pos=4 --binlog_dir=/app/oracle/oradata2/mysql-5.5.37/data --output_file=
/tmp/save_binary_logs_test --manager_version=0.57 --start_file=mysql-bin.000068
Fri Feb 3 00:21:59 2017 - [info] Connecting to root@192.168.222.156(192.168.222.156:22)..
Creating /tmp if not exists.. ok.
Checking output directory is accessible or not..
ok.
Binlog found at /app/oracle/oradata2/mysql-5.5.37/data, up to mysql-bin.000068
Fri Feb 3 00:21:59 2017 - [info] Binlog setting check done.
Fri Feb 3 00:21:59 2017 - [info] Checking SSH publickey authentication and checking recovery script configurations on all alive slave servers..
Fri Feb 3 00:21:59 2017 - [info] Executing command : apply_diff_relay_logs --command=test --slave_user='root' --slave_host=192.168.222.157 --slave_ip=192.168.222.15
7 --slave_port=3306 --workdir=/tmp --target_version=5.6.27-log --manager_version=0.57 --relay_log_info=/usr/local/mysql/data/relay-log.info --relay_dir=/usr/local/mys
ql/data/ --slave_pass=xxx
Fri Feb 3 00:21:59 2017 - [info] Connecting to root@192.168.222.157(192.168.222.157:22)..
Checking slave recovery environment settings..
Opening /usr/local/mysql/data/relay-log.info ... ok.
Relay log found at /usr/local/mysql/data, up to relay-bin.000002
Temporary relay log file is /usr/local/mysql/data/relay-bin.000002
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.
Fri Feb 3 00:22:00 2017 - [info] Slaves settings check done.
Fri Feb 3 00:22:00 2017 - [info]
192.168.222.156(192.168.222.156:3306) (current master)
+--192.168.222.157(192.168.222.157:3306)
Fri Feb 3 00:22:00 2017 - [info] Checking master_ip_failover_script status:
Fri Feb 3 00:22:00 2017 - [info] /usr/local/bin/master_ip_failover --command=status --ssh_user=root --orig_master_host=192.168.222.156 --orig_master_ip=192.168.222.
156 --orig_master_port=3306
Fri Feb 3 00:22:00 2017 - [info] OK.
Fri Feb 3 00:22:00 2017 - [warning] shutdown_script is not defined.
Fri Feb 3 00:22:00 2017 - [info] Set master ping interval 1 seconds.
Fri Feb 3 00:22:00 2017 - [info] Set secondary check script: /usr/local/bin/masterha_secondary_check -s mysqldb2 -s oradb --user=root --master_host=oradb --master_ip=
'192.168.222.156' --master_port=3306
Fri Feb 3 00:22:00 2017 - [info] Starting ping health check on 192.168.222.156(192.168.222.156:3306)..
Fri Feb 3 00:22:00 2017 - [info] Ping(SELECT) succeeded, waiting until MySQL doesn't respond..
Fri Feb 3 00:25:06 2017 - [warning] Got error on MySQL select ping: 2013 (Lost connection to MySQL server during query)
Fri Feb 3 00:25:06 2017 - [info] Executing secondary network check script: /usr/local/bin/masterha_secondary_check -s mysqldb2 -s oradb --user=root --master_host=orad
b --master_ip='192.168.222.156' --master_port=3306 --user=root --master_host=192.168.222.156 --master_ip=192.168.222.156 --master_port=3306 --master_user=root --ma
ster_password=123456 --ping_type=SELECT
Fri Feb 3 00:25:06 2017 - [info] Executing SSH check script: save_binary_logs --command=test --start_pos=4 --binlog_dir=/app/oracle/oradata2/mysql-5.5.37/data --outpu
t_file=/tmp/save_binary_logs_test --manager_version=0.57 --binlog_prefix=mysql-bin
Fri Feb 3 00:25:07 2017 - [warning] Got error on MySQL connect: 2003 (Can't connect to MySQL server on '192.168.222.156' (111))
Fri Feb 3 00:25:07 2017 - [warning] Connection failed 2 time(s)..
Monitoring server mysqldb2 is reachable, Master is not reachable from mysqldb2. OK.
Fri Feb 3 00:25:08 2017 - [warning] Got error on MySQL connect: 2003 (Can't connect to MySQL server on '192.168.222.156' (111))
Fri Feb 3 00:25:08 2017 - [warning] Connection failed 3 time(s)..
Monitoring server oradb is reachable, Master is not reachable from oradb. OK.
Fri Feb 3 00:25:08 2017 - [info] Master is not reachable from all other monitoring servers. Failover should start.
Fri Feb 3 00:25:08 2017 - [info] HealthCheck: SSH to 192.168.222.156 is reachable.
Fri Feb 3 00:25:09 2017 - [warning] Got error on MySQL connect: 2003 (Can't connect to MySQL server on '192.168.222.156' (111))
Fri Feb 3 00:25:09 2017 - [warning] Connection failed 4 time(s)..
Fri Feb 3 00:25:09 2017 - [warning] Master is not reachable from health checker!
Fri Feb 3 00:25:09 2017 - [warning] Master 192.168.222.156(192.168.222.156:3306) is not reachable!
Fri Feb 3 00:25:09 2017 - [warning] SSH is reachable.
Fri Feb 3 00:25:09 2017 - [info] Connecting to a master server failed. Reading configuration file /etc/masterha_default.cnf and /etc/masterha/app1.cnf again, and tryi
ng to connect to all servers to check server status..
Fri Feb 3 00:25:09 2017 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Fri Feb 3 00:25:09 2017 - [info] Reading application default configuration from /etc/masterha/app1.cnf..
Fri Feb 3 00:25:09 2017 - [info] Reading server configuration from /etc/masterha/app1.cnf..
Fri Feb 3 00:25:10 2017 - [warning] SQL Thread is stopped(no error) on 192.168.222.157(192.168.222.157:3306)
Fri Feb 3 00:25:10 2017 - [info] GTID failover mode = 0
Fri Feb 3 00:25:10 2017 - [info] Dead Servers:
Fri Feb 3 00:25:10 2017 - [info] 192.168.222.156(192.168.222.156:3306)
Fri Feb 3 00:25:10 2017 - [info] Alive Servers:
Fri Feb 3 00:25:10 2017 - [info] 192.168.222.157(192.168.222.157:3306)
Fri Feb 3 00:25:10 2017 - [info] Alive Slaves:
Fri Feb 3 00:25:10 2017 - [info] 192.168.222.157(192.168.222.157:3306) Version=5.6.27-log (oldest major version between slaves) log-bin:enabled
Fri Feb 3 00:25:10 2017 - [info] Replicating from 192.168.222.156(192.168.222.156:3306)
Fri Feb 3 00:25:10 2017 - [info] Primary candidate for the new Master (candidate_master is set)
Fri Feb 3 00:25:10 2017 - [info] Checking slave configurations..
Fri Feb 3 00:25:10 2017 - [info] Checking replication filtering settings..
Fri Feb 3 00:25:10 2017 - [info] Replication filtering check ok.
Fri Feb 3 00:25:10 2017 - [info] Master is down!
Fri Feb 3 00:25:10 2017 - [info] Terminating monitoring script.
Fri Feb 3 00:25:10 2017 - [info] Got exit code 20 (Master dead).
Fri Feb 3 00:25:10 2017 - [info] MHA::MasterFailover version 0.57.
Fri Feb 3 00:25:10 2017 - [info] Starting master failover.
Fri Feb 3 00:25:10 2017 - [info]
Fri Feb 3 00:25:10 2017 - [info] * Phase 1: Configuration Check Phase..
Fri Feb 3 00:25:10 2017 - [info]
Fri Feb 3 00:25:11 2017 - [warning] SQL Thread is stopped(no error) on 192.168.222.157(192.168.222.157:3306)
Fri Feb 3 00:25:11 2017 - [info] GTID failover mode = 0
Fri Feb 3 00:25:11 2017 - [info] Dead Servers:
Fri Feb 3 00:25:11 2017 - [info] 192.168.222.156(192.168.222.156:3306)
Fri Feb 3 00:25:11 2017 - [info] Checking master reachability via MySQL(double check)...
Fri Feb 3 00:25:11 2017 - [info] ok.
Fri Feb 3 00:25:11 2017 - [info] Alive Servers:
Fri Feb 3 00:25:11 2017 - [info] 192.168.222.157(192.168.222.157:3306)
Fri Feb 3 00:25:11 2017 - [info] Alive Slaves:
Fri Feb 3 00:25:11 2017 - [info] 192.168.222.157(192.168.222.157:3306) Version=5.6.27-log (oldest major version between slaves) log-bin:enabled
Fri Feb 3 00:25:11 2017 - [info] Replicating from 192.168.222.156(192.168.222.156:3306)
Fri Feb 3 00:25:11 2017 - [info] Primary candidate for the new Master (candidate_master is set)
Fri Feb 3 00:25:11 2017 - [info] Starting SQL thread on 192.168.222.157(192.168.222.157:3306) ..
Fri Feb 3 00:25:11 2017 - [info] done.
Fri Feb 3 00:25:11 2017 - [info] Starting Non-GTID based failover.
Fri Feb 3 00:25:11 2017 - [info]
Fri Feb 3 00:25:11 2017 - [info] ** Phase 1: Configuration Check Phase completed.
Fri Feb 3 00:25:11 2017 - [info]
Fri Feb 3 00:25:11 2017 - [info] * Phase 2: Dead Master Shutdown Phase..
Fri Feb 3 00:25:11 2017 - [info]
Fri Feb 3 00:25:11 2017 - [info] Forcing shutdown so that applications never connect to the current master..
Fri Feb 3 00:25:11 2017 - [info] Executing master IP deactivation script:
Fri Feb 3 00:25:11 2017 - [info] /usr/local/bin/master_ip_failover --orig_master_host=192.168.222.156 --orig_master_ip=192.168.222.156 --orig_master_port=3306 --com
mand=stopssh --ssh_user=root
Fri Feb 3 00:25:11 2017 - [info] done.
Fri Feb 3 00:25:11 2017 - [warning] shutdown_script is not set. Skipping explicit shutting down of the dead master.
Fri Feb 3 00:25:11 2017 - [info] * Phase 2: Dead Master Shutdown Phase completed.
Fri Feb 3 00:25:11 2017 - [info]
Fri Feb 3 00:25:11 2017 - [info] * Phase 3: Master Recovery Phase..
Fri Feb 3 00:25:11 2017 - [info]
Fri Feb<
本文題目:MYSQL主從復(fù)制部署MHA自動(dòng)故障轉(zhuǎn)移
URL標(biāo)題:http://bm7419.com/article36/jcecsg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導(dǎo)航、靜態(tài)網(wǎng)站、網(wǎng)站設(shè)計(jì)、域名注冊(cè)、全網(wǎng)營(yíng)銷推廣、軟件開(kāi)發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)