The MySQL master-slave copy structure is based on the MySQL Bin-log log from the library by opening the IO process to receive the Bin-log log increment information from the main library, and save to the local relay log, and then by opening the MySQL process from relay The increment information obtained on log is translated into the SQL statement and written to the database.
The master-slave replication architecture can actually implement two functions
1. A database backup instance that serves as the main library from the library
2. Read-write Separation Main library is responsible for normal read and write data from the library only responsible for reading data
The actual production environment because many applications actually read the database more often than the number of write the database so in the beginning of the project development program to make a judgment for all read operations all push to from the library if the data can not be obtained from the library and then to the main library to obtain data in a sense to achieve a read-write separation of the main library to alleviate the IO pressure.
This architecture is recommended for use in production environments.
System Environment centos6.3 x64
Database mysql-5.6.10
MySQL master:192.168.100.90
MySQL slave:192.168.100.91
I. Deployment environment
1. Close Iptables and SELinux
# Service Iptables Stop
# Setenforce 0
# Vi/etc/sysconfig/selinux
---------------
Selinux=disabled
---------------
2. Install and configure MySQL portal http://showerlee.blog.51cto.com/2047005/1174141
Two. Master MySQL configuration: (MySQL Master)
Modify MySQL configuration file
# VI/ETC/MY.CNF
Add to
-----------------
# Replication Master Server
# Bin Log Path
Log-bin =/usr/local/mysql/log/bin.log
# Server ID Number
Server-id = 1
# Ignore MySQL system library replication
Binlog-ignore-db=mysql
Binlog-ignore-db=information_schema
------------
Restart Service
# Service Mysqld Restart
Login to MySQL background
# mysql-u root-p123456
View login account Now
> select User ();
Add sync account number to slave in master
This column more highlights: http://www.bianceng.cn/database/MySQL/
> Grant replication slave on *.* to ' slave ' @ ' 192.168.100.91 ' identified by ' 123456 ';