MySQL 5.5 主从双向同步
在Red Hat Enterprise Linux平台,利用MySQL主从同步原理,实现MySQL双向同步
MySQL版本:5.5.28
操作系统:RHEL 5.8 32bit
Server1:192.168.1.1
配置:my.cnf
- server-id = 1
- binlog-do-db = testdb
- binlog-ignore-db = mysql
- log-slave-updates
- replicate-do-db = testdb
- replicate-ignore-db = mysql
同步testdb数据库,这里不对mysql数据库进行同步
新增同步用户:
- grant replication slave on *.* to [email protected] identified by '123456';
启动Sever1;
- service mysql start
查看MySQL同步binlog文件名以及pos值:
- show master status;
Server2:192.168.1.2
配置:my.cnf
- server-id = 2
- binlog-do-db = testdb
- binlog-ignore-db = mysql
- log-slave-updates
- replicate-do-db = testdb
- replicate-ignore-db = mysql
与Sever1配置基本相同,只是server-id不同,而且不能相同,另外记得在[mysqld]配置区域里配置开启二进制日志记录:log-bin = mysql-bin
新增同步用户:
- grant replication slave on *.* to [email protected] identified by '123456';
启动Server2:
- service mysql start
配置同步:
- mysql>change master to master_host='192.168.1.1',
- mysql>master_user='slaveuser',
- mysql>master_password='123456',
- mysql>master_log_file='mysql-bin.000020',
- mysql>master_log_pos=107;
- mysql>slave start;
- mysql>show slave status\G;
相关推荐
emmm00 2020-11-17
暗夜之城 2020-11-11
疯狂老司机 2020-09-08
王艺强 2020-11-17
aydh 2020-11-12
世樹 2020-11-11
zry 2020-11-11
URML 2020-11-11
spurity 2020-11-10
yifangs 2020-10-13
Andrea0 2020-09-18
Ida 2020-09-16
ltd00 2020-09-12
tufeiax 2020-09-03
xjd0 2020-09-10
greatboylc 2020-09-10
adsadadaddadasda 2020-09-08
CoderToy 2020-11-16
ribavnu 2020-11-16