master配置优化
max_binlog_szie=128M-1G
binglog_format=row
binlog_row_image=full
gtid_mode =on
enforce_gtid_consistency =on
master_info_repository=table
binlog_group_commit_sync_delay=100
binlog_group_commit_sync_no_delay_count=10
binlog_order_commits=off
sync_binlog=0
slave 配置优化
io_thread
slave_net_timeout=20-30
change master to 相关优化(5.7默认)
master_connect_retry=60
master_connect_count=24*3600
master_auto_position=1
master_delay=0
sql_thread
log_slave_updates=on
relay_log_info_repository=table
relay_log_recovery=1
slave_parallel_type=logical_clock ---启用并行复制
slave_parallel_workers=4|8
slave_checkpoint_group=512
slave_checkpoint_period=300
transaction_write_set_extraction=on
binlog_transaction_dependency_tracking=writeset_session
binlog_transaction_dependency_history_size=25000
slave_rows_search_algorithms=index_scan,hash_scan
无主键 或 使用外键 无法使用基于行级别并行复制
sync_relay_log_info =1 & relay_log_info_repository=table
增强半同步
加载plugin
install plugin rpl_semi_sync_master soname 'semisync_master.so'
install plugin rpl_semi_sync_slave soname 'semisync_slave.so'
master
set global rpl_semi_sync_master_enabled=1
set global rpl_semi_sync_master_timeout=N
set global rpl_semi_sync_master_wait_for_slave_count=N
set global innodb_flush_log_trx_commit=1
set global sync_binlog=1
slave
set global rpl_semi_sync_slave_enabled=1
set global read_only=1
set global super_read_only=1
set global innodb_flush_log_trx_commit=2
set global sync_binlog=0
stop slave
satrt slave
复制中重要功能启用
复制过滤
不建议在主库做过滤
binlog_do_db
binlog_ignore_do_db
针对sql_thread
change replication filter
replicate_do_db={db_list}
replicate_ignore_db={db_list}
replicate_do_table={tb_list}
replicate_ignore_table={tb_list}
replicate_wild_do_table={wild_tb_list}
延迟复制
stop slave sql_thread
change master to master_delay=3600
start slave sql_thread