本文共 1389 字,大约阅读时间需要 4 分钟。
1.主库和从库都必须要开启binlog
2.主库和从库server-id不相同3.建立主从辅助用户grant replication slave on . to 'rep'@'192.168.200.%' identified by 'oldboy';[mysqld]server-id=1log-bin=mysql.binbinlog_format=rowgtid_mode=ONenforce_gtid_consistencylog_slave_updatesrelay_log_purge=OFF备注:以上设置必须存在。change master to master_host='192.168.200.77',
master_port=3306,master_user='rep',master_password='oldboy123',master_auto_position=1;start slave;
show slave status\G;reset slave all; 清除所有slave信息错误提示:导出时提示warning,A partial dump from a server that has GTIDs
[root@bastion-IDC ~]# mysqldump -uroot -p xqsj_db > xqsj_db20160811.sqlWarning: A partial dump from a server that has GTIDs will by default include the GTIDs of all transactions, even those that changed suppressed parts of the database. If you don't want to restore GTIDs, pass --set-gtid-purged=OFF. To make a complete dump, pass --all-databases --triggers --routines --events.关于GTID是5.6以后,加入了全局事务 ID (GTID) 来强化数据库的主备一致性,故障恢复,以及容错能力。
官方给的:A global transaction identifier (GTID) is a unique identifier created and associated with each transaction committed on the server of origin (master).所以可能是因为在一个数据库里面唯一,但是当导入其他的库就有可能重复。所有会有一个提醒。可以通过添加--set-gtid-purged=off 或者–gtid-mode=OFF这两个参数设置。
很有肯能是在导入库中重新生产GTID,而不用原来的。[root@master]# mysqldump -uroot -poldboy --set-gtid-purged=off -A -B -F > all.sql #这样就ok了!
转载于:https://blog.51cto.com/hdl993101/2045106