资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

MysqlMHA部署怎样进行故障转移

这篇文章给大家介绍MySQL MHA部署怎样进行故障转移,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。

创新互联公司服务项目包括南和网站建设、南和网站制作、南和网页制作以及南和网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,南和网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到南和省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!

Mysql MHA部署-故障转移

架构说明:

Mysql MHA部署怎样进行故障转移

参考:http://www.zhaibibei.cn/mysql/mha/

1 主库187查看IP和VIP信息

[root@rac1 ~]# ifconfig 

enp0s3: flags=4163  mtu 1500

        inet 192.168.2.187 netmask 255.255.255.0  broadcast 192.168.2.255

        inet6 fe80::c3b0:4e87:f38f:d640  prefixlen 64  scopeid 0x20

        inet6 fe80::a3a6:33e0:1848:f  prefixlen 64  scopeid 0x20

        inet6 fe80::63c7:f30:11a7:4216  prefixlen 64  scopeid 0x20

        ether 08:00:27:83:9e:5c  txqueuelen 1000  (Ethernet)

        RX packets 12552  bytes 909017 (887.7 KiB)

        RX errors 0  dropped 996  overruns 0  frame 0

        TX packets 391  bytes 47354 (46.2 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s3:2: flags=4163  mtu 1500

        inet 192.168.2.189  netmask 255.255.255.0  broadcast 192.168.2.255

        ether 08:00:27:83:9e:5c  txqueuelen 1000  (Ethernet)

2 从库查看当前同步信息

---188:

mysql> show slave status \G;

*************************** 1. row ***************************

               Slave_IO_State: Waiting for master to send event

                  Master_Host: 192.168.2.187

                  Master_User: repl

                  Master_Port: 3306

                Connect_Retry: 60

              Master_Log_File: mysql-bin.000010

          Read_Master_Log_Pos: 250

               Relay_Log_File: mysql-relay.000002

                Relay_Log_Pos: 320

        Relay_Master_Log_File: mysql-bin.000010

             Slave_IO_Running: Yes

            Slave_SQL_Running: Yes

---223:

mysql> show slave status \G;

*************************** 1. row ***************************

               Slave_IO_State: Waiting for master to send event

                  Master_Host: 192.168.2.187

                  Master_User: repl

                  Master_Port: 3306

                Connect_Retry: 60

              Master_Log_File: mysql-bin.000010

          Read_Master_Log_Pos: 250

               Relay_Log_File: mysql-relay.000002

                Relay_Log_Pos: 320

        Relay_Master_Log_File: mysql-bin.000010

             Slave_IO_Running: Yes

            Slave_SQL_Running: Yes

              Replicate_Do_DB:   

3 管理节点查看信息  

222:

[root@rac4 ~]# masterha_check_status --conf=/etc/mha/mha.conf

mha (pid:3057) is running(0:PING_OK), master:rac1

4 主库手动停止mysql

187:

[mysql@rac1 ~]$ service mysqld stop

Shutting down MySQL..............[  OK  ]

5 管理节点查看故障转移过程

222:

[root@rac4 manager]# tail -f mha.log 

......

---(1) 确认主库状态(not reachable)

Sun Mar 15 14:01:16 2020 - [warning] Got error on MySQL select ping: 2006 (MySQL server has gone away)

Sun Mar 15 14:01:16 2020 - [info] Executing secondary network check script: /usr/bin/masterha_secondary_check -s 192.168.2.188  -s 192.168.2.223 --user=root  --master_host=192.168.2.187 --master_ip=192.168.2.187  --master_port=3306  --user=root  --master_host=rac1  --master_ip=192.168.2.187  --master_port=3306 --master_user=monitor --master_password=123456 --ping_type=SELECT

Sun Mar 15 14:01:16 2020 - [info] Executing SSH check script: save_binary_logs --command=test --start_pos=4 --binlog_dir=/datalog/mysql/binlog --output_file=/etc/mha/node/save_binary_logs_test --manager_version=0.56 --binlog_prefix=mysql-bin

Sun Mar 15 14:01:17 2020 - [info] HealthCheck: SSH to rac1 is reachable.

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

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

Sun Mar 15 14:01:17 2020 - [info] Master is not reachable from all other monitoring servers. Failover should start.

Sun Mar 15 14:01:17 2020 - [warning] Got error on MySQL connect: 2003 (Can't connect to MySQL server on '192.168.2.187' (111))

Sun Mar 15 14:01:17 2020 - [warning] Connection failed 2 time(s)..

Sun Mar 15 14:01:18 2020 - [warning] Got error on MySQL connect: 2003 (Can't connect to MySQL server on '192.168.2.187' (111))

Sun Mar 15 14:01:18 2020 - [warning] Connection failed 3 time(s)..

Sun Mar 15 14:01:19 2020 - [warning] Got error on MySQL connect: 2003 (Can't connect to MySQL server on '192.168.2.187' (111))

Sun Mar 15 14:01:19 2020 - [warning] Connection failed 4 time(s)..

Sun Mar 15 14:01:19 2020 - [warning] Master is not reachable from health checker!

Sun Mar 15 14:01:19 2020 - [warning] Master rac1(192.168.2.187:3306) is not reachable!

Sun Mar 15 14:01:19 2020 - [warning] SSH is reachable.

---(2) 重新检查主从(rac1,rac2,rac3)服务器状态

---确定master is down,从库rac2,rac3可用

Sun Mar 15 14:01:19 2020 - [info] Connecting to a master server failed. Reading configuration file /etc/masterha_default.cnf and /etc/mha/mha.conf again, and trying to connect to all servers to check server status..

Sun Mar 15 14:01:19 2020 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.

Sun Mar 15 14:01:19 2020 - [info] Reading application default configuration from /etc/mha/mha.conf..

Sun Mar 15 14:01:19 2020 - [info] Reading server configuration from /etc/mha/mha.conf..

Sun Mar 15 14:01:20 2020 - [info] GTID failover mode = 0

Sun Mar 15 14:01:20 2020 - [info] Dead Servers:

Sun Mar 15 14:01:20 2020 - [info]   rac1(192.168.2.187:3306)

Sun Mar 15 14:01:20 2020 - [info] Alive Servers:

Sun Mar 15 14:01:20 2020 - [info]   rac2(192.168.2.188:3306)

Sun Mar 15 14:01:20 2020 - [info]   rac3(192.168.2.223:3306)

Sun Mar 15 14:01:20 2020 - [info] Alive Slaves:

Sun Mar 15 14:01:20 2020 - [info]   rac2(192.168.2.188:3306)  Version=5.7.28-log (oldest major version between slaves) log-bin:enabled

Sun Mar 15 14:01:20 2020 - [info]     Replicating from 192.168.2.187(192.168.2.187:3306)

Sun Mar 15 14:01:20 2020 - [info]     Primary candidate for the new Master (candidate_master is set)

Sun Mar 15 14:01:20 2020 - [info]   rac3(192.168.2.223:3306)  Version=5.7.28-log (oldest major version between slaves) log-bin:enabled

Sun Mar 15 14:01:20 2020 - [info]     Replicating from 192.168.2.187(192.168.2.187:3306)

Sun Mar 15 14:01:20 2020 - [info]     Not candidate for the new Master (no_master is set)

Sun Mar 15 14:01:20 2020 - [info] Checking slave configurations..

Sun Mar 15 14:01:20 2020 - [warning]  relay_log_purge=0 is not set on slave rac2(192.168.2.188:3306).

Sun Mar 15 14:01:20 2020 - [warning]  relay_log_purge=0 is not set on slave rac3(192.168.2.223:3306).

Sun Mar 15 14:01:20 2020 - [info] Checking replication filtering settings..

Sun Mar 15 14:01:20 2020 - [info]  Replication filtering check ok.

Sun Mar 15 14:01:20 2020 - [info] Master is down!

Sun Mar 15 14:01:20 2020 - [info] Terminating monitoring script.

Sun Mar 15 14:01:20 2020 - [info] Got exit code 20 (Master dead).

---(3) MasterFailover配置文件确认

Sun Mar 15 14:01:20 2020 - [info] MHA::MasterFailover version 0.56.

Sun Mar 15 14:01:20 2020 - [info] Starting master failover.

Sun Mar 15 14:01:20 2020 - [info] 

Sun Mar 15 14:01:20 2020 - [info] * Phase 1: Configuration Check Phase..

Sun Mar 15 14:01:20 2020 - [info] 

Sun Mar 15 14:01:22 2020 - [info] GTID failover mode = 0

Sun Mar 15 14:01:22 2020 - [info] Dead Servers:

Sun Mar 15 14:01:22 2020 - [info]   rac1(192.168.2.187:3306)

Sun Mar 15 14:01:22 2020 - [info] Checking master reachability via MySQL(double check)...

Sun Mar 15 14:01:22 2020 - [info]  ok.

Sun Mar 15 14:01:22 2020 - [info] Alive Servers:

Sun Mar 15 14:01:22 2020 - [info]   rac2(192.168.2.188:3306)

Sun Mar 15 14:01:22 2020 - [info]   rac3(192.168.2.223:3306)

Sun Mar 15 14:01:22 2020 - [info] Alive Slaves:

Sun Mar 15 14:01:22 2020 - [info]   rac2(192.168.2.188:3306)  Version=5.7.28-log (oldest major version between slaves) log-bin:enabled

Sun Mar 15 14:01:22 2020 - [info]     Replicating from 192.168.2.187(192.168.2.187:3306)

Sun Mar 15 14:01:22 2020 - [info]     Primary candidate for the new Master (candidate_master is set)

Sun Mar 15 14:01:22 2020 - [info]   rac3(192.168.2.223:3306)  Version=5.7.28-log (oldest major version between slaves) log-bin:enabled

Sun Mar 15 14:01:22 2020 - [info]     Replicating from 192.168.2.187(192.168.2.187:3306)

Sun Mar 15 14:01:22 2020 - [info]     Not candidate for the new Master (no_master is set)

Sun Mar 15 14:01:22 2020 - [info] Starting Non-GTID based failover.

Sun Mar 15 14:01:22 2020 - [info] 

---(4) 禁用rac1上的VIP,停止rac1

没有定义shutdown_script,所以没有调用

Sun Mar 15 14:01:22 2020 - [info] ** Phase 1: Configuration Check Phase completed.

Sun Mar 15 14:01:22 2020 - [info] 

Sun Mar 15 14:01:22 2020 - [info] * Phase 2: Dead Master Shutdown Phase..

Sun Mar 15 14:01:22 2020 - [info] 

Sun Mar 15 14:01:22 2020 - [info] Forcing shutdown so that applications never connect to the current master..

Sun Mar 15 14:01:22 2020 - [info] Executing master IP deactivation script:

Sun Mar 15 14:01:22 2020 - [info]   /etc/mha/script/master_ip_failover --orig_master_host=rac1 --orig_master_ip=192.168.2.187 --orig_master_port=3306 --command=stopssh --ssh_user=root  

Disabling the VIP an old master: rac1 

---禁用VIP失败了(估计是网卡设置有问题)

SIOCSIFFLAGS: Cannot assign requested address

Sun Mar 15 14:01:22 2020 - [info]  done.

Sun Mar 15 14:01:22 2020 - [warning] shutdown_script is not set. Skipping explicit shutting down of the dead master.

Sun Mar 15 14:01:22 2020 - [info] * Phase 2: Dead Master Shutdown Phase completed.

Sun Mar 15 14:01:22 2020 - [info] 

---(5)主库恢复获取最新的slave

Sun Mar 15 14:01:22 2020 - [info] * Phase 3: Master Recovery Phase..

Sun Mar 15 14:01:22 2020 - [info] 

Sun Mar 15 14:01:22 2020 - [info] * Phase 3.1: Getting Latest Slaves Phase..

Sun Mar 15 14:01:22 2020 - [info] 

Sun Mar 15 14:01:22 2020 - [info] The latest binary log file/position on all slaves is mysql-bin.000015:250

Sun Mar 15 14:01:22 2020 - [info] Latest slaves (Slaves that received relay log files to the latest):

Sun Mar 15 14:01:22 2020 - [info]   rac2(192.168.2.188:3306)  Version=5.7.28-log (oldest major version between slaves) log-bin:enabled

Sun Mar 15 14:01:22 2020 - [info]     Replicating from 192.168.2.187(192.168.2.187:3306)

Sun Mar 15 14:01:22 2020 - [info]     Primary candidate for the new Master (candidate_master is set)

Sun Mar 15 14:01:22 2020 - [info]   rac3(192.168.2.223:3306)  Version=5.7.28-log (oldest major version between slaves) log-bin:enabled

Sun Mar 15 14:01:22 2020 - [info]     Replicating from 192.168.2.187(192.168.2.187:3306)

Sun Mar 15 14:01:22 2020 - [info]     Not candidate for the new Master (no_master is set)

Sun Mar 15 14:01:22 2020 - [info] The oldest binary log file/position on all slaves is mysql-bin.000015:250

Sun Mar 15 14:01:22 2020 - [info] Oldest slaves:

Sun Mar 15 14:01:22 2020 - [info]   rac2(192.168.2.188:3306)  Version=5.7.28-log (oldest major version between slaves) log-bin:enabled

Sun Mar 15 14:01:22 2020 - [info]     Replicating from 192.168.2.187(192.168.2.187:3306)

Sun Mar 15 14:01:22 2020 - [info]     Primary candidate for the new Master (candidate_master is set)

Sun Mar 15 14:01:22 2020 - [info]   rac3(192.168.2.223:3306)  Version=5.7.28-log (oldest major version between slaves) log-bin:enabled

Sun Mar 15 14:01:22 2020 - [info]     Replicating from 192.168.2.187(192.168.2.187:3306)

Sun Mar 15 14:01:22 2020 - [info]     Not candidate for the new Master (no_master is set)

Sun Mar 15 14:01:22 2020 - [info] 

Sun Mar 15 14:01:22 2020 - [info] * Phase 3.2: Saving Dead Master's Binlog Phase..

Sun Mar 15 14:01:22 2020 - [info] 

Sun Mar 15 14:01:22 2020 - [info] Fetching dead master's binary logs..

Sun Mar 15 14:01:22 2020 - [info] Executing command on the dead master rac1(192.168.2.187:3306): save_binary_logs --command=save --start_file=mysql-bin.000015  --start_pos=250 --binlog_dir=/datalog/mysql/binlog --output_file=/etc/mha/node/saved_master_binlog_from_rac1_3306_20200315140120.binlog --handle_raw_binlog=1 --disable_log_bin=0 --manager_version=0.56

  Creating /etc/mha/node if not exists..    ok.

 Concat binary/relay logs from mysql-bin.000015 pos 250 to mysql-bin.000015 EOF into /etc/mha/node/saved_master_binlog_from_rac1_3306_20200315140120.binlog ..

 Binlog Checksum enabled

  Dumping binlog format description event, from position 0 to 250.. ok.

  No need to dump effective binlog data from /datalog/mysql/binlog/mysql-bin.000015 (pos starts 250, filesize 250). Skipping.

ERROR: Error in Log_event::read_log_event(): 'Found invalid event in binary log', data_len: 127, event_type: 35

 Binlog Checksum enabled

 /etc/mha/node/saved_master_binlog_from_rac1_3306_20200315140120.binlog has no effective data events.

Event not exists.

Sun Mar 15 14:01:23 2020 - [info] Additional events were not found from the orig master. No need to save.

Sun Mar 15 14:01:23 2020 - [info] 

---(6)决定新的主库188

Sun Mar 15 14:01:23 2020 - [info] * Phase 3.3: Determining New Master Phase..

Sun Mar 15 14:01:23 2020 - [info] 

Sun Mar 15 14:01:23 2020 - [info] Finding the latest slave that has all relay logs for recovering other slaves..

Sun Mar 15 14:01:23 2020 - [info] All slaves received relay logs to the same position. No need to resync each other.

Sun Mar 15 14:01:23 2020 - [info] Searching new master from slaves..

Sun Mar 15 14:01:23 2020 - [info]  Candidate masters from the configuration file:

Sun Mar 15 14:01:23 2020 - [info]   rac2(192.168.2.188:3306)  Version=5.7.28-log (oldest major version between slaves) log-bin:enabled

Sun Mar 15 14:01:23 2020 - [info]     Replicating from 192.168.2.187(192.168.2.187:3306)

Sun Mar 15 14:01:23 2020 - [info]     Primary candidate for the new Master (candidate_master is set)

Sun Mar 15 14:01:23 2020 - [info]  Non-candidate masters:

Sun Mar 15 14:01:23 2020 - [info]   rac3(192.168.2.223:3306)  Version=5.7.28-log (oldest major version between slaves) log-bin:enabled

Sun Mar 15 14:01:23 2020 - [info]     Replicating from 192.168.2.187(192.168.2.187:3306)

Sun Mar 15 14:01:23 2020 - [info]     Not candidate for the new Master (no_master is set)

Sun Mar 15 14:01:23 2020 - [info]  Searching from candidate_master slaves which have received the latest relay log events..

Sun Mar 15 14:01:23 2020 - [info] New master is rac2(192.168.2.188:3306)

Sun Mar 15 14:01:23 2020 - [info] Starting master failover..

Sun Mar 15 14:01:23 2020 - [info] 

From:

rac1(192.168.2.187:3306) (current master)

 +--rac2(192.168.2.188:3306)

 +--rac3(192.168.2.223:3306)

To:

rac2(192.168.2.188:3306) (new master)

 +--rac3(192.168.2.223:3306)

Sun Mar 15 14:01:23 2020 - [info] 

Sun Mar 15 14:01:23 2020 - [info] * Phase 3.3: New Master Diff Log Generation Phase..

Sun Mar 15 14:01:23 2020 - [info] 

Sun Mar 15 14:01:23 2020 - [info]  This server has all relay logs. No need to generate diff files from the latest slave.

Sun Mar 15 14:01:23 2020 - [info] 

Sun Mar 15 14:01:23 2020 - [info] * Phase 3.4: Master Log Apply Phase..

Sun Mar 15 14:01:23 2020 - [info] 

Sun Mar 15 14:01:23 2020 - [info] *NOTICE: If any error happens from this phase, manual recovery is needed.

Sun Mar 15 14:01:23 2020 - [info] Starting recovery on rac2(192.168.2.188:3306)..

Sun Mar 15 14:01:23 2020 - [info]  This server has all relay logs. Waiting all logs to be applied.. 

Sun Mar 15 14:01:23 2020 - [info]   done.

Sun Mar 15 14:01:23 2020 - [info]  All relay logs were successfully applied.

Sun Mar 15 14:01:23 2020 - [info] Getting new master's binlog name and position..

Sun Mar 15 14:01:23 2020 - [info]  mysql-bin.000012:234

Sun Mar 15 14:01:23 2020 - [info]  All other slaves should start replication from here. Statement should be: CHANGE MASTER TO MASTER_HOST='rac2 or 192.168.2.188', MASTER_PORT=3306, MASTER_LOG_FILE='mysql-bin.000012', MASTER_LOG_POS=234, MASTER_USER='repl', MASTER_PASSWORD='xxx';

Sun Mar 15 14:01:23 2020 - [info] Executing master IP activate script:

Sun Mar 15 14:01:23 2020 - [info]   /etc/mha/script/master_ip_failover --command=start --ssh_user=root --orig_master_host=rac1 --orig_master_ip=192.168.2.187 --orig_master_port=3306 --new_master_host=rac2 --new_master_ip=192.168.2.188 --new_master_port=3306 --new_master_user='monitor' --new_master_password='123456'  

Set read_only=0 on the new master.

Enabling the VIP 192.168.2.189 on the new master: rac2 

Sun Mar 15 14:01:23 2020 - [info]  OK.

Sun Mar 15 14:01:23 2020 - [info] ** Finished master recovery successfully.

Sun Mar 15 14:01:23 2020 - [info] * Phase 3: Master Recovery Phase completed.

Sun Mar 15 14:01:23 2020 - [info] 

Sun Mar 15 14:01:23 2020 - [info] * Phase 4: Slaves Recovery Phase..

Sun Mar 15 14:01:23 2020 - [info] 

Sun Mar 15 14:01:23 2020 - [info] * Phase 4.1: Starting Parallel Slave Diff Log Generation Phase..

Sun Mar 15 14:01:23 2020 - [info] 

Sun Mar 15 14:01:23 2020 - [info] -- Slave diff file generation on host rac3(192.168.2.223:3306) started, pid: 10164. Check tmp log /etc/mha/manager/rac3_3306_20200315140120.log if it takes time..

Sun Mar 15 14:01:24 2020 - [info] 

Sun Mar 15 14:01:24 2020 - [info] Log messages from rac3 ...

Sun Mar 15 14:01:24 2020 - [info] 

Sun Mar 15 14:01:23 2020 - [info]  This server has all relay logs. No need to generate diff files from the latest slave.

Sun Mar 15 14:01:24 2020 - [info] End of log messages from rac3.

Sun Mar 15 14:01:24 2020 - [info] -- rac3(192.168.2.223:3306) has the latest relay log events.

Sun Mar 15 14:01:24 2020 - [info] Generating relay diff files from the latest slave succeeded.

Sun Mar 15 14:01:24 2020 - [info] 

Sun Mar 15 14:01:24 2020 - [info] * Phase 4.2: Starting Parallel Slave Log Apply Phase..

Sun Mar 15 14:01:24 2020 - [info] 

Sun Mar 15 14:01:24 2020 - [info] -- Slave recovery on host rac3(192.168.2.223:3306) started, pid: 10166. Check tmp log /etc/mha/manager/rac3_3306_20200315140120.log if it takes time..

Sun Mar 15 14:01:25 2020 - [info] 

Sun Mar 15 14:01:25 2020 - [info] Log messages from rac3 ...

Sun Mar 15 14:01:25 2020 - [info] 

Sun Mar 15 14:01:24 2020 - [info] Starting recovery on rac3(192.168.2.223:3306)..

Sun Mar 15 14:01:24 2020 - [info]  This server has all relay logs. Waiting all logs to be applied.. 

Sun Mar 15 14:01:24 2020 - [info]   done.

Sun Mar 15 14:01:24 2020 - [info]  All relay logs were successfully applied.

Sun Mar 15 14:01:24 2020 - [info]  Resetting slave rac3(192.168.2.223:3306) and starting replication from the new master rac2(192.168.2.188:3306)..

Sun Mar 15 14:01:24 2020 - [info]  Executed CHANGE MASTER.

Sun Mar 15 14:01:24 2020 - [info]  Slave started.

Sun Mar 15 14:01:25 2020 - [info] End of log messages from rac3.

Sun Mar 15 14:01:25 2020 - [info] -- Slave recovery on host rac3(192.168.2.223:3306) succeeded.

Sun Mar 15 14:01:25 2020 - [info] All new slave servers recovered successfully.

Sun Mar 15 14:01:25 2020 - [info] 

---(7) 清理阶段

Sun Mar 15 14:01:25 2020 - [info] * Phase 5: New master cleanup phase..

Sun Mar 15 14:01:25 2020 - [info] 

Sun Mar 15 14:01:25 2020 - [info] Resetting slave info on the new master..

Sun Mar 15 14:01:25 2020 - [info]  rac2: Resetting slave info succeeded.

Sun Mar 15 14:01:25 2020 - [info] Master failover to rac2(192.168.2.188:3306) completed successfully.

Sun Mar 15 14:01:25 2020 - [info] Deleted server1 entry from /etc/mha/mha.conf .

Sun Mar 15 14:01:25 2020 - [info] 

---(8) failover报告

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

mha: MySQL Master failover rac1(192.168.2.187:3306) to rac2(192.168.2.188:3306) succeeded

Master rac1(192.168.2.187:3306) is down!

Check MHA Manager logs at rac4:/etc/mha/manager/mha.log for details.

Started automated(non-interactive) failover.

Invalidated master IP address on rac1(192.168.2.187:3306)

The latest slave rac2(192.168.2.188:3306) has all relay logs for recovery.

Selected rac2(192.168.2.188:3306) as a new master.

rac2(192.168.2.188:3306): OK: Applying all logs succeeded.

rac2(192.168.2.188:3306): OK: Activated master IP address.

rac3(192.168.2.223:3306): This host has the latest relay log events.

Generating relay diff files from the latest slave succeeded.

rac3(192.168.2.223:3306): OK: Applying all logs succeeded. Slave started, replicating from rac2(192.168.2.188:3306)

rac2(192.168.2.188:3306): Resetting slave info succeeded.

Master failover to rac2(192.168.2.188:3306) completed successfully.

6 查看223从库对应的主库已经由187自动切换成188

223:

mysql> show slave status \G;

*************************** 1. row ***************************

               Slave_IO_State: Waiting for master to send event

                  Master_Host: 192.168.2.188

                  Master_User: repl

                  Master_Port: 3306

                Connect_Retry: 60

              Master_Log_File: mysql-bin.000009

          Read_Master_Log_Pos: 234

               Relay_Log_File: mysql-relay.000008

                Relay_Log_Pos: 407

        Relay_Master_Log_File: mysql-bin.000009

             Slave_IO_Running: Yes

            Slave_SQL_Running: Yes

7 查看VIP189已经从187节点漂移到188

188:

[root@rac2 ~]# ifconfig |grep 192

        inet 192.168.2.188  netmask 255.255.255.0  broadcast 192.168.2.255

        inet 192.168.2.189  netmask 255.255.255.0  broadcast 192.168.2.255

        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255

关于Mysql MHA部署怎样进行故障转移就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。


文章题目:MysqlMHA部署怎样进行故障转移
网站URL:http://cdkjz.cn/article/jidepe.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220