码迷,mamicode.com
首页 > 数据库 > 详细

mysql主从同步启用半同步

时间:2018-06-07 16:21:30      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:thread   level   安装插件   ike   主服务器   status   时长   res   sync   

安装mysql半同步插件:
  主服务器安装插件:
  mysql> show global variables like ‘plugin_dir%‘;
  +---------------+--------------------------+
  | Variable_name | Value |
  +---------------+--------------------------+
  | plugin_dir | /usr/lib64/mysql/plugin/ | 当前mysql插件目录的具体位置
  +---------------+--------------------------+

  mysql > INSTALL PLUGIN rpl_semi_sync_master SONAME ‘semisync_master.so‘;
  主服务器半同步参数(插件安装后才有):
  mysql> show global variables like ‘rpl_semi_sync_master%‘;
  +-------------------------------------------+------------+
  | Variable_name | Value |
  +-------------------------------------------+------------+
  | rpl_semi_sync_master_enabled | OFF | 开启半同步模式
  | rpl_semi_sync_master_timeout | 10000 | 半同步timeout时间10000毫秒
  | rpl_semi_sync_master_trace_level | 32 | 跟踪级别
  | rpl_semi_sync_master_wait_for_slave_count | 1 | 等待最少多少台从服务器完成同步
  | rpl_semi_sync_master_wait_no_slave | ON |
  | rpl_semi_sync_master_wait_point | AFTER_SYNC | 5.7的新半同步模式(value=AFTER_SYNC为Loss-Less半同步复制,AFTER_COMMIT为老版半同步)
  +-------------------------------------------+------------+

  开启主服务器半同步:mysql> set global rpl_semi_sync_master_enabled=ON;从服务器安装插件:

  mysql > INSTALL PLUGIN rpl_semi_sync_slave SONAME ‘semisync_slave.so‘;
  从服务器半同步参数(插件安装后才有):
  mysql> show global variables like ‘rpl_semi_sync_slave%‘;
  +---------------------------------+-------+
  | Variable_name | Value |
  +---------------------------------+-------+
  | rpl_semi_sync_slave_enabled | OFF | 开启半同步模式
  | rpl_semi_sync_slave_trace_level | 32 | 跟踪级别
  +---------------------------------+-------+
  开从服务器启半同步:mysql> set global rpl_semi_sync_slave_enabled=ON;

查看具体半同步状态信息:
主:
  mysql > show global status like ‘rpl_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 |
  +--------------------------------------------+-------+

注:这之后需要重启一下从服务器的线程,之前一直卡着主从都已经开启了半同步,状态(Rpl_semi_sync_master_status=ON),但是没有从客户端(Rpl_semi_sync_master_clients=0),见上面的状态信息
  mysql> STOP SLAVE [IO_THREAD];
  mysql> START SLAVE [IO_THREAD];

mysql主从同步启用半同步

标签:thread   level   安装插件   ike   主服务器   status   时长   res   sync   

原文地址:https://www.cnblogs.com/colinshi/p/9151098.html

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