mysql主从复制、GTID复制、半同步复制、多主复制

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_41927237/article/details/81535468

整篇实验要求:mysql5.7 虚拟机6.5版本

一、mysql的主从复制
原理图:
一主一从
这里写图片描述
MySQL之间数据复制的基础是二进制日志文件(binary log file),这个日志会记录下所有修改了数据库的SQL语句(insert,update,delete,ALTER TABLE,grant等等)。 一台MySQL数据库一旦启用二进制日志后,其作为master,它的数据库中所有操作都会以“事件”的方式记录在二进制日志中,其他数据库作为slave通过一个I/O线程与主服务器保持通信,并监控master的二进制日志文件的变化,如果发现master二进制日志文件发生变化,则会把变化复制到自己的中继日志中,然后slave的一个SQL线程会把相关的“事件”执行到自己的数据库中,以此实现从数据库和主数据库的一致性,也就实现了主从复制。
实验:
server1、serve2:

get 
mysql-community-client-5.7.17-1.el6.x86_64.rpm
mysql-community-common-5.7.17-1.el6.x86_64.rpm
mysql-community-libs-5.7.17-1.el6.x86_64.rpm
mysql-community-libs-compat-5.7.17-1.el6.x86_64.rpm
mysql-community-server-5.7.17-1.el6.x86_64.rpm
yum install * -y

server1:

修改mysql配置
[root@server1 ~]# vim /etc/my.cnf
server-id=1         #设置server-id
log-bin=mysql-bin   #开启二进制日志
[root@server1 ~]# /etc/init.d/mysqld start
查看数据库初始密码
grep password /var/log/mysqld.log  
mysql安全设置
mysql_secure_installation
Estimated strength of the password: 100 
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : n
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
[root@server1 ~]# mysql -p

server2:

修改mysql配置
[root@server2 ~]# vim /etc/my.cnf
server-id=2   #设置serverid,必须唯一
[root@server2 ~]# /etc/init.d/mysqld start
[root@server2 ~]# grep password /var/log/mysqld.log 
[root@server2 ~]# mysql_secure_installation 

server1:
主数据库master:

[root@server1 ~]# mysql -p
mysql> show databases;
mysql> grant replication slave on *.* to repl@'172.25.10.%' identified by 'Wxj14370902!';
mysql> show master status;
查看master状态,记录二进制文件名(mysql-bin.000004)和位置(843)
+------------------+----------+--------------+------------------+-------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000004 |      843 |              |                  |                   |
+------------------+----------+--------------+------------------+-------------------+

server2:
从数据库slave:

mysql -p
打开mysql会话,执行同步SQL语句(需要主服务器主机名,登陆凭据,二进制文件的名称和位置):
mysql> change master to master_host='172.25.10.1',master_user='repl',master_password='Wxj14370902!',master_log_file='mysql-bin.000004',master_log_pos=843;
启动slave同步进程:
mysql> start slave;
查看slave状态:
mysql> show slave status\G;
             Slave_IO_Running: Yes #I/O线程是否被启动并成功地连接到主服务器上
            Slave_SQL_Running: Yes #SQL线程是否被启动

当Slave_IO_Running和Slave_SQL_Running都为YES的时候就表示主从同步设置成功了。接下来就可以进行一些验证了.
master:

mysql> create database test;
mysql> use test
mysql> create table userlist (
    -> username varchar(15) not null,
    -> password varchar(25) not null);
mysql> desc userlist;
+----------+-------------+------+-----+---------+-------+
| Field    | Type        | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| username | varchar(15) | NO   |     | NULL    |       |
| password | varchar(25) | NO   |     | NULL    |       |
+----------+-------------+------+-----+---------+-------+
mysql> insert into userlist values('user1','123');
mysql> insert into userlist values('user2','456');

slave:

mysql> show databases;
mysql> use test
mysql> select * from userlist;
+----------+----------+
| username | password |
+----------+----------+
| user1    | 123      |
| user2    | 456      |
+----------+----------+

二、GTID复制
master、slave:

vim /etc/my.cnf
gtid_mode=ON
enforce-gtid-consistency=true
/etc/init.d/mysqld restart
mysql -p

slave:

mysql> stop slave;
mysql> change master to master_host='172.25.10.1',master_user='repl',master_password='Wxj14370902!',MASTER_AUTO_POSITION=1;

三、三台虚拟机实现主从同步
server1:master
server2:master、slave
server3:slave
1、编辑配置文件
server1:

vim /etc/my.cnf
 29 server-id=1
 30 log-bin=mysql-bin
 31 
 32 gtid_mode=ON
 33 enforce-gtid-consistency=true

server2:

 29 server-id=2
 30 log-bin=mysql-bin
 31 log-slave-updates
 32 
 33 gtid_mode=ON
 34 enforce-gtid-consistency=true

server3:

 29 server-id=3
 30 
 31 gtid_mode=ON
 32 enforce-gtid-consistency=true

2、server2给server3授权
server2:

授权
mysql> grant replication slave on *.* to repl@'172.25.10.%' identified by 'Wxj14370902!';
mysql> flush privileges;
mysql> show master status

server3:

测试能否登入,不做任何操作
[root@server3 ~]# mysql -u repl -p -h 172.25.10.2
mysql> ^C
mysql> exit

3、server2作为server1的slave从master同步的信息导入文件中给server3发去
server2:

[root@server2 ~]# mysqldump -p test > test.sql
添加信息
[root@server2 ~]# vim test.sql 
 27 --
 28 -- Table structure for table `userlist`
 29 --
 30 
* 31 create database test;
 32 
* 33 use test;
 34 
 35 
 36 DROP TABLE IF EXISTS `userlist`;
[root@server2 ~]# scp test.sql 172.25.10.3:/root

4、在server3中导入库信息
server3:

[root@server3 ~]# mysql -p < test.sql
Enter password: 
[root@server3 ~]# mysql -p
mysql> show databases;
mysql> use test
mysql> show tables;
mysql> select * from userlist;

这里写图片描述
同步授权

mysql> change master to master_host='172.25.10.2',master_user='repl',master_password='Wxj14370902!',master_auto_position=1;
mysql> start slave;
mysql> show slave status\G;
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes

5、测试
在server1 userlist表中插入字符
server1:

mysql> insert into userlist values('user3','333');

server2中将库文件发送至3
server2:

[root@server2 ~]# scp test.sql server3:/root

server3中同步
server3:

mysql> select * from userlist;

这里写图片描述

server2:

[root@server2 ~]# mysql -p
查看进程表
mysql> show processlist;
编辑配置文件
[root@server2 ~]# vim /etc/my.cnf
server-id=2
log-bin=mysql-bin
log-slave-updates

gtid_mode=ON
enforce-gtid-consistency=true

slave-parallel-type=LOGICAL_CLOCK
slave-parallel-workers=16
master_info_repository=TABLE
relay_log_info_repository=TABLE
relay_log_recovery=ON
[root@server2 mysql]# /etc/init.d/mysqld restart
[root@server2 ~]# mysql -p
再次查看进程表
mysql> show processlist;
[root@server2 ~]# cd /var/lib/mysql
[root@server2 mysql]# ls
[root@server2 mysql]# cat relay-log.info 
[root@server2 mysql]# cat master.info 

server3:

[root@server3 ~]# vim /etc/my.cnf
server-id=3

gtid_mode=ON
enforce-gtid-consistency=true

slave-parallel-type=LOGICAL_CLOCK
slave-parallel-workers=16
master_info_repository=TABLE
relay_log_info_repository=TABLE
relay_log_recovery=ON
[root@server3 ~]# /etc/init.d/mysqld restart

四、半同步复制
何为半同步复制模式呢?在此我们先了解异步复制模式,这是MySQL的默认复制选项。异步复制即是master数据库把binlog日志发送给slave数据库,然后就没有了然后了。在此暴露一个问题,当slave服务器发生故障了,那么肯定会导致主从数据库服务器的数据不一致。
介于异步复制和全同步复制之间,主库在执行完客户端提交的事务后不是立刻返回给客户端,而是等待至少一个从库接收到并写到relay log中才返回给客户端。相对于异步复制,半同步复制提高了数据的安全性,同时它也造成了一定程度的延迟,这个延迟最少是一个TCP/IP往返的时间。所以,半同步复制最好在低延时的网络中使用。
server1:

mysql> INSTALL PLUGIN rpl_semi_sync_master SONAME 'semisync_master.so';
mysql> SET GLOBAL rpl_semi_sync_master_enabled = 1;
mysql> SHOW VARIABLES LIKE 'rpl_semi_sync%';
+-------------------------------------------+------------+
| Variable_name                             | Value      |
+-------------------------------------------+------------+
| rpl_semi_sync_master_enabled              | ON         |
| rpl_semi_sync_master_timeout              | 10000      |  ##超时设置 单位是毫秒,默认为10000,即10s
| rpl_semi_sync_master_trace_level          | 32         |
| rpl_semi_sync_master_wait_for_slave_count | 1          |
| rpl_semi_sync_master_wait_no_slave        | ON         |
| rpl_semi_sync_master_wait_point           | AFTER_SYNC |
+-------------------------------------------+------------+
mysql> SHOW STATUS LIKE 'Rpl_semi_sync%';
+--------------------------------------------+-------+
| Variable_name                              | Value |
+--------------------------------------------+-------+
| Rpl_semi_sync_master_clients               | 1     |
| Rpl_semi_sync_master_net_avg_wait_time     | 0     |
| Rpl_semi_sync_master_net_wait_time         | 0     |
| Rpl_semi_sync_master_net_waits             | 0     |
| Rpl_semi_sync_master_no_times              | 0     |
| Rpl_semi_sync_master_no_tx                 | 0     |
| Rpl_semi_sync_master_status                | ON    |  ##master半同步运行
| Rpl_semi_sync_master_timefunc_failures     | 0     |
| Rpl_semi_sync_master_tx_avg_wait_time      | 0     |
| Rpl_semi_sync_master_tx_wait_time          | 0     |
| Rpl_semi_sync_master_tx_waits              | 0     |
| Rpl_semi_sync_master_wait_pos_backtraverse | 0     |
| Rpl_semi_sync_master_wait_sessions         | 0     |
| Rpl_semi_sync_master_yes_tx                | 0     |
+--------------------------------------------+-------+

server2:

mysql> INSTALL PLUGIN rpl_semi_sync_slave SONAME 'semisync_slave.so';
mysql> INSTALL PLUGIN rpl_semi_sync_master SONAME 'semisync_master.so';
mysql> SET GLOBAL rpl_semi_sync_slave_enabled = 1;
mysql> SET GLOBAL rpl_semi_sync_master_enabled = 1;
mysql> STOP SLAVE IO_THREAD;
mysql> START SLAVE IO_THREAD;
mysql> SHOW VARIABLES LIKE 'rpl_semi_sync%';
+-------------------------------------------+------------+
| Variable_name                             | Value      |
+-------------------------------------------+------------+
| rpl_semi_sync_master_enabled              | ON         |
| rpl_semi_sync_master_timeout              | 10000      |
| rpl_semi_sync_master_trace_level          | 32         |
| rpl_semi_sync_master_wait_for_slave_count | 1          |
| rpl_semi_sync_master_wait_no_slave        | ON         |
| rpl_semi_sync_master_wait_point           | AFTER_SYNC |
| rpl_semi_sync_slave_enabled               | ON         |
| rpl_semi_sync_slave_trace_level           | 32         |
+-------------------------------------------+------------+
mysql> SHOW STATUS LIKE 'Rpl_semi_sync%';
+--------------------------------------------+-------+
| Variable_name                              | Value |
+--------------------------------------------+-------+
| Rpl_semi_sync_master_clients               | 1     |
| Rpl_semi_sync_master_net_avg_wait_time     | 0     |
| Rpl_semi_sync_master_net_wait_time         | 0     |
| Rpl_semi_sync_master_net_waits             | 0     |
| Rpl_semi_sync_master_no_times              | 0     |
| Rpl_semi_sync_master_no_tx                 | 0     |
| Rpl_semi_sync_master_status                | ON    | ##master半同步运行
| Rpl_semi_sync_master_timefunc_failures     | 0     |
| Rpl_semi_sync_master_tx_avg_wait_time      | 0     |
| Rpl_semi_sync_master_tx_wait_time          | 0     |
| Rpl_semi_sync_master_tx_waits              | 0     |
| Rpl_semi_sync_master_wait_pos_backtraverse | 0     |
| Rpl_semi_sync_master_wait_sessions         | 0     |
| Rpl_semi_sync_master_yes_tx                | 0     |
| Rpl_semi_sync_slave_status                 | ON    | ##slave半同步运行
+--------------------------------------------+-------+

server3:

mysql> INSTALL PLUGIN rpl_semi_sync_slave SONAME 'semisync_slave.so';
mysql> SET GLOBAL rpl_semi_sync_slave_enabled = 1;
重启IO线程
mysql> STOP SLAVE IO_THREAD;
mysql> START SLAVE IO_THREAD;
mysql> SHOW STATUS LIKE 'Rpl_semi_sync%';
+----------------------------+-------+
| Variable_name              | Value |
+----------------------------+-------+
| Rpl_semi_sync_slave_status | ON    |  ##slave半同步运行
+----------------------------+-------+
mysql> SHOW VARIABLES LIKE 'rpl_semi_sync%';
+---------------------------------+-------+
| Variable_name                   | Value |
+---------------------------------+-------+
| rpl_semi_sync_slave_enabled     | ON    |
| rpl_semi_sync_slave_trace_level | 32    |
+---------------------------------+-------+

验证:
1、在Slave执行stop slave之前,主的insert操作很快就能返回。
server1:

mysql> insert into userlist values ('user4','222');
mysql> insert into userlist values ('user5','333');

server2:

mysql> SHOW STATUS LIKE 'Rpl_semi_sync%';
+--------------------------------------------+-------+
| Variable_name                              | Value |
+--------------------------------------------+-------+
| Rpl_semi_sync_master_clients               | 1     |
| Rpl_semi_sync_master_net_avg_wait_time     | 0     |
| Rpl_semi_sync_master_net_wait_time         | 0     |
| Rpl_semi_sync_master_net_waits             | 2     |
| Rpl_semi_sync_master_no_times              | 0     |
| Rpl_semi_sync_master_no_tx                 | 0     |
| Rpl_semi_sync_master_status                | ON    |
| Rpl_semi_sync_master_timefunc_failures     | 0     |
| Rpl_semi_sync_master_tx_avg_wait_time      | 331   |
| Rpl_semi_sync_master_tx_wait_time          | 662   |
| Rpl_semi_sync_master_tx_waits              | 2     |
| Rpl_semi_sync_master_wait_pos_backtraverse | 0     |
| Rpl_semi_sync_master_wait_sessions         | 0     |
| Rpl_semi_sync_master_yes_tx                | 2     |   ##半同步
| Rpl_semi_sync_slave_status                 | ON    |
+--------------------------------------------+-------+

server3:

mysql> use test
mysql> select * from userlist;
+----------+----------+
| username | password |
+----------+----------+
| user1    | 123      |
| user2    | 456      |
| user2    | 456      |
| user3    | 333      |
| user4    | 222      |
| user5    | 333      |
+----------+----------+

2、当在2中执行stop slave后,在1表中插入字符需要10.08s才返回,与超时参数符合,在3中没有同步
server2:

mysql> STOP SLAVE IO_THREAD;

server1:

mysql> insert into userlist values ('user6','666');
Query OK, 1 row affected (10.08 sec)
server3中没有同步

当在server2中执行start slave,在1表中插入字符很快就能返回,在3中即可同步
server2:

mysql> START SLAVE IO_THREAD;
server3中同步

这里写图片描述
五、mysql多主复制

1)复制组由多个 server成员构成,并且组中的每个 server 成员可以独立地执行事务。但所有读写(RW)事务
只有在冲突检测成功后才会提交。只读(RO)事务不需要在冲突检测,可以立即提交。


2)换句话说,对于任何 RW 事务,提交操作并不是由始发 server 单向决定的,而是由组来决定是否提交。
准确地说,在始发 server 上,当事务准备好提交时,该 server 会广播写入值(已改变的行)和对应的写入集
(已更新的行的唯一标识符)。然后会为该事务建立一个全局的顺序。最终,这意味着所有 server 成员以相同的
顺序接收同一组事务。因此,所有 server 成员以相同的顺序应用相同的更改,以确保组内一致。


3)组复制使您能够根据在一组 server 中复制系统的状态来创建具有冗余的容错系统。因此,只要它不是全部或
多数 server 发生故障,即使有一些 server 故障,系统仍然可用,最多只是性能和可伸缩性降低,但它仍然可用。
server 故障是孤立并且独立的。它们由组成员服务来监控,组成员服务依赖于分布式故障检测系统,其能够在
任何 server 自愿地或由于意外停止而离开组时发出信号。


4)他们是由一个分布式恢复程序来确保当有 server 加入组时,它们会自动更新组信息到最新。并且多主更新确保了
即使在单个服务器故障的情况下也不会阻止更新,不必进行 server故障转移。因此,MySQL 组复制保证数据库服务持续可用。


5)值得注意的一点是,尽管数据库服务可用,但当有一个 server 崩溃时,连接到它的客户端必须定向或故障
转移到不同的 server。
这不是组复制要解决的问题。连接器,负载均衡器,路由器或其他形式的中间件更适合处理这个问题。
总之,MySQL 组复制提供了高可用性,高弹性,可靠的 MySQL 服务。

实验:
实验环境:
server1、2、3:

先停止mysql数据库
[root@server1 ~]# /etc/init.d/mysqld stop
删掉之前做实验的数据库内容
[root@server1 ~]# cd /var/lib/mysql
[root@server1 mysql]# rm -fr *

1、编辑配置文件

[root@server1 mysql]# vim /etc/my.cnf
 29 server_id=1    ##server2、server3中分别改为2、3
 30 gtid_mode=ON
 31 enforce_gtid_consistency=ON
 32 master_info_repository=TABLE
 33 relay_log_info_repository=TABLE
 34 binlog_checksum=NONE
 35 log_slave_updates=ON
 36 log_bin=binlog
 37 binlog_format=ROW
 38 
 39 transaction_write_set_extraction=XXHASH64
 40 loose-group_replication_group_name="b5020ba9-9c7b-11e8-b7b2-5254009d6d14"
 41 loose-group_replication_start_on_boot=off
 42 loose-group_replication_local_address= "172.25.10.1:24901"  ##server2、3中分别改为2、3
 43 loose-group_replication_group_seeds="172.25.10.1:24901,172.25.10.2:24901,172.    25.10.3:24901"
 44 loose-group_replication_bootstrap_group=off
 45 loose-group_replication_single_primary_mode=off
 46 loose-group_replication_enforce_update_everywhere_checks=on
 47 loose-group_replication_ip_whitelist="172.25.10.0/24,127.0.0.1/8"
开启数据库
[root@server1 mysql]# /etc/init.d/mysqld start

2、数据库配置
server1:

查看初始密码
[root@server1 mysql]# grep password /var/log/mysqld.log 
使用初始密码登陆
[root@server1 mysql]# mysql -p
mysql> ALTER USER root@localhost identified by 'Wxj14370902!';
mysql> show databases;     ##修改密码才可查看内容
mysql> SET SQL_LOG_BIN=0;
mysql> GRANT REPLICATION SLAVE ON *.* TO rpl_user@'%' IDENTIFIED BY 'Wxj14370902!';
mysql> FLUSH PRIVILEGES;
mysql> reset master;
mysql> SET SQL_LOG_BIN=1;
mysql> CHANGE MASTER TO MASTER_USER='rpl_user', MASTER_PASSWORD='Wxj14370902!' FOR CHANNEL 'group_replication_recovery';
mysql> INSTALL PLUGIN group_replication SONAME 'group_replication.so';
mysql> SHOW PLUGINS;
| group_replication          | ACTIVE   | GROUP REPLICATION  | group_replication.so | GPL     |
mysql> SET GLOBAL group_replication_bootstrap_group=ON;
mysql> START GROUP_REPLICATION;
mysql> SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | d2a4739a-9c7c-11e8-8903-5254001476cf | server1     |        3306 | ONLINE       |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
mysql> create database test;
mysql> use test;
mysql> INSERT INTO t1 VALUES (1, 'Luis');
mysql> SELECT * FROM t1;
+----+------+
| c1 | c2   |
+----+------+
|  1 | Luis |
+----+------+

这里写图片描述
这里写图片描述
server2:

[root@server2 mysql]# grep password /var/log/mysqld.log 
[root@server2 mysql]# mysql -p
mysql> ALTER USER root@localhost identified by 'Wxj14370902!';
mysql> show databases;
mysql> SET SQL_LOG_BIN=0;
mysql> GRANT REPLICATION SLAVE ON *.* TO rpl_user@'%' IDENTIFIED BY 'Wxj14370902!';
mysql> reset master;
mysql> SET SQL_LOG_BIN=1;
mysql> CHANGE MASTER TO MASTER_USER='rpl_user', MASTER_PASSWORD='Wxj14370902!' FOR CHANNEL 'group_replication_recovery';
mysql> INSTALL PLUGIN group_replication SONAME 'group_replication.so';
mysql> START GROUP_REPLICATION;
mysql> SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | d2a4739a-9c7c-11e8-8903-5254001476cf | server1     |        3306 | ONLINE       |
| group_replication_applier | d6306b9d-9c80-11e8-8411-525400d42000 | server2     |        3306 | ONLINE       |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
mysql> use test
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| t1             |
+----------------+
mysql> select * from t1;
+----+------+
| c1 | c2   |
+----+------+
|  1 | Luis |
+----+------+

这里写图片描述
server3:

[root@server3 mysql]# grep password /var/log/mysqld.log 
[root@server3 mysql]# mysql -p
mysql> ALTER USER root@localhost identified by 'Wxj14370902!';
mysql> show databases;
mysql> SET SQL_LOG_BIN=0;
mysql> GRANT REPLICATION SLAVE ON *.* TO rpl_user@'%' IDENTIFIED BY 'Wxj14370902!';
mysql> reset master;
mysql> SET SQL_LOG_BIN=1;
mysql> CHANGE MASTER TO MASTER_USER='rpl_user', MASTER_PASSWORD='Wxj14370902!' FOR CHANNEL 'group_replication_recovery';
mysql> INSTALL PLUGIN group_replication SONAME 'group_replication.so';
mysql> START GROUP_REPLICATION;
mysql> SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | 47f02b48-9c82-11e8-9e63-5254009d6d14 | server3     |        3306 | ONLINE       |
| group_replication_applier | d2a4739a-9c7c-11e8-8903-5254001476cf | server1     |        3306 | ONLINE       |
| group_replication_applier | d6306b9d-9c80-11e8-8411-525400d42000 | server2     |        3306 | ONLINE       |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
mysql> use test
mysql> select * from t1;
+----+------+
| c1 | c2   |
+----+------+
|  1 | Luis |
+----+------+

3、检测:3台主机数据同步
server3中:

mysql> insert into t1 values (2,'haha');

在1、2中:

这里写图片描述

server2中:

mysql> insert into t1 values (3,'xixi');

在1、3中:
这里写图片描述

展开阅读全文

没有更多推荐了,返回首页