preparing: two MySQL databases
First, configure the primary database
1. Add Users
mysql> grant replication Slave on * * \
→
-e [email protected] "192.168.4.12" Authorized User/IP
-Identified by "111111"; Password
2. Start Binlog Log
[Mysqld]
Server_id=1
Log-bin=master1
binlog_format= "Mixed"
3. Restart the database service
[[Email protected] ~] #systemctl Restart Mysqld
4 Viewing log information
Mysql> Show master status;
Second, the configuration from the database
1. Verify the authorized users provided by the main library
[Email protected] ~]# mysql-h192.168.4.11-uslaveuser-p111111
2. Modify configuration file to specify configuration file
[Mysqld]
server_id=2
Log-bin=master2
3. Specify the main library information
mysql> Change Master to master_host= "192.168.4.11",
Master_user= "Slaveuser",
Master_password= "111111",
Master_log_file= "master1.000001",
master_log_pos=154;
4. Open service
mysql> start slave;
Close Service
mysql> stop Slave;
Delete Service
mysql> Reset Slave;
5. View
Mysql> show Slave status\g;
Slave_io_running:yes IO thread is running
Slave_sql_running:yesSQL thread is running
Multiple files from the database directory
[[Email protected] ~] #cat/var/lib/mysql/*
Master.info connecting master server information
Relay-log.info Interrupt log information
Host name-relay-bin.xxxxxx Interrupt Log
Bogon-realy-bin.index Interrupt Log index file
third, the test master-Slave synchronization configuration
1. Create a library on the primary server
mysql> CREATE DATABASE Ctoll;
2, from the server can also view
"One master and more from"
mysql> grant replication Slave on *. *
To
[email protected] "%"%---> Multiple hosts
Identified by "111111";
MySQL master-slave synchronization basic Configuration