• mysql 高可用架构 mha 之三 master_ip_online_change


    os:centos 7.4
    mysql: 5.7
    mha: 0.58

    这一篇blog介绍下 master_ip_online_change 的设置。

    ip 规划如下:

    192.168.56.101 node1 (mha manager)

    192.168.56.102 node2 (mysql master)
    192.168.56.103 node3 (mysql master candicate)
    192.168.56.104 node4 (mysql slave)

    master 的 vip 192.168.56.100/24

    mha 提供快速切换(switchover)和优雅的阻塞写入,这个切换过程只需要 0.5-2s 的时间,这段时间内数据是无法写入的。
    在很多情况下,0.5-2s 的阻塞写入是可以接受的。
    因此切换主服务器不需要计划分配维护时间窗口。

    master_ip_online_change参数

    mha manager 节点上

    # vi /etc/masterha/app1.cnf 
    
    #手动switchover时候的切换脚本
    master_ip_online_change_script= /usr/local/bin/master_ip_online_change

    master_ip_online_change_script 指的是手动执行mysql master switchover时执行的切换脚本。
    没有使用 keepalived ,通过脚本的方式管理vip。

    # cp /usr/local/bin/master_ip_online_change /usr/local/bin/master_ip_online_change.bak
    # vi /usr/local/bin/master_ip_online_change
    
    #!/usr/bin/env perl
    
    use strict;
    use warnings FATAL => 'all';
    
    use Getopt::Long;
    use MHA::DBHelper;
    use MHA::NodeUtil;
    use Time::HiRes qw( sleep gettimeofday tv_interval );
    use Data::Dumper;
    
    my $_tstart;
    my $_running_interval = 0.1;
    my (
      $command,          
      $orig_master_is_new_slave, $orig_master_host, $orig_master_ip,  $orig_master_port, $orig_master_user,    $orig_master_password, $orig_master_ssh_user,
      $new_master_host,          $new_master_ip,    $new_master_port, $new_master_user,  $new_master_password, $new_master_ssh_user,
    );
    
    
    my $vip = '192.168.56.100';
    my $brdc = '192.168.56.255';
    my $ifdev = 'enp0s8';
    my $key = '1';
    my $ssh_start_vip = "/usr/sbin/ip addr add $vip/24 brd $brdc dev $ifdev label $ifdev:$key;/usr/sbin/arping -q -A -c 1 -I $ifdev $vip;iptables -F;";
    my $ssh_stop_vip = "/usr/sbin/ip addr del $vip/24 dev $ifdev label $ifdev:$key";
    
    
    GetOptions(
      'command=s'                => $command,
      'orig_master_is_new_slave' => $orig_master_is_new_slave,
      'orig_master_host=s'       => $orig_master_host,
      'orig_master_ip=s'         => $orig_master_ip,
      'orig_master_port=i'       => $orig_master_port,
      'orig_master_user=s'       => $orig_master_user,
      'orig_master_password=s'   => $orig_master_password,
      'orig_master_ssh_user=s'   => $orig_master_ssh_user,
      '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,
      'new_master_ssh_user=s'    => $new_master_ssh_user,
    );
    
    exit &main();
    
    sub current_time_us {
      my ( $sec, $microsec ) = gettimeofday();
      my $curdate = localtime($sec);
      return $curdate . " " . sprintf( "%06d", $microsec );
    }
    
    sub sleep_until {
      my $elapsed = tv_interval($_tstart);
      if ( $_running_interval > $elapsed ) {
        sleep( $_running_interval - $elapsed );
      }
    }
    
    sub get_threads_util {
      my $dbh                    = shift;
      my $my_connection_id       = shift;
      my $running_time_threshold = shift;
      my $type                   = shift;
      $running_time_threshold = 0 unless ($running_time_threshold);
      $type                   = 0 unless ($type);
      my @threads;
    
      my $sth = $dbh->prepare("SHOW PROCESSLIST");
      $sth->execute();
    
      while ( my $ref = $sth->fetchrow_hashref() ) {
        my $id         = $ref->{Id};
        my $user       = $ref->{User};
        my $host       = $ref->{Host};
        my $command    = $ref->{Command};
        my $state      = $ref->{State};
        my $query_time = $ref->{Time};
        my $info       = $ref->{Info};
        $info =~ s/^s*(.*?)s*$/$1/ if defined($info);
        next if ( $my_connection_id == $id );
        next if ( defined($query_time) && $query_time < $running_time_threshold );
        next if ( defined($command)    && $command eq "Binlog Dump" );
        next if ( defined($user)       && $user eq "system user" );
        next
          if ( defined($command)
          && $command eq "Sleep"
          && defined($query_time)
          && $query_time >= 1 );
    
        if ( $type >= 1 ) {
          next if ( defined($command) && $command eq "Sleep" );
          next if ( defined($command) && $command eq "Connect" );
        }
    
        if ( $type >= 2 ) {
          next if ( defined($info) && $info =~ m/^select/i );
          next if ( defined($info) && $info =~ m/^show/i );
        }
    
        push @threads, $ref;
      }
      return @threads;
    }
    
    sub main {
      if ( $command eq "stop" ) {
        ## Gracefully killing connections on the current master
        # 1. Set read_only= 1 on the new master
        # 2. DROP USER so that no app user can establish new connections
        # 3. Set read_only= 1 on the current master
        # 4. Kill current queries
        # * Any database access failure will result in script die.
        my $exit_code = 1;
        eval {
          ## Setting read_only=1 on the new master (to avoid accident)
          my $new_master_handler = new MHA::DBHelper();
    
          # args: hostname, port, user, password, raise_error(die_on_error)_or_not
          $new_master_handler->connect( $new_master_ip, $new_master_port,
            $new_master_user, $new_master_password, 1 );
          print current_time_us() . " Set read_only on the new master.. ";
          $new_master_handler->enable_read_only();
          if ( $new_master_handler->is_read_only() ) {
            print "ok.
    ";
          }
          else {
            die "Failed!
    ";
          }
          $new_master_handler->disconnect();
    
          # Connecting to the orig master, die if any database error happens
          my $orig_master_handler = new MHA::DBHelper();
          $orig_master_handler->connect( $orig_master_ip, $orig_master_port,
            $orig_master_user, $orig_master_password, 1 );
    
          ## Drop application user so that nobody can connect. Disabling per-session binlog beforehand
          #$orig_master_handler->disable_log_bin_local();
          #print current_time_us() . " Drpping app user on the orig master..
    ";
          #FIXME_xxx_drop_app_user($orig_master_handler);
    
          ## Waiting for N * 100 milliseconds so that current connections can exit
          my $time_until_read_only = 15;
          $_tstart = [gettimeofday];
          my @threads = get_threads_util( $orig_master_handler->{dbh},
            $orig_master_handler->{connection_id} );
          while ( $time_until_read_only > 0 && $#threads >= 0 ) {
            if ( $time_until_read_only % 5 == 0 ) {
              printf
    "%s Waiting all running %d threads are disconnected.. (max %d milliseconds)
    ",
                current_time_us(), $#threads + 1, $time_until_read_only * 100;
              if ( $#threads < 5 ) {
                print Data::Dumper->new( [$_] )->Indent(0)->Terse(1)->Dump . "
    "
                  foreach (@threads);
              }
            }
            sleep_until();
            $_tstart = [gettimeofday];
            $time_until_read_only--;
            @threads = get_threads_util( $orig_master_handler->{dbh},
              $orig_master_handler->{connection_id} );
          }
    
          ## Setting read_only=1 on the current master so that nobody(except SUPER) can write
          print current_time_us() . " Set read_only=1 on the orig master.. ";
          $orig_master_handler->enable_read_only();
          if ( $orig_master_handler->is_read_only() ) {
            print "ok.
    ";
          }
          else {
            die "Failed!
    ";
          }
    
          ## Waiting for M * 100 milliseconds so that current update queries can complete
          my $time_until_kill_threads = 5;
          @threads = get_threads_util( $orig_master_handler->{dbh},
            $orig_master_handler->{connection_id} );
          while ( $time_until_kill_threads > 0 && $#threads >= 0 ) {
            if ( $time_until_kill_threads % 5 == 0 ) {
              printf
    "%s Waiting all running %d queries are disconnected.. (max %d milliseconds)
    ",
                current_time_us(), $#threads + 1, $time_until_kill_threads * 100;
              if ( $#threads < 5 ) {
                print Data::Dumper->new( [$_] )->Indent(0)->Terse(1)->Dump . "
    "
                  foreach (@threads);
              }
            }
            sleep_until();
            $_tstart = [gettimeofday];
            $time_until_kill_threads--;
            @threads = get_threads_util( $orig_master_handler->{dbh},
              $orig_master_handler->{connection_id} );
          }
    
    
    
                    print "Disabling the VIP on old master: $orig_master_host 
    ";
                    &stop_vip();     
    
    
          ## Terminating all threads
          print current_time_us() . " Killing all application threads..
    ";
          $orig_master_handler->kill_threads(@threads) if ( $#threads >= 0 );
          print current_time_us() . " done.
    ";
          #$orig_master_handler->enable_log_bin_local();
          $orig_master_handler->disconnect();
    
          ## After finishing the script, MHA executes FLUSH TABLES WITH READ LOCK
          $exit_code = 0;
        };
        if ($@) {
          warn "Got Error: $@
    ";
          exit $exit_code;
        }
        exit $exit_code;
      }
      elsif ( $command eq "start" ) {
        ## Activating master ip on the new master
        # 1. Create app user with write privileges
        # 2. Moving backup script if needed
        # 3. Register new master's ip to the catalog database
    
    # We don't return error even though activating updatable accounts/ip failed so that we don't interrupt slaves' recovery.
    # If exit code is 0 or 10, MHA does not abort
        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 current_time_us() . " Set read_only=0 on the new master.
    ";
          $new_master_handler->disable_read_only();
    
          ## Creating an app user on the new master
          #print current_time_us() . " Creating app user on the new master..
    ";
          #FIXME_xxx_create_app_user($new_master_handler);
          #$new_master_handler->enable_log_bin_local();
          $new_master_handler->disconnect();
    
          ## Update master ip on the catalog database, etc
                    print "Enabling the VIP - $vip on the new master - $new_master_host 
    ";
                    &start_vip();
                    $exit_code = 0;
        };
        if ($@) {
          warn "Got Error: $@
    ";
          exit $exit_code;
        }
        exit $exit_code;
      }
      elsif ( $command eq "status" ) {
    
        # do nothing
        exit 0;
      }
      else {
        &usage();
        exit 1;
      }
    }
    
    # A simple system call that enable the VIP on the new master 
    sub start_vip() {
        `ssh $new_master_ssh_user@$new_master_host " $ssh_start_vip "`;
    }
    # A simple system call that disable the VIP on the old_master
    sub stop_vip() {
        `ssh $orig_master_ssh_user@$orig_master_host " $ssh_stop_vip "`;
    }
    
    sub usage {
      print
    "Usage: master_ip_online_change --command=start|stop|status --orig_master_host=host --orig_master_ip=ip --orig_master_port=port --orig_master_user=user --orig_master_password=password --orig_master_ssh_user=sshuser --new_master_host=host --new_master_ip=ip --new_master_port=port --new_master_user=user --new_master_password=password --new_master_ssh_user=sshuser 
    ";
      die;
    }

    更换ip后,一定要执行下 arping

    验证 switchover (online change)

    手动切换之前必须先停止 mha manager。

    关闭 mha manager

    关闭 manager

    # masterha_stop --conf=/etc/masterha/app1.cnf

    查看 manager status

    # masterha_check_status --conf=/etc/masterha/app1.cnf

    查看 manager log

    # tail -n 1000 -f /var/log/masterha/app1-manager.log

    检查复制环境ssh

    # masterha_check_ssh --conf=/etc/masterha/app1.cnf 

    检查整个复制环境

    # masterha_check_repl --conf=/etc/masterha/app1.cnf

    手动执行

    node2 目前是 master,node3 是 node2 的 slave,
    需要将 node3 提升为 master,node2 为 node3 的 slave。

    # masterha_master_switch --conf=/etc/masterha/app1.cnf --master_state=alive --orig_master_is_new_slave  --new_master_host=192.168.56.103 --new_master_port=3306 --running_updates_limit=10000
    
    
    Tue Aug  7 09:33:42 2018 - [info] * Phase 1: Configuration Check Phase..
    Tue Aug  7 09:34:05 2018 - [info] ** Phase 1: Configuration Check Phase completed.
    
    Tue Aug  7 09:34:05 2018 - [info] * Phase 2: Rejecting updates Phase..
    Tue Aug  7 09:34:05 2018 - [info] Executing master ip online change script to allow write on the new master:
    Tue Aug  7 09:34:05 2018 - [info]   /usr/local/bin/master_ip_online_change --command=start --orig_master_host=192.168.56.102 --orig_master_ip=192.168.56.102 --orig_master_port=3306 --orig_master_user='mha_mon' --new_master_host=192.168.56.103 --new_master_ip=192.168.56.103 --new_master_port=3306 --new_master_user='mha_mon' --orig_master_ssh_user=root --new_master_ssh_user=root   --orig_master_is_new_slave --orig_master_password=xxx --new_master_password=xxx
    
    Tue Aug  7 09:34:06 2018 - [info]  Executed CHANGE MASTER.
    Tue Aug  7 09:34:06 2018 - [info] Starting orig master as a new slave..
    Tue Aug  7 09:34:06 2018 - [info]  Resetting slave 192.168.56.102(192.168.56.102:3306) and starting replication from the new master 192.168.56.103(192.168.56.103:3306)..
    Tue Aug  7 09:34:07 2018 - [info]  Executed CHANGE MASTER.
    Tue Aug  7 09:34:07 2018 - [info]  Slave started.
    Tue Aug  7 09:34:07 2018 - [info] All new slave servers switched successfully.
    Tue Aug  7 09:34:07 2018 - [info] 
    Tue Aug  7 09:34:07 2018 - [info] * Phase 5: New master cleanup phase..
    Tue Aug  7 09:34:07 2018 - [info] 
    Tue Aug  7 09:34:07 2018 - [info]  192.168.56.103: Resetting slave info succeeded.
    Tue Aug  7 09:34:07 2018 - [info] Switching master to 192.168.56.103(192.168.56.103:3306) completed successfully

    上面的日志时挑选了一些关键信息,完整的日志输出在后面。

    查看 node3 的信息

    # ifconfig  enp0s8:1
    enp0s8:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.56.100  netmask 255.255.255.0  broadcast 192.168.56.255
            ether 08:00:27:e8:24:31  txqueuelen 1000  (Ethernet)
    
    mysql> show processlist;
    +----+------------+-------------+------+-------------+------+---------------------------------------------------------------+------------------+
    | Id | User       | Host        | db   | Command     | Time | State                                                         | Info             |
    +----+------------+-------------+------+-------------+------+---------------------------------------------------------------+------------------+
    |  2 | root       | localhost   | NULL | Query       |    0 | starting                                                      | show processlist |
    | 17 | replicator | node4:57638 | NULL | Binlog Dump |  524 | Master has sent all binlog to slave; waiting for more updates | NULL             |
    | 18 | replicator | node2:55922 | NULL | Binlog Dump |  523 | Master has sent all binlog to slave; waiting for more updates | NULL             |
    +----+------------+-------------+------+-------------+------+---------------------------------------------------------------+------------------+
    3 rows in set (0.00 sec)
    

    查看 node2 的 mysql slave status

    mysql> show slave statusG
    *************************** 1. row ***************************
                   Slave_IO_State: Waiting for master to send event
                      Master_Host: 192.168.56.103
                      Master_User: replicator
                      Master_Port: 3306
                    Connect_Retry: 60
                  Master_Log_File: mysql-bin.000008
              Read_Master_Log_Pos: 154
                   Relay_Log_File: node2-relay-bin.000002
                    Relay_Log_Pos: 320
            Relay_Master_Log_File: mysql-bin.000008
                 Slave_IO_Running: Yes
                Slave_SQL_Running: Yes
    

    查看 node4 的 mysql slave status

    mysql> show slave statusG
    *************************** 1. row ***************************
                   Slave_IO_State: Waiting for master to send event
                      Master_Host: 192.168.56.103
                      Master_User: replicator
                      Master_Port: 3306
                    Connect_Retry: 60
                  Master_Log_File: mysql-bin.000008
              Read_Master_Log_Pos: 154
                   Relay_Log_File: node4-relay-bin.000002
                    Relay_Log_Pos: 320
            Relay_Master_Log_File: mysql-bin.000008
                 Slave_IO_Running: Yes
                Slave_SQL_Running: Yes
    

    完美!

    启动 mha manager

    switchover成功后,修改/etc/masterha/app1.cnf,然后再启动 mha manager
    启动 manager

    # nohup masterha_manager --conf=/etc/masterha/app1.cnf --remove_dead_master_conf --ignore_last_failover < /dev/null > /var/log/masterha/app1-manager.log 2>&1 &  

    查看 manager status

    # masterha_check_status --conf=/etc/masterha/app1.cnf

    查看 manager log

    # tail -n 1000 -f /var/log/masterha/app1-manager.log

    vip 的一些操作

    # ip addr add 192.168.56.100/24 brd 192.168.56.255 dev enp0s8 label enp0s8:1
    # /usr/sbin/arping -q -A -c 1 -I enp0s8 192.168.56.100
    # ip addr del 192.168.56.100/24 dev enp0s8 label enp0s8:1

    slave 的设置

    mysql> change master to
      master_host='192.168.56.102',
      master_user='replicator',
      master_password='2wsx3edc',
      master_port=3306,
      master_log_file='mysql-bin.000007',
      master_log_pos=154;
    mysql> start slave; 

    参考:
    https://github.com/yoshinorim/mha4mysql-manager/wiki
    https://github.com/yoshinorim/mha4mysql-manager/wiki/Parameters

    https://github.com/yoshinorim/mha4mysql-manager/releases
    https://github.com/yoshinorim/mha4mysql-node/releases

    https://github.com/yoshinorim/mha4mysql-manager
    https://github.com/yoshinorim/mha4mysql-node

    switchover的过程,基本为以下步骤:

    1.检测复制设置和确定当前主服务器
    2.确定新的主服务器
    3.阻塞写入到当前主服务器
    4.等待所有从服务器赶上复制
    5.授予写入到新的主服务器
    6.重新设置从服务器

    下面是完整日志输出

    # masterha_master_switch --conf=/etc/masterha/app1.cnf --master_state=alive --orig_master_is_new_slave  --new_master_host=192.168.56.103 --new_master_port=3306 --running_updates_limit=10000
    
    
    Tue Aug  7 09:33:42 2018 - [info] MHA::MasterRotate version 0.58.
    Tue Aug  7 09:33:42 2018 - [info] Starting online master switch..
    Tue Aug  7 09:33:42 2018 - [info] 
    Tue Aug  7 09:33:42 2018 - [info] * Phase 1: Configuration Check Phase..
    Tue Aug  7 09:33:42 2018 - [info] 
    Tue Aug  7 09:33:42 2018 - [info] Reading default configuration from /etc/masterha_default.cnf..
    Tue Aug  7 09:33:42 2018 - [info] Reading application default configuration from /etc/masterha/app1.cnf..
    Tue Aug  7 09:33:42 2018 - [info] Reading server configuration from /etc/masterha/app1.cnf..
    Tue Aug  7 09:33:43 2018 - [info] GTID failover mode = 0
    Tue Aug  7 09:33:43 2018 - [info] Current Alive Master: 192.168.56.102(192.168.56.102:3306)
    Tue Aug  7 09:33:43 2018 - [info] Alive Slaves:
    Tue Aug  7 09:33:43 2018 - [info]   192.168.56.103(192.168.56.103:3306)  Version=5.7.22-log (oldest major version between slaves) log-bin:enabled
    Tue Aug  7 09:33:43 2018 - [info]     Replicating from 192.168.56.102(192.168.56.102:3306)
    Tue Aug  7 09:33:43 2018 - [info]     Primary candidate for the new Master (candidate_master is set)
    Tue Aug  7 09:33:43 2018 - [info]   192.168.56.104(192.168.56.104:3306)  Version=5.7.23-log (oldest major version between slaves) log-bin:enabled
    Tue Aug  7 09:33:43 2018 - [info]     Replicating from 192.168.56.102(192.168.56.102:3306)
    
    It is better to execute FLUSH NO_WRITE_TO_BINLOG TABLES on the master before switching. Is it ok to execute on 192.168.56.102(192.168.56.102:3306)? (YES/no): yes
    Tue Aug  7 09:33:55 2018 - [info] Executing FLUSH NO_WRITE_TO_BINLOG TABLES. This may take long time..
    Tue Aug  7 09:33:55 2018 - [info]  ok.
    Tue Aug  7 09:33:55 2018 - [info] Checking MHA is not monitoring or doing failover..
    Tue Aug  7 09:33:55 2018 - [info] Checking replication health on 192.168.56.103..
    Tue Aug  7 09:33:55 2018 - [info]  ok.
    Tue Aug  7 09:33:55 2018 - [info] Checking replication health on 192.168.56.104..
    Tue Aug  7 09:33:55 2018 - [info]  ok.
    Tue Aug  7 09:33:55 2018 - [info] 192.168.56.103 can be new master.
    Tue Aug  7 09:33:55 2018 - [info] 
    From:
    192.168.56.102(192.168.56.102:3306) (current master)
     +--192.168.56.103(192.168.56.103:3306)
     +--192.168.56.104(192.168.56.104:3306)
    
    To:
    192.168.56.103(192.168.56.103:3306) (new master)
     +--192.168.56.104(192.168.56.104:3306)
     +--192.168.56.102(192.168.56.102:3306)
    
    Starting master switch from 192.168.56.102(192.168.56.102:3306) to 192.168.56.103(192.168.56.103:3306)? (yes/NO): yes
    Tue Aug  7 09:34:05 2018 - [info] Checking whether 192.168.56.103(192.168.56.103:3306) is ok for the new master..
    Tue Aug  7 09:34:05 2018 - [info]  ok.
    Tue Aug  7 09:34:05 2018 - [info] 192.168.56.102(192.168.56.102:3306): SHOW SLAVE STATUS returned empty result. To check replication filtering rules, temporarily executing CHANGE MASTER to a dummy host.
    Tue Aug  7 09:34:05 2018 - [info] 192.168.56.102(192.168.56.102:3306): Resetting slave pointing to the dummy host.
    Tue Aug  7 09:34:05 2018 - [info] ** Phase 1: Configuration Check Phase completed.
    Tue Aug  7 09:34:05 2018 - [info] 
    Tue Aug  7 09:34:05 2018 - [info] * Phase 2: Rejecting updates Phase..
    Tue Aug  7 09:34:05 2018 - [info] 
    Tue Aug  7 09:34:05 2018 - [info] Executing master ip online change script to disable write on the current master:
    Tue Aug  7 09:34:05 2018 - [info]   /usr/local/bin/master_ip_online_change --command=stop --orig_master_host=192.168.56.102 --orig_master_ip=192.168.56.102 --orig_master_port=3306 --orig_master_user='mha_mon' --new_master_host=192.168.56.103 --new_master_ip=192.168.56.103 --new_master_port=3306 --new_master_user='mha_mon' --orig_master_ssh_user=root --new_master_ssh_user=root   --orig_master_is_new_slave --orig_master_password=xxx --new_master_password=xxx
    Tue Aug  7 09:34:05 2018 375945 Set read_only on the new master.. ok.
    Tue Aug  7 09:34:05 2018 378356 Set read_only=1 on the orig master.. ok.
    Disabling the VIP on old master: 192.168.56.102 
    Tue Aug  7 09:34:05 2018 688030 Killing all application threads..
    Tue Aug  7 09:34:05 2018 688091 done.
    Tue Aug  7 09:34:05 2018 - [info]  ok.
    Tue Aug  7 09:34:05 2018 - [info] Locking all tables on the orig master to reject updates from everybody (including root):
    Tue Aug  7 09:34:05 2018 - [info] Executing FLUSH TABLES WITH READ LOCK..
    Tue Aug  7 09:34:05 2018 - [info]  ok.
    Tue Aug  7 09:34:05 2018 - [info] Orig master binlog:pos is mysql-bin.000007:154.
    Tue Aug  7 09:34:05 2018 - [info]  Waiting to execute all relay logs on 192.168.56.103(192.168.56.103:3306)..
    Tue Aug  7 09:34:05 2018 - [info]  master_pos_wait(mysql-bin.000007:154) completed on 192.168.56.103(192.168.56.103:3306). Executed 0 events.
    Tue Aug  7 09:34:05 2018 - [info]   done.
    Tue Aug  7 09:34:05 2018 - [info] Getting new master's binlog name and position..
    Tue Aug  7 09:34:05 2018 - [info]  mysql-bin.000008:154
    Tue Aug  7 09:34:05 2018 - [info]  All other slaves should start replication from here. Statement should be: CHANGE MASTER TO MASTER_HOST='192.168.56.103', MASTER_PORT=3306, MASTER_LOG_FILE='mysql-bin.000008', MASTER_LOG_POS=154, MASTER_USER='replicator', MASTER_PASSWORD='xxx';
    Tue Aug  7 09:34:05 2018 - [info] Executing master ip online change script to allow write on the new master:
    Tue Aug  7 09:34:05 2018 - [info]   /usr/local/bin/master_ip_online_change --command=start --orig_master_host=192.168.56.102 --orig_master_ip=192.168.56.102 --orig_master_port=3306 --orig_master_user='mha_mon' --new_master_host=192.168.56.103 --new_master_ip=192.168.56.103 --new_master_port=3306 --new_master_user='mha_mon' --orig_master_ssh_user=root --new_master_ssh_user=root   --orig_master_is_new_slave --orig_master_password=xxx --new_master_password=xxx
    Tue Aug  7 09:34:05 2018 773788 Set read_only=0 on the new master.
    Enabling the VIP - 192.168.56.100 on the new master - 192.168.56.103 
    Tue Aug  7 09:34:05 2018 - [info]  ok.
    Tue Aug  7 09:34:05 2018 - [info] 
    Tue Aug  7 09:34:05 2018 - [info] * Switching slaves in parallel..
    Tue Aug  7 09:34:05 2018 - [info] 
    Tue Aug  7 09:34:05 2018 - [info] -- Slave switch on host 192.168.56.104(192.168.56.104:3306) started, pid: 32206
    Tue Aug  7 09:34:05 2018 - [info] 
    Tue Aug  7 09:34:06 2018 - [info] Log messages from 192.168.56.104 ...
    Tue Aug  7 09:34:06 2018 - [info] 
    Tue Aug  7 09:34:05 2018 - [info]  Waiting to execute all relay logs on 192.168.56.104(192.168.56.104:3306)..
    Tue Aug  7 09:34:06 2018 - [info]  master_pos_wait(mysql-bin.000007:154) completed on 192.168.56.104(192.168.56.104:3306). Executed 0 events.
    Tue Aug  7 09:34:06 2018 - [info]   done.
    Tue Aug  7 09:34:06 2018 - [info]  Resetting slave 192.168.56.104(192.168.56.104:3306) and starting replication from the new master 192.168.56.103(192.168.56.103:3306)..
    Tue Aug  7 09:34:06 2018 - [info]  Executed CHANGE MASTER.
    Tue Aug  7 09:34:06 2018 - [info]  Slave started.
    Tue Aug  7 09:34:06 2018 - [info] End of log messages from 192.168.56.104 ...
    Tue Aug  7 09:34:06 2018 - [info] 
    Tue Aug  7 09:34:06 2018 - [info] -- Slave switch on host 192.168.56.104(192.168.56.104:3306) succeeded.
    Tue Aug  7 09:34:06 2018 - [info] Unlocking all tables on the orig master:
    Tue Aug  7 09:34:06 2018 - [info] Executing UNLOCK TABLES..
    Tue Aug  7 09:34:06 2018 - [info]  ok.
    Tue Aug  7 09:34:06 2018 - [info] Starting orig master as a new slave..
    Tue Aug  7 09:34:06 2018 - [info]  Resetting slave 192.168.56.102(192.168.56.102:3306) and starting replication from the new master 192.168.56.103(192.168.56.103:3306)..
    Tue Aug  7 09:34:07 2018 - [info]  Executed CHANGE MASTER.
    Tue Aug  7 09:34:07 2018 - [info]  Slave started.
    Tue Aug  7 09:34:07 2018 - [info] All new slave servers switched successfully.
    Tue Aug  7 09:34:07 2018 - [info] 
    Tue Aug  7 09:34:07 2018 - [info] * Phase 5: New master cleanup phase..
    Tue Aug  7 09:34:07 2018 - [info] 
    Tue Aug  7 09:34:07 2018 - [info]  192.168.56.103: Resetting slave info succeeded.
    Tue Aug  7 09:34:07 2018 - [info] Switching master to 192.168.56.103(192.168.56.103:3306) completed successfully.
    
    
  • 相关阅读:
    Linux下查看网卡驱动和版本信息
    HTML <!--...--> 标签
    linux物理网卡检测命令mii-tool
    Git错误non-fast-forward后的冲突解决
    ubuntu上解决访问github慢的方法
    右侧添加悬浮打赏功能
    VSCode 预览 .md 文件
    Matlab绘制三维曲面(以二维高斯函数为例)
    matlab的三维绘图和四维绘图
    ubuntu查看文件和文件夹大小
  • 原文地址:https://www.cnblogs.com/ctypyb2002/p/9792909.html
Copyright © 2020-2023  润新知