master主库端操作:
保障server-id不一样
保证开启binglog
此处的192.168.1.8为从库机器的ip地址
reset master;
mysql -uroot -p'sred(5678%$#@!)d70' -e "grant replication slave on *.* to novelrep@'192.168.1.8' identified by 'JuwoSdk21TbUser'; flush privileges;"
mysqldump -uroot -p'sred(5678%$#@!)d70' -B -A -F --master-data=2 --single-transaction --events|gzip >/opt/juwo_$(date +%F).sql.gz
slave从库端操作:
reset slave all;
此处的192.168.1.9为master机器的ip地址
source juwo_$(date +%F).sql.gz
mysql -uroot -p -e "CHANGE MASTER TO MASTER_HOST='192.168.1.9',MASTER_PORT=3306,MASTER_USER='novelrep',MASTER_PASSWORD='JuwoSdk21TbUser';start slave;show slave status\G" |grep -i "yes"