mysql快速部署主從復制
master主庫端:
保障server-id不一樣
保證開啟binglog
此處的192.168.1.8為從庫機器的ip地址
reset master;
mysql -uroot -p‘sred(5678%$#@!)d70‘ -e "grant replication slave on *.* to [email protected]‘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
grant replication slave on *.* to [email protected]‘192.168.10.21‘ identified by ‘JuwoSdk21TbUser‘; flush privileges;
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"
CHANGE MASTER TO MASTER_HOST=‘192.168.1.9‘,MASTER_PORT=3306,MASTER_USER=‘novelrep‘,MASTER_PASSWORD=‘JuwoSdk21TbUser‘;start slave;show slave status\G
本文出自 “10931853” 博客,請務必保留此出處http://wujianwei.blog.51cto.com/10931853/1961247
mysql快速部署主從復制