MySQL半同步复制的安装和配置
2016-07-06 15:06 abce 阅读(503) 评论(0) 编辑 收藏 举报(1)检查master/slave是否支持动态加载插件
> show variables like 'have_dynamic_loading'; +----------------------+-------+ | Variable_name | Value | +----------------------+-------+ | have_dynamic_loading | YES | +----------------------+-------+
(2)检查plugin_dir位置,插件的放置位置
> show variables like '%plugin_dir%'; +---------------+------------------------------+ | Variable_name | Value | +---------------+------------------------------+ | plugin_dir | /usr/local/mysql/lib/plugin/ | +---------------+------------------------------+
(3)在master端执行
> install plugin rpl_semi_sync_master soname 'semisync_master.so'; > show plugins\G *************************** 43. row *************************** Name: rpl_semi_sync_master Status: ACTIVE Type: REPLICATION Library: semisync_master.so License: GPL 43 rows in set (0.00 sec) >select plugin_name,plugin_status from information_schema.plugins where plugin_name like '%semi%'; +----------------------+---------------+ | plugin_name | plugin_status | +----------------------+---------------+ | rpl_semi_sync_master | ACTIVE | +----------------------+---------------+
(4)在slave端执行
> install plugin rpl_semi_sync_slave soname 'semisync_slave.so'; > show plugins\G *************************** 43. row *************************** Name: rpl_semi_sync_master Status: ACTIVE Type: REPLICATION Library: semisync_master.so License: GPL 43 rows in set (0.00 sec) >select plugin_name,plugin_status from information_schema.plugins where plugin_name like '%semi%'; +----------------------+---------------+ | plugin_name | plugin_status | +----------------------+---------------+ | rpl_semi_sync_master | ACTIVE | +----------------------+---------------+
(5)master开启半同步复制
> set global rpl_semi_sync_master_enabled=1; > set global rpl_semi_sync_master_timeout=30; >show global variables like 'rpl_semi_sync_master_enabled'; +------------------------------+-------+ | Variable_name | Value | +------------------------------+-------+ | rpl_semi_sync_master_enabled | ON | +------------------------------+-------+
(6)slave开启半同步复制
> set global rpl_semi_sync_slave_enabled=1; > show global variables like 'rpl_semi_sync_slave_enabled'; +-----------------------------+-------+ | Variable_name | Value | +-----------------------------+-------+ | rpl_semi_sync_slave_enabled | ON | +-----------------------------+-------+
(7)如果slave在运行状态,要重启io_thread
> stop slave io_thread; > start slave io_thread;
(8)把配置信息写入配置文件
master端: [mysqld] rpl_semi_sync_master_enabled=1 rpl_semi_sync_master_timeout=1000 # 1 second slave端: [mysqld] rpl_semi_sync_slave_enabled=1