Want to play in a group? Separation of reading and writing? You have to understand this first!
The answer is: Mysql master-slave synchronization, clustering, read-write separation, will involve data synchronization of data, so what do you want to play, we still have to learn the basis of this data synchronization before we can play other, today it is dream PHP to bring you this small case, pro-test, no problem!
The following examples are test cases, of course, your online server is the same! First of all, you have to ensure the unity of your operating system, the unity of the version of the database before you can open the door to data synchronization! Here are the steps!
1: First you need a virtual machine, then configure two systems on it, and of course your mysql version should be consistent.
2: You create a mysql database in your master's mysql that you want to synchronize
3: etc/in Linux directory
There's a file for my.cnf.
Configuration of the primary server
4:vi /etc/my.cnf
log-bin=mysql-bin
binlog_format=mixed
server-id = 1
binlog_do_db = test #Specify the database to be synchronized (specified according to actual situation in actual application)
binlog_ignore_db = mysql #Database without synchronization
binlog_ignore_db = information_schema #Database without synchronization
% After setting up synchronization, note that if you create a database on the master server, the slave server will also be created, and then they will also synchronize, so you have to create other databases to prevent them from synchronizing.
The red line is the configuration you want to add.
5: Log in to mysql, and then check the status of master, the file and position values of Ji County, which will be used later from service
Configuration from Server:
1: Also find that my.cnf file
log-bin=mysql-bin
binlog_format=mixed
server-id = 2 #here is 2 the master server is 1, the following database needs to be synchronized what configuration is the same as the master server
binlog_do_db = test #Specify the database to be synchronized (specified according to actual situation in practical application)
binlog_ignore_db = mysql #Database without synchronization
binlog_ignore_db = information_schema #Database without synchronization
2: Enter mysql, execute slave stop