centos6.10+mysql5.7主从简易配置

主库ip:192.168.0.225

从库ip:192.168.0.224

步骤:

(一)

主库:

[root@localhost ~]# cat /etc/my.cnf
[mysqld]
...
log-bin=mysql-bin
server-id=125

...

service  mysqld restart

从库:

[root@localhost ~]# cat /etc/my.cnf
[mysqld]
...
log-bin=mysql-bin
server-id=124

...

service  mysqld restart

(二)

主库:

mysql> grant replication slave,reload,super on *.* to 'backup'@'%' identified by '000';
mysql> show master status;

+------------------+----------+--------------+------------------+-------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000001 |     454|              |                  |                   |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)

从库:

stop slave;

change master to master_host='192.168.0.125',master_user='backup',master_password='000',master_log_file='mysql-bin.000001',master_log_pos=454;

start  slave;

show slave status\G;


mysql> show slave status \G;
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 192.168.0.225
                  Master_User: backup
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000001
          Read_Master_Log_Pos: 1959
               Relay_Log_File: localhost-relay-bin.000002
                Relay_Log_Pos: 1825
        Relay_Master_Log_File: mysql-bin.000001
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes

...

搞定!

2018-08-02

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值