设为首页 加入收藏

TOP

MySQL 主从双向同步
2014-11-24 18:35:45 】 浏览:2691
Tags:MySQL 主从 双向 同步

主库:my.cnf


server-id=1 ######只能有一个server-id


log-bin=mysql-bin


master-host = 192.168.0.121


master-user = copy ###授权远程连接


master-password = 1


master-port = 3306


从库:my.cnf


server-id=2 ######只能有一个server-id


log-bin=slave-bin


master-host = 192.168.0.120


master-user = copy ###授权远程连接


master-password = 1


master-port = 3306


主从/usr/local/mysql/bin/mysql -uroot -p1


mysql>reset master ######重置所有binlog日志


mysql>show slave status;


Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.0.120
Master_User: copy
Master_Port: 3306
Connect_Retry: 60 ####闲置时定期同步


Master_Log_File: mysql-bin.000002
Read_Master_Log_Pos: 106 ######同步的pos位置
Relay_Log_File: localhost-relay-bin.000005
Relay_Log_Pos: 251
Relay_Master_Log_File: mysql-bin.000002
Slave_IO_Running: Yes ####必须是yes
Slave_SQL_Running: Yes ####必须是yes
Replicate_Do_DB:
Replicate_Ignore_DB:


若同步不成功试着删除所有同步有关数据


/etc/init.d/mysql stop


rm -rf /usr/local/mysql/var /localhost-relay-bin.* master.info mysql-bin.* relay-log.info


/etc/init.d/mysql start


同步成功后主从重启等等一般不会造成同步不成功的问题


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Linux下PHP连接MSSQL2005/2008 下一篇Oracle性能问题诊断一例

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目