Master configuration
Find the my.cnf file
Configure under [mysqld]
[mysqld]
server-id=1
log-bin=master-bin
Restart the service and log in to mysql
Create a user to obtain the log file.
mysql> CREATE USER 'sree'@'%' IDENTIFIED BY 'sree'
Grant relevant permissions (copy permissions) *.* represents all tables in all libraries
mysql> grant replication slave on *.* to 'sree'@'%'
Refresh permissions
mysql> flush privileges
mysql> show master status;
| File | Position
| master-bin.000004 | 120
Slave configuration
====================
Modify the configuration file:
Configure under [mysqld]
[mysqld]
server-id=2 #As long as it is different from the above.
Then log in to mysql
mysql>
CHANGE MASTER TO
MASTER_LOG_FILE='master-bin.000004 ', #above file
MASTER_LOG_POS = 120 ; #The above position
MASTER_HOST='192.168.249.130', #The ip address of the main library
MASTER_USER = 'sree',
MASTER_PASSWORD = 'sree',
Then start slave
============
mysql> show slave status\G;
see:
===
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
It means that it was successful.
Errors in the whole process:
Slave_IO_Running: Connecting
1. Mine is the wrong host ip.
2. There are still some firewalls on the Internet that are not turned off
I use centos7 to turn off the firewall: systemctl stop firewalld
3. There is also a mistake in the above-mentioned secret.
Fatal error: The slave I/O thread stops because master and slave have equal MySQL server UUIDs
This error generally occur when we clone the master to slaver. Delete auto.cnf of mysql, and then restart the service.
1