前言:
由于修改了linux服务器的主机名,所以mysql主从复制失效了,现在需要恢复主从复制.这个有点不同于纯净的库的主从复制.
首先要把网站放一个维护页面.要不然用户会觉得你们网站坏掉了.
0. Lock master database table;
show master status;
flush table with read lock;
show master status;
1. Backup master database;
/usr/local/mysql/bin/mysqldump -uroot -p'a#~f`Ej+:Q?TyU8s@CaE' -S /tmp/mysql.sock -A --events -B --master-data=2 > /home/backup/mysql/kng.sql
grep MASTER /home/backup/mysql/kng.sql
show master status;
1.2 Unlock master database;
mysql> unlock tables;
2. Transfer database to slave database;
scp -r -P 3389 /home/backup/mysql/kng.sql allen@192.168.3.3:/tmp
3. recovery slave database;
mysql -uroot -p'a#~f`Ej+:Q?TyU8s@CaE' -S /tmp/mysql.sock < /home/backup/mysql/kng.sql
mysql -uroot -p'a#~f`Ej+:Q?TyU8s@CaE'
change master to master_host='192.168.3.2',master_user='remotesql',master_password='EhAhoCoevU4MR,nTsJfEo', master_log_file='mysql-bin.000183',master_log_pos=1058354975;
start slave;
4. Show slave status;
show slave status\G
阅读(8889) | 评论(0) | 转发(1) |