mysql 5.6配置同步_一步一步教你配置 MySQL 5.6 主從同步

主庫IP:192.168.56.111  主機名:ace

備庫IP:192.168.56.123 主機名:luffy

MySQL版本:5.6

1、確保主庫的binlog打開,確保主從庫的server-id不相同

[root@ace mysql]# egrep 'log-bin|server-id' < /etc/my.cnf

log-bin=/var/lib/mysql/binlog

server-id=1

[root@luffy ~]# egrep 'log-bin|server-id' < /etc/my.cnflog-bin=/var/lib/mysql/binlogserver-id=2

注:我這里備庫的binlog也打開了,如果不做鏈式同步的話備庫binlog可不必打開。

2、在主庫創建備庫復制時使用的用戶

mysql> create user 'rep'@'%' identified by 'rep';

Query OK, 0 rows affected (0.00 sec)

mysql> grant replication slave on *.* to 'rep'@'%';

Query OK, 0 rows affected (0.00 sec)在備庫進行登陸測試

[root@luffy ~]# mysql -urep -prep -h192.168.56.111

Warning: Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 53

Server version: 5.6.30-log MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

登陸成功。

3、主庫鎖表后進行全備

mysql> flush tables with read lock;

Query OK, 0 rows affected (0.00 sec)

mysql> insert into test1.aaa values (123123);

ERROR 1223 (HY000): Can't execute the query because you have a conflicting read lock鎖表成功

然后備份

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值