cd /usr/local/mysql/lib
cd plugins
ls
scmisync_slave.so
设置半同步步骤:
在Master和Slave的mysql命令行运行如下代码:
# On Master
mysql> INSTALL PLUGIN rpl_semi_sync_master SONAME ‘semisync_master.so‘;
show giobal variables like ‘%rpl%‘;
mysql> SET GLOBAL rpl_semi_sync_master_enabled = 1;
mysql> SET GLOBAL rpl_semi_sync_master_timeout = 1000;
# On Slave
mysql> INSTALL PLUGIN rpl_semi_sync_slave SONAME ‘semisync_slave.so‘;
mysql> SET GLOBAL rpl_semi_sync_slave_enabled = 1;
mysql> STOP SLAVE IO_THREAD; START SLAVE IO_THREAD;
主
show global status like ‘rpl%‘
rpl_semi_sync_master_clients =1
在Master和Slave的my.cnf中编辑:
# On Master
[mysqld]
rpl_semi_sync_master_enabled=1
rpl_semi_sync_master_timeout=1000 # 1 second
# On Slave
[mysqld]
rpl_semi_sync_slave_enabled=1
percona: percona-tools
mattkit-tools
yum localintsall percona-tookit-2.2.2-1.noarch.rpm --nogpgcheck
pt
# 也可通过设置全局变量的方式来设置,如下:
set global rpl_semi_sync_master_enabled=1
# 取消加载插件
mysql> UNINSTALL PLUGIN rpl_semi_sync_master;
==============================================
查看从服务器上的semi_sync是否开启:
mysql> SHOW GLOBAL STATUS LIKE ‘rpl_semi%‘;
查看主服务器上的semi_sync是否开启,注意clients 变为1 ,证明主从半同步复制连接成功:
mysql> SHOW GLOBAL STATUS LIKE ‘rpl_semi%‘;
stop slave IO_Thread