Home > Database > Mysql Tutorial > AB复制(mysql同步)_MySQL

AB复制(mysql同步)_MySQL

WBOY
Release: 2016-06-01 13:47:08
Original
1014 people have browsed it

bitsCN.com

项目环境:
系统均为cent os 5.5
主服务器IP:192.168.19.172  (master)
从服务器IP:192.168.19.168  (slave)
俩台都搭建了mysql(root用户、密码为空)
1:设置同步master、修改mysql主配置文件:
server-id = 1
log-bin
set-variable=binlog-ignore-db=mysql
2:然后在Master上增加一个账号专门用于同步,如下:
 GRANT REPLICATION SLAVE ON *.* TO rep@192.168.19.168 IDENTIFIED BY rep;
3:查询主数据库状态(master)
Show master status;

AB复制(mysql同步)_MySQL

注:
  记录下master服务器上的file、position参数
4:配置从服务器slave、修改配置文件
修改my.cnf,增加如下几行:
server-id = 2
 master-user = rep  
 master-password = rep
master-port = 3306
5:配置命令项、

AB复制(mysql同步)_MySQL

6:start slave;        启用了复制功能
7:查看同步状态、

AB复制(mysql同步)_MySQL

注:
   Slave_IO_Running: Yes 和 Slave_SQL_Running: Yes 如果这两个状态不是yes,那么请检查上面的配置是否正确,主要是file和position设置是否正确,从库是否能用主库的账号登陆

bitsCN.com
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template