Home  >  Article  >  Database  >  MySQL 5.5 主从双向同步

MySQL 5.5 主从双向同步

WBOY
WBOYOriginal
2016-06-07 17:23:57762browse

MySQL的5.5版本已经不支持在my.cnf中配置同步的主机信息了,即master-host等字段,否则MySQL会启不动,这点要注意下,网上也有很

在Red Hat Enterprise Linux平台,利用MySQL主从同步原理,实现MySQL双向同步
MySQL版本:5.5.28
操作系统:RHEL 5.8 32bit

Server1:192.168.1.1
配置:my.cnf

同步testdb数据库,这里不对mysql数据库进行同步
新增同步用户:

  • grant replication slave on *.* to slaveuser@192.168.1.2 identified by '123456';
  • 启动Sever1;

  • service mysql start
  • 查看MySQL同步binlog文件名以及pos值:

  • show master status;
  • Server2:192.168.1.2
    配置:my.cnf

    与Sever1配置基本相同,,只是server-id不同,而且不能相同,另外记得在[mysqld]配置区域里配置开启二进制日志记录:log-bin = mysql-bin
    新增同步用户:

  • grant replication slave on *.* to slaveuser@192.168.1.1 identified by '123456';
  • 启动Server2:

  • service mysql start
  • 配置同步:

    linux

    Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn