1.多实例安装见:https://blog.csdn.net/zhigang_9/article/details/113762183
2. 主从异步复制见:https://blog.csdn.net/zhigang_9/article/details/113820247
3.半同步复制安装条件:
1)MySQL 5.5及以上版本;
2)参数have_dynamic_loading为YES,查看命令:show variables like "have_dynamic_loading";
3)异步主从复制已经正常配置运行;
4.安装半同步复制插件
主库安装插件:
INSTALL PLUGIN rpl_semi_sync_master SONAME 'semisync_master.dll';
从库安装插件:
INSTALL PLUGIN rpl_semi_sync_slave SONAME 'semisync_slave.dll';
查看插件:
mysql> show plugins;
| rpl_semi_sync_master | ACTIVE | REPLICATION | semisync_master.dll | GPL |
+----------------------------+----------+--------------------+---------------------+---------+
或者
SELECT PLUGIN_NAME, PLUGIN_STATUS FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME LIKE '%semi%';
+----------------------+---------------+
| PLUGIN_NAME | PLUGIN_STATUS |
+----------------------+---------------+
| rpl_semi_sync_master | ACTIVE |
+----------------------+---------------+
5.配置文件修改
主库配置文件增加启动半同步复制
plugin-load=rpl_semi_sync_master=semisync_master.dll
rpl_semi_sync_master_enabled=1
从库配置文件增加启动半同步复制
plugin-load=rpl_semi_sync_slave=semisync_slave.dll
rpl_semi_sync_slave_enabled=1
6.从库重新启动同步线程
mysql> STOP SLAVE IO_THREAD;
mysql> START SLAVE IO_THREAD;
7.查看运行状态
主库查看半同步是否在运行
show status like 'Rpl_semi_sync_master_status';
+-----------------------------+-------+
| Variable_name | Value |
+-----------------------------+-------+
| Rpl_semi_sync_master_status | ON |
+-----------------------------+-------+
从库查看半同步是否在运行
mysql> show status like 'Rpl_semi_sync_slave_status';
+----------------------------+-------+
| Variable_name | Value |
+----------------------------+-------+
| Rpl_semi_sync_slave_status | ON |
+----------------------------+-------+
查看半同步超时时间,默认10秒,超时会自动降级为异步复制
mysql> show variables like "rpl_semi_sync_master_timeout";
+------------------------------+-------+
| Variable_name | Value |
+------------------------------+-------+
| rpl_semi_sync_master_timeout | 10000 |
+------------------------------+-------+
配置完毕