在主服务器
[mysqld]
rpl_semi_sync_master_enabled=1
rpl_semi_sync_master_timeout=2000
在从服务i其上
[mysqld]
rpl_semi_sync_slave_enabled=1
在主服务器上
mysql> INSTALL PLUGIN rpl_semi_sync_master SONAME'semisync_master.so';
Query OK, 0 rows affected (0.78 sec)mysql> SET GLOBAL rpl_semi_sync_master_enabled = 1;
Query OK, 0 rows affected (0.08 sec)
mysql> SET GLOBAL rpl_semi_sync_master_timeout = 2000;
Query OK, 0 rows affected (0.13 sec)
mysql> show status like '%semi_sync%';
+--------------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------------+-------+
| Rpl_semi_sync_master_clients | 0 |
| 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 |
| 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 |
+--------------------------------------------+-------+
14 rows in set (0.07 sec)
在从服务器上
mysql> INSTALL PLUGIN rpl_semi_sync_slave SONAME'semisync_slave.so';
Query OK, 0 rows affected (0.51 sec)
mysql> SET GLOBAL rpl_semi_sync_slave_enabled = 1;
Query OK, 0 rows affected (0.02 sec)
mysql> STOP SLAVE IO_THREAD;
Query OK, 0 rows affected (0.04 sec)
mysql> START SLAVE IO_THREAD;
Query OK, 0 rows affected (0.01 sec)
测试
mysql> create table a (id int(4));
Query OK, 0 rows affected (0.72 sec)
mysql> show create table a;
+-------+------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+------------------------------------------------------------------------------------+
| a | CREATE TABLE `a` (
`id` int(4) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+-------+------------------------------------------------------------------------------------+
1 row in set (0.13 sec)
这里吧从服务器听了
mysql> drop table a;
Query OK, 0 rows affected (2.14 sec)