CentOS6.8 MySQL 5.6 implements master-slave replication, centos6.8mysql
Master database operations
1. Add the mysqldump command to/usr/bin.
1 ln -s /application/mysql/bin/mysqldump /usr/bin/
2. Enable the log-bin function on the master.
1 # vim /etc/my.cnf
log_bin=mysql-binserver_id =1
3. Restart mysql
1 # /etc/init.d/mysqld restart
4. log onto mysql to create an account on the master server and authorize the slave function.
1 #mysql –uroot –p2 mysql> grant replication slave on *.* to 'repl'@'%' identified by 'repl';3 mysql> flush priviliges;4 mysql> flush tables with read lock;
5. Use the mysqldump command to back up the database of the master server
1 # mysqldump -uroot -p -A --master-data=1 > /tmp/master_16-09-12.sql
6. After the backup is complete, restore the write operation.
1 mysql> unlock tables;
Slave database operations
1. Stop the slave synchronization operation
1 mysql> stop slave;
2. modify the configuration file of the slave Database
1 # vim /etc/my.cnf
log_bin=mysql-binserver_id = 2
3. Import the master_16-09-12. SQL file to the slave Database
1 # mysql -uroot -p < master_16-09-12.sql
4. Configure the slave server slave
1 mysql> change master to 2 master_host="192.168.92.137",3 master_user="repl",4 master_password="repl";
5. Start the slave server slave
1 mysql> start slave;
6. Check the slave server status
1 mysql> show slave status\G;
Note: Only when Slave_IO_Running and Slave_ SQL _Running both succeed. If the master-slave synchronization is successful, no verification is performed. You can perform an experiment on your own.