热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

mysql高可用测试,MysqlMHA高可用实验测试

说明:centos6.5mysql5.5.37mha4mysql-manager-0.55mha4mysql-node-0.54manager192.168.1.1m

说明: centos 6.5mysql 5.5.37 mha4mysql-manager-0.55 mha4mysql-node-0.54 manager 192.168.1.1 mha-manager管理端 db1 192.168.1.2 现有主库 db2 192.168.1.3 即将做双主的数据库 db3 192.168.1.4 现有从库 配置mysql主从 db1主库: server-id = 1 log-bi

说明:

centos 6.5 mysql 5.5.37 mha4mysql-manager-0.55 mha4mysql-node-0.54

manager 192.168.1.1 mha-manager管理端

db1 192.168.1.2 现有主库

db2 192.168.1.3 即将做双主的数据库

db3 192.168.1.4 现有从库

配置mysql主从

db1主库:

server-id = 1log-bin=mysql-bin

binlog_format=mixed

db2主库:

server-id = 2log-bin=mysql-bin

binlog_format=mixed

relay_log_purge=0

db3从库:server_id = 3

log_bin = mysql-bin

relay_log = mysql-relay-bin

max_relay_log_size = 2G

log_slave_updates = 1read_only = 1

relay_log_purge=0

db1主 (现有的主库)grant replication slave on *.* to mharep@'192.168.1.%' identified by 'passwd';

flush privileges;

stop slave;

#设置复制权限帐号

GRANT ALL PRIVILEGES ON *.* TO 'mha_manager'@'192.168.1.%' IDENTIFIED BY '123456';

reset master;

show master status\G

db2备 (即将做双主的这台机)grant replication slave on *.* to mharep@'192.168.1.%' identified by 'passwd';

GRANT ALL PRIVILEGES ON *.* TO 'mha_manager'@'192.168.1.%' IDENTIFIED BY '123456';

flush privileges;

reset master;

slave stop;

change master to MASTER_HOST='192.168.1.2', MASTER_PORT=3306,MASTER_USER='mharep', MASTER_PASSWORD='passwd',master_log_file='mysql-bin.000001', master_log_pos=107;

slave start;

show slave status\G;

db3从 (现有的从库)reset master;

slave stop;

GRANT ALL PRIVILEGES ON *.* TO 'mha_manager'@'192.168.1.%' IDENTIFIED BY '123456';

flush privileges;

change master to MASTER_HOST='192.168.1.2', MASTER_PORT=3306,MASTER_USER='mharep', MASTER_PASSWORD='passwd',master_log_file='mysql-bin.000001', master_log_pos=107;

slave start;

show slave status\G;

配置双机互信

managerssh-keygen -t rsa

for i in db1 db2 db3;do ssh-copy-id -i ~/.ssh/id_rsa.pub root@$i;done

db1主ssh-keygen -t rsa

for i in manager db2 db3;do ssh-copy-id -i ~/.ssh/id_rsa.pub root@$i;done

db2备 和 db3从 配置略

/usr/sbin/ntpdate 132.163.4.101 请把时间同步

安装mysql-MHA

https://downloads.mariadb.com/files/MHAwget https://downloads.mariadb.com/files/MHA/mha4mysql-manager-0.55-0.el6.noarch.rpm

wget https://downloads.mariadb.com/files/MHA/mha4mysql-node-0.54-0.el6.noarch.rpm

db1主 db2备 db3从

yum install perl-DBD-MySQL

yum localinstall mha4mysql-node-0.54-0.el6.noarch.rpm

manageryum install perl cpan

yum install perl-DBD-MySQL perl-Config-Tiny perl-Log-Dispatch perl-Parallel-ForkManager

#这两个yum没有安装上 perl-Log-Dispatch perl-Parallel-ForkManagerwget http://rpmfind.net/linux/dag/redhat/el6/en/x86_64/dag/RPMS/perl-Log-Dispatch-2.26-1.el6.rf.noarch.rpm

wget ftp://rpmfind.net/linux/dag/redhat/el6/en/x86_64/dag/RPMS/perl-Parallel-ForkManager-0.7.5-2.2.el6.rf.noarch.rpm

wget ftp://rpmfind.net/linux/dag/redhat/el6/en/x86_64/dag/RPMS/perl-Mail-Sender-0.8.16-1.el6.rf.noarch.rpm

wget ftp://rpmfind.net/linux/dag/redhat/el6/en/x86_64/dag/RPMS/perl-Mail-Sendmail-0.79-1.2.el6.rf.noarch.rpmrpm -ivh perl-Mail-Sender-0.8.16-1.el6.rf.noarch.rpm

rpm -ivh perl-Mail-Sendmail-0.79-1.2.el6.rf.noarch.rpm

yum localinstall perl-Log-Dispatch-2.26-1.el6.rf.noarch.rpm

yum localinstall perl-Parallel-ForkManager-0.7.5-2.2.el6.rf.noarch.rpm

yum localinstall mha4mysql-node-0.54-0.el6.noarch.rpm

yum localinstall mha4mysql-manager-0.55-0.el6.noarch.rpm

配置mysql-MHA[root@manager ~]# masterha_masterha_check_repl masterha_conf_host masterha_master_switch

masterha_check_ssh masterha_manager masterha_secondary_check

masterha_check_status masterha_master_monitor masterha_stop

tar -xzf mha4mysql-manager-0.55.tar.gz #

ls mha4mysql-manager-0.55/samples/conf #大家了解mha自带的配置文件,可忽略

masterha_default.cnf app1.cnf

mkdir -p /usr/local/mha/scripts

cp mha4mysql-manager-0.55/samples/scripts/* /usr/local/mha/scripts[root@manager ~]# vim /usr/local/mha/mha.conf #根据自己的mysql配置改动

[server default]

user=mha_manager #mha管理的用户名

password=123456

manager_workdir=/usr/local/mha

manager_log=/usr/local/mha/manager.log

remote_workdir=/usr/local/mha

ssh_user=root #上面双机互信的用户

repl_user=mharep #mysql复制(同步)的用户名

repl_password=passwd

ping_interval=1

#下面是mysql检测设置

secondary_check_script= masterha_secondary_check -s 192.168.1.2 -s 192.168.1.3 -s 192.168.1.4

#master_ip_failover_script=/usr/local/mha/scripts/master_ip_failover

#shutdown_script= /usr/local/mha/scripts/power_manager

report_script= /usr/local/mha/scripts/send_report

master_ip_online_change_script= /usr/local/mha/scripts/master_ip_online_change

[server1]

hostname=192.168.1.2 #写ip或者主机名都可以

ssh_port=22

master_binlog_dir=/var/mysql/log

candidate_master=1

[server2]

hostname=192.168.1.3

ssh_port=22

master_binlog_dir=/var/mysql/log

candidate_master=1

[server3]

hostname=192.168.1.4

ssh_port=22

master_binlog_dir=/var/mysql/log

no_master=1

#验证ssh通讯

masterha_check_ssh --conf=/usr/local/mha/mha.conf

c318feba148506ac80d3cc9106847089.png

#验证mysql复制wget ftp://rpmfind.net/linux/dag/redhat/el6/en/x86_64/extras/RPMS/perl-Net-Telnet-3.03-2.el6.rfx.noarch.rpm

yum localinstall perl-Net-Telnet-3.03-2.el6.rfx.noarch.rpm

#mysql必须都启动[root@manager ~]# masterha_check_repl --conf=/usr/local/mha/mha.conf

Thu Jan 8 18:05:40 2015 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.

Thu Jan 8 18:05:40 2015 - [info] Reading application default configurations from /usr/local/mha/mha.conf..

Thu Jan 8 18:05:40 2015 - [info] Reading server configurations from /usr/local/mha/mha.conf..

Thu Jan 8 18:05:40 2015 - [info] MHA::MasterMonitor version 0.55.

Thu Jan 8 18:05:40 2015 - [info] Dead Servers:

Thu Jan 8 18:05:40 2015 - [info] Alive Servers:

Thu Jan 8 18:05:40 2015 - [info] 192.168.1.2(192.168.1.2:3306)

Thu Jan 8 18:05:40 2015 - [info] 192.168.1.3(192.168.1.3:3306)

Thu Jan 8 18:05:40 2015 - [info] 192.168.1.4(192.168.1.4:3306)

Thu Jan 8 18:05:40 2015 - [info] Alive Slaves:

Thu Jan 8 18:05:40 2015 - [info] 192.168.1.3(192.168.1.3:3306) Version=5.5.37-log (oldest major version between slaves) log-bin:enabled

Thu Jan 8 18:05:40 2015 - [info] Replicating from 192.168.1.2(192.168.1.2:3306)

Thu Jan 8 18:05:40 2015 - [info] Primary candidate for the new Master (candidate_master is set)

Thu

Jan 8 18:05:40 2015 - [info] 192.168.1.4(192.168.1.4:3306)

Version=5.5.37-log (oldest major version between slaves) log-bin:enabled

Thu Jan 8 18:05:40 2015 - [info] Replicating from 192.168.1.2(192.168.1.2:3306)

Thu Jan 8 18:05:40 2015 - [info] Not candidate for the new Master (no_master is set)

Thu Jan 8 18:05:40 2015 - [info] Current Alive Master: 192.168.1.2(192.168.1.2:3306)

Thu Jan 8 18:05:40 2015 - [info] Checking slave configurations..

Thu Jan 8 18:05:40 2015 - [info] Checking replication filtering settings..

Thu Jan 8 18:05:40 2015 - [info] binlog_do_db= , binlog_ignore_db=

Thu Jan 8 18:05:40 2015 - [info] Replication filtering check ok.

Thu Jan 8 18:05:40 2015 - [info] Starting SSH connection tests..

Thu Jan 8 18:05:41 2015 - [info] All SSH connection tests passed successfully.

Thu Jan 8 18:05:41 2015 - [info] Checking MHA Node version..

Thu Jan 8 18:05:42 2015 - [info] Version check ok.

Thu Jan 8 18:05:42 2015 - [info] Checking SSH publickey authentication settings on the current master..

Thu Jan 8 18:05:42 2015 - [info] HealthCheck: SSH to 192.168.1.2 is reachable.

Thu Jan 8 18:05:42 2015 - [info] Master MHA Node version is 0.54.

Thu Jan 8 18:05:42 2015 - [info] Checking recovery script configurations on the current master..

Thu

Jan 8 18:05:42 2015 - [info] Executing command: save_binary_logs

--command=test --start_pos=4 --binlog_dir=/var/mysql/log

--output_file=/usr/local/mha/save_binary_logs_test

--manager_version=0.55 --start_file=mysql-bin.000002

Thu Jan 8 18:05:42 2015 - [info] Connecting to root@192.168.1.2(192.168.1.2)..

Creating /usr/local/mha if not exists.. ok.

Checking output directory is accessible or not..

ok.

Binlog found at /var/mysql/log, up to mysql-bin.000002

Thu Jan 8 18:05:42 2015 - [info] Master setting check done.

Thu

Jan 8 18:05:42 2015 - [info] Checking SSH publickey authentication and

checking recovery script configurations on all alive slave servers..

Thu

Jan 8 18:05:42 2015 - [info] Executing command :

apply_diff_relay_logs --command=test --slave_user='mha_manager'

--slave_host=192.168.1.3 --slave_ip=192.168.1.3 --slave_port=3306

--workdir=/usr/local/mha --target_version=5.5.37-log

--manager_version=0.55 --relay_log_info=/var/mysql/data/relay-log.info

--relay_dir=/var/mysql/data/ --slave_pass=xxx

Thu Jan 8 18:05:42 2015 - [info] Connecting to root@192.168.1.3(192.168.1.3:22)..

Checking slave recovery environment settings..

Opening /var/mysql/data/relay-log.info ... ok.

Relay log found at /var/mysql/data, up to mysql-relay-bin.000007

Temporary relay log file is /var/mysql/data/mysql-relay-bin.000007

Testing mysql connection and privileges.. done.

Testing mysqlbinlog output.. done.

Cleaning up test file(s).. done.

Thu

Jan 8 18:05:42 2015 - [info] Executing command :

apply_diff_relay_logs --command=test --slave_user='mha_manager'

--slave_host=192.168.1.4 --slave_ip=192.168.1.4 --slave_port=3306

--workdir=/usr/local/mha --target_version=5.5.37-log

--manager_version=0.55 --relay_log_info=/var/mysql/data/relay-log.info

--relay_dir=/var/mysql/data/ --slave_pass=xxx

Thu Jan 8 18:05:42 2015 - [info] Connecting to root@192.168.1.4(192.168.1.4:22)..

Checking slave recovery environment settings..

Opening /var/mysql/data/relay-log.info ... ok.

Relay log found at /var/mysql/data, up to mysql-relay-bin.000006

Temporary relay log file is /var/mysql/data/mysql-relay-bin.000006

Testing mysql connection and privileges.. done.

Testing mysqlbinlog output.. done.

Cleaning up test file(s).. done.

Thu Jan 8 18:05:43 2015 - [info] Slaves settings check done.

Thu Jan 8 18:05:43 2015 - [info]

192.168.1.2 (current master)

+--192.168.1.3

+--192.168.1.4

Thu Jan 8 18:05:43 2015 - [info] Checking replication health on 192.168.1.3..

Thu Jan 8 18:05:43 2015 - [info] ok.

Thu Jan 8 18:05:43 2015 - [info] Checking replication health on 192.168.1.4..

Thu Jan 8 18:05:43 2015 - [info] ok.

Thu Jan 8 18:05:43 2015 - [info] Checking master_ip_failover_script status:

Thu

Jan 8 18:05:43 2015 - [info]

/usr/local/mha/scripts/master_ip_failover --command=status

--ssh_user=root --orig_master_host=192.168.1.2

--orig_master_ip=192.168.1.2 --orig_master_port=3306

IN

SCRIPT TEST====/sbin/ifconfig eth0:1 down==/sbin/ifconfig eth0:1

192.168.1.100;/sbin/arping -I eth0 -c 3 -s 192.168.1.100 192.168.1.1

>/dev/null 2>&1===

Checking the Status of the script.. OK

Thu Jan 8 18:05:46 2015 - [info] OK.

Thu Jan 8 18:05:46 2015 - [warning] shutdown_script is not defined.

Thu Jan 8 18:05:46 2015 - [info] Got exit code 0 (Not master dead).

MySQL Replication Health is OK.

启动MHA

mv /usr/local/mha/scripts/master_ip_failover /usr/local/mha/scripts/master_ip_failover.def

vim /usr/local/mha/scripts/master_ip_failover#!/usr/bin/env perl

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.100'; # 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";

}

# sed -i 's/#master_ip_failover_script/master_ip_failover_script/' /usr/local/mha/mha.conf

配置文件的master_ip_failover_script前面注释#取消

# chmod 755 /usr/local/mha/scripts/master_ip_failover

# masterha_check_repl --conf=/usr/local/mha/mha.conf

启动mha

[root@manager ~]# masterha_manager --conf=/usr/local/mha/mha.conf &

或者

nohup masterha_manager --conf=/usr/local/mha/mha.conf > /tmp/mha_manager.log &1 &

查看MHA

b27e3b9ab031444464442aa7baa6738a.png

[root@manager ~]# masterha_check_status --conf=/usr/local/mha/mha.conf

mha (pid:2686) is running(0:PING_OK), master:192.168.1.2

到mysql主库上看看ip信息,自己的ip,VIP

447a4b285f274de56a5b69e72d72a92d.png

停止MHA

[root@manager ~]# masterha_stop --conf=/usr/local/mha/mha.conf

验证MHA:

[root@db1 ~]# ip a #现在有VIP

[root@db1 ~]# service mysqld stop #mysql停止,在这时候VIP会做转移

Shutting down MySQL... SUCCESS!

[root@db1 ~]# ip a #已经没有VIP

IP已经转移到db2,并且在db3上 mysql> show slave status\G 查看 Master_Server_Id: 2

5a43426993f09b33512e3ab4edd44a2e.png

查看mysql_MHA日志

/usr/local/mha/manager.log

#检查到db1数据库出错

Fri Jan 9 10:09:39 2015 - [info] Executing seconary network check script: masterha_secondary_check -s 192.168.1.2 -s 192.168.1.3 -s 192.168.1.4 --user=root --master_host=192.168.1.2 --master_ip=192.168.1.2 --master_port=3306

Fri Jan 9 10:09:39 2015 - [info] Executing SSH check script: save_binary_logs --command=test --start_pos=4 --binlog_dir=/var/mysql/log --output_file=/usr/local/mha/save_binary_logs_test --manager_version=0.55 --binlog_prefix=mysql-bin

Fri Jan 9 10:09:39 2015 - [info] HealthCheck: SSH to 192.168.1.2 is reachable.

Monitoring server 192.168.1.2 is reachable, Master is not reachable from 192.168.1.2. OK.

Monitoring server 192.168.1.3 is reachable, Master is not reachable from 192.168.1.3. OK.

Monitoring server 192.168.1.4 is reachable, Master is not reachable from 192.168.1.4. OK.

Fri Jan 9 10:09:39 2015 - [info] Master is not reachable from all other monitoring servers. Failover should start.

Fri Jan 9 10:09:40 2015 - [warning] Got error on MySQL connect: 2013 (Lost connection to MySQL server at 'reading initial communication packet', system error: 111)

Fri Jan 9 10:09:40 2015 - [warning] Connection failed 1 time(s)..

#转移Fri Jan 9 10:09:42 2015 - [info] Dead Servers:

Fri Jan 9 10:09:42 2015 - [info] 192.168.1.2(192.168.1.2:3306)

Fri Jan 9 10:09:42 2015 - [info] Alive Servers:

Fri Jan 9 10:09:42 2015 - [info] 192.168.1.3(192.168.1.3:3306)

Fri Jan 9 10:09:42 2015 - [info] 192.168.1.4(192.168.1.4:3306)

Fri Jan 9 10:09:42 2015 - [info] Alive Slaves:

Fri Jan 9 10:09:42 2015 - [info] 192.168.1.3(192.168.1.3:3306) Version=5.5.37-log (oldest major version between slaves) log-bin:enabled

Fri Jan 9 10:09:42 2015 - [info] Replicating from 192.168.1.2(192.168.1.2:3306)

Fri Jan 9 10:09:42 2015 - [info] Primary candidate for the new Master (candidate_master is set)

Fri Jan 9 10:09:42 2015 - [info] 192.168.1.4(192.168.1.4:3306) Version=5.5.37-log (oldest major version between slaves) log-bin:enabled

Fri Jan 9 10:09:42 2015 - [warning] relay_log_purge=0 is not set on slave 192.168.1.3(192.168.1.3:3306).

Fri Jan 9 10:09:42 2015 - [warning] relay_log_purge=0 is not set on slave 192.168.1.4(192.168.1.4:3306).

Disabling the VIP on old master: 192.168.1.2

Fri Jan 9 10:09:42 2015 - [info] done.

Fri Jan 9 10:09:42 2015 - [warning] shutdown_script is not set. Skipping explicit shutting down of the dead master.

Fri Jan 9 10:09:42 2015 - [info] The latest binary log file/position on all slaves is mysql-bin.000003:107

Fri Jan 9 10:09:42 2015 - [info] Latest slaves (Slaves that received relay log files to the latest):

Fri Jan 9 10:09:42 2015 - [info] 192.168.1.3(192.168.1.3:3306) Version=5.5.37-log (oldest major version between slaves) log-bin:enabled

Fri Jan 9 10:09:42 2015 - [info] Replicating from 192.168.1.2(192.168.1.2:3306)

Fri Jan 9 10:09:42 2015 - [info] Primary candidate for the new Master (candidate_master is set)

Fri Jan 9 10:09:42 2015 - [info] 192.168.1.4(192.168.1.4:3306) Version=5.5.37-log (oldest major version between slaves) log-bin:enabled

#转移后

Fri Jan 9 10:09:43 2015 - [info] Starting master failover..

Fri Jan 9 10:09:43 2015 - [info]

From:

192.168.1.2 (current master)

+--192.168.1.3

+--192.168.1.4

To:

192.168.1.3 (new master)

+--192.168.1.4

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

mha: MySQL Master failover 192.168.1.2 to 192.168.1.3 succeeded

Master 192.168.1.2 is down!

看这个日志就跟看电影一样,高潮部分,O(∩_∩)O哈哈~

在 db1 此目录 /usr/local/mha/ 会有binlog文件

saved_master_binlog_from_192.168.1.2_3306_20150109100942.binlog

当db1 mysql down后,manager会停止运行,

[root@manager ~]# masterha_check_status --conf=/usr/local/mha/mha.conf

mha is stopped(2:NOT_RUNNING).

[1]+ Done nohup masterha_manager --conf=/usr/local/mha/mha.conf > /tmp/mha_manager.log &1

#恢复操作

1,db1启动mysql

[root@db1 ~]# service mysqld start

Starting MySQL.. SUCCESS!

2,mysqlbinlog 查看binlog文件,然后把db1主做为备

# mysqlbinlog saved_master_binlog_from_192.168.1.2_3306_20150109100942.binlog > mysqlbinlog.sql #转换binlog为sql语句

3,less mysqlbinlog.sql #找出同步的pos做从,或者重新做mysql从

change master to MASTER_HOST='192.168.1.3', MASTER_PORT=3306,MASTER_USER='mharep', MASTER_PASSWORD='passwd',master_log_file='mysql-bin.000001', master_log_pos=107;

slave start;

show slave status\G;

4,启动manager的管理

eb7c60ed226ee86af5254662ced4bbe0.png

# nohup masterha_manager --conf=/usr/local/mha/mha.conf > /tmp/mha_manager.log &1 &

# masterha_check_status --conf=/usr/local/mha/mha.conf

如果有这个提示,那么删除此文件/usr/local/mha/mha.failover.complete

[error][/usr/share/perl5/vendor_perl/MHA/MasterFailover.pm, ln298] Last failover was done at 2015/01/09 10:00:47. Current time is too early to do failover again. If you want to do failover, manually remove /usr/local/mha/mha.failover.complete and run this script again.

5,MmysqlMHA的VIP手动切换

masterha_check_repl --conf=/usr/local/mha/mha.conf

nohup masterha_manager --conf=/usr/local/mha/mha.conf > /tmp/mha_manager.log &1 &

masterha_check_status --conf=/usr/local/mha/mha.conf

masterha_stop --conf=/usr/local/mha/mha.conf

masterha_master_switch --conf=/usr/local/mha/mha.conf --master_state=alive --new_master_host=192.168.(new master IP address) --new_master_port=3306 --orig_master_is_new_slave --running_updates_limit=10000

上面用到的配置下载地址:http://down.51cto.com/data/2065725

本文原创发布php中文网,转载请注明出处,感谢您的尊重!



推荐阅读
  • 本文档提供了详细的MySQL安装步骤,包括解压安装文件、选择安装类型、配置MySQL服务以及设置管理员密码等关键环节,帮助用户顺利完成MySQL的安装。 ... [详细]
  • 本文详细介绍了如何在Linux系统上安装和配置单节点的Redis服务,包括下载、解压、编译安装以及启动服务的具体步骤。 ... [详细]
  • 使用 Docker 部署 MongoDB 并通过 IntelliJ IDEA 远程访问
    本文详细介绍了如何使用 Docker 部署 MongoDB,并通过 IntelliJ IDEA 实现远程连接的方法。包括 MongoDB 的基本配置、用户管理以及如何在 IDE 中配置连接。 ... [详细]
  • 抽象工厂模式 c++
    抽象工厂模式包含如下角色:AbstractFactory:抽象工厂ConcreteFactory:具体工厂AbstractProduct:抽象产品Product:具体产品https ... [详细]
  • Nagios可视化插件开发指南 —— 配置详解
    本文详细介绍了Nagios监控系统的配置过程,包括数据库的选择与安装、Nagios插件的安装及配置文件的解析。同时,针对常见的配置错误提供了具体的解决方法。 ... [详细]
  • 本文介绍了如何使用Workman框架构建一个功能全面的即时通讯系统,该系统不仅支持一对一聊天、群组聊天,还集成了视频会议和实时音视频通话功能,同时提供了红包发送等附加功能。 ... [详细]
  • 本文探讨了在使用Apache Flink向Kafka发送数据过程中遇到的事务频繁失败问题,并提供了详细的解决方案,包括必要的配置调整和最佳实践。 ... [详细]
  • Python中调用Java代码的方法与实践
    本文探讨了如何在Python环境中集成并调用Java代码,通过具体的步骤和示例展示了这一过程的技术细节。适合对跨语言编程感兴趣的开发者阅读。 ... [详细]
  • 本文详细介绍如何在Spring Boot项目中集成和使用JPA,涵盖JPA的基本概念、Spring Data JPA的功能以及具体的操作步骤,帮助开发者快速掌握这一强大的持久化技术。 ... [详细]
  • 本文详细探讨了 Java 中 com.codahale.metrics.servlets.AdminServlet.() 方法的实现与应用,并提供了多个实际项目中的代码示例,帮助开发者更好地理解和使用这一方法。 ... [详细]
  • 本文介绍了JSP的基本概念、常用标签及其功能,并通过示例详细说明了如何在JSP页面中使用Java代码。 ... [详细]
  • 本文介绍了多种Eclipse插件,包括XML Schema Infoset Model (XSD)、Graphical Editing Framework (GEF)、Eclipse Modeling Framework (EMF)等,涵盖了从Web开发到图形界面编辑的多个方面。 ... [详细]
  • 本文详细解析了Java中流的概念,特别是OutputStream和InputStream的区别,并通过实际案例介绍了如何实现Java对象的序列化。文章不仅解释了流的基本概念,还探讨了序列化的重要性和具体实现步骤。 ... [详细]
  • 探讨了生成时间敏感的一次性伪随机密码的方法,旨在通过加入时间因素防止重放攻击。 ... [详细]
  • 深入解析轻量级数据库 SQL Server Express LocalDB
    本文详细介绍了 SQL Server Express LocalDB,这是一种轻量级的本地 T-SQL 数据库解决方案,特别适合开发环境使用。文章还探讨了 LocalDB 与其他轻量级数据库的对比,并提供了安装和连接 LocalDB 的步骤。 ... [详细]
author-avatar
欢乐文艺女青年
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有