Sunday, July 20, 2014

Enable Semi-synchronous Replication on existing Multi-Master (2-node) replication

Install Plugins

root@server1> install plugin rpl_semi_sync_master soname 'semisync_master.so';
root@server1> install plugin rpl_semi_sync_slave soname 'semisync_slave.so';

root@server2> install plugin rpl_semi_sync_master soname 'semisync_master.so';
root@server2> install plugin rpl_semi_sync_slave soname 'semisync_slave.so';

Enable replication

root@server1> set global rpl_semi_sync_master_enabled = 1;
root@server1> set global rpl_semi_sync_master_timeout = 10000;
root@server1> set global rpl_semi_sync_slave_enabled = 1;

root@server2> set global rpl_semi_sync_master_enabled = 1;
root@server2> set global rpl_semi_sync_master_timeout = 10000;
root@server2> set global rpl_semi_sync_slave_enabled = 1;

Restart Slaves

root@server1> stop slave;
root@server1> start slave;

root@server2> stop slave;
root@server2> start slave;

Monitoring the Status

root@server1> show variables like 'rpl_semi_sync%';
+------------------------------------+-------+
| Variable_name                      | Value |
+------------------------------------+-------+
| rpl_semi_sync_master_enabled       | ON    |
| rpl_semi_sync_master_timeout       | 10000 |
| rpl_semi_sync_master_trace_level   | 32    |
| rpl_semi_sync_master_wait_no_slave | ON    |
| rpl_semi_sync_slave_enabled        | ON    |
| rpl_semi_sync_slave_trace_level    | 32    |
+------------------------------------+-------+
6 rows in set (0.00 sec)

root@server1> update appdb.t1 set name='server1' where id=2;

root@server1> show status like 'rpl_semi_sync%';
+--------------------------------------------+----------+
| Variable_name                              | Value    |
+--------------------------------------------+----------+
| Rpl_semi_sync_master_clients               | 1        |
| Rpl_semi_sync_master_net_avg_wait_time     | 2178     |
| Rpl_semi_sync_master_net_wait_time         | 2178     |
| Rpl_semi_sync_master_net_waits             | 1        |
| Rpl_semi_sync_master_no_times              | 1        |
| Rpl_semi_sync_master_no_tx                 | 3        |
| Rpl_semi_sync_master_status                | ON       |
| Rpl_semi_sync_master_timefunc_failures     | 0        |
| Rpl_semi_sync_master_tx_avg_wait_time      | 4011376  |
| Rpl_semi_sync_master_tx_wait_time          | 20056881 |
| Rpl_semi_sync_master_tx_waits              | 5        |
| Rpl_semi_sync_master_wait_pos_backtraverse | 4        |
| Rpl_semi_sync_master_wait_sessions         | 0        |
| Rpl_semi_sync_master_yes_tx                | 1        |
| Rpl_semi_sync_slave_status                 | ON       |
+--------------------------------------------+----------+
15 rows in set (0.01 sec)

root@server1> select * from information_schema.plugins where plugin_name like 'rpl%'\G
*************************** 1. row ***************************
           PLUGIN_NAME: rpl_semi_sync_master
        PLUGIN_VERSION: 1.0
         PLUGIN_STATUS: ACTIVE
           PLUGIN_TYPE: REPLICATION
   PLUGIN_TYPE_VERSION: 2.0
        PLUGIN_LIBRARY: semisync_master.so
PLUGIN_LIBRARY_VERSION: 1.4
         PLUGIN_AUTHOR: He Zhenxing
    PLUGIN_DESCRIPTION: Semi-synchronous replication master
        PLUGIN_LICENSE: GPL
           LOAD_OPTION: ON
*************************** 2. row ***************************
           PLUGIN_NAME: rpl_semi_sync_slave
        PLUGIN_VERSION: 1.0
         PLUGIN_STATUS: ACTIVE
           PLUGIN_TYPE: REPLICATION
   PLUGIN_TYPE_VERSION: 2.0
        PLUGIN_LIBRARY: semisync_slave.so
PLUGIN_LIBRARY_VERSION: 1.4
         PLUGIN_AUTHOR: He Zhenxing
    PLUGIN_DESCRIPTION: Semi-synchronous replication slave
        PLUGIN_LICENSE: GPL
           LOAD_OPTION: ON
2 rows in set (0.00 sec)