MYSQL並行複製(parallel replication部署篇)
MySQL5.6開始執行基於庫級別的並行複製,MYSQL5.7支援基於表和行級別的並行複製(Enhanced Multi-Threaded Slave),這裡主要是配置MYSQL5.7的基於組提交的並行複製。
一、環境描述
二、主要相關配置引數
node1節點:
#replicate
server-id=1001
skip-slave-start = false
read-only = false
log-slave-updates = 1
expire_logs_days = 2
max_binlog_size = 1G
max_binlog_cache_size = 2G
log-bin = /home/mysql/mysql-bin
log-bin-index = /home/mysql/bin-index
sync_binlog = 1
binlog_format = row
log-slow-slave-statements = 1
max-relay-log-size = 1G
relay-log = /home/mysql/mysql-relay
relay-log-index = /home/mysql/relay-index
relay_log_recovery=ON
gtid_mode=ON
enforce_gtid_consistency=ON
master_info_repository=TABLE
relay_log_info_repository=TABLE
binlog_checksum=NONE
node2節點
#replicate
server-id=1002
skip-slave-start = false
read-only = false
log-slave-updates = 1
expire_logs_days = 2
max_binlog_size = 1G
max_binlog_cache_size = 2G
log-bin = /home/mysql/mysql-bin
log-bin-index = /home/mysql/bin-index
sync_binlog = 1
binlog_format = row
log-slow-slave-statements = 1
max-relay-log-size = 1G
relay-log = /home/mysql/mysql-relay
relay-log-index = /home/mysql/relay-index
relay_log_recovery=ON
gtid_mode=ON
enforce_gtid_consistency=ON
master_info_repository=TABLE
relay_log_info_repository=TABLE
binlog_checksum=NONE
#parallel slave
slave-parallel-type=LOGICAL_CLOCK
slave-parallel-workers=8
##slave-parallel-type
DATABASE:預設值,基於庫的並行複製方式
LOGICAL_CLOCK:基於組提交的並行複製方式
三、資料庫啟動並配置主從服務
資料庫啟動略
node2從節點執行下面命令:
change master to master_host='10.26.7.129',master_user='rpl_user',master_password='rpl_pass',master_port=3306,master_auto_position=1;
start slave;
show slave status \G
四、資料庫多執行緒複製測試、狀態監控
node1:
node2:
(root:localhost:Thu Jul 20 11:27:34 2017)[information_schema]>use performance_schema;
Database changed
(root:localhost:Thu Jul 20 11:27:38 2017)[performance_schema]>show tables like '%replica%';
+-------------------------------------------+
| Tables_in_performance_schema (%replica%) |
+-------------------------------------------+
| replication_applier_configuration |
| replication_applier_status |
| replication_applier_status_by_coordinator |
| replication_applier_status_by_worker |
| replication_connection_configuration |
| replication_connection_status |
| replication_group_member_stats |
| replication_group_members |
+-------------------------------------------+
8 rows in set (0.00 sec)
多線複製狀態監控:
select * from replication_applier_status_by_coordinator ;
select * from replication_applier_status_by_worker ;
一、環境描述
名稱 | 版本 | 備註 |
作業系統 | RHEL6.5_X86_64 | |
資料庫 | 5.7.18-15 | Percona二進位制版本 |
複製節點 | 10.26.7.129 |
node1 主節點 |
10.26.7.142 |
node2 從節點 |
node1節點:
#replicate
server-id=1001
skip-slave-start = false
read-only = false
log-slave-updates = 1
expire_logs_days = 2
max_binlog_size = 1G
max_binlog_cache_size = 2G
log-bin = /home/mysql/mysql-bin
log-bin-index = /home/mysql/bin-index
sync_binlog = 1
binlog_format = row
log-slow-slave-statements = 1
max-relay-log-size = 1G
relay-log = /home/mysql/mysql-relay
relay-log-index = /home/mysql/relay-index
relay_log_recovery=ON
gtid_mode=ON
enforce_gtid_consistency=ON
master_info_repository=TABLE
relay_log_info_repository=TABLE
binlog_checksum=NONE
node2節點
#replicate
server-id=1002
skip-slave-start = false
read-only = false
log-slave-updates = 1
expire_logs_days = 2
max_binlog_size = 1G
max_binlog_cache_size = 2G
log-bin = /home/mysql/mysql-bin
log-bin-index = /home/mysql/bin-index
sync_binlog = 1
binlog_format = row
log-slow-slave-statements = 1
max-relay-log-size = 1G
relay-log = /home/mysql/mysql-relay
relay-log-index = /home/mysql/relay-index
relay_log_recovery=ON
gtid_mode=ON
enforce_gtid_consistency=ON
master_info_repository=TABLE
relay_log_info_repository=TABLE
binlog_checksum=NONE
#parallel slave
slave-parallel-type=LOGICAL_CLOCK
slave-parallel-workers=8
##slave-parallel-type
DATABASE:預設值,基於庫的並行複製方式
LOGICAL_CLOCK:基於組提交的並行複製方式
三、資料庫啟動並配置主從服務
資料庫啟動略
node2從節點執行下面命令:
change master to master_host='10.26.7.129',master_user='rpl_user',master_password='rpl_pass',master_port=3306,master_auto_position=1;
start slave;
show slave status \G
點選(此處)摺疊或開啟
-
(root:localhost:Thu Jul 20 11:21:10 2017)[(none)]>show slave status \G
-
*************************** 1. row ***************************
-
Slave_IO_State: Waiting for master to send event
-
Master_Host: 10.26.7.129
-
Master_User: rpl_user
-
Master_Port: 3306
-
Connect_Retry: 60
-
Master_Log_File: mysql-bin.000006
-
Read_Master_Log_Pos: 190
-
Relay_Log_File: mysql-relay.000002
-
Relay_Log_Pos: 355
-
Relay_Master_Log_File: mysql-bin.000006
-
Slave_IO_Running: Yes
-
Slave_SQL_Running: Yes
-
Replicate_Do_DB:
-
Replicate_Ignore_DB:
-
Replicate_Do_Table:
-
Replicate_Ignore_Table:
-
Replicate_Wild_Do_Table:
-
Replicate_Wild_Ignore_Table:
-
Last_Errno: 0
-
Last_Error:
-
Skip_Counter: 0
-
Exec_Master_Log_Pos: 190
-
Relay_Log_Space: 550
-
Until_Condition: None
-
Until_Log_File:
-
Until_Log_Pos: 0
-
Master_SSL_Allowed: No
-
Master_SSL_CA_File:
-
Master_SSL_CA_Path:
-
Master_SSL_Cert:
-
Master_SSL_Cipher:
-
Master_SSL_Key:
-
Seconds_Behind_Master: 0
-
Master_SSL_Verify_Server_Cert: No
-
Last_IO_Errno: 0
-
Last_IO_Error:
-
Last_SQL_Errno: 0
-
Last_SQL_Error:
-
Replicate_Ignore_Server_Ids:
-
Master_Server_Id: 1001
-
Master_UUID: 2faa74b8-66bb-11e7-ab7e-b8ca3a6a61ec
-
Master_Info_File: mysql.slave_master_info
-
SQL_Delay: 0
-
SQL_Remaining_Delay: NULL
-
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
-
Master_Retry_Count: 86400
-
Master_Bind:
-
Last_IO_Error_Timestamp:
-
Last_SQL_Error_Timestamp:
-
Master_SSL_Crl:
-
Master_SSL_Crlpath:
-
Retrieved_Gtid_Set:
-
Executed_Gtid_Set: 2faa74b8-66bb-11e7-ab7e-b8ca3a6a61ec:1-28,
-
35e38786-66bb-11e7-bcc3-b8ca3a6a61a4:1
-
Auto_Position: 1
-
Replicate_Rewrite_DB:
-
Channel_Name:
-
Master_TLS_Version:
- 1 row in set (0.00 sec)
node1:
點選(此處)摺疊或開啟
-
(root:localhost:Thu Jul 20 11:23:05 2017)[(none)]>drop database db01;
-
Query OK, 1 row affected (0.02 sec)
-
-
(root:localhost:Thu Jul 20 11:23:17 2017)[(none)]>use dbtest;
-
Database changed
-
(root:localhost:Thu Jul 20 11:23:22 2017)[dbtest]>create table t(id int);
-
Query OK, 0 rows affected (0.01 sec)
-
-
(root:localhost:Thu Jul 20 11:25:03 2017)[dbtest]>insert into t values(10);
- Query OK, 1 row affected (0.01 sec)
點選(此處)摺疊或開啟
-
(root:localhost:Thu Jul 20 11:23:12 2017)[(none)]>show databases;
-
+--------------------+
-
| Database |
-
+--------------------+
-
| information_schema |
-
| dbtest |
-
| mysql |
-
| performance_schema |
-
| sys |
-
+--------------------+
-
5 rows in set (0.00 sec)
-
-
(root:localhost:Thu Jul 20 11:25:12 2017)[(none)]>use dbtest;
-
Database changed
-
(root:localhost:Thu Jul 20 11:25:15 2017)[dbtest]>select * from t;
-
+------+
-
| id |
-
+------+
-
| 10 |
-
+------+
-
1 row in set (0.00 sec)
-
(root:localhost:Thu Jul 20 11:25:20 2017)[dbtest]>show slave status \G
-
*************************** 1. row ***************************
-
Slave_IO_State: Waiting for master to send event
-
Master_Host: 10.26.7.129
-
Master_User: rpl_user
-
Master_Port: 3306
-
Connect_Retry: 60
-
Master_Log_File: mysql-bin.000006
-
Read_Master_Log_Pos: 732
-
Relay_Log_File: mysql-relay.000002
-
Relay_Log_Pos: 897
-
Relay_Master_Log_File: mysql-bin.000006
-
Slave_IO_Running: Yes
-
Slave_SQL_Running: Yes
-
Replicate_Do_DB:
-
Replicate_Ignore_DB:
-
Replicate_Do_Table:
-
Replicate_Ignore_Table:
-
Replicate_Wild_Do_Table:
-
Replicate_Wild_Ignore_Table:
-
Last_Errno: 0
-
Last_Error:
-
Skip_Counter: 0
-
Exec_Master_Log_Pos: 732
-
Relay_Log_Space: 1092
-
Until_Condition: None
-
Until_Log_File:
-
Until_Log_Pos: 0
-
Master_SSL_Allowed: No
-
Master_SSL_CA_File:
-
Master_SSL_CA_Path:
-
Master_SSL_Cert:
-
Master_SSL_Cipher:
-
Master_SSL_Key:
-
Seconds_Behind_Master: 0
-
Master_SSL_Verify_Server_Cert: No
-
Last_IO_Errno: 0
-
Last_IO_Error:
-
Last_SQL_Errno: 0
-
Last_SQL_Error:
-
Replicate_Ignore_Server_Ids:
-
Master_Server_Id: 1001
-
Master_UUID: 2faa74b8-66bb-11e7-ab7e-b8ca3a6a61ec
-
Master_Info_File: mysql.slave_master_info
-
SQL_Delay: 0
-
SQL_Remaining_Delay: NULL
-
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
-
Master_Retry_Count: 86400
-
Master_Bind:
-
Last_IO_Error_Timestamp:
-
Last_SQL_Error_Timestamp:
-
Master_SSL_Crl:
-
Master_SSL_Crlpath:
-
Retrieved_Gtid_Set: 2faa74b8-66bb-11e7-ab7e-b8ca3a6a61ec:29-31
-
Executed_Gtid_Set: 2faa74b8-66bb-11e7-ab7e-b8ca3a6a61ec:1-31,
-
35e38786-66bb-11e7-bcc3-b8ca3a6a61a4:1
-
Auto_Position: 1
-
Replicate_Rewrite_DB:
-
Channel_Name:
-
Master_TLS_Version:
- 1 row in set (0.00 sec)
Database changed
(root:localhost:Thu Jul 20 11:27:38 2017)[performance_schema]>show tables like '%replica%';
+-------------------------------------------+
| Tables_in_performance_schema (%replica%) |
+-------------------------------------------+
| replication_applier_configuration |
| replication_applier_status |
| replication_applier_status_by_coordinator |
| replication_applier_status_by_worker |
| replication_connection_configuration |
| replication_connection_status |
| replication_group_member_stats |
| replication_group_members |
+-------------------------------------------+
8 rows in set (0.00 sec)
多線複製狀態監控:
select * from replication_applier_status_by_coordinator ;
select * from replication_applier_status_by_worker ;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/27067062/viewspace-2142339/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL 5.7 並行複製MySql並行
- mysql 並行複製原理MySql並行
- MySQL 5.7並行複製MySql並行
- [Mysql]Mysql5.7並行複製MySql並行
- MySQL並行複製(MTS)原理(完整版)MySql並行
- MySQL並行複製-原始碼理解記錄MySql並行原始碼
- MySQL Case-MySQL8.0真正的並行複製writesetMySql並行
- MySQL Case-MySQL5.7無效的並行複製MySql並行
- Redis 主從複製(Replication)Redis
- Mysql 5.7 基於組複製(MySQL Group Replication) - 運維小結MySql運維
- MySQL 8 複製(八)——組複製安裝部署MySql
- Windows Mysql主從複製部署WindowsMySql
- MySQL並行複製延時時間不準確MySql並行
- 並行處理 Parallel Processing並行Parallel
- Mysql MHA部署-02主從複製MySql
- mysql主從複製詳細部署MySql
- MySQL主從複製環境部署MySql
- MySQL 並行複製方案演進歷史及原理分析MySql並行
- MGR(MySQL Group Replication)部署搭建測試MySql
- MySQL 8.0新特性-並行查詢innodb_parallel_read_threadsMySql並行Parallelthread
- Redis replication主從複製原理及配置Redis
- 並行閘道器 Parallel Gateway並行ParallelGateway
- MySQL 主從複製之多執行緒複製MySql執行緒
- MySQL案例-並行複製亂序提交引起的同步異常MySql並行
- MySQL 主從複製安裝部署配置MySql
- MySQL 的主從複製(高階篇)MySql
- MySQL面試寶典-主從複製篇MySql面試
- OGG 12c mysql複製到oracle部署方案MySqlOracle
- MySQL複製MySql
- Build mysql replicationUIMySql
- MySQL Group ReplicationMySql
- mysql複製--主從複製配置MySql
- MySQL 主從複製的執行流程MySql
- Linux下MySQL主從複製(Binlog)的部署過程LinuxMySql
- 例項解讀:MySQL並行複製如何解決特定的主從問題?MySql並行
- MySQL 8 複製(三)——延遲複製與部分複製MySql
- MySQL主從複製之GTID複製MySql
- MySQL 8 複製(一)——非同步複製MySql非同步
- MySQL 8 複製(二)——半同步複製MySql