mysql 5.7 多主一從的多源複製搭建
主伺服器建立使用者
主1
多源同步引數
#multi replication
master_info_repository=TABLE
relay_log_info_repository=TABLE
開啟GTID
[mysqld]
#GTID parameter
log-slave-updates=true
gtid-mode=on
enforce-gtid-consistency=true
report-port=3306
report-host=192.168.56.212
master-info-repository=TABLE
relay-log-info-repository=TABLE
sync-master-info=1
slave-parallel-workers=10
binlog-checksum=CRC32
master-verify-checksum=1
slave-sql-verify-checksum=1
binlog-rows-query-log_events=1
[mysql@ray ~]$ /usr/local/mysql/bin/mysql -uroot -p123456 -S /data/3306/soket/mysql.sock
mysql> GRANT REPLICATION SLAVE ON *.* TO 'rep'@'%' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.05 sec)
主2
多源同步引數
#multi replication
master_info_repository=TABLE
relay_log_info_repository=TABLE
開啟GTID
[mysqld]
#GTID parameter
log-slave-updates=true
gtid-mode=on
enforce-gtid-consistency=true
report-port=3307
report-host=192.168.56.212
master-info-repository=TABLE
relay-log-info-repository=TABLE
sync-master-info=1
slave-parallel-workers=10
binlog-checksum=CRC32
master-verify-checksum=1
slave-sql-verify-checksum=1
binlog-rows-query-log_events=1
[mysql@ray ~]$ /usr/local/mysql/bin/mysql -uroot -p123456 -S /data/3307/soket/mysql.sock
mysql> GRANT REPLICATION SLAVE ON *.* TO 'rep'@'%' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.05 sec)
從伺服器連線主伺服器
多源同步引數
#multi replication
master_info_repository=TABLE
relay_log_info_repository=TABLE
開啟GTID
[mysqld]
#GTID parameter
log-slave-updates=true
gtid-mode=on
enforce-gtid-consistency=true
report-port=3308
report-host=192.168.56.212
master-info-repository=TABLE
relay-log-info-repository=TABLE
sync-master-info=1
slave-parallel-workers=10
binlog-checksum=CRC32
master-verify-checksum=1
slave-sql-verify-checksum=1
binlog-rows-query-log_events=1
連線主1:
change master to
master_host='192.168.56.212',
master_user='rep',
master_password='123456',
master_port=3306,
master_auto_position = 1
for channel 'm1';
連線主2
change master to
master_host='192.168.56.212',
master_user='rep',
master_password='123456',
master_port=3307,
master_auto_position = 1
for channel 'm2';
啟動slave程式
mysql> start slave;
檢視影印程式
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.56.212
Master_User: rep
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: ray-bin.000005
Read_Master_Log_Pos: 194
Relay_Log_File: localhost-relay-bin-m1.000004
Relay_Log_Pos: 403
Relay_Master_Log_File: ray-bin.000005
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: 194
Relay_Log_Space: 1260
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: 1
Master_UUID: 97e8847a-ffdf-11e6-87ed-08002736c224
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: 97e8847a-ffdf-11e6-87ed-08002736c224:1-2
Executed_Gtid_Set: 517e04ac-ffe3-11e6-a7ea-08002736c224:1-2,
97e8847a-ffdf-11e6-87ed-08002736c224:1-2
Auto_Position: 1
Replicate_Rewrite_DB:
Channel_Name: m1
Master_TLS_Version:
*************************** 2. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.56.212
Master_User: rep
Master_Port: 3307
Connect_Retry: 60
Master_Log_File: ray-bin.000003
Read_Master_Log_Pos: 194
Relay_Log_File: localhost-relay-bin-m2.000005
Relay_Log_Pos: 403
Relay_Master_Log_File: ray-bin.000003
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: 194
Relay_Log_Space: 1083
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: 2
Master_UUID: 517e04ac-ffe3-11e6-a7ea-08002736c224
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: 517e04ac-ffe3-11e6-a7ea-08002736c224:1-2
Executed_Gtid_Set: 517e04ac-ffe3-11e6-a7ea-08002736c224:1-2,
97e8847a-ffdf-11e6-87ed-08002736c224:1-2
Auto_Position: 1
Replicate_Rewrite_DB:
Channel_Name: m2
Master_TLS_Version:
2 rows in set (0.00 sec)
啟動和停止單獨slave程式
mysql> start slave for channel 'm1';
mysql> stop slave for channel 'm1';
mariaDB:
CHANGE MASTER 'm1' TO
MASTER_HOST='192.168.56.91',
MASTER_USER='rep',
MASTER_PASSWORD='123456',
MASTER_PORT=3306,
MASTER_LOG_FILE='ray-bin.000007',
MASTER_LOG_POS=396;
mysql:
CHANGE MASTER TO
MASTER_HOST='192.168.56.91',
MASTER_USER='rep',
MASTER_PASSWORD='123456',
MASTER_PORT=3306,
MASTER_LOG_FILE='ray-bin.000007',
MASTER_LOG_POS=396
for channel="m1";
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28572479/viewspace-2134685/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL 5.7 多主一從(多源複製)同步配置MySql
- mysql主從複製(一):一主多從MySql
- mysql 5.7 主從複製搭建及原理MySql
- MySQL5.7主從複製-半同步複製搭建MySql
- MySQL叢集之 主從複製 主主複製 一主多從 多主一叢 實現方式MySql
- MySQL 5.7 基於GTID搭建主從複製MySql
- mysql5.7主從複製,主主複製MySql
- MySQL5.7主從複製教程MySql
- MySQL(14)---Docker搭建MySQL主從複製(一主一從)MySqlDocker
- MySQL 多源複製MySql
- MySQL 5.7的安裝及主從複製(主從同步)MySql主從同步
- mysql主從複製搭建MySql
- MySQL 5.7基於GTID的主從複製MySql
- mysql主從複製的理解和搭建MySql
- MySQL5.7在滴滴雲主機上的主從複製MySql
- 簡單搭建MySQL主從複製MySql
- Mysql主從複製原理及搭建MySql
- docker-compase搭建mysql主從複製DockerMySql
- MySQL 5.7傳統複製到GTID線上切換(一主一從)MySql
- MySQL的主從複製MySql
- Mysql 8.4.0 結合 Docker 搭建GTID主從複製,以及傳統主從複製MySqlDocker
- mysql複製--主從複製配置MySql
- Docker Compose搭建MySQL主從複製叢集DockerMySql
- MySQL主從複製MySql
- Mysql實現主從複製(一主雙從)MySql
- MySQL-主從複製之搭建主資料庫MySql資料庫
- MySQL-主從複製之搭建從資料庫MySql資料庫
- 基於 Docker 的 MySQL 主從複製搭建(真正弄懂)DockerMySql
- MySQL主從複製之GTID複製MySql
- Windows 環境下,MySQL 的主從複製和主主複製WindowsMySql
- windows環境下,Mysql的主從複製和主主複製WindowsMySql
- mysql 8.4 主從複製MySql
- mysql--主從複製MySql
- MySQL主從複製原理MySql
- Linux實現MySql資料庫的主從複製(一主一從)LinuxMySql資料庫
- MySQL主從複製之半同步複製MySql
- MySQL主從複製之非同步複製MySql非同步
- mysql資料庫的主從複製和主主複製實踐MySql資料庫
- MySQL 的主從複製實踐MySql