mysql -h host -P port -u user -p --databases db1 db2 > test.sql
//导出时添加--single-transaction即可解决
source /root/test.sql
vim /etc/my.cnf
server-id=55
gtid-mode=ON
enforce-gtid-consistency=ON
log-slave-updates=ON
change master to master_host='ip',
master_port=port,
master_user='username',
master_password='password',
master_auto_position=1;
参考:
https://cloud.tencent.com/developer/article/1158202