1.多源复制设置
change master to
master_host='192.168.1.11',
master_port=3306,
master_user='repuser',
master_password='repuser123',
master_auto_position=1
for channel 'master11';
ERROR 3077 (HY000): To have multiple channels, repository cannot be of type FILE;
Please check the repository configuration and convert them to TABLE
--修复方法。
master_info_repository = FILE
relay_log_info_repository =FILE
--修改为:
master_info_repository = TABLE
relay_log_info_repository =TABLE
2.检查主库。
--检查主1;
"root@localhost">show master status;
+-----------------+----------+--------------+-------------------------------------------------+------------------------------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+-----------------+----------+--------------+-------------------------------------------------+------------------------------------------+
| mybinlog.000003 | 194 | itpuxdb | mysql,information_schema,performance_schema,sys | 02283b7e-7a50-11ee-bcd0-000c290123cd:1-5 |
+-----------------+----------+--------------+-------------------------------------------------+------------------------------------------+
1 row in set (0.00 sec)
"root@localhost">reset master;
Query OK, 0 rows affected (0.01 sec)
"root@localhost">show master status;
+-----------------+----------+--------------+-------------------------------------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+-----------------+----------+--------------+-------------------------------------------------+-------------------+
| mybinlog.000001 | 154 | itpuxdb | mysql,information_schema,performance_schema,sys | |
+-----------------+----------+--------------+-------------------------------------------------+-------------------+
1 row in set (0.00 sec)
--检查主2;
"root@localhost">show master status;
+-----------------+----------+--------------+-------------------------------------------------+------------------------------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+-----------------+----------+--------------+-------------------------------------------------+------------------------------------------+
| mybinlog.000003 | 194 | itpuxdb1 | mysql,information_schema,performance_schema,sys | 1c599192-4fec-11ef-8490-000c29c189d5:1-5 |
+-----------------+----------+--------------+-------------------------------------------------+------------------------------------------+
1 row in set (0.00 sec)
"root@localhost">reset master;
Query OK, 0 rows affected (0.01 sec)
"root@localhost">show master status;
+-----------------+----------+--------------+-------------------------------------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+-----------------+----------+--------------+-------------------------------------------------+-------------------+
| mybinlog.000001 | 154 | itpuxdb | mysql,information_schema,performance_schema,sys | |
+-----------------+----------+--------------+-------------------------------------------------+-------------------+
1 row in set (0.00 sec)
3.开启多源复制。
由于两个主库,从库都重置了reset master;
都没有GTID;此时可以启动从库成功。
change master to
master_host='192.168.1.11',
master_port=3306,
master_user='repuser',
master_password='repuser123',
master_auto_position=1
for channel 'master11';
change master to
master_host='192.168.1.12',
master_port=3306,
master_user='repuser',
master_password='repuser123',
master_auto_position=1
for channel 'master52';
start slave;
show slave status\G
"root@localhost">show master status\G;
*************************** 1. row ***************************
File: mybinlog.000002
Position: 154
Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set:
1 row in set (0.00 sec)
ERROR:
No query specified
"root@localhost">change master to
-> master_host='192.168.1.11',
-> master_port=3306,
-> master_user='repuser',
-> master_password='repuser123',
-> master_auto_position=1
-> for channel 'master11';
Query OK, 0 rows affected, 2 warnings (0.01 sec)
"root@localhost">change master to
-> master_host='192.168.1.12',
-> master_port=3306,
-> master_user='repuser',
-> master_password='repuser123',
-> master_auto_position=1
-> for channel 'master52';
Query OK, 0 rows affected, 2 warnings (0.01 sec)
"root@localhost">start slave;
Query OK, 0 rows affected (0.06 sec)
"root@localhost">show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.1.11
Master_User: repuser
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mybinlog.000001
Read_Master_Log_Pos: 154
Relay_Log_File: mysql3-relay-master11.000002
Relay_Log_Pos: 365
Relay_Master_Log_File: mybinlog.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: itpuxdb,itpuxdb1
Replicate_Ignore_DB: mysql,information_schema,performance_schema,sys
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table: itpuxdb.%,itpuxdb1.%
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 154
Relay_Log_Space: 578
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: 113306
Master_UUID: 02283b7e-7a50-11ee-bcd0-000c290123cd
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:
Auto_Position: 1
Replicate_Rewrite_DB:
Channel_Name: master11
Master_TLS_Version:
*************************** 2. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.1.12
Master_User: repuser
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mybinlog.000001
Read_Master_Log_Pos: 154
Relay_Log_File: mysql3-relay-master52.000002
Relay_Log_Pos: 365
Relay_Master_Log_File: mybinlog.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: itpuxdb,itpuxdb1
Replicate_Ignore_DB: mysql,information_schema,performance_schema,sys
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table: itpuxdb.%,itpuxdb1.%
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 154
Relay_Log_Space: 578
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: 123306
Master_UUID: 1c599192-4fec-11ef-8490-000c29c189d5
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:
Auto_Position: 1
Replicate_Rewrite_DB:
Channel_Name: master52
Master_TLS_Version:
2 rows in set (0.00 sec)
4.数据同步。
--主库1;写入数据
"root@localhost">select * from test_1;
+------+------+
| id | name |
+------+------+
| 1 | xsq1 |
| 2 | xsq2 |
+------+------+
2 rows in set (0.00 sec)
--主库二写入数据
--从库数据检查
"root@localhost">select * from itpuxdb1.test1_1;
+------+------+
| id | name |
+------+------+
| 1 | xsq1 |
| 2 | xsq2 |
+------+------+
2 rows in set (0.00 sec)
"root@localhost">select * from itpuxdb.test_1;
+------+------+
| id | name |
+------+------+
| 1 | xsq1 |
| 2 | xsq2 |
+------+------+
2 rows in set (0.00 sec)