centos7 configuration from the master copy mysql8.0

Note:
1, main library: 10.1.131.75, from the library: 10.1.131.76
2, server-id number must be pure, and from the two main server-id unique to the LAN.

The master node] [
VI /etc/my.cnf
[mysqld]
log-bin bin = MySQL-
Server-ID = 2019001

Restart the service
service mysqld restart

[Node] From
VI /etc/my.cnf
[mysqld]
Server-ID = 2019002

Restart the service
service mysqld restart

【主节点】
mysql> CREATE USER 'repl'@'10.1.131.76' IDENTIFIED WITH mysql_native_password BY 'XXXXXX';

mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'10.1.131.76';
mysql> flush privileges;

Get the current master node binary log file name and location (position)
MySQL> SHOW the MASTER the STATUS;
+ ------------------ + ---------- + - ------------- + ------------------ + ----------------- - +
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+ ------------------ + ---------- + ----- + ------------------ + ------------------- + ---------
| bin.000001-MySQL | 155 | | | |
+ ------------------ + ---------- + -------- ------ + ------ + ------- +

【从节点】
mysql> CHANGE MASTER TO
MASTER_HOST='10.1.131.75',MASTER_USER='repl',MASTER_PASSWORD='XXXXXX',MASTER_LOG_FILE='mysql-bin.000001',MASTER_LOG_POS=155;

Open master-slave synchronization
mysql> start slave;

再查看主从同步状态
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 10.1.131.75
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 155
Relay_Log_File: localhost-relay-bin.000002
Relay_Log_Pos: 322
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes

Note the Slave_IO_Running and Slave_SQL_Running, must all be YES, if Slave_IO_Running is No, usually server-id configuration problem.

Guess you like

Origin www.cnblogs.com/duanlinxiao/p/12091663.html