5.7mysql 多线程slave
1.主库需要设置参数:
server_id=202
log-bin=mysql-bin
binlog_format=row
log-slave-updates
sync_binlog=1
innodb_flush_log_at_trx_commit=1
2.从库配置
server_id=203
log-bin=mysql-bin
binlog_format=row
log-slave-updates
slave-parallel-type=LOGICAL_CLOCK
slave-parallel-workers=8
master_info_repository=TABLE
relay_log_info_repository=TABLE
relay_log_recovery=ON
slave_preserve_commit_order=on
sync_relay_log=100
CHANGE MASTER TO MASTER_HOST='142.60.0.121',MASTER_PORT=3306,MASTER_USER='repl',MASTER_PASSWORD='skyvis_123' ,MASTER_LOG_FILE='mysql-bin.000005',MASTER_LOG_POS=763;
主从分别安装:
install plugin rpl_semi_sync_master soname 'semisync_master.so';
install plugin rpl_semi_sync_slave soname 'semisync_master.so';
从库先开始:
执行
set global rpl_semi_sync_slave_enabled =1;
stop slave io_thread;
start slave io_thread;
set global rpl_semi_sync_master_enabled =1 ; # 0
set global rpl_semi_sync_slave_enabled =1 ; # 0
set global rpl_semi_sync_master_timeout =1000 ; # 1000(1 second) 同步复制中由于网络原因导致复制时间超过1s后,增强半同步复制就变成了异步复制了
set global rpl_semi_sync_master_wait_for_slave_count=1;
查看状态:
show status like
'Rpl_semi_sync_master_status'
;
show status like
'Rpl_semi_sync_slave_status'
;