Mac MySQL database of the master-slave synchronization configuration mysql

This paper to introduce the next mac MySQL database mysql master-slave synchronization of configuration show to you through specific content, I want to learn MySQL database help.

First, the environmental description
of two mac, mysql environment master is 5.7.20, slave is 5.7.21
master IP: 172.21.127.10
Slave IP: 172.21.127.12

two, master machine configuration
1, change the configuration file

# Homebrew the Default MySQL Server config
[ mysqld]
# Only the allow localhost Connections from
the bind-address = 172.21.127.10

log-error = / var / log / mysqld.log
PID-File = / var / RUN / mysqld / mysqld.pid

Server-ID. 1 =
log-bin = bin-mysql
the binlog-row select the format # mode the rOW =
2, so that the configuration takes effect mysql restart

3, creating a master-slave synchronization users, only landing 172.21.127.12 in this machine for authorization, and specifies the user .

. Grant Slave Replication * to * ON 'slave1'@'172.21.127.12' IDENTIFIED by "slavepass";
4, in order to ensure consistency of master database from the library, you need to master plus a read lock, it becomes read-only

FLUSH TABLE WITH READ LOCK
5, record the master's binlog log files, and offset
technology to share pictures

6, the existing master data export, the next you want to export directory sql file, execute the following statement.

Databases --all--uroot--proot the mysqldump> db.sql
. 7, the master releasing read locks

the UNLOCK TABLES;
. 8, the copying machine to the slave db.sql

three, arranged slave machine
1, above all, modify the configuration file. Disposed on the reference master machine. The server-id changes can not be repeated, if the server-id is not configured for a while start slave being given

2, restart MySQL

3, import db.sql written to the database

database name mysqldump -u root -p to export> name at random. SQL 
# here directly
mysqldump -root -proot </Users/my/db.sql
4, the slave and master build their _x005f_x0008_ for synchronization, which is a crucial step _x0008_

STOP SLAVE;

the CHANGE MASTER the tO
    MASTER_HOST = '172.21.127.10',
    MASTER_USER = 'Slave1',
    MASTER_PASSWORD = 'slavepass',
    of MASTER_LOG_FILE = 'MySQL-bin.000003',
    1791 = MASTER_LOG_POS;

the START SLAVE;
IV Summary
After the above steps you can simply achieve master-slave synchronization, and if there are problems, you can look at log-error log configuration before, having problems multi-check log ~    

This article compiled by the post coordinate and publish, we want to help the students learn MySQL, please pay attention to more functional coordinate database MySQL database Channel!

Guess you like

Origin www.cnblogs.com/HKROnline-SyncNavigator/p/10971839.html