Home  >  Article  >  Database  >  MySQL主从同步设置和同步错误处理

MySQL主从同步设置和同步错误处理

WBOY
WBOYOriginal
2016-06-07 17:18:25908browse

1、两台服务器数据库版本应一致,如果不一致,从服务器的版本要高于主服务器的版本。2、MySQL进行实时数据同步,本质上是将mysql

注意:

1、两台服务器数据库版本应一致,如果不一致,从服务器的版本要高于主服务器的版本。

2、MySQL进行实时数据同步,本质上是将mysql动作同步到Slave服务器,而不是对实质的数据进行同步。所以同步开始前,,两端的数据要保持一致。

 

Master服务器:192.168.0.1

Slave服务器:192.168.0.2

 

===  Master停止运行时,Mysql同步配置===

 

一、主服务器设置:

 

1、修改/etc/my.cnf 

在[mysqld]区段内加入参数 

server-id=1

log-bin 

sql-bin-update-same

 

2、为Slave服务器创建连接账户,用于同步

  • mysql>FLUSH PRIVILEGES
  • 3、重启mysql服务:service mysqld restart

    此时因为有加入log-bin参数,因此开始有index产生了,在/var/lib/mysql目录下有.index档案纪录数据库的异动log.

     

    二、Slave服务器设置:

     

    1、修改/etc/my.cnf 

    在[mysqld]区段加入  【Linux公社 】

  • 2、重启Slave服务器mysql服务

    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