MySQL master-slave replication:
Lab Environment:
Linux CentOS7 two: 192.168.230.10 (master)----192.168.230.11 (from) (System installed, switch off the firewall or configure the firewall).
MySQL 5.7 (Download the official Yum source, yum install-y MySQL mysql-server)
To start the configuration:
MySQL configuration files in general Linux are all in/ETC/MY.CNF (the configuration file in Windows is Mysql.ini)
server-ID1 (guaranteed unique in the entire MySQL cluster) log-bin = binlog (binary) log-bin-index = Binlog.index
Note: The binary log must be turned on because the synchronization of the data is essentially the other MySQL database server executes the binary log of this data change again on this computer.
Start building:
The first step:
Create a MySQL user in 192.168.230.10 that can log on in a 192.168.230.11 host
Users: Mysql11
Password: [email protected] (mysql5.7 default password complexity verification, the actual production environment should also be more complex password settings)
Mysql>grant REPLICATION SLAVE on * * to ' mysql11 ' @ '192.168. 230.11' identified by ' [email protected]one by one'; MySQL>flush privileges;
Step Three:
Tell the binary file name and location
Execute in 192.168.230.11:
mysql> changeMASTER to >master_host= '192.168. 230.10', >master_user=' mysql11 ', >master_password= ' [email protected]11 ', >master_log_file= ' Binlog. 000003', >master_log_pos=668;
Or
Change MASTER to master_host= ' 192.168.230.10 ', master_user= ' mysql11 ', master_password= ' [email protected] ', Master_log _file= ' binlog.000003 ', master_log_pos=
668;
Complete the master-slave configuration.
To turn on master-slave replication:
In the 192.168.230.11 (slave translated as slaves)
Mysql>start slave; #开启复制 This stop slave;//is definitely stopping the copy mode
mysql>show slave status\g #查看主从复制是否配置成功
When you see Slave_io_running:yes and Slave_sql_running:yes, it shows the state is normal.
Here are a few of the exclusion commands:
MySQL master-slave replication and primary master replication