`
tiantianfei
  • 浏览: 38451 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

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

    博客分类:
  • work
阅读更多

mysql 主从同步出问题,重新修复从库
2010-05-18 02:05

主库相关操作

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 
表示正常

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics