分别在master和slave的my.cnf里添加以下配置
master
rpl_semi_sync_master_enabled=1 rpl_semi_sync_master_timeout=1000 rpl_semi_sync_master_trace_level=32 rpl_semi_sync_master_wait_no_slave=onslave
rpl_semi_sync_slave_enabled=1
master日志
140203 23:06:17 [Note] Semi-sync replication initialized for transactions. 140203 23:06:17 [Note] Semi-sync replication enabled on the master. 140203 23:06:17 [Note] Server hostname (bind-address): '0.0.0.0'; port: 30307 140203 23:06:17 [Note] - '0.0.0.0' resolves to '0.0.0.0'; 140203 23:06:17 [Note] Server socket created on IP: '0.0.0.0'. 140203 23:06:17 [Warning] 'proxies_priv' entry '@ root@mynode1' ignored in --skip-name-resolve mode. 140203 23:06:17 [Note] Event Scheduler: Loaded 0 events 140203 23:06:17 [Note] /service/mysql/bin/mysqld: ready for connections. Version: '5.5.34-log' socket: '/data/mysql/mysql.sock' port: 30307 MASTER_DB 140203 23:06:17 [Note] Event Scheduler: scheduler thread started with id 1 140203 23:06:20 [Note] Start semi-sync binlog_dump to slave (server_id: 2), pos(binlog-master.000010, 290)
140203 23:06:20 [Note] Slave I/O thread: Start semi-sync replication to master 'rep@mynode1:30307' in log 'binlog-master.000010' at position 290 140203 23:06:20 [Note] Slave SQL thread initialized, starting replication in log 'binlog-master.000010' at position 290, relay log './mynode2-relay-bin.000029' position: 440 140203 23:06:20 [Note] Event Scheduler: scheduler thread started with id 1 140203 23:06:20 [Note] Slave I/O thread: connected to master 'rep@mynode1:30307',replication started in log 'binlog-master.000010' at position 290
MASTER@root@test 11:10:41>show global status like 'rpl%'; +--------------------------------------------+-------------+ | Variable_name | Value | +--------------------------------------------+-------------+ | Rpl_semi_sync_master_clients | 1 | | Rpl_semi_sync_master_net_avg_wait_time | 619 | | Rpl_semi_sync_master_net_wait_time | 619 | | Rpl_semi_sync_master_net_waits | 1 | | 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 | 734 | | Rpl_semi_sync_master_tx_wait_time | 734 | | Rpl_semi_sync_master_tx_waits | 1 | | Rpl_semi_sync_master_wait_pos_backtrav