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

你可能感兴趣的:(database)