mysql主从复制1064_MYSQL双向主从复制

假如配置 192.168.2.100(主) 和 192.168.2.95(备)两台服务器 mysql 双向同步,数据库用户为test

Ø 配置文件修改

两台主机上修改mysql配置文件 mysqld.cnf

server-id = 100

log_bin = /var/log/mysql/mysql-bin.log

expire_logs_days = 10

max_binlog_size = 100M

log-bin-trust-function-creators=1

sql_mode='NO_ENGINE_SUBSTITUTION'

slave_skip_errors=1032,1064,1062

binlog-do_db = test_db#指定同步的数据库名

binlog_ignore_db = mysql,information_schema,performance_schema

replicate-do-db = test_db

replicate-ignore-db = mysql,information_schema,performance_schema

replicate-ignore-table=test_db.tb_test#不同步数据库的表

Ø 100同步到95 配置命令

100命令行执行:

mysql -uroot -ppassword123

grant replication slave on *.* to 'test'@'192.168.2.95' identified by 'password123';

flush privileges;

show variables like 'log%';

show master status;

95执行下面命令(log_file 和 log_pos 都需要读取100的结果)

mysql -uroot -ppassword123

stop slave;

change master to master_host='192.168.2.100',master_user='test',master_password='password123',master_log_file='mysql-bin.000001',master_log_pos= 80094;

start slave;

show slave status;

Ø 95 配置同步到 100

95执行

grant replication slave on *.* to 'test'@'192.168.2.100' identified by 'password123';

flush privileges;

show variables like 'log%';

show master status;

100执行

stop slave;

change master to master_host='192.168.2.95',master_user='test',master_password='password123',master_log_file='mysql-bin.000001',master_log_pos= 125389;

start slave;

show slave status;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值