--## #半同步配置
--1, plug-in location
Mysql> Show variables like ' Plugin_dir '
;
+---------------+------------------------------+
| variable_name | Value |
+---------------+------------------------------+
| Plugin_dir | /usr/local/mysql/lib/plugin/|
+---------------+------------------------------+
[Email protected] data]$ ll/usr/local/mysql/lib/plugin/semisync_*
-rwxr-xr-x 1 root root 415020 Jul 5 19:50/usr/local/mysql/lib/plugin/semisync_master.so
-rwxr-xr-x 1 root root 248711 Jul 5 19:50/usr/local/mysql/lib/plugin/semisync_slave.so
--2, Master Loading plugin
INSTALL PLUGIN rpl_semi_sync_master SONAME ' semisync_master.so ';
Show plugins; #--verifying that the load is normal
--3, master turn on the half-sync function
Vi/etc/mysql/my.cnf
rpl_semi_sync_master_enabled = 1;
Rpl_semi_sync_master_timeout = 3000; #超出3秒改为异步复制
--4, restart MySQL
--5, slave loading plugin
INSTALL PLUGIN rpl_semi_sync_slave SONAME ' semisync_slave.so ';
Show plugins; #--verifying that the load is normal
--6, slave turn on the semi-synchronous function
Vi/etc/mysql/my.cnf
rpl_semi_sync_slave_enabled = 1;
--7, restart MySQL
--## #监控半同步复制 monitor sync mode/monitor sync status
--master
mysql> show status like '%rpl_semi_sync% ';
+--------------------------------------------+-------+
| variable_name | Value |
+--------------------------------------------+-------+
| rpl_semi_sync_master_clients | 1 |
| Rpl_semi_sync_master_net_avg_wait_time | 476 |
| Rpl_semi_sync_master_net_wait_time | 476 |
| 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 | 610 |
| Rpl_semi_sync_master_tx_wait_time | 610 |
| Rpl_semi_sync_master_tx_waits | 1 |
| Rpl_semi_sync_master_wait_pos_backtraverse | 0 |
| rpl_semi_sync_master_wait_sessions | 0 |
| Rpl_semi_sync_master_yes_tx | 1 |
+--------------------------------------------+-------+
Rpl_semi_sync_master_status = on #--master turn on the half-sync function
rpl_semi_sync_master_clients = 1 #--How many clients turn on the half-sync function
--slave
Mysql> Show status like '%rpl_semi_sync% ';
+----------------------------+-------+
| variable_name | Value |
+----------------------------+-------+
| Rpl_semi_sync_slave_status | On |
+----------------------------+-------+
--analog timeout after the semi-synchronous state
--slave
Stop slave Io_thread;
Mysql> Show status like '%rpl_semi_sync% ';
+----------------------------+-------+
| variable_name | Value |
+----------------------------+-------+
| Rpl_semi_sync_slave_status | OFF |
+----------------------------+-------+
--master more than Rpl_semi_sync_master_timeout this value, master no longer waits for the slave to accept the acknowledgment, but instead automatically commits and becomes asynchronous replication
Mysql> Show variables like '%rpl_semi_sync_master_timeout% ';
+------------------------------+-------+
| variable_name | Value |
+------------------------------+-------+
| Rpl_semi_sync_master_timeout | 3000 |
+------------------------------+-------+
mysql5.6 semi replication semi-synchronous replication configuration