码迷,mamicode.com
首页 > 其他好文 > 详细

半同步复制

时间:2016-05-10 18:56:39      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:半同步复制

  1. 是否支持

mysql> select  @@have_dynamic_loading;

+------------------------+

| @@have_dynamic_loading |

+------------------------+

| YES                    |

+------------------------+

1 row in set (0.00 sec)


mysql>

2.查看插件

[root@192 /]# ll /usr/local/mysql/lib/plugin/

     semisync_master.so

     semisync_slave.so

在主库上安装:

mysql> install plugin rpl_semi_sync_master SONAME "semisync_master.so";

Query OK, 0 rows affected (0.03 sec)

再从库上安装:

mysql> install plugin rpl_semi_sync_slave SONAME "semisync_slave.so";       

Query OK, 0 rows affected (0.02 sec)

检查:

mysql> select * from mysql.plugin;

+----------------------+--------------------+

| name                 | dl                 |

+----------------------+--------------------+

| rpl_semi_sync_master | semisync_master.so |

+----------------------+--------------------+

mysql> select * from mysql.plugin;

+---------------------+-------------------+

| name                | dl                |

+---------------------+-------------------+

| rpl_semi_sync_slave | semisync_slave.so |

+---------------------+-------------------+

3.在主库和从库上配置参数打开半同步:

主库

mysql> set global rpl_semi_sync_master_enabled  = 1;

Query OK, 0 rows affected (0.00 sec)


mysql> set global rpl_semi_sync_master_timeout = 3000;

Query OK, 0 rows affected (0.00 sec)

从库

mysql> set global rpl_semi_sync_slave_enabled = 1;

Query OK, 0 rows affected (0.00 sec)

由于之前是异步复制,所以要重新启动下I/O线程:

mysql> stop slave io_thread; start slave io_thread;

Query OK, 0 rows affected (0.07 sec)


Query OK, 0 rows affected (0.01 sec)

回到主库,查看半同步的一些状态值:

mysql> show status like "%semi_sync%";  

+--------------------------------------------+-------+

| Variable_name                              | Value |

+--------------------------------------------+-------+

| Rpl_semi_sync_master_clients               | 1     |

| 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     |

+--------------------------------------------+-------+

执行一个事务再次查看:

mysql> show status like "%semi_sync%";  

+--------------------------------------------+-------+

| Variable_name                              | Value |

+--------------------------------------------+-------+

| Rpl_semi_sync_master_clients               | 1     |

| Rpl_semi_sync_master_net_avg_wait_time     | 1072  |

| Rpl_semi_sync_master_net_wait_time         | 1072  |

| 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      | 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                | 1     |

+--------------------------------------------+-------+


如果超时会自动降级为异步,从库正常会恢复到半同步。













半同步复制

标签:半同步复制

原文地址:http://wangqh.blog.51cto.com/5367393/1771874

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!