MySQL5.7.x安装插件配置半同步:
主库配置:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
mysql> show variables like '%semi%'; mysql> show plugins; mysql> install plugin rpl_semi_sync_master soname 'semisync_master.so'; mysql> show variables like '%semi%'; +-------------------------------------------+------------+ | Variable_name | Value | +-------------------------------------------+------------+ | rpl_semi_sync_master_enabled | OFF | | rpl_semi_sync_master_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 | +-------------------------------------------+------------+ mysql> set global rpl_semi_sync_master_enabled=1; mysql> set global rpl_semi_sync_master_timeout=1000; or [root@DB1 ~]# tail -3 /etc/my.cnf rpl_semi_sync_master_enabled = ON rpl_semi_sync_master_timeout=1000 rpl_semi_sync_master_wait_point = AFTER_SYNC mysql> show global variables like '%rpl_semi%'; +-------------------------------------------+------------+ | Variable_name | Value | +-------------------------------------------+------------+ | rpl_semi_sync_master_enabled | ON | | rpl_semi_sync_master_timeout | 1000 | | 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 | +-------------------------------------------+------------+ 6 rows in set (0.00 sec) mysql> show status like '%semi%'; +--------------------------------------------+--------+ | Variable_name | Value | +--------------------------------------------+--------+ | Rpl_semi_sync_master_clients | 2 |记录支持slave连接的个数 | Rpl_semi_sync_master_net_avg_wait_time | 0 |master 等待slave 回复的平均等待时间。 单位毫秒. | Rpl_semi_sync_master_net_wait_time | 0 |master 总的等待时间。 | Rpl_semi_sync_master_net_waits | 1544 |master 等待slave 回复的的总的等待次数 | Rpl_semi_sync_master_no_times | 0 |master 关闭半同步复制的次数 | Rpl_semi_sync_master_no_tx | 0 |master 没有收到slave的回复而提交的次数,(应该可以理解为master 等待超时的次数) | Rpl_semi_sync_master_status | ON |标记master现在是否是半同步复制状态 | Rpl_semi_sync_master_timefunc_failures | 0 |时间函数未正常工作的次数 | Rpl_semi_sync_master_tx_avg_wait_time | 762 |master 花在每个事务上的平均等待时间。 | Rpl_semi_sync_master_tx_wait_time | 649686 |master 总的等待次数。 | Rpl_semi_sync_master_tx_waits | 852 |事务等待备库响应的总次数 | Rpl_semi_sync_master_wait_pos_backtraverse | 0 |改变当前等待最小二进制日志的次数 | Rpl_semi_sync_master_wait_sessions | 0 |当前有多少个session 因为slave 的回复而造成等待。 | Rpl_semi_sync_master_yes_tx | 852 |master 成功接收到slave的回复的次数。 +--------------------------------------------+--------+ 14 rows in set (0.00 sec) |
从库配置:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
mysql> INSTALL PLUGIN rpl_semi_sync_slave SONAME 'semisync_slave.so'; mysql> show global variables like 'rpl%'; +---------------------------------+----------+ | Variable_name | Value | +---------------------------------+----------+ | rpl_semi_sync_slave_enabled | OFF | | rpl_semi_sync_slave_trace_level | 32 | | rpl_stop_slave_timeout | 31536000 | +---------------------------------+----------+ 3 rows in set (0.00 sec) mysql> set global rpl_semi_sync_slave_enabled=1; mysql> stop slave io_thread; Query OK, 0 rows affected (0.00 sec) mysql> start slave io_thread; Query OK, 0 rows affected (0.00 sec) mysql> show slave status\G or [root@DB2 ~]# tail -1 /etc/my.cnf rpl_semi_sync_slave_enabled = ON mysql> show global variables like '%rpl_semi%'; +---------------------------------+-------+ | Variable_name | Value | +---------------------------------+-------+ | rpl_semi_sync_slave_enabled | ON | | rpl_semi_sync_slave_trace_level | 32 | +---------------------------------+-------+ 2 rows in set (0.00 sec) |
0 |
mysql> UNINSTALL PLUGIN rpl_semi_sync_master; |
申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!