MHA高可用+VIP漂移

news/发布时间2024/5/15 18:37:17

目录
  • 一、环境搭建
    • 1、关闭防火墙firewalld,selinux
    • 2、每台主机安装MySQL
  • 二、基于GTID的主从复制
    • 1、修改/etc/my.cnf文件
    • 2、检查GTID状态
    • 3、配置主从复制
    • 4、从库设置
  • 三、部署MHA
    • 1、准备环境(所有节点)
    • 2、部署管理节点(可以部署在任何机器上)
    • 3、配置ssh信任
    • 4、启动测试(manage节点)
  • 四、启动MHA
  • 五、切换master测试
    • 1、检查两从复制情况
    • 2、停掉主库
    • 3、手动将主库以slave身份加回去
  • 六、配置VIP漂移
    • 1、编辑配置文件
    • 2、编辑MHA自带的脚本
    • 3、手动绑定VIP(master节点)
    • 4、启动测试(manage节点)
    • 5、重启MHA(manage节点)
    • 6、测试IP漂移

一、环境搭建

涉及主机

主机名 IP地址
db01(master) 192.168.112.40
db02(slave1) 192.168.112.50
db03(slave2) 192.168.112.60

1、关闭防火墙firewalld,selinux

systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i 's/SELINUX=enforcing /SELINUX=disabled/g' /etc/selinux/config

2、每台主机安装MySQL

#二进制安装
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz
tar xzvf mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz
mkdir /application
mv mysql-5.6.40-linux-glibc2.12-x86_64 /application/mysql-5.6.40
ln -s /application/mysql-5.6.40/ /application/mysql
cd /application/mysql/support-files/
\cp my-default.cnf /etc/my.cnf
cp mysql.server /etc/init.d/mysqld
cd /application/mysql/scripts
useradd mysql -s /sbin/nologin -M
yum -y install autoconf
cd /application/mysql/scripts/
./mysql_install_db --user=mysql --basedir=/application/mysql --data=/application/mysql/data
echo 'export PATH="/application/mysql/bin:$PATH"' >> /etc/profile.d/mysql.sh
source /etc/profile
sed -i 's#/usr/local#/application#g' /etc/init.d/mysqld /application/mysql/bin/mysqld_safe
#指定MySQL安装根目录以及数据目录
vim /etc/my.cnf
basedir = /application/mysql/
datadir = /application/mysql/data
#设置密码
mysqladmin -uroot password '123'

二、基于GTID的主从复制

1、修改/etc/my.cnf文件

主库

vim /etc/my.cnf
[mysqld]	#在mysqld标签下配置
server_id=1
log_bin=mysql-bin	#开启binlog日志
skip-name-resolv	#跳过域名解析
gtid_mode=ON
log_slave_updates	#开启slave binlog同步
enforce_gtid_consistency	#不允许任何违反GTID一致性
[root@db01 ~]# /etc/init.d/mysqld restart	#重启MySQL

所有主机

#创建主从复制用户
mysql -uroot -p123	#登录数据库
grant replication slave on *.* to slave@'192.168.112.%' identified by '123';	#创建slave用户

从库

[root@db02 ~]# vim /etc/my.cnf[mysqld]	#在mysqld标签下配置
server_id=2	#主库server-id为1,从库必须大于1
log_bin=mysql-bin	#开启binlog日志
gtid_mode=ON
log_slave_updates	#开启slave binlog同步
enforce_gtid_consistency	#不允许任何违反GTID一致性
[root@db02 ~]# /etc/init.d/mysqld restart	#重启MySQL[root@db03 ~]# vim /etc/my.cnf[mysqld]	#在mysqld标签下配置
server_id=3	#主库server-id为1,从库必须大于1
log_bin=mysql-bin	#开启binlog日志
gtid_mode=ON
log_slave_updates	#开启slave binlog同步
enforce_gtid_consistency	#不允许任何违反GTID一致性
[root@db02 ~]# /etc/init.d/mysqld restart	#重启MySQL

2、检查GTID状态

主库上查看

show global variables like '%gtid%';

image-20240328221422017

3、配置主从复制

从库配置

mysql> change master to-> master_host='192.168.112.40',-> master_user='slave',-> master_password='123',-> master_auto_position=1;mysql> start slave;
mysql> show slave status\G;	#确保从库的IO和SQL线程开启Yes

image-20240328222915740

4、从库设置

mysql> set global relay_log_purge = 0;	#禁用自动删除relay log 功能
mysql> set global read_only=1;	#设置从库只读
[root@mysql-db02 ~]# vim /etc/my.cnf
#编辑配置文件
[mysqld]
#在mysqld标签下添加
relay_log_purge = 0
#禁用自动删除relay log 永久生效

三、部署MHA

1、准备环境(所有节点)

#下载工具包
cd && wget https://download.s21i.faiusr.com/23126342/0/0/ABUIABBPGAAg3OHUiAYolpPt7AQ.zip?f=mysql-master-ha.zip&v=1628778716
#安装依赖包
yum install -y perl-DBD-MySQL
yum install -y unzip
mv ABUIABBPGAAg3OHUiAYolpPt7AQ.zip\?f\=mysql-master-ha.zip master-ha.zip
unzip master-ha.zip
cd mysql-master-ha/
#安装node包
rpm -ivh mha4mysql-node-0.56-0.el6.noarch.rpm
#登录数据库
mysql -uroot -p123
#添加MHA管理账号
mysql> grant all privileges on *.* to mha@'192.168.112.%' identified by 'mha';
#查看账号是否添加成功
mysql> select user,host,password from mysql.user;
#创建软链接
ln -s /application/mysql/bin/mysqlbinlog /usr/bin/mysqlbinlog
ln -s /application/mysql/bin/mysql /usr/bin/mysql

2、部署管理节点(可以部署在任何机器上)

这里选择db03作为管理节点

[root@db03 ~]# yum install -y epel-release
#安装manager依赖包
[root@db03 ~]# yum install -y perl-Config-Tiny epel-release perl-Log-Dispatch perl-Parallel-ForkManager perl-Time-HiRes
#安装manager包
[root@db03 ~]# cd ~/mysql-master-ha/ && rpm -ivh mha4mysql-manager-0.56-0.el6.noarch.rpm

编辑manager节点配置文件

[root@db03 ~]# mkdir -p /etc/mha
[root@db03 ~]# mkdir -p /var/log/mha/app1
[root@db03 ~]# vim /etc/mha/app1.cnf
[server default]
manager_log=/var/log/mha/app1/manager.log
manager_workdir=/var/log/mha/app1
master_binlog_dir=/application/mysql/data
user=mha
password=mha
ping_interval=2
repl_password=123
repl_user=slave
ssh_user=root
[server1]
hostname=192.168.112.40
port=3306
[server2]
hostname=192.168.112.50
port=3306
candidate_master=1
check_repl_delay=0
[server3]
hostname=192.168.112.60
port=3306

3、配置ssh信任

#创建密钥对
[root@db01 ~]# ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa >/dev/null 2>&1
#发送密钥,包括自己
[root@db01 ~]# ssh-copy-id -i /root/.ssh/id_dsa.pub root@192.168.112.40
[root@db01 ~]# ssh-copy-id -i /root/.ssh/id_dsa.pub root@192.168.112.50
[root@db01 ~]# ssh-copy-id -i /root/.ssh/id_dsa.pub root@192.168.112.60

4、启动测试(manage节点)

#测试ssh
[root@db03 ~]# masterha_check_ssh --conf=/etc/mha/app1.cnf

image-20240328232738515


#测试复制
[root@db03 ~]# masterha_check_repl --conf=/etc/mha/app1.cnf

如果遇到MySQL Replication Health is NOT OK!

可以尝试在manage节点的/etc/my.cnf配置文件里添加skip-name-resolv跳过解析域名

image-20240328233828296

四、启动MHA

#启动
[root@db03 ~]# nohup masterha_manager --conf=/etc/mha/app1.cnf --remove_dead_master_conf --ignore_last_failover < /dev/null > /var/log/mha/app1/manager.log 2>&1 &
[root@db03 ~]# jobs
[1]+  运行中               nohup masterha_manager --conf=/etc/mha/app1.cnf --remove_dead_master_conf --ignore_last_failover < /dev/null > /var/log/mha/app1/manager.log 2>&1 &
#检测状态
[root@db03 ~]# masterha_check_status --conf=/etc/mha/app1.cnf
app1 (pid:19754) is running(0:PING_OK), master:192.168.112.40

五、切换master测试

1、检查两从复制情况

#登录db02
[root@db02 ~]# mysql -uroot -p123
#检查复制情况
mysql> show slave status\G;
*************************** 1. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: 192.168.112.40Master_User: slaveMaster_Port: 3306Connect_Retry: 60Master_Log_File: mysql-bin.000002Read_Master_Log_Pos: 405Relay_Log_File: db02-relay-bin.000002Relay_Log_Pos: 615Relay_Master_Log_File: mysql-bin.000002Slave_IO_Running: YesSlave_SQL_Running: YesReplicate_Do_DB:Replicate_Ignore_DB:Replicate_Do_Table:Replicate_Ignore_Table:Replicate_Wild_Do_Table:Replicate_Wild_Ignore_Table:Last_Errno: 0Last_Error:Skip_Counter: 0Exec_Master_Log_Pos: 405Relay_Log_Space: 818Until_Condition: NoneUntil_Log_File:Until_Log_Pos: 0Master_SSL_Allowed: NoMaster_SSL_CA_File:Master_SSL_CA_Path:Master_SSL_Cert:Master_SSL_Cipher:Master_SSL_Key:Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: NoLast_IO_Errno: 0Last_IO_Error:Last_SQL_Errno: 0Last_SQL_Error:Replicate_Ignore_Server_Ids:Master_Server_Id: 1Master_UUID: 51fc215b-eab2-11ee-b7f0-000c29c4dc96Master_Info_File: /application/mysql/data/master.infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update itMaster_Retry_Count: 86400Master_Bind:Last_IO_Error_Timestamp:Last_SQL_Error_Timestamp:Master_SSL_Crl:Master_SSL_Crlpath:Retrieved_Gtid_Set: 51fc215b-eab2-11ee-b7f0-000c29c4dc96:1Executed_Gtid_Set: 51fc215b-eab2-11ee-b7f0-000c29c4dc96:1,
e5c86268-ed04-11ee-8716-000c2936523e:1Auto_Position: 1
1 row in set (0.00 sec)ERROR:
No query specified#登录db03
[root@db03 ~]# mysql -uroot -p123
#检查复制情况
mysql> show slave status\G;
*************************** 1. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: 192.168.112.40Master_User: slaveMaster_Port: 3306Connect_Retry: 60Master_Log_File: mysql-bin.000002Read_Master_Log_Pos: 405Relay_Log_File: db03-relay-bin.000004Relay_Log_Pos: 448Relay_Master_Log_File: mysql-bin.000002Slave_IO_Running: YesSlave_SQL_Running: YesReplicate_Do_DB:Replicate_Ignore_DB:Replicate_Do_Table:Replicate_Ignore_Table:Replicate_Wild_Do_Table:Replicate_Wild_Ignore_Table:Last_Errno: 0Last_Error:Skip_Counter: 0Exec_Master_Log_Pos: 405Relay_Log_Space: 1461Until_Condition: NoneUntil_Log_File:Until_Log_Pos: 0Master_SSL_Allowed: NoMaster_SSL_CA_File:Master_SSL_CA_Path:Master_SSL_Cert:Master_SSL_Cipher:Master_SSL_Key:Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: NoLast_IO_Errno: 0Last_IO_Error:Last_SQL_Errno: 0Last_SQL_Error:Replicate_Ignore_Server_Ids:Master_Server_Id: 1Master_UUID: 51fc215b-eab2-11ee-b7f0-000c29c4dc96Master_Info_File: /application/mysql-5.6.40/data/master.infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update itMaster_Retry_Count: 86400Master_Bind:Last_IO_Error_Timestamp:Last_SQL_Error_Timestamp:Master_SSL_Crl:Master_SSL_Crlpath:Retrieved_Gtid_Set: 51fc215b-eab2-11ee-b7f0-000c29c4dc96:1Executed_Gtid_Set: 15c89969-ed05-11ee-8717-000c291d4def:1,
51fc215b-eab2-11ee-b7f0-000c29c4dc96:1Auto_Position: 1
1 row in set (0.00 sec)ERROR:
No query specified

2、停掉主库

#停掉主库
[root@db01 ~]# /etc/init.d/mysqld stop
Shutting down MySQL...... SUCCESS!#查看db02的slave状态
mysql> show slave status\G;
Empty set (0.00 sec)ERROR:
No query specified#查看db03的slave状态
mysql> show slave status\G;
*************************** 1. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: 192.168.112.50Master_User: slaveMaster_Port: 3306Connect_Retry: 60Master_Log_File: mysql-bin.000002Read_Master_Log_Pos: 659Relay_Log_File: db03-relay-bin.000002Relay_Log_Pos: 662Relay_Master_Log_File: mysql-bin.000002Slave_IO_Running: YesSlave_SQL_Running: YesReplicate_Do_DB:Replicate_Ignore_DB:Replicate_Do_Table:Replicate_Ignore_Table:Replicate_Wild_Do_Table:Replicate_Wild_Ignore_Table:Last_Errno: 0Last_Error:Skip_Counter: 0Exec_Master_Log_Pos: 659Relay_Log_Space: 865Until_Condition: NoneUntil_Log_File:Until_Log_Pos: 0Master_SSL_Allowed: NoMaster_SSL_CA_File:Master_SSL_CA_Path:Master_SSL_Cert:Master_SSL_Cipher:Master_SSL_Key:Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: NoLast_IO_Errno: 0Last_IO_Error:Last_SQL_Errno: 0Last_SQL_Error:Replicate_Ignore_Server_Ids:Master_Server_Id: 2Master_UUID: e5c86268-ed04-11ee-8716-000c2936523eMaster_Info_File: /application/mysql-5.6.40/data/master.infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update itMaster_Retry_Count: 86400Master_Bind:Last_IO_Error_Timestamp:Last_SQL_Error_Timestamp:Master_SSL_Crl:Master_SSL_Crlpath:Retrieved_Gtid_Set: e5c86268-ed04-11ee-8716-000c2936523e:1Executed_Gtid_Set: 15c89969-ed05-11ee-8717-000c291d4def:1,
51fc215b-eab2-11ee-b7f0-000c29c4dc96:1,
e5c86268-ed04-11ee-8716-000c2936523e:1Auto_Position: 1
1 row in set (0.00 sec)ERROR:
No query specified

可以清晰的看到db02已经切换为master

#manage节点的状态检测也停止了
[root@db03 ~]# masterha_check_status --conf=/etc/mha/app1.cnf
app1 is stopped(2:NOT_RUNNING).
#对应的[server1]也被删除了
[root@db03 ~]# cat /etc/mha/app1.cnf
[server default]
manager_log=/var/log/mha/app1/manager.log
manager_workdir=/var/log/mha/app1
master_binlog_dir=/application/mysql/data
password=mha
ping_interval=2
repl_password=123
repl_user=slave
ssh_user=root
user=mha[server2]
candidate_master=1
check_repl_delay=0
hostname=192.168.112.50
port=3306[server3]
hostname=192.168.112.60
port=3306

3、手动将主库以slave身份加回去

即使重新开启主库,主库也不会自动加回去了,只能以slave的身份手动加回去

mysql> change master to-> master_host='192.168.112.50',-> master_user='slave',-> master_password='123',-> master_auto_position=1;
Query OK, 0 rows affected, 2 warnings (0.01 sec)mysql> start slave;
Query OK, 0 rows affected (0.00 sec)mysql> show slave status\G;
*************************** 1. row ***************************Slave_IO_State: Connecting to masterMaster_Host: 192.168.112.50Master_User: slaveMaster_Port: 3306Connect_Retry: 60Master_Log_File:Read_Master_Log_Pos: 4Relay_Log_File: db01-relay-bin.000001Relay_Log_Pos: 4Relay_Master_Log_File:Slave_IO_Running: ConnectingSlave_SQL_Running: YesReplicate_Do_DB:Replicate_Ignore_DB:Replicate_Do_Table:Replicate_Ignore_Table:Replicate_Wild_Do_Table:Replicate_Wild_Ignore_Table:Last_Errno: 0Last_Error:Skip_Counter: 0Exec_Master_Log_Pos: 0Relay_Log_Space: 151Until_Condition: NoneUntil_Log_File:Until_Log_Pos: 0Master_SSL_Allowed: NoMaster_SSL_CA_File:Master_SSL_CA_Path:Master_SSL_Cert:Master_SSL_Cipher:Master_SSL_Key:Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: NoLast_IO_Errno: 0Last_IO_Error:Last_SQL_Errno: 0Last_SQL_Error:Replicate_Ignore_Server_Ids:Master_Server_Id: 0Master_UUID:Master_Info_File: /application/mysql/data/master.infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update itMaster_Retry_Count: 86400Master_Bind:Last_IO_Error_Timestamp:Last_SQL_Error_Timestamp:Master_SSL_Crl:Master_SSL_Crlpath:Retrieved_Gtid_Set:Executed_Gtid_Set: 51fc215b-eab2-11ee-b7f0-000c29c4dc96:1Auto_Position: 1
1 row in set (0.00 sec)ERROR:
No query specified

六、配置VIP漂移

在MHA(MySQL Master High Availability)高可用架构中,虚拟IP(VIP)漂移是用于确保服务不间断的一种策略,当主数据库发生故障时,VIP会从原主节点迁移到新的主节点,这样应用程序和服务始终可以通过VIP访问到当前的主数据库,而无需修改任何指向数据库的实际IP地址

  • VIP漂移的两种方式

    • 通过keepalived的方式,管理虚拟IP的漂移

    • 通过MHA自带脚本方式,管理虚拟IP的漂移

1、编辑配置文件

#manage节点
[root@db03 ~]# vim /etc/mha/app1.cnf[server default]
master_ip_failover_script=/etc/mha/master_ip_failover	#在[server default]标签下添加
#随便把之前删除的[server1]加回来
[server1]
hostname=192.168.112.40
port=3306	

2、编辑MHA自带的脚本

[root@db03 ~]# vim /etc/mha/master_ip_failover
#!/usr/bin/env perluse 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.112.66/24';
my $key = '0';
my $ssh_start_vip = "/sbin/ifconfig ens33:$key $vip";
my $ssh_stop_vip = "/sbin/ifconfig ens33:$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" ) {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" ) {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";exit 0;}else {&usage();exit 1;}
}sub start_vip() {`ssh $ssh_user\@$new_master_host \" $ssh_start_vip \"`;
}
sub stop_vip() {return 0  unless  ($ssh_user);`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";
}

这里面需要依据个人修改的是

my $vip = '192.168.112.66/24';

然后添加执行权限

[root@db03 ~]# chmod a+x /etc/mha/master_ip_failover

3、手动绑定VIP(master节点)

#所有主机,主要是ifconfig命令
yum install -y net-tools
#绑定vip
[root@db02 ~]# ifconfig ens33:0 192.168.112.66/24
[root@db02 ~]# ip a | grep ens33
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000inet 192.168.112.50/24 brd 192.168.112.255 scope global noprefixroute ens33inet 192.168.112.66/24 brd 192.168.112.255 scope global secondary ens33:0

4、启动测试(manage节点)

masterha_check_ssh --conf=/etc/mha/app1.cnf
masterha_check_repl --conf=/etc/mha/app1.cnf

5、重启MHA(manage节点)

#启动
[root@db03 ~]# nohup masterha_manager --conf=/etc/mha/app1.cnf --remove_dead_master_conf --ignore_last_failover < /dev/null > /var/log/mha/app1/manager.log 2>&1 &
[1] 21063
[root@db03 ~]# jobs
[1]+  运行中               nohup masterha_manager --conf=/etc/mha/app1.cnf --remove_dead_master_conf --ignore_last_failover < /dev/null > /var/log/mha/app1/manager.log 2>&1 &
#检测状态,识别出master
[root@db03 ~]# masterha_check_status --conf=/etc/mha/app1.cnf
app1 (pid:21063) is running(0:PING_OK), master:192.168.112.50

6、测试IP漂移

#停掉主库
[root@db02 ~]# /etc/init.d/mysqld stop
Shutting down MySQL..... SUCCESS!
#db01查看slave信息,经历了一个连接不上主库到自己提升为主库的过程
mysql> show slave status\G;
*************************** 1. row ***************************Slave_IO_State:Master_Host: 192.168.112.50Master_User: slaveMaster_Port: 3306Connect_Retry: 60Master_Log_File: mysql-bin.000003Read_Master_Log_Pos: 231Relay_Log_File: db01-relay-bin.000003Relay_Log_Pos: 401Relay_Master_Log_File: mysql-bin.000003Slave_IO_Running: NoSlave_SQL_Running: NoReplicate_Do_DB:Replicate_Ignore_DB:Replicate_Do_Table:Replicate_Ignore_Table:Replicate_Wild_Do_Table:Replicate_Wild_Ignore_Table:Last_Errno: 0Last_Error:Skip_Counter: 0Exec_Master_Log_Pos: 231Relay_Log_Space: 1115Until_Condition: NoneUntil_Log_File:Until_Log_Pos: 0Master_SSL_Allowed: NoMaster_SSL_CA_File:Master_SSL_CA_Path:Master_SSL_Cert:Master_SSL_Cipher:Master_SSL_Key:Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: NoLast_IO_Errno: 2003Last_IO_Error: error reconnecting to master 'slave@192.168.112.50:3306' - retry-time: 60  retries: 1Last_SQL_Errno: 0Last_SQL_Error:Replicate_Ignore_Server_Ids:Master_Server_Id: 2Master_UUID: e5c86268-ed04-11ee-8716-000c2936523eMaster_Info_File: /application/mysql/data/master.infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State:Master_Retry_Count: 86400Master_Bind:Last_IO_Error_Timestamp: 240329 00:45:33Last_SQL_Error_Timestamp:Master_SSL_Crl:Master_SSL_Crlpath:Retrieved_Gtid_Set: e5c86268-ed04-11ee-8716-000c2936523e:1Executed_Gtid_Set: 51fc215b-eab2-11ee-b7f0-000c29c4dc96:1,
e5c86268-ed04-11ee-8716-000c2936523e:1Auto_Position: 1
1 row in set (0.00 sec)ERROR:
No query specifiedmysql> show slave status\G;
Empty set (0.00 sec)ERROR:
No query specified#db03查看slave信息,发现主库已经成功切换到db01
mysql> show slave status\G;
*************************** 1. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: 192.168.112.40Master_User: slaveMaster_Port: 3306Connect_Retry: 60Master_Log_File: mysql-bin.000003Read_Master_Log_Pos: 445Relay_Log_File: db03-relay-bin.000002Relay_Log_Pos: 408Relay_Master_Log_File: mysql-bin.000003Slave_IO_Running: YesSlave_SQL_Running: YesReplicate_Do_DB:Replicate_Ignore_DB:Replicate_Do_Table:Replicate_Ignore_Table:Replicate_Wild_Do_Table:Replicate_Wild_Ignore_Table:Last_Errno: 0Last_Error:Skip_Counter: 0Exec_Master_Log_Pos: 445Relay_Log_Space: 611Until_Condition: NoneUntil_Log_File:Until_Log_Pos: 0Master_SSL_Allowed: NoMaster_SSL_CA_File:Master_SSL_CA_Path:Master_SSL_Cert:Master_SSL_Cipher:Master_SSL_Key:Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: NoLast_IO_Errno: 0Last_IO_Error:Last_SQL_Errno: 0Last_SQL_Error:Replicate_Ignore_Server_Ids:Master_Server_Id: 1Master_UUID: 51fc215b-eab2-11ee-b7f0-000c29c4dc96Master_Info_File: /application/mysql-5.6.40/data/master.infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update itMaster_Retry_Count: 86400Master_Bind:Last_IO_Error_Timestamp:Last_SQL_Error_Timestamp:Master_SSL_Crl:Master_SSL_Crlpath:Retrieved_Gtid_Set:Executed_Gtid_Set: 15c89969-ed05-11ee-8717-000c291d4def:1,
51fc215b-eab2-11ee-b7f0-000c29c4dc96:1,
e5c86268-ed04-11ee-8716-000c2936523e:1Auto_Position: 1
1 row in set (0.00 sec)ERROR:
No query specified
#在db01上查看vip信息
[root@db01 ~]# ip a |grep ens33
#在db02上查看vip信息
[root@db02 ~]# ip a |grep ens33
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000inet 192.168.112.40/24 brd 192.168.112.255 scope global noprefixroute ens33inet 192.168.112.66/24 brd 192.168.112.255 scope global secondary ens33:0

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.ulsteruni.cn/article/01266284.html

如若内容造成侵权/违法违规/事实不符,请联系编程大学网进行投诉反馈email:xxxxxxxx@qq.com,一经查实,立即删除!

相关文章

Flutter逆向

环境配置(Blutter)及使用 参考 [原创]flutter逆向 ACTF native app-Android安全-看雪-安全社区|安全招聘|kanxue.com 其中在编译过程中遇到 -- Configuring done (2.5s) -- Generating done (0.0s) -- Build files have been written to: E:/blutter/build/blutter_dartvm3.4…

人工智能复试考察要点

什么是人工智能 人工智能是计算机科学的一个重要分支. 也是一门正在发展中的综合性前沿学科,它是由计算机科学、控制论、信息论、神经生理学、哲学、语言学等多种学科相互渗透而发展起来的,目前正处于发展阶段尚未形成完整 休系。 人工智能三大学派——符号、连接、行为 合取…

方差与标准差

标准差,反映了一组数与平均值的紧密关系。 举例,有一组数,4,5,9,11,16。 第一步:求出平均值。 (4+5+9+11+16)5=9 第二步:求出各数与平均数的差 分别为,-5,-4,0,2,7 第三步:把差平方一下(目的就是转成正数) 结果为,25,16,0,4,49 第四步:把平方后的数求一个平均…

支持MacOS苹果操作系统的网卡你用过吗?

Marvell AQC113以太网控制器支持苹果操作系统(MacOS),进一步扩展搭载了AQC113设备的应用领域。 众所周知,苹果操作系统应用生态完善,是业内备受瞩目的巨头级操作系统,其应用领域覆盖了游戏、社交、娱乐、工具,甚至NAS存储、工作站、家用PC及其他嵌入式应用等。 Marvell …

etcd与redis之间的区别

一、简介 我们之前用了redis,那么好用为什么还要来用etcd呢,这里就来和大家聊聊为什么有的业务场景选择etcd。 分析:在当今的分布式系统中,数据存储及一致性相当重要。etcd和redis都是我们最受欢迎的开源分布式数据存储的解决方案,但是他们有着不同的试用场景。下面我个人对…

[转帖]比黄金更贵的显卡,疯狂H100

https://zhuanlan.zhihu.com/p/654361974 华尔街和硅谷联袂奉上了一件震撼业界的大事:让一家创业公司拿到23亿美元的债务融资,抵押物则是当前全球最硬的通货——H100显卡。 这个大事件的主角叫做CoreWeave,主营业务是AI私有云服务,简单说就是通过搭建拥有大量GPU算力的数据…