Author: dante
Website: dantesite.ihostfull.com
centos7.4 (centos 1708)
mysql 5.7
IP address is 192.168.159.50 master host
IP address is 192.168.159.51 slave host
Master host user name and password synchronization: Slave / Admin @ 123
slave synchronization host user name and password: Master / Admin @ 123
we /etc/my.cnf
Add the following
server-id = 1 -------------------------------> configuration server service number
log-bin = master ---------------------------> Specify a log file database operations
replicate-do-db = pos --------------------> Specifies the database to be synchronized, if there are multiple, repeat and modifies the row corresponding to the name of the database database.
replicate-ignore-db = mysql --------------> Specifies the database does not require synchronization
replicate-ignore-db=information_schema
max_binlog_size -----------------> log file is set to give maximum = 500M, other than the start value of the log file
binlog_cache_size = 128K ---------------> set the log file cache size
we /etc/my.cnf
The following was added (configuration only if master-slave synchronization, may not be configured, the red part)
server-id = 2 -------------------------------> configuration server service number
log-bin = master ---------------------------> Specify a log file database operations
replicate-do-db = pos -------------------- > Specifies the database to be synchronized, if there are multiple, repeat and modifies the row corresponding to the name of the database database.
replicate-ignore-db = mysql -------------- > Specifies the database does not require synchronization
replicate-ignore-db=information_schema
max_binlog_size -----------------> = 500M log file is set to give a maximum value, beyond which further enable the log file
binlog_cache_size = 128K ---------------> set the log file cache size
Log on to the database
On the master host
mysql> grantreplication slave on *.* to
->‘slave‘@'192.168.159.%'
-> identifiedby 'Admin@123';
mysql> flushprivileges;
In the slave host
mysql> grantreplication slave on *.* to
->‘master’@'192.168.159.%'
-> identifiedby 'Admin@123';
mysql> flushprivileges;
On the master host
mysql> Changemaster to master_host='192.168.159.51',
->master_user='master',
->master_password='Admin@123';
In the slave host
mysql> Changemaster to master_host='192.168.159.50',
->master_user=’slave',
->master_password='Admin@123';
After the initial two hosts to ensure consistent data, proceed as follows to start the synchronization feature to let mysql synchronization to start from scratch
On the master host
mysql>resetmaster;
mysql>resetslave
mysql>slavestart
In the slave host (if it is master-slave synchronization, content can not operate red font)
mysql>reset master;
mysql>resetslave
mysql>slavestart
mysql> showmaster status;
mysql> showslave status \G ;