MySQL master from mount

1. Modify the my.cnf file

vim /etc/my.cnf

1.1 Main Library< /p>

#The current mysql service number is 1, which is the first mysql server

server
-id=1
#Binary log file
log
-bin=mysql-bin

1.2 from the library p>

#The current mysql service number is 1, which is the first mysql server

server
-id=2
#Binary log file
log
-bin=mysql-bin

2. Edit slave library

#Master-slave mount ip address, port number, user name, password, binary file, location: these are the information of the master library

CHANGE MASTER TO
MASTER_HOST
="192.168.174.139",
MASTER_PORT
=3306,
MASTER_USER
="root",
MASTER_PASSWORD
="root",
MASTER_LOG_FILE
="mysql-bin.000002",
MASTER_LOG_POS
=120

#Start the master-slave service
START SLAVE

#Check master-slave service status
SHOW SLAVE STATUS

#Close master-slave service
STOP SLAVE

3. Check SHOW SLAVE STATUS if there is an error:

The error message is: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server UUIDs;
these UUIDs must be different for replication to work Consistent, you need to modify a UUID to view the location of the auto.cnf file. You can do this: vim /etc/my.cnf view in the my.cnf file
datadir=/var/lib/ mysql this attribute, the following value is the file storage location, modify one after finding it and restart it

vim /etc/my.cnf

#The current mysql service number is 1, which is the first mysql server

server
-id=1
#Binary log file
log
-bin=mysql-bin

#The current mysql service number is 1, which is the first mysql server

server
-id=2
#Binary log file
log
-bin=mysql-bin

#Master-slave mount ip address, port No., username, password, binary file, location: these are the information of the main library

CHANGE MASTER TO
MASTER_HOST
="192.168.174.139",
MASTER_PORT
=3306,
MASTER_USER
="root",
MASTER_PASSWORD
="root",
MASTER_LOG_FILE
="mysql-bin.000002",
MASTER_LOG_POS
=120

#Start the master-slave service
START SLAVE

#Check master-slave service status
SHOW SLAVE STATUS

#Close master-slave service
STOP SLAVE

The error message is: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server UUIDs;
these UUIDs must be different for replication to work means that the UUID in the auto.cnf file of the master library and the slave library is the same, you need to modify a UUID to view the location of the auto.cnf file. You can do this: vim /etc/my.cnf is in the my.cnf file Check
datadir=/var/lib/mysql This attribute, the following value is the file storage location, modify one after finding it, and restart it

< p>

Leave a Comment

Your email address will not be published.