天天看点

master_ip_failover_script脚本何时被调用master_ip_failover_script脚本调用

文章目录

  • master_ip_failover_script脚本调用
    • 启动masterha_manager时
    • Failover时调用两次

master_ip_failover_script脚本调用

master_ip_failover_script脚本是failover时用的. 默认的示例脚本其实就一个main函数, 判断

--command

的值做操作, 就收三种:

  • stop || stopssh
  • start 引用lib/MHA下面的DBHelper默认
  • status

stop || stopssh 是一样的, MHA用的stopssh

示例脚本中什么都没做, 我们增加了ssh到orig_master_host增加vip

start 示例脚本中调用了

# 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();
      
      
disable_log_bin_local == SET sql_log_bin=0
enable_log_bin_local == SET sql_log_bin=1
他就是给你个例子, 你可以在新主上创建用户, 创建用户的话可以set sql_log_bin=0

我们在这里还ssh到new_master_host增加vip
           

status 什么都没做

启动masterha_manager时

启动

#/usr/local/bin/masterha_manager --global_conf=/etc/masterha/conf/masterha_default.cnf --conf=/etc/masterha/conf/cls_all.cnf --ignore_last_failover
Fri Feb 28 20:25:23 2020 - [info] Reading default configuration from /etc/masterha/conf/masterha_default.cnf..
Fri Feb 28 20:25:23 2020 - [info] Reading application default configuration from /etc/masterha/conf/cls_all.cnf..
Fri Feb 28 20:25:23 2020 - [info] Reading server configuration from /etc/masterha/conf/cls_all.cnf..

           

查看日志

manager_log=/masterha/cls_all/manager.log

Fri Feb 28 20:25:23 2020 - [info] MHA::MasterMonitor version 0.58.
Fri Feb 28 20:25:25 2020 - [info] GTID failover mode = 1
Fri Feb 28 20:25:25 2020 - [info] Dead Servers:
Fri Feb 28 20:25:25 2020 - [info] Alive Servers:
Fri Feb 28 20:25:25 2020 - [info]   192.168.98.10(192.168.98.10:3306)
Fri Feb 28 20:25:25 2020 - [info]   192.168.98.11(192.168.98.11:3306)
Fri Feb 28 20:25:25 2020 - [info]   192.168.98.12(192.168.98.12:3306)
Fri Feb 28 20:25:25 2020 - [info] Alive Slaves:
Fri Feb 28 20:25:25 2020 - [info]   192.168.98.10(192.168.98.10:3306)  Version=5.7.29-32-log (oldest major version between slaves) log-bin:enabled
Fri Feb 28 20:25:25 2020 - [info]     GTID ON
Fri Feb 28 20:25:25 2020 - [info]     Replicating from 192.168.98.11(192.168.98.11:3306)
Fri Feb 28 20:25:25 2020 - [info]     Primary candidate for the new Master (candidate_master is set)
Fri Feb 28 20:25:25 2020 - [info]   192.168.98.12(192.168.98.12:3306)  Version=5.7.29-32-log (oldest major version between slaves) log-bin:enabled
Fri Feb 28 20:25:25 2020 - [info]     GTID ON
Fri Feb 28 20:25:25 2020 - [info]     Replicating from 192.168.98.11(192.168.98.11:3306)
Fri Feb 28 20:25:25 2020 - [info] Current Alive Master: 192.168.98.11(192.168.98.11:3306)
Fri Feb 28 20:25:25 2020 - [info] Checking slave configurations..
Fri Feb 28 20:25:25 2020 - [info] Checking replication filtering settings..
Fri Feb 28 20:25:25 2020 - [info]  binlog_do_db= , binlog_ignore_db= 
Fri Feb 28 20:25:25 2020 - [info]  Replication filtering check ok.
Fri Feb 28 20:25:25 2020 - [info] GTID (with auto-pos) is supported. Skipping all SSH and Node package checking.
Fri Feb 28 20:25:25 2020 - [info] Checking SSH publickey authentication settings on the current master..
Fri Feb 28 20:25:25 2020 - [info] HealthCheck: SSH to 192.168.98.11 is reachable.
Fri Feb 28 20:25:25 2020 - [info] 
192.168.98.11(192.168.98.11:3306) (current master)
 +--192.168.98.10(192.168.98.10:3306)
 +--192.168.98.12(192.168.98.12:3306)

Fri Feb 28 20:25:25 2020 - [info] Checking master_ip_failover_script status:
Fri Feb 28 20:25:25 2020 - [info]   /etc/masterha/scripts/master_ip_failover_vip --vip=192.168.98.100 --command=status --ssh_user=root --orig_master_host=192.168.98.11 --orig_master_ip=192.168.98.11 --orig_master_port=3306 
Fri Feb 28 20:25:25 2020 - [info]  OK.
Fri Feb 28 20:25:25 2020 - [warning] shutdown_script is not defined.
Fri Feb 28 20:25:25 2020 - [info] Set master ping interval 3 seconds.
Fri Feb 28 20:25:25 2020 - [info] Set secondary check script: masterha_secondary_check -s 192.168.98.10 -s 192.168.98.12
Fri Feb 28 20:25:25 2020 - [info] Starting ping health check on 192.168.98.11(192.168.98.11:3306)..
Fri Feb 28 20:25:25 2020 - [info] Ping(CONNECT) succeeded, waiting until MySQL doesn't respond..

           

可以看到这里调用了一次

/etc/masterha/scripts/master_ip_failover_vip --vip=192.168.98.100 --command=status --ssh_user=root --orig_master_host=192.168.98.11 --orig_master_ip=192.168.98.11 --orig_master_port=3306
           

在官方示例脚本中, 可以看到这个脚本通过判断

--command

接收到的值来决定要做什么操作

[[email protected] 20:30:48 /usr/local/src/mha4mysql-manager-0.58/samples/scripts]
#ll
total 32
-rwxr-xr-x. 1 1000 1000  3648 Mar 23  2018 master_ip_failover
-rwxr-xr-x. 1 1000 1000  9870 Mar 23  2018 master_ip_online_change
-rwxr-xr-x. 1 1000 1000 11867 Mar 23  2018 power_manager
-rwxr-xr-x. 1 1000 1000  1360 Mar 23  2018 send_report

           

status是不做任何操作的

elsif ( $command eq "status" ) {

    # do nothing
    exit 0;
  }
           

我想这里本意是留给用户, 自己添加一些内容.

Failover时调用两次

Fri Feb 28 20:54:50 2020 - [warning] Got error on MySQL connect ping: DBI connect(';host=192.168.98.11;port=3306;mysql_connect_timeout=1','mha',...) failed: Can't connect to MySQL server on '192.168.98.11' (111) at /usr/local/share/perl5/MHA/HealthCheck.pm line 98.
2003 (Can't connect to MySQL server on '192.168.98.11' (111))
Fri Feb 28 20:54:50 2020 - [info] Executing SSH check script: exit 0
Fri Feb 28 20:54:50 2020 - [info] Executing secondary network check script: masterha_secondary_check -s 192.168.98.10 -s 192.168.98.12  --user=root  --master_host=192.168.98.11  --master_ip=192.168.98.11  --master_port=3306 --master_user=mha --master_password=mha --ping_type=CONNECT
Fri Feb 28 20:54:51 2020 - [info] HealthCheck: SSH to 192.168.98.11 is reachable.
Monitoring server 192.168.98.10 is reachable, Master is not reachable from 192.168.98.10. OK.
Monitoring server 192.168.98.12 is reachable, Master is not reachable from 192.168.98.12. OK.
Fri Feb 28 20:54:52 2020 - [info] Master is not reachable from all other monitoring servers. Failover should start.
Fri Feb 28 20:54:53 2020 - [warning] Got error on MySQL connect: 2003 (Can't connect to MySQL server on '192.168.98.11' (111))
Fri Feb 28 20:54:53 2020 - [warning] Connection failed 2 time(s)..
Fri Feb 28 20:54:56 2020 - [warning] Got error on MySQL connect: 2003 (Can't connect to MySQL server on '192.168.98.11' (111))
Fri Feb 28 20:54:56 2020 - [warning] Connection failed 3 time(s)..
Fri Feb 28 20:54:59 2020 - [warning] Got error on MySQL connect: 2003 (Can't connect to MySQL server on '192.168.98.11' (111))
Fri Feb 28 20:54:59 2020 - [warning] Connection failed 4 time(s)..
Fri Feb 28 20:54:59 2020 - [warning] Master is not reachable from health checker!
Fri Feb 28 20:54:59 2020 - [warning] Master 192.168.98.11(192.168.98.11:3306) is not reachable!
Fri Feb 28 20:54:59 2020 - [warning] SSH is reachable.
Fri Feb 28 20:54:59 2020 - [info] Connecting to a master server failed. Reading configuration file /etc/masterha/conf/masterha_default.cnf and /etc/masterha/conf/cls_all.cnf again, and trying to connect to all servers to check server status..
Fri Feb 28 20:54:59 2020 - [info] Reading default configuration from /etc/masterha/conf/masterha_default.cnf..
Fri Feb 28 20:54:59 2020 - [info] Reading application default configuration from /etc/masterha/conf/cls_all.cnf..
Fri Feb 28 20:54:59 2020 - [info] Reading server configuration from /etc/masterha/conf/cls_all.cnf..
Fri Feb 28 20:55:00 2020 - [info] GTID failover mode = 1
Fri Feb 28 20:55:00 2020 - [info] Dead Servers:
Fri Feb 28 20:55:00 2020 - [info]   192.168.98.11(192.168.98.11:3306)
Fri Feb 28 20:55:00 2020 - [info] Alive Servers:
Fri Feb 28 20:55:00 2020 - [info]   192.168.98.10(192.168.98.10:3306)
Fri Feb 28 20:55:00 2020 - [info]   192.168.98.12(192.168.98.12:3306)
Fri Feb 28 20:55:00 2020 - [info] Alive Slaves:
Fri Feb 28 20:55:00 2020 - [info]   192.168.98.10(192.168.98.10:3306)  Version=5.7.29-32-log (oldest major version between slaves) log-bin:enabled
Fri Feb 28 20:55:00 2020 - [info]     GTID ON
Fri Feb 28 20:55:00 2020 - [info]     Replicating from 192.168.98.11(192.168.98.11:3306)
Fri Feb 28 20:55:00 2020 - [info]     Primary candidate for the new Master (candidate_master is set)
Fri Feb 28 20:55:00 2020 - [info]   192.168.98.12(192.168.98.12:3306)  Version=5.7.29-32-log (oldest major version between slaves) log-bin:enabled
Fri Feb 28 20:55:00 2020 - [info]     GTID ON
Fri Feb 28 20:55:00 2020 - [info]     Replicating from 192.168.98.11(192.168.98.11:3306)
Fri Feb 28 20:55:00 2020 - [info] Checking slave configurations..
Fri Feb 28 20:55:00 2020 - [info] Checking replication filtering settings..
Fri Feb 28 20:55:00 2020 - [info]  Replication filtering check ok.
Fri Feb 28 20:55:00 2020 - [info] Master is down!
Fri Feb 28 20:55:00 2020 - [info] Terminating monitoring script.
Fri Feb 28 20:55:00 2020 - [info] Got exit code 20 (Master dead).
Fri Feb 28 20:55:00 2020 - [info] MHA::MasterFailover version 0.58.
Fri Feb 28 20:55:00 2020 - [info] Starting master failover.
Fri Feb 28 20:55:00 2020 - [info] 
Fri Feb 28 20:55:00 2020 - [info] * Phase 1: Configuration Check Phase..
Fri Feb 28 20:55:00 2020 - [info] 
Fri Feb 28 20:55:01 2020 - [info] GTID failover mode = 1
Fri Feb 28 20:55:01 2020 - [info] Dead Servers:
Fri Feb 28 20:55:01 2020 - [info]   192.168.98.11(192.168.98.11:3306)
Fri Feb 28 20:55:01 2020 - [info] Checking master reachability via MySQL(double check)...
Fri Feb 28 20:55:01 2020 - [info]  ok.
Fri Feb 28 20:55:01 2020 - [info] Alive Servers:
Fri Feb 28 20:55:01 2020 - [info]   192.168.98.10(192.168.98.10:3306)
Fri Feb 28 20:55:01 2020 - [info]   192.168.98.12(192.168.98.12:3306)
Fri Feb 28 20:55:01 2020 - [info] Alive Slaves:
Fri Feb 28 20:55:01 2020 - [info]   192.168.98.10(192.168.98.10:3306)  Version=5.7.29-32-log (oldest major version between slaves) log-bin:enabled
Fri Feb 28 20:55:01 2020 - [info]     GTID ON
Fri Feb 28 20:55:01 2020 - [info]     Replicating from 192.168.98.11(192.168.98.11:3306)
Fri Feb 28 20:55:01 2020 - [info]     Primary candidate for the new Master (candidate_master is set)
Fri Feb 28 20:55:01 2020 - [info]   192.168.98.12(192.168.98.12:3306)  Version=5.7.29-32-log (oldest major version between slaves) log-bin:enabled
Fri Feb 28 20:55:01 2020 - [info]     GTID ON
Fri Feb 28 20:55:01 2020 - [info]     Replicating from 192.168.98.11(192.168.98.11:3306)
Fri Feb 28 20:55:01 2020 - [info] Starting GTID based failover.
Fri Feb 28 20:55:01 2020 - [info] 
Fri Feb 28 20:55:01 2020 - [info] ** Phase 1: Configuration Check Phase completed.
Fri Feb 28 20:55:01 2020 - [info] 
Fri Feb 28 20:55:01 2020 - [info] * Phase 2: Dead Master Shutdown Phase..
Fri Feb 28 20:55:01 2020 - [info] 
Fri Feb 28 20:55:01 2020 - [info] Forcing shutdown so that applications never connect to the current master..
Fri Feb 28 20:55:01 2020 - [info] Executing master IP deactivation script:
Fri Feb 28 20:55:01 2020 - [info]   /etc/masterha/scripts/master_ip_failover_vip --vip=192.168.98.100 --orig_master_host=192.168.98.11 --orig_master_ip=192.168.98.11 --orig_master_port=3306 --command=stopssh --ssh_user=root  
Disabling the VIP on old master: 192.168.98.11 
Fake!!! 原主库 rpl_semi_sync_master_enabled=0 rpl_semi_sync_slave_enabled=1 
Fri Feb 28 20:55:02 2020 - [info]  done.
Fri Feb 28 20:55:02 2020 - [warning] shutdown_script is not set. Skipping explicit shutting down of the dead master.
Fri Feb 28 20:55:02 2020 - [info] * Phase 2: Dead Master Shutdown Phase completed.
Fri Feb 28 20:55:02 2020 - [info] 
Fri Feb 28 20:55:02 2020 - [info] * Phase 3: Master Recovery Phase..
Fri Feb 28 20:55:02 2020 - [info] 
Fri Feb 28 20:55:02 2020 - [info] * Phase 3.1: Getting Latest Slaves Phase..
Fri Feb 28 20:55:02 2020 - [info] 
Fri Feb 28 20:55:02 2020 - [info] The latest binary log file/position on all slaves is mysql-bin.000004:234
Fri Feb 28 20:55:02 2020 - [info] Latest slaves (Slaves that received relay log files to the latest):
Fri Feb 28 20:55:02 2020 - [info]   192.168.98.10(192.168.98.10:3306)  Version=5.7.29-32-log (oldest major version between slaves) log-bin:enabled
Fri Feb 28 20:55:02 2020 - [info]     GTID ON
Fri Feb 28 20:55:02 2020 - [info]     Replicating from 192.168.98.11(192.168.98.11:3306)
Fri Feb 28 20:55:02 2020 - [info]     Primary candidate for the new Master (candidate_master is set)
Fri Feb 28 20:55:02 2020 - [info]   192.168.98.12(192.168.98.12:3306)  Version=5.7.29-32-log (oldest major version between slaves) log-bin:enabled
Fri Feb 28 20:55:02 2020 - [info]     GTID ON
Fri Feb 28 20:55:02 2020 - [info]     Replicating from 192.168.98.11(192.168.98.11:3306)
Fri Feb 28 20:55:02 2020 - [info] The oldest binary log file/position on all slaves is mysql-bin.000004:234
Fri Feb 28 20:55:02 2020 - [info] Oldest slaves:
Fri Feb 28 20:55:02 2020 - [info]   192.168.98.10(192.168.98.10:3306)  Version=5.7.29-32-log (oldest major version between slaves) log-bin:enabled
Fri Feb 28 20:55:02 2020 - [info]     GTID ON
Fri Feb 28 20:55:02 2020 - [info]     Replicating from 192.168.98.11(192.168.98.11:3306)
Fri Feb 28 20:55:02 2020 - [info]     Primary candidate for the new Master (candidate_master is set)
Fri Feb 28 20:55:02 2020 - [info]   192.168.98.12(192.168.98.12:3306)  Version=5.7.29-32-log (oldest major version between slaves) log-bin:enabled
Fri Feb 28 20:55:02 2020 - [info]     GTID ON
Fri Feb 28 20:55:02 2020 - [info]     Replicating from 192.168.98.11(192.168.98.11:3306)
Fri Feb 28 20:55:02 2020 - [info] 
Fri Feb 28 20:55:02 2020 - [info] * Phase 3.3: Determining New Master Phase..
Fri Feb 28 20:55:02 2020 - [info] 
Fri Feb 28 20:55:02 2020 - [info] Searching new master from slaves..
Fri Feb 28 20:55:02 2020 - [info]  Candidate masters from the configuration file:
Fri Feb 28 20:55:02 2020 - [info]   192.168.98.10(192.168.98.10:3306)  Version=5.7.29-32-log (oldest major version between slaves) log-bin:enabled
Fri Feb 28 20:55:02 2020 - [info]     GTID ON
Fri Feb 28 20:55:02 2020 - [info]     Replicating from 192.168.98.11(192.168.98.11:3306)
Fri Feb 28 20:55:02 2020 - [info]     Primary candidate for the new Master (candidate_master is set)
Fri Feb 28 20:55:02 2020 - [info]  Non-candidate masters:
Fri Feb 28 20:55:02 2020 - [info]  Searching from candidate_master slaves which have received the latest relay log events..
Fri Feb 28 20:55:02 2020 - [info] New master is 192.168.98.10(192.168.98.10:3306)
Fri Feb 28 20:55:02 2020 - [info] Starting master failover..
Fri Feb 28 20:55:02 2020 - [info] 
From:
192.168.98.11(192.168.98.11:3306) (current master)
 +--192.168.98.10(192.168.98.10:3306)
 +--192.168.98.12(192.168.98.12:3306)

To:
192.168.98.10(192.168.98.10:3306) (new master)
 +--192.168.98.12(192.168.98.12:3306)
Fri Feb 28 20:55:02 2020 - [info] 
Fri Feb 28 20:55:02 2020 - [info] * Phase 3.3: New Master Recovery Phase..
Fri Feb 28 20:55:02 2020 - [info] 
Fri Feb 28 20:55:02 2020 - [info]  Waiting all logs to be applied.. 
Fri Feb 28 20:55:02 2020 - [info]   done.
Fri Feb 28 20:55:02 2020 - [info] Getting new master's binlog name and position..
Fri Feb 28 20:55:02 2020 - [info]  mysql-bin.000010:234
Fri Feb 28 20:55:02 2020 - [info]  All other slaves should start replication from here. Statement should be: CHANGE MASTER TO MASTER_HOST='192.168.98.10', MASTER_PORT=3306, MASTER_AUTO_POSITION=1, MASTER_USER='repler', MASTER_PASSWORD='xxx';
Fri Feb 28 20:55:02 2020 - [info] Master Recovery succeeded. File:Pos:Exec_Gtid_Set: mysql-bin.000010, 234, 3a60f8c7-592c-11ea-8cb1-000c2973aaf0:1-6,
68703597-592c-11ea-88b3-000c2998280b:1-4
Fri Feb 28 20:55:02 2020 - [info] Executing master IP activate script:
Fri Feb 28 20:55:02 2020 - [info]   /etc/masterha/scripts/master_ip_failover_vip --vip=192.168.98.100 --command=start --ssh_user=root --orig_master_host=192.168.98.11 --orig_master_ip=192.168.98.11 --orig_master_port=3306 --new_master_host=192.168.98.10 --new_master_ip=192.168.98.10 --new_master_port=3306 --new_master_user='mha'   --new_master_password=xxx
Enabling the VIP - 192.168.98.100 on the new master - 192.168.98.10 
Fake!!! 新主库 rpl_semi_sync_master_enabled=1 rpl_semi_sync_slave_enabled=0 
Set read_only=0 on the new master.
Creating app user on the new master..
Fri Feb 28 20:55:02 2020 - [info]  OK.
Fri Feb 28 20:55:02 2020 - [info] ** Finished master recovery successfully.
Fri Feb 28 20:55:02 2020 - [info] * Phase 3: Master Recovery Phase completed.
Fri Feb 28 20:55:02 2020 - [info] 
Fri Feb 28 20:55:02 2020 - [info] * Phase 4: Slaves Recovery Phase..
Fri Feb 28 20:55:02 2020 - [info] 
Fri Feb 28 20:55:02 2020 - [info] 
Fri Feb 28 20:55:02 2020 - [info] * Phase 4.1: Starting Slaves in parallel..
Fri Feb 28 20:55:02 2020 - [info] 
Fri Feb 28 20:55:02 2020 - [info] -- Slave recovery on host 192.168.98.12(192.168.98.12:3306) started, pid: 92955. Check tmp log /masterha/cls_all//192.168.98.12_3306_20200228205500.log if it takes time..
Fri Feb 28 20:55:03 2020 - [info] 
Fri Feb 28 20:55:03 2020 - [info] Log messages from 192.168.98.12 ...
Fri Feb 28 20:55:03 2020 - [info] 
Fri Feb 28 20:55:02 2020 - [info]  Resetting slave 192.168.98.12(192.168.98.12:3306) and starting replication from the new master 192.168.98.10(192.168.98.10:3306)..
Fri Feb 28 20:55:02 2020 - [info]  Executed CHANGE MASTER.
Fri Feb 28 20:55:02 2020 - [info]  Slave started.
Fri Feb 28 20:55:02 2020 - [info]  gtid_wait(3a60f8c7-592c-11ea-8cb1-000c2973aaf0:1-6,
68703597-592c-11ea-88b3-000c2998280b:1-4) completed on 192.168.98.12(192.168.98.12:3306). Executed 0 events.
Fri Feb 28 20:55:03 2020 - [info] End of log messages from 192.168.98.12.
Fri Feb 28 20:55:03 2020 - [info] -- Slave on host 192.168.98.12(192.168.98.12:3306) started.
Fri Feb 28 20:55:03 2020 - [info] All new slave servers recovered successfully.
Fri Feb 28 20:55:03 2020 - [info] 
Fri Feb 28 20:55:03 2020 - [info] * Phase 5: New master cleanup phase..
Fri Feb 28 20:55:03 2020 - [info] 
Fri Feb 28 20:55:03 2020 - [info] Resetting slave info on the new master..
Fri Feb 28 20:55:03 2020 - [info]  192.168.98.10: Resetting slave info succeeded.
Fri Feb 28 20:55:03 2020 - [info] Master failover to 192.168.98.10(192.168.98.10:3306) completed successfully.
Fri Feb 28 20:55:03 2020 - [info] 

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

cls_all: MySQL Master failover 192.168.98.11(192.168.98.11:3306) to 192.168.98.10(192.168.98.10:3306) succeeded

Master 192.168.98.11(192.168.98.11:3306) is down!

Check MHA Manager logs at localhost.localdomain:/masterha/cls_all/manager.log for details.

Started automated(non-interactive) failover.
Invalidated master IP address on 192.168.98.11(192.168.98.11:3306)
Selected 192.168.98.10(192.168.98.10:3306) as a new master.
192.168.98.10(192.168.98.10:3306): OK: Applying all logs succeeded.
192.168.98.10(192.168.98.10:3306): OK: Activated master IP address.
192.168.98.12(192.168.98.12:3306): OK: Slave started, replicating from 192.168.98.10(192.168.98.10:3306)
192.168.98.10(192.168.98.10:3306): Resetting slave info succeeded.
Master failover to 192.168.98.10(192.168.98.10:3306) completed successfully.
Fri Feb 28 20:55:03 2020 - [info] Sending mail..

           

阶段2

Executing master IP deactivation script , 下原主库上的vip

Fri Feb 28 20:55:01 2020 - [info] * Phase 2: Dead Master Shutdown Phase..
Fri Feb 28 20:55:01 2020 - [info] 
Fri Feb 28 20:55:01 2020 - [info] Forcing shutdown so that applications never connect to the current master..
Fri Feb 28 20:55:01 2020 - [info] Executing master IP deactivation script:
Fri Feb 28 20:55:01 2020 - [info]   /etc/masterha/scripts/master_ip_failover_vip --vip=192.168.98.100 --orig_master_host=192.168.98.11 --orig_master_ip=192.168.98.11 --orig_master_port=3306 --command=stopssh --ssh_user=root  
Disabling the VIP on old master: 192.168.98.11 
Fake!!! 原主库 rpl_semi_sync_master_enabled=0 rpl_semi_sync_slave_enabled=1 
Fri Feb 28 20:55:02 2020 - [info]  done.
Fri Feb 28 20:55:02 2020 - [warning] shutdown_script is not set. Skipping explicit shutting down of the dead master.
Fri Feb 28 20:55:02 2020 - [info] * Phase 2: Dead Master Shutdown Phase completed.
           

阶段3.3

Executing master IP activate script新主库添加vip

Fri Feb 28 20:55:02 2020 - [info] * Phase 3.3: New Master Recovery Phase..
Fri Feb 28 20:55:02 2020 - [info] 
Fri Feb 28 20:55:02 2020 - [info]  Waiting all logs to be applied.. 
Fri Feb 28 20:55:02 2020 - [info]   done.
Fri Feb 28 20:55:02 2020 - [info] Getting new master's binlog name and position..
Fri Feb 28 20:55:02 2020 - [info]  mysql-bin.000010:234
Fri Feb 28 20:55:02 2020 - [info]  All other slaves should start replication from here. Statement should be: CHANGE MASTER TO MASTER_HOST='192.168.98.10', MASTER_PORT=3306, MASTER_AUTO_POSITION=1, MASTER_USER='repler', MASTER_PASSWORD='xxx';
Fri Feb 28 20:55:02 2020 - [info] Master Recovery succeeded. File:Pos:Exec_Gtid_Set: mysql-bin.000010, 234, 3a60f8c7-592c-11ea-8cb1-000c2973aaf0:1-6,
68703597-592c-11ea-88b3-000c2998280b:1-4
Fri Feb 28 20:55:02 2020 - [info] Executing master IP activate script:
Fri Feb 28 20:55:02 2020 - [info]   /etc/masterha/scripts/master_ip_failover_vip --vip=192.168.98.100 --command=start --ssh_user=root --orig_master_host=192.168.98.11 --orig_master_ip=192.168.98.11 --orig_master_port=3306 --new_master_host=192.168.98.10 --new_master_ip=192.168.98.10 --new_master_port=3306 --new_master_user='mha'   --new_master_password=xxx
Enabling the VIP - 192.168.98.100 on the new master - 192.168.98.10 
Fake!!! 新主库 rpl_semi_sync_master_enabled=1 rpl_semi_sync_slave_enabled=0 
Set read_only=0 on the new master.
Creating app user on the new master..
Fri Feb 28 20:55:02 2020 - [info]  OK.
Fri Feb 28 20:55:02 2020 - [info] ** Finished master recovery successfully.
Fri Feb 28 20:55:02 2020 - [info] * Phase 3: Master Recovery Phase completed.
           

如上所示, 我们可以分别在两个阶段做一些操作, 比如修改半同步的参数等.

继续阅读