您的位置:首页 > 数据库 > MySQL

mysql 主从同步出问题,重新修复从库(转)

2012-08-21 11:21 295 查看
主库相关操作

1.flush tables with read lock; //主库上锁表

2.show master status; //记录 master log file及file position
比如:
+--------------------------+----------------+-------------------+------------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+--------------------------+----------------+--------------------+-----------------------+
| xxxx-log.000031 | 199039244 | xxxx | |
+--------------------------+----------------+--------------------+-----------------------+

3.$tar -cvf database.tar ./data //备份数据文件

4.unlock tables; //解锁主库表

从库相关操作

1.将主库数据库文件copy到从库中
2.启动从库
3.stop slave;
4.reset slave;
5.change master to master_host='10.xx.xx.xxx,master_user='xxxx',master_password='xxxx',master_port=xxxx,master_log_file='xxxx-log.000031',master_log_pos=199039244;
5.start slave;
验证方法一:
//登陆从库
slave status\G;

Slave_IO_Running: Yes
Slave_SQL_Running: Yes
上面2项都为'Yes',表示slave正常

验证方法二:
//登陆主库
show processlist;
Has read all relay log; waiting for the slave I/O thread to update it
表示正常

来源:http://hihitiger.iteye.com/blog/900099
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: