環境:
RDS版本:阿里雲的5.6
ECS自建MySQL5.6.34(官方版本)
通過將阿里雲rds的自動全量備份下載到ECS上,按照官方的步驟解壓--> aploy-log ---> mv 到mysql的datadir 並啓動mysql。
然後執行
reset slave all;
reset master;
change master to master_host='rm-xxxxxxxxx.mysql.rds.aliyuncs.com',
master_user='rpl',
master_password='123456' ,
MASTER_PORT=3306,
MASTER_AUTO_POSITION=1;
這裏就報錯了。錯誤日誌提示:
2017-06-05 16:35:19 16759 [ERROR] Error reading relay log configuration.
2017-06-05 16:37:00 16759 [ERROR] Error reading master configuration.
原因:
阿里雲的RDS是做個修改的版本,和官方部分表結構的不一樣。(目前發現的有mysql庫下面的slave_master_info、slave_relay_log_info、slave_worker_info,其他的表還沒仔細關注)
RDS恢復出來的這3張表裏面,比官方的版本多了個Channel_name字段。導致我們change master失敗。
下圖是我在編譯的alisql上面查看的表結構:
解決方法:
use mysql;
drop table slave_master_info;
drop table slave_relay_log_info;
drop table slave_worker_info;
然後參照其他MySQL5.6的機器,重新建這3張表。
完成後,再按照常規的GTID複製的從庫搭建步驟操作:
change master to master_host='rm-xxxxxxxxxxx.mysql.rds.aliyuncs.com',
master_user='rpl',
master_password='rpl' ,
MASTER_PORT=3306,
MASTER_AUTO_POSITION=1;
SET GLOBAL gtid_purged='b9f0343a-3ac4-11e7-9769-008cfaf59624:1-6751, d50b0441-3ac4-11e7-976a-7cd30ac47780:1-106693';
start salve;
這樣就可以自動開始同步數據了。
(如果用編譯安裝的alisql則不需要這幾步驟,因爲阿里雲開源出來的ALiSQL和RDS都有Channel_name字段)