標籤:5.7並行複製
開啟多線程複製,預設關鍵的參數有兩個:
mysql> show variables like ‘slave_parallel_%‘;
+------------------------+---------------+
| Variable_name | Value |
+------------------------+---------------+
| slave_parallel_type | DATABASE |
| slave_parallel_workers | 0 |
+------------------------+---------------+
2 rows in set (0.00 sec)
slave-parallel-type 預設值為database
slave-parallel-workers 預設值為0
線上開啟:
mysql> stop slave sql_thread;
Query OK, 0 rows affected (0.07 sec)
mysql> set global slave_parallel_type=‘LOGICAL_CLOCK‘;
Query OK, 0 rows affected (0.00 sec)
mysql> set global slave_parallel_workers=4;
Query OK, 0 rows affected (0.00 sec)
mysql> start slave sql_thread;
Query OK, 0 rows affected (0.06 sec)
最佳化選項:
啟用table模式是因為如果在多線程模式下,會頻繁更新master.info檔案,消耗代價過高,並且此值也不是非常準確
master_info_repository=table 對應的表為mysql.slave_master_info
relay_log_recovery=on
relay_log_info_repository=table 對應的表為mysql.slave_relay_log_info
mysql 5.7開啟並行複製