Home > Database > Mysql Tutorial > MySQL做同步实例

MySQL做同步实例

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 15:26:08
Original
996 people have browsed it

译者:叶金荣(Email: 多余的废话就不说了,直接开始实战. 本次试验的mysql版本都是 4.1.7-standard-log , master 端的操作系统是 redhat 9.0 , slave 端的操作系统是 redhat 7.3. 1.修改 master 端的my.cnf,增加配置参数: [mysqld] log-bin server-id=1 2.

译者:叶金荣(Email:MySQL做同步实例

多余的废话就不说了,直接开始实战.
本次试验的mysql版本都是 4.1.7-standard-log , master 端的操作系统是 redhat 9.0 , slave 端的操作系统是 redhat 7.3.
1.修改 master 端的my.cnf,增加配置参数:
[mysqld]
log-bin
server-id=1

2. 修改 slave 端的my.cnf,增加配置参数:
log-bin
master-host=master
master-user=rep
master-password=rep
master-port=3306
server-id=2

以上参数都是最基本的配置,就不多解释了,解下来势初始化数据.
1.清空 master 上的所有 binlog,如果现存的 binlog有用的话,请先备份起来;接着把 master 上的所有数据文件打包,包括ibdata那些文件.
2.类似的放假清空 slave 上的所有 binlog,将 master上的数据文件压缩包拷贝到自身的数据文件目录下.

启动master,新增一个rep用户," grant all privileges on *.* to rep@% identified by 'rep'; flush privileges; ".
启动slave,检测同步是否成功.

一般情况下,不成功的原因是slave连接上master之后定位binlog失败,这就需要将双方的binlog都设置成一致,然后stop slave; start slave; 即可.

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
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template