标签:工作总结
2014-5-14:
今天来公司突然发现mysql数据库不同步;
方法一:
slave stop; set global sql_slave_skip_counter=1; slave start; show slave status\G;
跳过一个事件 event
方法二:
1.查看从服务器的状态 show slave status\G 记录下 maser_log_file 和 read_master_log_pos 记录下这两个值
Master_Log_File: mysql-bin.000503 Read_Master_Log_Pos: 437442392
2.查看主的show master status; 记录下同上面两个值。
+------------------+-----------+-------------------------------------------------------------------------------------------+------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | +------------------+-----------+-------------------------------------------------------------------------------------------+------------------+ | mysql-bin.000503 | 452561403 | ,account,advertisement,blog,blogen,help,log,mysql,report,search,test,pp,store | | +------------------+-----------+-------------------------------------------------------------------------------------------+------------------+
3.把主的上把偏移量导入出来 mysqlbinlog --start-postion --stop-postion mysql-bin.000503 > /tmp/bin.sql
4.在从的上面导入 mysql -uroot -p < /bin.sql
5.修改master现在的状态
CHANGE MASTER TO MASTER_HOST=‘master2.mycompany.com‘, MASTER_USER=‘replication‘, MASTER_PASSWORD=‘bigs3cret‘, MASTER_PORT=3306, MASTER_LOG_FILE=‘master2-bin.001‘, MASTER_LOG_POS=4,
6.启动start slave;
如果出现以下问题 binlog 导入失败 删除 文件的最后两条命令即可。
标签:工作总结
原文地址:http://gyulong.blog.51cto.com/6844383/1410945