一、將主庫(kù)數(shù)據(jù)導(dǎo)出
mysqldump -uuser -ppassword -S /tmp/mysql.sock --single-transaction --master-data=2 --all-databases --triggers --routines --events >/root/master_dump.sql
二、在主庫(kù)創(chuàng)建主從復(fù)制用戶
mysql>grant replication slave on *.* to 'rep'@'%' identified by 'rep';
三、將數(shù)據(jù)文件導(dǎo)入從庫(kù)
mysql>source /root/master_dump.sql
四、查找日志應(yīng)用點(diǎn)
less /root/master_dump.sql
然后在從庫(kù)執(zhí)行
change master to MASTER_HOST='主庫(kù)IP',MASTER_USER='rep',MASTER_PASSWORD='rep',MASTER_LOG_FILE='查出的日志號(hào)',MASTER_LOG_POS=查出的postition;