主从延时问题
主从环境
从库延时数据同步
方案:把从库设置双一修改
sync_binlog=0
innodb_flush_log_at_trx_commit=2
同时设置多线程复制
配置多线程
1、停止从节点复制
mysql> stop slave;
Query OK, 0 rows affected (0.01 sec)
2、设置复制类型为 LOGICAL_CLOCK
mysql> set global slave_parallel_type= 'logical_clock' ;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like 'slave_parallel_type' ;
+ ---------------------+---------------+
| Variable_name | Value |
+ ---------------------+---------------+
| slave_parallel_type | LOGICAL_CLOCK |
+ ---------------------+---------------+
1 row in set (0.01 sec)
3、设置并行数量为 4
mysql> set global slave_parallel_workers=4;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like 'slave_parallel_workers' ;
+ ------------------------+-------+
| Variable_name | Value |
+ ------------------------+-------+
| slave_parallel_workers | 4 |
+ ------------------------+-------+
1 row in set (0.00 sec)
4、启动从节点复制
mysql> start slave;
Query OK, 0 rows affected (0.02 sec)
5、查看一下当前工作的线程数
mysql> show processlist;