平滑2N扩容方案实践

一、资源准备

编号 ip 网关 子网掩码 系统
1 192.168.0.101 192.168.0.2 255.255.255.0 CentOS7
2 192.168.0.102 192.168.0.2 255.255.255.0 CentOS7
3 192.168.0.103 192.168.0.2 255.255.255.0 CentOS7
4 192.168.0.104 192.168.0.2 255.255.255.0 CentOS7

二、MariaDB服务安装

1.切换阿里云镜像服务(YUM安装过慢可以切换)

yum -y install wget

## 备份CentOS-Base.repo
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

wget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/epel-7.repo

yum clean all

yum makecache

2.配置YUM源

vi /etc/yum.repos.d/mariadb-10.2.repo

增加以下内容:

[mariadb]
name=MariaDB
baseurl=https://mirrors.ustc.edu.cn/mariadb/yum/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

3.执行安装

yum -y install mariadb mariadb-server MariaDB-client MariaDB-common

4.如果之前已经安装, 需要先删除(如果之前没有安装, 可以忽略此步骤) 停止Mariadb服务

ps -ef | grep mysql

## kill杀死线程
kill 1954

卸载Mariadb服务

yum -y remove Maria*

删除数据与配置:

rm -rf /var/lib/mysql/*
rm -rf /etc/my.cnf.d/
rm -rf /etc/my.cnf

5.启动MariaDB后,执行安全配置向导命令,可根据安全配置向导提高数据库的安全性

systemctl start mariadb

## 执行安全配置向导命令
[root@linux1 ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
# 首次安装,直接跳过
Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
# 设置root用户密码 这里我设置的是root
Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
# 删除匿名用户
Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.
# 允许root用户远程登录
Disallow root login remotely? [Y/n] n
 ... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
# 删除test数据库
Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
# 刷新权限
Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

6.开启用户远程连接权限 将连接用户root开启远程连接权限;

mysql -uroot -proot

进入MySQL服务, 执行以下操作:

[root@linux1 ~]# mysql -uroot -proot
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 15
Server version: 10.2.43-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
## 切换到mysql数据库
MariaDB [(none)]>  use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
## 删除所有用户
MariaDB [mysql]>  delete from user;
Query OK, 4 rows affected (0.00 sec)
## 配置root用户使用密码123456从任何主机都可以连接到mysql服务器
MariaDB [mysql]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
Query OK, 0 rows affected (0.01 sec)
## 刷新权限
MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]>

三、MariaDB双主同步

1.在linux1增加配置: 在/etc/my.cnf中添加以下配置:

vi /etc/my.cnf

## 添加以下配置
[mysqld]
server-id=1
log-bin=mysql-bin
relay-log=mysql-relay-bin
## 忽略mysql、information_schema库下对表的操作
replicate-wild-ignore-table=mysql.%
replicate-wild-ignore-table=information_schema.%
## 默认的情况下mysql是关闭的;
log-slave-updates=on
## 复制过程中,有任何错误,直接跳过
slave-skip-errors=all
auto-increment-offset=1
auto-increment-increment=2
## binlog的格式:STATEMENT,ROW,MIXED
binlog_format=mixed
## 自动过期清理binlog,默认0天,即不自动清理
expire_logs_days=10

2.在linux2增加配置:

vi /etc/my.cnf

## 添加以下配置
[mysqld]
server-id=2
log-bin=mysql-bin
relay-log=mysql-relay-bin
replicate-wild-ignore-table=mysql.%
replicate-wild-ignore-table=information_schema.%
log-slave-updates=on
slave-skip-errors=all
auto-increment-offset=2
auto-increment-increment=2
binlog_format=mixed
expire_logs_days=10

linux1自增为偶数位: auto-increment-offset=2 主键自增基数, 从2开始。

auto-increment-increment=2 主键自增偏移量,每次为2。

配置修改完成后, 重启数据库。

systemctl restart mariadb

3.同步授权配置 在linux30创建replica用于主从同步的用户:

mysql -uroot -proot

## 授权replica用户 replication slave, replication client 权限
grant replication slave, replication client on *.* to 'replica'@'%' identified by 'replica';

## 刷新权限
flush privileges;

查询日志文件与偏移量,开启同步时需使用:

MariaDB [(none)]> show master status;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000003 |      677 |              |                  |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)

同样, 在linux2创建replica用于主从同步的用户:

mysql -uroot -proot

## 授权replica用户 replication slave, replication client 权限
grant replication slave, replication client on *.* to 'replica'@'%' identified by 'replica';

## 刷新权限
flush privileges;

查询日志文件与偏移量:

MariaDB [(none)]> show master status;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000003 |      677 |              |                  |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)

4.配置主从同步信息 在linux1中执行:

change master to master_host='192.168.0.102',master_user='replica', master_password='replica', master_port=3306, master_log_file='mysql-bin.000003', master_log_pos=677, master_connect_retry=30;

在linux2中执行:

change master to master_host='192.168.0.101',master_user='replica',master_password='replica', master_port=3306, master_log_file='mysql-bin.000003', master_log_pos=677, master_connect_retry=30;

5.开启双主同步 在linux30和linux31中分别执行:

start slave;

在linux1查询同步信息:

MariaDB [(none)]> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 192.168.0.102
                  Master_User: replica
                  Master_Port: 3306
                Connect_Retry: 30
              Master_Log_File: mysql-bin.000003
          Read_Master_Log_Pos: 677
               Relay_Log_File: mysql-relay-bin.000002
                Relay_Log_Pos: 555
        Relay_Master_Log_File: mysql-bin.000003
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: mysql.%,information_schema.%
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 677
              Relay_Log_Space: 864
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_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: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 2
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
                   Using_Gtid: No
                  Gtid_IO_Pos: 
      Replicate_Do_Domain_Ids: 
  Replicate_Ignore_Domain_Ids: 
                Parallel_Mode: conservative
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
1 row in set (0.00 sec)

在linux2查询同步信息:

MariaDB [(none)]> start slave;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 192.168.0.101
                  Master_User: replica
                  Master_Port: 3306
                Connect_Retry: 30
              Master_Log_File: mysql-bin.000003
          Read_Master_Log_Pos: 677
               Relay_Log_File: mysql-relay-bin.000002
                Relay_Log_Pos: 555
        Relay_Master_Log_File: mysql-bin.000003
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: mysql.%,information_schema.%
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 677
              Relay_Log_Space: 864
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_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: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 1
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
                   Using_Gtid: No
                  Gtid_IO_Pos: 
      Replicate_Do_Domain_Ids: 
  Replicate_Ignore_Domain_Ids: 
                Parallel_Mode: conservative
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
1 row in set (0.00 sec)

四、KeepAlived安装与高可用配置

1.在linux1与linux2两台节点安装keepalived:

yum -y install keepalived

2.关闭防火墙

# 1.查看防火墙状态
firewall-cmd --state
# 2.关闭防火墙
systemctl stop firewalld.service
# 3.禁止开机启动防火墙
systemctl disable firewalld.service 

3.设置主机名称: 这里我在安装的时候已经更改了 所以就不再操作

linux1节点:

hostnamectl set-hostname linux1

linux2节点:

hostnamectl set-hostname linux2

4.linux1节点配置 /etc/keepalived/keepalived.conf:

vi /etc/keepalived/keepalived.conf


global_defs {
    
    
	router_id linux1 # 机器标识,和主机名保持一致,运行keepalived服务器的一个标识
}

vrrp_instance VI_1 {
    
     #vrrp实例定义
	state BACKUP #lvs的状态模式,MASTER代表主, BACKUP代表备份节点
	interface ens33 #绑定对外访问的网卡,vrrp实例绑定的网卡
	virtual_router_id 111 #虚拟路由标示,同一个vrrp实例采用唯一标示
	priority 100 #优先级,100代表最大优先级, 数字越大优先级越高
	advert_int 1 #master与backup节点同步检查的时间间隔,单位是秒
	authentication {
    
     #设置验证信息
		auth_type PASS #有PASS和AH两种
		auth_pass 6666 #验证密码,BACKUP密码须相同
	}
	virtual_ipaddress {
    
     #KeepAlived虚拟的IP地址
		192.168.0.150
	}
}

virtual_server 192.168.0.150 3306 {
    
     #配置虚拟服务器IP与访问端口
	delay_loop 6 #健康检查时间
	lb_algo rr #负载均衡调度算法, rr代表轮询
	lb_kind DR #负载均衡转发规则 DR/NAT/
	persistence_timeout 0 #会话保持时间,这里要做测试, 所以设为0, 实际可根据session有效时间配置
	protocol TCP #转发协议类型,支持TCP和UDP
	real_server 192.168.0.101 3306 {
    
     #配置服务器节点VIP1
		notify_down /opt/mariaDB/mariadb.sh #当服务挂掉时, 会执行此脚本,结束keepalived进程
		weight 1 #设置权重,越大权重越高
		TCP_CHECK {
    
     #状态监测设置
			connect_timeout 10 #超时配置, 单位秒
			retry 3 #重试次数
			delay_before_retry 3 #重试间隔
			connect_port 3306 #连接端口, 和上面保持一致
		}
	}
}

创建关闭脚本mariadb.sh

## 创建文件夹
mkdir -p /opt/mariaDB

## 创建文件
vi /opt/mariaDB/mariadb.sh

## 添加脚本内容
pkill keepalived

## 加入执行权限
chmod a+x /opt/mariaDB/mariadb.sh

5.linux2节点配置:

vi /etc/keepalived/keepalived.conf

global_defs {
    
    
	router_id linux2 # 机器标识,和主机名保持一致,运行keepalived服务器的一个标识
}
vrrp_instance VI_1 {
    
     #vrrp实例定义
	state BACKUP #lvs的状态模式,MASTER代表主, BACKUP代表备份节点
	interface ens33 #绑定对外访问的网卡
	virtual_router_id 111 #虚拟路由标示,同一个vrrp实例采用唯一标示
	priority 98 #优先级,100代表最大优先级, 数字越大优先级越高
	advert_int 1 #master与backup节点同步检查的时间间隔,单位是秒
	authentication {
    
     #设置验证信息
		auth_type PASS #有PASS和AH两种
		auth_pass 6666 #验证密码,BACKUP密码须相同
	}
	virtual_ipaddress {
    
     #KeepAlived虚拟的IP地址
		192.168.0.150
	}
}

virtual_server 192.168.0.150 3306 {
    
     #配置虚拟服务器IP与访问端口
	delay_loop 6 #健康检查时间
	lb_algo rr #负载均衡调度算法, rr代表轮询, 可以关闭
	lb_kind DR #负载均衡转发规则, 可以关闭
	persistence_timeout 0 #会话保持时间,这里要做测试, 所以设为0, 实际可根据session有效时间配置
	protocol TCP #转发协议类型,支持TCP和UDP
	real_server 192.168.0.102 3306 {
    
     #配置服务器节点linux31
		notify_down /opt/mariaDB/mariadb.sh #当服务挂掉时, 会执行此脚本,结束keepalived进程
		weight 1 #设置权重,越大权重越高
		TCP_CHECK {
    
     #r状态监测设置
			connect_timeout 10 #超时配置, 单位秒
			retry 3 #重试次数
			delay_before_retry 3 #重试间隔
			connect_port 3306 #连接端口, 和上面保持一致
        }
	}
}

和linux1的差异项:

router_id linux2 # 机器标识,和主机名保持一致
priority 98 #优先级,100代表最大优先级, 数字越大优先级越高
real_server 192.168.0.102 3306 #配置服务器节点linux2

注意, 两台节点都设为BACKUP

virtual_router_id 111 #同一个vrrp实例采用唯一标示
state BACKUP

如果不想重启后, 争夺备用节点的VIP, 可以设置此项

nopreempt #不主动抢占资源

注意:这个配置只能设置在backup主机上,而且这个主机优先级要比另外一台高

6.验证高可用 停止主节点MariaDB服务, 验证是否自动切换。

## 创建库
create database smooth;

## 选择库 create database smooth
use smooth;

## 新建表
drop table if exists  t_trade_order;
CREATE TABLE `t_trade_order` (
                                 `id` bigint(20) NOT NULL ,15AUTO_INCREMENT COMMENT '主键标识',
                                 `accountNo` bigint(21) DEFAULT NULL COMMENT '交易账户编号',
                                 `execPrice` bigint(21) DEFAULT NULL COMMENT '交易价格',
                                 `execTime` datetime DEFAULT NULL COMMENT '成交时间',
                                 PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='订单信息表';


## 插入数据 分别
insert into t_trade_order values(null,1,15,'2022-03-29 12:00:00');
insert into t_trade_order values(null,2,19,'2022-02-19 11:00:00');
## 查询数据
select * from t_trade_order;
systemctl start mariadb
systemctl start keepalived


systemctl stop mariadb
systemctl stop keepalived

五、实现数据库的秒级平滑2N扩容

5.1、新增数据库VIP

1.在linux2节点, 增加VIP 修改/etc/keepalived/keepalived.conf

vi /etc/keepalived/keepalived.conf


global_defs {
    
    
	router_id linux1 # 机器标识,和主机名保持一致,运行keepalived服务器的一个标识
}

vrrp_instance VI_1 {
    
     #vrrp实例定义
	state BACKUP #lvs的状态模式,MASTER代表主, BACKUP代表备份节点
	interface ens33 #绑定对外访问的网卡,vrrp实例绑定的网卡
	virtual_router_id 112 #虚拟路由标示,同一个vrrp实例采用唯一标示
	priority 100 #优先级,100代表最大优先级, 数字越大优先级越高
	advert_int 1 #master与backup节点同步检查的时间间隔,单位是秒
	authentication {
    
     #设置验证信息
		auth_type PASS #有PASS和AH两种
		auth_pass 6666 #验证密码,BACKUP密码须相同
	}
	virtual_ipaddress {
    
     #KeepAlived虚拟的IP地址
		192.168.0.151
	}
}

virtual_server 192.168.0.151 3306 {
    
     #配置虚拟服务器IP与访问端口
	delay_loop 6 #健康检查时间
	persistence_timeout 0 #会话保持时间,这里要做测试, 所以设为0, 实际可根据session有效时间配置
	protocol TCP #转发协议类型,支持TCP和UDP
	real_server 192.168.0.102 3306 {
    
     #配置服务器节点VIP1
		notify_down /opt/mariaDB/mariadb.sh #当服务挂掉时, 会执行此脚本,结束keepalived进程
		weight 1 #设置权重,越大权重越高
		TCP_CHECK {
    
     #状态监测设置
			connect_timeout 10 #超时配置, 单位秒
			retry 3 #重试次数
			delay_before_retry 3 #重试间隔
			connect_port 3306 #连接端口, 和上面保持一致
		}
	}
}

注意配置项:

virtual_router_id 112 #虚拟路由标示,同一个vrrp实例采用唯一标示
priority 100 #优先级,100代表最大优先级, 数字越大优先级越高

5.2、应用服务增加动态数据源

1.修改应用服务配置, 增加新的数据源, 指向新设置的VIP: 192.168.0.151

2.通过应用服务接口, 动态扩容调整

5.3、解除原双主同步

## 1.进入linux1
mysql -uroot -proot

## 2.进入linux2
stop slave;

## 3.通过应用服务接口验证数据是否解除同步

5.4、安装MariaDB扩容服务器

1、新建两台虚拟机, 分别为linux3和linux4。

2、在linux3和linux4两台节点上安装MariaDB服务

参考MariaDB服务安装

3、配置linux3与linux4,实现新的双主同步

  1. linux3节点, 修改/etc/my.cnf
vi /etc/my.cnf

[mysqld]
server-id=3
log-bin=mysql-bin
relay-log = mysql-relay-bin
replicate-wild-ignore-table=mysql.%
replicate-wild-ignore-table=information_schema.%
log-slave-updates=on
slave-skip-errors=all
auto-increment-offset=2
auto-increment-increment=2
binlog_format=mixed
expire_logs_days=10
  1. 重启linux3数据库
service mariadb restart
  1. 创建replica用于主从同步的用户:
mysql -uroot -proot
 
grant replication slave, replication client on *.* to 'replica'@'%' identified by 'replica';

flush privileges;
  1. 在linux1节点,进行数据全量备份:
[root@linux1 mariaDB]# mysqldump -uroot -proot --routines --single_transaction --master-data=2 --databases smooth > linux1.sql
[root@linux1 mariaDB]# ll
总用量 12
-rw-r--r--. 1 root root 5452 330 21:33 linux1.sql
-rwxr-xr-x. 1 root root   17 329 17:31 mariadb.sh
[root@linux1 mariaDB]# 
  1. 查看并记录master status信息:
MariaDB [(none)]> show master status;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000015 |      401 |              |                  |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
  1. 将备份的linux1.sql通过scp命令拷贝至linux3节点。
##  linux3上创建
[root@linux3 opt]# mkdir -p /opt/mariaDB

## linux1上执行
[root@linux1 mariaDB]# scp linux1.sql [email protected]:/opt/mariaDB
  1. 将数据还原至linux3节点:
mysql -uroot -proot < /opt/mariaDB/linux1.sql
  1. 配置主从同步信息 根据上面的master status信息, 在linux3中执行:
MariaDB [(none)]> change master to master_host='192.168.0.101',master_user='replica', master_password='replica', master_port=3306, master_log_file='mysql-bin.000015', master_log_pos=401, master_connect_retry=30;
  1. 开启主从同步:
start slave;

如果出现问题, 复原主从同步信息:

reset slave;
  1. 检查同步状态信息:
MariaDB [(none)]> show slave status \G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 192.168.0.101
                  Master_User: replica
                  Master_Port: 3306
                Connect_Retry: 30
              Master_Log_File: mysql-bin.000015
          Read_Master_Log_Pos: 401
               Relay_Log_File: mysql-relay-bin.000002
                Relay_Log_Pos: 555
        Relay_Master_Log_File: mysql-bin.000015
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: mysql.%,information_schema.%
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 401
              Relay_Log_Space: 864
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_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: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 1
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
                   Using_Gtid: No
                  Gtid_IO_Pos: 
      Replicate_Do_Domain_Ids: 
  Replicate_Ignore_Domain_Ids: 
                Parallel_Mode: conservative
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
1 row in set (0.00 sec)
  1. 配置linux1与linux3节点的同步 查看linux3的日志信息:
MariaDB [(none)]> show master status;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000005 |      385 |              |                  |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)

在linux1节点, 配置同步信息:

MariaDB [(none)]> reset slave;
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> change master to master_host='192.168.0.103',master_user='replica', master_password='replica', master_port=3306, master_log_file='mysql-bin.000005', master_log_pos=385, master_connect_retry=30;

4、 配置linux4与linux2的双主同步

  1. linux4节点, 修改/etc/my.cnf:
[root@linux4 ~]# vi /etc/my.cnf


[mysqld]
server-id=4
log-bin=mysql-bin
relay-log = mysql-relay-bin
replicate-wild-ignore-table=mysql.%
replicate-wild-ignore-table=information_schema.%
log-slave-updates=on
slave-skip-errors=all
auto-increment-offset=2
auto-increment-increment=2
binlog_format=mixed
expire_logs_days=10
  1. 重启linux4数据库
[root@linux4 ~]# service mariadb restart
  1. 创建replica用于主从同步的用户
[root@linux4 ~]# mysql -uroot -proot

MariaDB [(none)]> grant replication slave, replication client on *.* to 'replica'@'%' identified by 'replica';
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
  1. 在linux2节点,进行数据全量备份:
[root@linux3 mariaDB]# mysqldump -uroot -proot --routines --single_transaction --master-data=2 --databases smooth > linux2.sql
[root@linux3 mariaDB]# ll
总用量 16
-rw-r--r--. 1 root root 5451 331 16:21 linux2.sql

开启主从同步

start slave;

检查同步状态信息:

MariaDB [(none)]> show slave status \G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 192.168.0.103
                  Master_User: replica
                  Master_Port: 3306
                Connect_Retry: 30
              Master_Log_File: mysql-bin.000005
          Read_Master_Log_Pos: 385
               Relay_Log_File: mysql-relay-bin.000002
                Relay_Log_Pos: 555
        Relay_Master_Log_File: mysql-bin.000005
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: mysql.%,information_schema.%
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 385
              Relay_Log_Space: 864
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_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: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 3
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
                   Using_Gtid: No
                  Gtid_IO_Pos: 
      Replicate_Do_Domain_Ids: 
  Replicate_Ignore_Domain_Ids: 
                Parallel_Mode: conservative
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
1 row in set (0.00 sec)

注意:

Slave_IO_Running: No
Slave_SQL_Running: Yes

Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: ‘Could not find first log file name in binary log index file’

原因是binlog位置索引处不对,mysql-bin.000005我输成了mysqlbin.000005,少了一个“-”

4、配置linux2与linux4的双主同步

  1. linux4节点, 修改/etc/my.cnf
vi /etc/my.cnf


[mysqld]
server-id=4
log-bin=mysql-bin
relay-log = mysql-relay-bin
replicate-wild-ignore-table=mysql.%
replicate-wild-ignore-table=information_schema.%
log-slave-updates=on
slave-skip-errors=all
auto-increment-offset=2
auto-increment-increment=2
binlog_format=mixed
expire_logs_days=10
  1. 重启linux4数据库
[root@linux4 ~]# service mariadb restart
Redirecting to /bin/systemctl restart mariadb.service
  1. 创建replica用于主从同步的用户:
[root@linux4 ~]#  mysql -uroot -proot
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.2.43-MariaDB-log MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> grant replication slave, replication client on *.* to 'replica'@'%' identified by 'replica';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
  1. 在linux2节点,进行数据全量备份:
[root@linux2 mariaDB]# mysqldump -uroot -proot --routines --single_transaction --master-data=2 --databases smooth > linux2.sql
[root@linux2 mariaDB]# ll
总用量 12
-rw-r--r--. 1 root root 5415 331 16:25 linux2.sql
-rwxr-xr-x. 1 root root   18 330 21:57 mariadb.sh
  1. 查看并记录master status信息:
[root@linux2 mariaDB]# mysql -uroot -proot

MariaDB [(none)]> show master status;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000008 |      358 |              |                  |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
  1. 将备份的linux2.sql通过scp命令拷贝至linux4节点。
## linux4上执行
[root@linux4 ~]# mkdir -p /opt/mariaDB

## 在linux2上执行
[root@linux2 mariaDB]# scp linux2.sql [email protected]:/opt/mariaDB
  1. 将数据还原至linux4节点
[root@linux4 ~]# mysql -uroot -proot < /opt/mariaDB/linux2.sql
  1. 配置主从同步信息

根据上面的master status信息, 在linux4中执行:

[root@linux4 ~]# mysql -uroot -proot

MariaDB [(none)]> change master to master_host='192.168.0.102',master_user='replica', master_password='replica', master_port=3306, master_log_file='mysql-bin.000008', master_log_pos=358, master_connect_retry=30;
Query OK, 0 rows affected (0.01 sec)
  1. 开启主从同步:
MariaDB [(none)]> start slave;
Query OK, 0 rows affected (0.01 sec)
  1. 检查同步状态信息
MariaDB [(none)]> show slave status \G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 192.168.0.102
                  Master_User: replica
                  Master_Port: 3306
                Connect_Retry: 30
              Master_Log_File: mysql-bin.000008
          Read_Master_Log_Pos: 358
               Relay_Log_File: mysql-relay-bin.000002
                Relay_Log_Pos: 555
        Relay_Master_Log_File: mysql-bin.000008
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: mysql.%,information_schema.%
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 358
              Relay_Log_Space: 864
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_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: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 2
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
                   Using_Gtid: No
                  Gtid_IO_Pos: 
      Replicate_Do_Domain_Ids: 
  Replicate_Ignore_Domain_Ids: 
                Parallel_Mode: conservative
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
1 row in set (0.00 sec)
  1. 配置linux2与linux4节点的同步 查看linux4的日志信息:
MariaDB [(none)]> show master status;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 |     4901 |              |                  |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)

在linux2节点, 配置同步信息:

[root@linux2 mariaDB]# mysql -uroot -proot

MariaDB [(none)]> change master to master_host='192.168.0.104',master_user='replica', master_password='replica', master_port=3306, master_log_file='mysql-bin.000001', master_log_pos=4901, master_connect_retry=30;
Query OK, 0 rows affected (0.01 sec)
  1. 开启主从同步:
MariaDB [(none)]> start slave;
Query OK, 0 rows affected (0.01 sec)
  1. 检查同步状态信息
MariaDB [(none)]> show slave status \G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 192.168.0.104
                  Master_User: replica
                  Master_Port: 3306
                Connect_Retry: 30
              Master_Log_File: mysql-bin.000001
          Read_Master_Log_Pos: 4901
               Relay_Log_File: mysql-relay-bin.000002
                Relay_Log_Pos: 555
        Relay_Master_Log_File: mysql-bin.000001
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: mysql.%,information_schema.%
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 4901
              Relay_Log_Space: 864
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_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: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 4
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
                   Using_Gtid: No
                  Gtid_IO_Pos: 
      Replicate_Do_Domain_Ids: 
  Replicate_Ignore_Domain_Ids: 
                Parallel_Mode: conservative
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
1 row in set (0.00 sec)

5.5、增加KeepAlived服务实现高可用

  1. 确保新增的linux3和linux4节点安装Keepalived服务。
  2. 修改linux3节点配置
vi /etc/keepalived/keepalived.conf

global_defs {
    
    
	router_id linux3 # 机器标识,和主机名保持一致,运行keepalived服务器的一个标识
}
vrrp_instance VI_1 {
    
     #vrrp实例定义
	state BACKUP #lvs的状态模式,MASTER代表主, BACKUP代表备份节点
	interface ens33 #绑定对外访问的网卡
	virtual_router_id 111 #虚拟路由标示,同一个vrrp实例采用唯一标示
	priority 98 #优先级,100代表最大优先级, 数字越大优先级越高
	advert_int 1 #master与backup节点同步检查的时间间隔,单位是秒
	authentication {
    
     #设置验证信息
		auth_type PASS #有PASS和AH两种
		auth_pass 6666 #验证密码,BACKUP密码须相同
	}
	virtual_ipaddress {
    
     #KeepAlived虚拟的IP地址
		192.168.0.150
	}
}

virtual_server 192.168.0.150 3306 {
    
     #配置虚拟服务器IP与访问端口
	delay_loop 6 #健康检查时间
	persistence_timeout 0 #会话保持时间,这里要做测试, 所以设为0, 实际可根据session有效时间配置
	protocol TCP #转发协议类型,支持TCP和UDP
	real_server 192.168.0.103 3306 {
    
     #配置服务器节点linux31
		notify_down /opt/mariaDB/mariadb.sh #当服务挂掉时, 会执行此脚本,结束keepalived进程
		weight 1 #设置权重,越大权重越高
		TCP_CHECK {
    
     #r状态监测设置
			connect_timeout 10 #超时配置, 单位秒
			retry 3 #重试次数
			delay_before_retry 3 #重试间隔
			connect_port 3306 #连接端口, 和上面保持一致
        }
	}
}

注意里面IP配置正确, 修改完成后重启服务。

[root@linux3 keepalived]# systemctl restart keepalived

创建关闭脚本mariadb.sh

[root@linux3 keepalived]# vi /opt/mariaDB/mariadb.sh 

# 添加如下内容
pkill keepalived

加入执行权限:

chmod a+x mariadb.sh
  1. 修改linux4节点配置
vi /etc/keepalived/keepalived.conf

global_defs {
    
    
	router_id linux4 # 机器标识,一般设为hostname,故障发生时,邮件通知会使用到。
}
vrrp_instance VI_1 {
    
     #vrrp实例定义
	state BACKUP #lvs的状态模式,MASTER代表主, BACKUP代表备份节点
	interface ens33 #绑定对外访问的网卡
    virtual_router_id 112 #虚拟路由标示,同一个vrrp实例采用唯一标示
	priority 98 #优先级,100代表最大优先级, 数字越大优先级越高
	advert_int 1 #master与backup节点同步检查的时间间隔,单位是秒
	authentication {
    
     #设置验证信息
		auth_type PASS #有PASS和AH两种
		auth_pass 6666 #验证密码,BACKUP密码须相同
	}
	virtual_ipaddress {
    
     #KeepAlived虚拟的IP地址
		192.168.0.151
	}
}
virtual_server 192.168.0.151 3306 {
    
     #配置虚拟服务器IP与访问端口
	delay_loop 6 #健康检查时间
	persistence_timeout 0 #会话保持时间,这里要做测试, 所以设为0, 实际可根据session有效时间配置
	protocol TCP #转发协议类型,支持TCP和UDP
	real_server 192.168.0.104 3306{
    
     #配置服务器节点linux33
		notify_down /opt/mariaDB/mariadb.sh
		weight 1 #设置权重,越大权重越高
		TCP_CHECK {
    
     #r状态监测设置
			connect_timeout 10 #超时配置, 单位秒
			retry 3 #重试次数
			delay_before_retry 3 #重试间隔
			connect_port 3306 #连接端口, 和上面保持一致
		}
	}
}

创建关闭脚本mariadb.sh

[root@linux3 keepalived]# vi /opt/mariaDB/mariadb.sh 

# 添加如下内容
pkill keepalived

加入执行权限:

chmod a+x mariadb.sh
  1. 修改完后重启Keepalived服务。
systemctl restart keepalived

5.6、清理数据并验证

  1. 通过应用服务动态扩容接口做调整和验证
  2. 在linux1节点清理数据 根据取模规则, 保留accountNo为偶数的数据
delete from smooth.t_trade_order where accountNo % 2 != 0;


MariaDB [smooth]> select * from t_trade_order;
+-----+-----------+-----------+---------------------+
| id  | accountNo | execPrice | execTime            |
+-----+-----------+-----------+---------------------+
|   3 |         2 |        19 | 2022-02-19 11:00:00 |
|   7 |         4 |       400 | 2022-03-30 03:40:58 |
|  11 |         6 |       400 | 2022-03-30 03:41:24 |
|  15 |         8 |       400 | 2022-03-30 03:41:58 |
|  19 |        10 |       400 | 2022-03-30 03:46:40 |
|  23 |        12 |       400 | 2022-03-30 03:46:47 |
|  27 |        14 |       401 | 2022-03-30 03:47:00 |
|  31 |        16 |       402 | 2022-03-30 03:47:10 |
|  45 |        20 |       402 | 2022-03-30 06:39:45 |
|  49 |        20 |       402 | 2022-03-30 06:43:20 |
|  51 |        20 |       402 | 2022-03-30 06:43:23 |
|  53 |        20 |       402 | 2022-03-30 06:43:42 |
|  55 |        20 |       402 | 2022-03-30 06:43:43 |
|  57 |        20 |       402 | 2022-03-30 06:43:44 |
|  59 |        20 |       402 | 2022-03-30 06:43:44 |
|  61 |        20 |       402 | 2022-03-30 06:43:44 |
|  63 |        20 |       402 | 2022-03-30 06:43:44 |
|  65 |        20 |       402 | 2022-03-30 06:43:44 |
|  66 |        20 |       402 | 2022-03-30 07:38:06 |
|  68 |        20 |       402 | 2022-03-30 07:38:08 |
|  70 |        20 |       402 | 2022-03-30 07:38:09 |
|  72 |        20 |       402 | 2022-03-30 07:38:09 |
|  74 |        20 |       402 | 2022-03-30 07:38:09 |
|  76 |        20 |       402 | 2022-03-30 07:38:10 |
|  78 |        20 |       402 | 2022-03-30 07:38:10 |
|  80 |        20 |       402 | 2022-03-30 07:38:10 |
|  82 |        20 |       402 | 2022-03-30 07:38:10 |
|  83 |        20 |       402 | 2022-03-30 07:38:45 |
|  85 |        20 |       402 | 2022-03-30 07:38:46 |
|  87 |        20 |       402 | 2022-03-30 07:38:46 |
|  89 |        20 |       402 | 2022-03-30 07:38:46 |
|  91 |        20 |       402 | 2022-03-30 07:38:46 |
|  93 |        20 |       402 | 2022-03-30 07:38:46 |
|  95 |        20 |       402 | 2022-03-30 07:38:46 |
|  97 |        20 |       402 | 2022-03-30 07:38:47 |
|  99 |        20 |       402 | 2022-03-30 09:14:09 |
| 101 |        20 |       402 | 2022-03-30 09:14:09 |
| 103 |        20 |       402 | 2022-03-30 09:14:09 |
| 105 |        20 |       402 | 2022-03-30 09:14:09 |
| 106 |        20 |       402 | 2022-03-30 09:14:28 |
| 108 |        20 |       402 | 2022-03-30 09:14:29 |
| 110 |        20 |       402 | 2022-03-30 09:14:30 |
| 112 |        20 |       402 | 2022-03-30 09:14:30 |
| 114 |        20 |       402 | 2022-03-30 09:14:30 |
| 116 |        20 |       402 | 2022-03-30 09:14:30 |
| 118 |        20 |       402 | 2022-03-30 09:14:30 |
| 120 |        20 |       402 | 2022-03-30 09:14:31 |
| 122 |        20 |       402 | 2022-03-30 09:14:31 |
| 124 |        20 |       402 | 2022-03-30 09:14:31 |
| 126 |        20 |       402 | 2022-03-30 09:14:31 |
| 128 |        20 |       402 | 2022-03-30 09:14:31 |
| 130 |        20 |       402 | 2022-03-30 09:14:31 |
| 132 |        20 |       402 | 2022-03-30 09:14:31 |
| 134 |        20 |       402 | 2022-03-30 09:14:32 |
| 136 |        20 |       402 | 2022-03-30 09:14:32 |
| 138 |        20 |       402 | 2022-03-30 09:14:32 |
| 140 |        20 |       402 | 2022-03-30 09:14:32 |
| 141 |        20 |       402 | 2022-03-30 09:26:13 |
| 143 |        20 |       402 | 2022-03-30 09:26:14 |
| 145 |        20 |       402 | 2022-03-30 09:26:14 |
| 147 |        20 |       402 | 2022-03-30 09:26:14 |
| 149 |        20 |       402 | 2022-03-30 09:26:14 |
| 151 |        20 |       402 | 2022-03-30 09:26:14 |
| 153 |        20 |       402 | 2022-03-30 09:26:14 |
| 157 |        22 |       402 | 2022-03-30 09:26:36 |
+-----+-----------+-----------+---------------------+
65 rows in set (0.00 sec)
  1. 在linux2节点清理数据

    根据取模规则, 保留accountNo为奇数的数据

delete from smooth.t_trade_order where accountNo % 2 != 1;

MariaDB [smooth]> select * from t_trade_order;
+-----+-----------+-----------+---------------------+
| id  | accountNo | execPrice | execTime            |
+-----+-----------+-----------+---------------------+
|   2 |         1 |        15 | 2022-03-29 12:00:00 |
|   5 |         3 |         3 | 2022-03-30 03:40:02 |
|   9 |         5 |       400 | 2022-03-30 03:41:12 |
|  13 |         7 |       400 | 2022-03-30 03:41:54 |
|  17 |         9 |       400 | 2022-03-30 03:46:35 |
|  21 |        11 |       400 | 2022-03-30 03:46:44 |
|  25 |        13 |       400 | 2022-03-30 03:46:52 |
|  29 |        15 |       401 | 2022-03-30 03:47:03 |
|  33 |        17 |       402 | 2022-03-30 03:48:22 |
|  35 |        17 |       402 | 2022-03-30 06:32:39 |
|  37 |        17 |       402 | 2022-03-30 06:32:40 |
|  39 |        17 |       402 | 2022-03-30 06:32:42 |
|  41 |        17 |       402 | 2022-03-30 06:32:43 |
|  43 |        19 |       402 | 2022-03-30 06:39:40 |
|  46 |        21 |       666 | 2022-03-29 12:00:00 |
|  48 |        21 |       666 | 2022-03-29 12:00:00 |
| 155 |        21 |       401 | 2022-03-30 09:26:28 |
+-----+-----------+-----------+---------------------+
17 rows in set (0.00 sec)

5.7、测试

1、在linux1上执行

mysql -uroot -proot

use smooth;

select * from t_trade_order;

insert into t_trade_order values(null, 111, 666, '2022-03-31 00:00:00');

2、在linux3上执行,检查新增数据是否同步

mysql -uroot -proot

use smooth;

select * from t_trade_order;

3、在linux2和linux4上执行,检查新增数据是否末同步,防止前面配置出现问题

4、在linux2上执行

mysql -uroot -proot

use smooth;

select * from t_trade_order;

insert into t_trade_order values(null, 520, 520, '2022-03-31 12:30:00');

5、在linux4上执行,检查新增数据是否同步

mysql -uroot -proot

use smooth;

select * from t_trade_order;

3、在linux1和linux3上执行,检查新增数据是否末同步,防止前面配置出现问题

猜你喜欢

转载自blog.csdn.net/qq_37242720/article/details/123897888
今日推荐