configuring MySQL master-slave replication
Environment: Redhat 7.3 System two hosts one Master one slave
1, the master-slave copy of the steps
1, build time NTP server, synchronization time
1) Set up a time synchronization environment to build a time synchronization server on the master node
Time synchronization is no longer repeated here, so you can scroll through the last document.
2, firewall open outside the column, or directly shut down
3. Install MySQL This step is no longer explained.
4. mysql master server (master)
1) Modify the/ETC/MY.CNF configuration file
Server-id = single//mysql of data (cannot be duplicated)
Log-slave-updates=true//Allow secondary replication (increase)
Log-bin=master-bin//binary file name (modified)
Og-bin=mysql-bin
5. Restart MySQL
6. Create a MySQL user who can log on in the master server 192.168.95.11 in the 192.168.95.12 host
Mysql>grant REPLICATION SLAVE on
.To ' mysql12 ' @ ' 192.168.95.12 ' identified by ' mysql12 ';
Mysql>flush privileges;
7. View the main service 192.168.95.11MySQL server binary file name and location
Mysql>show MASTER STATUS;
8. Configure the slave server
In/etc/my.cnf, modify the following:
[Email protected] ~]# VIM/ETC/MY.CNF
Server-id = 22//cannot be duplicated with other instances
Log-bin=mysql-bin//binary log file name modification
Relay-log=relay-log-bin//Copy over the binary file name, add
Relay-log-index=slave-relay-bin.index//trunk Log Store file name, add
9. The configuration file needs to be restarted after editing
10, inform the binary file name and location (in the slave server configuration)
Execute in 192.168.95.12
Mysql>change MASTER
Master_host= ' 192.168.95.11 ',
master_user= ' ATM ' >
Master_password= ' mysql12 ',
Master_log_file= ' mysql-bin.000048 ',
master_log_pos=432;
11.
1) Start slave; start synchronization from server
2) Check the slave status to make sure the following two values are Yes
An error occurs during this process
Summarize two small errors that I encountered in the configuration
Question one:
Workaround: Delete the auto.cnf file from the database and restart the database.
Question two:
Error message; Last_io_error:got fatal error 1236 from master when reading data from binary log: ' Could not ' find first log file Na Me in binary log index file '
Workaround:
You can execute the following command from the server
Stop slave;
Reset slave;
Start slave;
Question three:
Be sure to turn on the binary log
Added within MY.CNF file
Log-bin=mysql-bin
See if binary files are turned on
Show variables like ' Log_bin ';
12. Test whether the master/slave database is available
To create a database in the primary database
create databases it;
show databases; see if the master-slave database is already available
Done!!!
Production environment configuration MySQL master-slave replication