1 案例1:MySQL一主一从
1.1 问题
• 构建 主–>从 复制结构
• 其中主机192.168.4.10作为主库
• 主机192.168.4.20作为从库
1.2 方案
使用2台RHEL 7虚拟机,如图-1所示。其中192.168.4.10是MySQL主服务器,负责提供同步源;另一台192.168.4.20作为MySQL从服务器,通过调取主服务器上的binlog日志,在本地重做对应的库、表,实现与主服务器的AB复制(同步)。
图-1
提前为两台MySQL服务器安装好MySQL-server、MySQL-Client软件包,并为数据库用户root修改密码;Linux客户机上则只需安装MySQL-Client软件包即可。
1.3 步骤
实现此案例需要按照如下步骤进行。
步骤一:初始化现有库
为了在启用binlog日志及同步之前保持主、从库的一致性,建议进行初始化——备份主服务器上现有的库,然后导入到从服务器上。
当现有库、表都采用MyISAM引擎时,可执行离线备份、恢复,这样更有效率;否则,可通过mysqldump等工具来实现库的导出、导入。
1)备份MySQL Master(192.168.4.10)上现有的库
如果服务器已经启用binlog,建议对日志做一次重置,否则可忽略:
-
[root@zlz ~]# mysql -u root -pEnter password: //以数据库用户root登入.. ..mysql> RESET MASTER; //重置binlog日志Query OK, 0 rows affected (0.06 sec)mysql> quit //退出mysql> 环境Bye
以备份mysql库、sys库为例,导出操作如下:
-
[root@zlz ~]# mysqldump -u root -p –all-databases > /root/mytest.sqlEnter password: //验证口令[root@zlz ~]# ls -lh /root/mytest.sql //确认备份结果-rw-r--r--. 1 root root 777172 4月 23 12:21 /root/mytest.sql
2)在MySQL Slave(192.168.4.20)上导入备份的库
先清理目标库,避免导入时冲突。主要是采用InnoDB引擎的库,授权库mysql多采用MyISAM引擎,可不做清理。
-
[root@zlz ~]# mysql -u root -pEnter password: //以数据库用户root登入.. ..mysql> DROP DATABASE test; //删除test库Query OK, 0 rows affected (0.03 sec)mysql> quit //退出mysql> 环境Bye
使用scp工具下载备份文件:
-
[root@zlz ~]# scp /root/mytest.sql root@192.168.4.20:/root@dbsvr1\'s password: //验证对方系统用户root的口令mytest.sql 100% 759KB 759.0KB/s 00:00[root@zlz ~]# ls -lh mytest.sql //确认下载结果-rw-r--r--. 1 root root 759K 4月 23 12:22 /mytest.sql
执行导入操作:
-
[root@zlz ~]# mysql -u root -p < /mytest.sqlEnter password: //验证口令
导入成功后,可重新登入 mysql> 环境,确认清理的目标库已恢复:
-
mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || sys |+--------------------+4 rows in set (0.00 sec)
步骤二:配置MySQL Master(主服务器,192.168.4.10)
1)修改/etc/my.cnf配置,重新启动MySQL服务程序
指定服务器ID号、允许日志同步:
-
[root@zlz mysql]# vim /etc/my.cnf[mysqld]log_bin=dbsvr1-bin //启用binlog日志,并指定文件名前缀server_id = 10 //指定服务器ID号......
重启mysql服务:
-
[root@zlz ~]# systemctl restart mysqld.service
2)新建一个备份用户,授予复制权限
需要的权限为REPLICATION SLAVE,允许其从Slave服务器访问:
-
mysql> GRANT REPLICATION SLAVE ON *.* TO \'replicater\'@\'192.168.4.%\' IDENTIFIED BY \'pwd123\';Query OK, 0 rows affected, 1 warning (0.09 sec)
3)检查Master服务器的同步状态
在已经初始化现有库的情况下,查看MASTER状态,记录下当前的日志文件名、偏移的位置(下面SLAVE发起复制时需要用到):
-
mysql> SHOW MASTER STATUS\\G*************************** 1. row ***************************File: dbsvr1-bin.000001 //记住当前的日志文件名Position: 154 //记住当前的位置Binlog_Do_DB:Binlog_Ignore_DB:Executed_Gtid_Set:1 row in set (0.00 sec)
步骤三:配置MySQL Slave(从服务器,192.168.4.20)
1)修改/etc/my.cnf配置,重新启动MySQL服务程序
指定服务器ID号、允许日志同步:
-
[root@zlz ~]# vim /etc/my.cnf[mysqld]log_bin=dbsvr2-bin //启动SQL日志,并指定文件名前缀server_id = 20 //指定服务器ID号,不要与Master的相同.. ..
在生产环境中,还可以根据需要设置更详细的同步选项。比如,指定当主、从网络中断时的重试超时时间(slave-net-timeout=60 )等,具体可参考MySQL手册。
配置完成后,重启mysql服务:
-
[root@zlz ~]# systemctl restart mysqld.service
通过CHANGE MASTER语句指定MASTER服务器的IP地址、同步用户名/密码、起始日志文件、偏移位置(参考MASTER上的状态输出):
-
mysql> CHANGE MASTER TO MASTER_HOST=\'192.168.4.10\',-> MASTER_USER=\'replicater\',-> MASTER_PASSWORD=\'pwd123\',-> MASTER_LOG_FILE=\'dbsvr1-bin.000002\', //对应Master的日志文件-> MASTER_LOG_POS=334; //对应Master的日志偏移位置Query OK, 0 rows affected, 2 warnings (0.12 sec)
然后执行START SLAVE(较早版本中为SLAVE START)启动复制:
-
mysql> START SLAVE; //启动复制Query OK, 0 rows affected (0.00 sec)
注意:一旦启用SLAVE复制,当需要修改MASTER信息时,应先执行STOP SLAVE停止复制,然后重新修改、启动复制。
通过上述连接操作,MASTER服务器的设置信息自动存为master.info文件,以后每次MySQL服务程序时会自动调用并更新,无需重复设置。查看master.info文件的开头部分内容,可验证相关设置:
-
[root@zlz ~]# ls -lh /var/lib/mysql/master.info-rw-r-----. 1 mysql mysql 132 4月 23 12:06 /var/lib/mysql/master.info[root@zlz ~]# head /var/lib/mysql/master.info25dbsvr1-bin.000001154192.168.4.10replicaterpwd1233306600
2)检查Slave服务器的同步状态
通过SHOW SLAVE STATUS语句可查看从服务器状态,确认其中的IO线程、SQL线程正常运行,才能成功同步:
-
mysql> SHOW SLAVE STATUS\\GSlave_IO_State: Waiting for master to send eventMaster_Host: 192.168.4.1Master_User: replicaterMaster_Port: 3306Connect_Retry: 60Master_Log_File: dbsvr1-bin.000001Read_Master_Log_Pos: 154Relay_Log_File: db2-relay-bin.000003Relay_Log_Pos: 321Relay_Master_Log_File: dbsvr1-bin.000001Slave_IO_Running: Yes //IO线程应该已运行Slave_SQL_Running: Yes //SQL线程应该已运行Replicate_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: 154Relay_Log_Space: 2490Until_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: 0Master_SSL_Verify_Server_Cert: NoLast_IO_Errno: 0Last_IO_Error:Last_SQL_Errno: 0Last_SQL_Error:Replicate_Ignore_Server_Ids:Master_Server_Id: 10Master_UUID: 2d4d8a11-27b7-11e7-ae78-52540055c180Master_Info_File: /var/lib/mysql/master.infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State: Slave has read all relay log; waiting for more updatesMaster_Retry_Count: 86400Master_Bind:Last_IO_Error_Timestamp:Last_SQL_Error_Timestamp:Master_SSL_Crl:Master_SSL_Crlpath:Retrieved_Gtid_Set:Executed_Gtid_Set:Auto_Position: 0Replicate_Rewrite_DB:Channel_Name:Master_TLS_Version:1 row in set (0.00 sec)
若START SLAVE直接报错失败,请检查CHANGE MASTER相关设置是否有误,纠正后再重试;若IO线程或SQL线程有一个为“No”,则应检查服务器的错误日志,分析并排除故障后重启主从复制。
步骤四:测试主从同步效果
1)在Master上操作数据库、表、表记录
新建newdb库、newtable表,随意插入几条表记录:
-
mysql> CREATE DATABASE newdb; //新建库newdbQuery OK, 1 row affected (0.17 sec)mysql> USE newdb; //切换到newdb库Database changedmysql> CREATE TABLE newtable(id int(4)); //新建ne wtable表Query OK, 0 rows affected (0.46 sec)mysql> INSERT INTO newtable VALUES(1234),(5678); //插入2条表记录Query OK, 2 rows affected (0.24 sec)Records: 2 Duplicates: 0 Warnings: 0mysql> SELECT * FROM newtable; //确认表数据+------+| id |+------+| 1234 || 5678 |+------+2 rows in set (0.00 sec)
2)在Slave上确认自动同步的结果
直接切换到newdb库,并查询newtable表的记录,应该与Master上的一样,这才说明主从同步已经成功生效:
-
mysql> USE newdb; //直接切换到newdb库Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> SELECT * FROM newtable; //输出表记录+------+| id |+------+| 1234 || 5678 |+------+2 rows in set (0.02 sec)
3)在Master服务器上可查看Slave主机的信息
-
mysql> SHOW SLAVE HOSTS;+-----------+------+------+-----------+--------------------------------------+| Server_id | Host | Port | Master_id | Slave_UUID |+-----------+------+------+-----------+--------------------------------------+| 2 | | 3306 | 10 | 512cf7c1-27c4-11e7-8f4b-5254007b030b |+-----------+------+------+-----------+--------------------------------------+1 row in set (0.00 sec)
2 案例2:配置主从从同步结构
2.1 问题
• 具体要求如下:
• 配置主机192.168.4.51为主数据库服务器
• 配置主机192.168.4.52为51主机的从库服务器
• 配置主机192.168.4.53为52主机的从库服务器
• 客户端连接主数据库服务器51主机创建的数据,连接52和53主机时,也可以访问到库、表、记录。
2.2 方案
使用3台RHEL 7虚拟机,如图-2所示。其中192.168.4.51是MySQL主服务器,负责提供同步源;另一台192.168.4.52作为192.168.4.51从服务器,最后一台192.168.4.53作为192.168.4.52从服务器,通过调取主服务器上的binlog日志,客户端访问主库51 时 创建库表记录 在52 和53 数据库服务器都可以看到
图-2
2.3 步骤
实现此案例需要按照如下步骤进行。
步骤一:环境准备
为了在启用binlog日志及同步之前保持主、从库的一致性,主从同步未配置之前,要保证从库上要有主库上的数据,禁用selinux,关闭防火墙服务,保证物理连接正常
-
[root@zlz ~]# systemctl stop firewalld[root@zlz ~]# setenforce 0[root@zlz ~]# ping -c 2 192.168.4.51PING 192.168.4.51 (192.168.4.51) 56(84) bytes of data.64 bytes from 192.168.4.51: icmp_seq=1 ttl=64 time=0.059 ms64 bytes from 192.168.4.51: icmp_seq=2 ttl=64 time=0.063 ms--- 192.168.4.51 ping statistics ---2 packets transmitted, 2 received, 0% packet loss, time 999msrtt min/avg/max/mdev = 0.059/0.061/0.063/0.002 ms[root@zlz ~]# ping -c 2 192.168.4.52PING 192.168.4.52 (192.168.4.52) 56(84) bytes of data.64 bytes from 192.168.4.52: icmp_seq=1 ttl=64 time=0.698 ms64 bytes from 192.168.4.52: icmp_seq=2 ttl=64 time=0.365 ms--- 192.168.4.52 ping statistics ---2 packets transmitted, 2 received, 0% packet loss, time 1000msrtt min/avg/max/mdev = 0.365/0.531/0.698/0.168 ms
步骤二:配置主服务器192.168.4.51
1)对yaya用户进行授权
-
[root@zlz ~]# mysql -uroot -p123456mysql> grant replication slave on *.* to yaya@\"%\" identified by \"123456\";Query OK, 0 rows affected, 1 warning (0.03 sec)
2)启用binlog日志,修改/etc/my.cnf配置,重新启动MySQL服务程序
指定服务器ID号、允许日志同步:
-
[root@zlz ~]# vim /etc/my.cnf[mysqld]log_bin=db51 //启用binlog日志,并指定文件名前缀server_id=51 //指定服务器ID号binlog-format=\"mixed\" // 指定binlog日志格式
重启mysql服务:
-
[root@zlz ~]# systemctl restart mysqld
确保/var/lib/mysql下面有两个文件:
-
[root@zlz ~]# ls /var/lib/mysql/db51.*/var/lib/mysql/db51.000001 /var/lib/mysql/db51.index
查看主服务正在使用的日志信息
查看主服务器状态,记录下当前的日志文件名、偏移的位置(下面SLAVE发起复制时需要用到):
-
mysql> show master status;+-------------+----------+--------------+------------------+-------------------+| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |+-------------+----------+--------------+------------------+-------------------+| db51.000002 | 437 | | | |+-------------+----------+--------------+------------------+-------------------+1 row in set (0.00 sec)
步骤三:配置从服务器192.168.4.52
1)在服务器192.168.4.52上对user53用户进行授权
-
[root@zlz ~]# mysql -u root -p123456mysql> grant replication slave on *.* to user53@\"192.168.4.53\" identified by \"654321\";Query OK, 0 rows affected, 1 warning (0.00 sec)
2)修改/etc/my.cnf配置,启用binlog日志,指定server_id 和 允许级联复制
-
[root@zlz ~]# vim /etc/my.cnf[mysqld]server_id=52log-bin=db52binlog-format=\"mixed\"log_slave_updates //允许级联复制
3)配置完成后,重启mysql服务:
-
[root@zlz ~]# systemctl restart mysqld
4)确保/var/lib/mysql下面有两个文件:
-
[root@zlz ~]# ls /var/lib/mysql/db52.*/var/lib/mysql/db52.000001 /var/lib/mysql/db52.index
5)查看正在使用的日志信息
-
[root@zlz ~]# mysql -uroot -p123456mysql> show master status;+-------------+----------+--------------+------------------+-------------------+| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |+-------------+----------+--------------+------------------+-------------------+| db52.000001 | 154 | | | |+-------------+----------+--------------+------------------+-------------------+1 row in set (0.00 sec) //查看日志文件名、偏移的位置
6)验证主库的授权用户
-
[root@zlz ~]# mysql -h192.168.4.51 -uyaya -p123456mysql: [Warning] Using a password on the command line interface can be insecure.Welcome to the MySQL monitor. Commands end with ; or \\g.Your MySQL connection id is 4Server version: 5.7.17-log MySQL Community Server (GPL)Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type \'help;\' or \'\\h\' for help. Type \'\\c\' to clear the current input statement.mysql> //验证成功
7)通过change master语句指定master服务器的IP地址、同步用户名/密码、起始日志文件、偏移位置(参考master上的状态输出):
-
[root@zlz ~]# mysql -uroot -p123456mysql> change master to-> master_host=\"192.168.4.51\",-> master_user=\"yaya\",-> master_password=\"123456\",-> master_log_file=\"db51.000002\",-> master_log_pos=437;Query OK, 0 rows affected, 2 warnings (0.43 sec)
8)启动slave进程
-
mysql> start slave;Query OK, 0 rows affected (0.03 sec)
9)查看进程状态信息,通过show slave status语句可查看从服务器状态,确认其中的IO线程、SQL线程正常运行,才能成功同步,IO线程和SQL线程必须是Yes
-
mysql> show slave status \\G;*************************** 1. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: 192.168.4.51Master_User: yayaMaster_Port: 3306Connect_Retry: 60Master_Log_File: db51.000002Read_Master_Log_Pos: 437Relay_Log_File: db52-relay-bin.000002Relay_Log_Pos: 315Relay_Master_Log_File: db51.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: 437Relay_Log_Space: 521Until_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: 0Master_SSL_Verify_Server_Cert: NoLast_IO_Errno: 0Last_IO_Error:Last_SQL_Errno: 0Last_SQL_Error:Replicate_Ignore_Server_Ids:Master_Server_Id: 51Master_UUID: 81a13101-aa66-11e8-ad11-525400019e62Master_Info_File: /var/lib/mysql/master.infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State: Slave has read all relay log; waiting for more updatesMaster_Retry_Count: 86400Master_Bind:Last_IO_Error_Timestamp:Last_SQL_Error_Timestamp:Master_SSL_Crl:Master_SSL_Crlpath:Retrieved_Gtid_Set:Executed_Gtid_Set:Auto_Position: 0Replicate_Rewrite_DB:Channel_Name:Master_TLS_Version:1 row in set (0.00 sec)
步骤四:配置从服务器192.168.4.53
1)验证主库的授权用户
-
[root@zlz ~]# mysql -h192.168.4.52 -uuser53 -p654321mysql: [Warning] Using a password on the command line interface can be insecure.Welcome to the MySQL monitor. Commands end with ; or \\g.Your MySQL connection id is 7Server version: 5.7.17-log MySQL Community Server (GPL)Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type \'help;\' or \'\\h\' for help. Type \'\\c\' to clear the current input statement.mysql> //验证成功
2)指定server_id
-
[mysqld]validate_password_policy=0validate_password_length=6server_id=53
3)重新启动服务
- [root@zlz ~]# systemctl restart mysqld
4)管理员登录指定主库信息 -
[root@zlz ~]# mysql -uroot -p123456mysql> change master to-> master_host=\"192.168.4.52\",-> master_user=\"user53\",-> master_password=\"654321\",-> master_log_file=\" db52.000001\",-> master_log_pos=154;Query OK, 0 rows affected, 2 warnings (0.37 sec)
5)启动slave进程
- mysql> start slave;
- Query OK, 0 rows affected (0.04 sec)
6)查看进程状态信息 -
mysql> show slave status\\G*************************** 1. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: 192.168.4.52Master_User: user53Master_Port: 3306Connect_Retry: 60Master_Log_File: db52.000001Read_Master_Log_Pos: 154Relay_Log_File: db53-relay-bin.000003Relay_Log_Pos: 315Relay_Master_Log_File: db52.000001Slave_IO_Running: YesSlave_SQL_Running: Yes
步骤五:客户端验证配置
1)在主服务器上在主库上授权访问gamedb库的用户
-
[root@zlz ~]# mysql -uroot -p123456mysql> grant all on gamedb.* to dada@\"%\" identified by \"123456\";Query OK, 0 rows affected, 1 warning (0.03 sec)
2)客户端使用授权用户连接主库,建库、表、插入记录
-
[root@zlz ~]# mysql -h192.168.4.51 -udada -p123456Welcome to the MariaDB monitor. Commands end with ; or \\g.Your MySQL connection id is 7Server version: 5.7.17-log MySQL Community Server (GPL)Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.Type \'help;\' or \'\\h\' for help. Type \'\\c\' to clear the current input statement.MySQL [(none)]> //验证成功MySQL [(none)]> create database gamedb; //创建测试库Query OK, 1 row affected (0.04 sec)MySQL [(none)]> create table gamedb.t1(id int); //在gamedb下创建t1表Query OK, 0 rows affected (0.17 sec)MySQL [(none)]> insert into gamedb.t1 values(8888); //在t1表中插入数值Query OK, 1 row affected (0.22 sec)
3)客户端使用授权用户连接2台从库时,也可以看到主库上新的库表记录
-
[root@zlz ~]# mysql -h192.168.4.52 -udada -p123456 //验证52主机的状态Welcome to the MariaDB monitor. Commands end with ; or \\g.Your MySQL connection id is 10Server version: 5.7.17-log MySQL Community Server (GPL)Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.Type \'help;\' or \'\\h\' for help. Type \'\\c\' to clear the current input statement.MySQL [(none)]> select * from gamedb.t1; //查询插入的表格+------+| id |+------+| 8888 |+------+1 row in set (0.00 sec)MySQL [(none)]> exit[root@zlz ~]# mysql -h192.168.4.53 -udada -p123456 //验证53主机的状态Welcome to the MariaDB monitor. Commands end with ; or \\g.Your MySQL connection id is 6Server version: 5.7.17 MySQL Community Server (GPL)Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.Type \'help;\' or \'\\h\' for help. Type \'\\c\' to clear the current input statement.MySQL [(none)]> select * from gamedb.t1;+------+| id |+------+| 8888 |+------+1 row in set (0.00 sec)
3 配置半同步复制模式
3.1 问题
• 开启案例1 主库192.168.4.51 半同步复制模式
• 开启案例1 从库192.168.4.52 半同步复制模式
• 开启案例1 从库192.168.4.53 半同步复制模式
• 查看半同步复制模式是否开启
3.2 步骤
实现此案例需要按照如下步骤进行。
步骤一:查看是否允许动态加载模块,
1)查看是否允许动态加载模块默认允许
-
mysql> show variables like \'have_dynamic_loading\';+----------------------+-------+| Variable_name | Value |+----------------------+-------+| have_dynamic_loading | YES |+----------------------+-------+1 row in set (0.01 sec)
2)命令行加载插件,用户需有SUPER权限
主库上面操作:
-
mysql> INSTALL PLUGIN rpl_semi_sync_master SONAME \'semisync_master.so\';
查看系统库下的表,模块是否安装成功:
-
mysql> SELECT PLUGIN_NAME, PLUGIN_STATUS FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME LIKE \'%semi%\';+----------------------+---------------+| PLUGIN_NAME | PLUGIN_STATUS |+----------------------+---------------+| rpl_semi_sync_master | ACTIVE || rpl_semi_sync_slave | ACTIVE |+----------------------+---------------+2 rows in set (0.00 sec)
3)启用半同步复制,在安装完插件后,半同步复制默认是关闭的
主库上面执行:
-
mysql> SET GLOBAL rpl_semi_sync_master_enabled = 1;Query OK, 0 rows affected (0.00 sec)
查看半同步复制模式是否启用:
-
mysql> show variables like \"rpl_semi_sync_%_enabled\";+------------------------------+-------+| Variable_name | Value |+------------------------------+-------+| rpl_semi_sync_master_enabled | ON || rpl_semi_sync_slave_enabled | ON |+------------------------------+-------+2 rows in set (0.00 sec)
4)永久启用半同步复制
主库配置
-
[root@zlz ~]# vim /etc/my.cnf[mysqld]plugin-load=rpl_semi_sync_master=semisync_master.sorpl_semi_sync_master_enabled=1
在高可用架构下,master和slave需同时启动,以便在切换后能继续使用半同步复制
-
[root@zlz ~]# vim /etc/my.cnf[mysqld]plugin-load \\=\"rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so\"rpl-semi-sync-master-enabled = 1rpl-semi-sync-slave-enabled = 1