在MySQL上安装插件需要数据库支持动态载入。检查是否支持: mysql> show global variables like 'have_dynamic_loading'; +----------------------+-------+ | Variable_name | Value | +----------------------+-------+ | have_dynamic_loading | YES | +----------------------+-------+
mysql> show global variables like 'rpl_semi%'; +---------------------------------+-------+ | Variable_name | Value | +---------------------------------+-------+ | rpl_semi_sync_slave_enabled | OFF | | rpl_semi_sync_slave_trace_level | 32 | +---------------------------------+-------+
3.启用半同步复制功能(先主后从) 3.1主服务器: mysql> set global rpl_semi_sync_master_enabled=1;
mysql> show global variables like 'rpl_semi%'; +------------------------------------+-------+ | Variable_name | Value | +------------------------------------+-------+ | rpl_semi_sync_master_enabled | ON | | rpl_semi_sync_master_timeout | 10000 | | rpl_semi_sync_master_trace_level | 32 | | rpl_semi_sync_master_wait_no_slave | ON | +------------------------------------+-------+
3.2从服务器: mysql> set global rpl_semi_sync_slave_enabled=1;
mysql> show global variables like 'rpl_semi%'; +---------------------------------+-------+ | Variable_name | Value | +---------------------------------+-------+ | rpl_semi_sync_slave_enabled | ON | | rpl_semi_sync_slave_trace_level | 32 | +---------------------------------+-------+
4.测试 mysql> show global variables like 'rpl_semi_sync_slave_enabled'; +-----------------------------+-------+ | Variable_name | Value | +-----------------------------+-------+ | rpl_semi_sync_slave_enabled | ON | +-----------------------------+-------+
mysql> show global variables like 'rpl_semi_sync_master_enabled'; +------------------------------+-------+ | Variable_name | Value | +------------------------------+-------+ | rpl_semi_sync_master_enabled | ON | +------------------------------+-------+
4.3其他信息 通过半同步复制机制复制成功的事务 mysql> show global status like 'rpl_semi_sync_master_yes_tx'; +-----------------------------+-------+ | Variable_name | Value | +-----------------------------+-------+ | Rpl_semi_sync_master_yes_tx | 3 | +-----------------------------+-------+
没有通过半同步复制机制复制的事务 mysql> show global status like 'rpl_semi_sync_master_no_tx'; +----------------------------+-------+ | Variable_name | Value | +----------------------------+-------+ | Rpl_semi_sync_master_no_tx | 2 | +----------------------------+-------+