The answer is: MySQL master-slave synchronization, clustering, read and write separation, will involve data synchronization, so want to play what things, we still want to put this data synchronization of the basic learning after we can play other, today, think of the dream of PHP to everyone brought this small case, pro-test, no problem!
The following case is a test case, of course, your online server is the same! First you want to ensure that the unity of your operating system, the unity of the version of the database you can open the door of data synchronization! Here's the next step!
1: First you need a virtual machine, then configure the two systems above, of course your MySQL version to be consistent
2: You create a MySQL database in your master's MySQL that you want to sync
etc/under the 3:linux directory
There's a my.cnf file.
Configuration of the primary server
4:vi/etc/my.cnf
Log-bin=mysql-bin
Binlog_format=mixed
Server-id = 1
binlog_do_db = Test #指定需要同步的数据库 (actual application is specified according to the actual situation)
binlog_ignore_db = MySQL #无需同步的数据库
binlog_ignore_db = Information_schema #无需同步的数据库
% settings After synchronization note that if you create a database on the primary server, it will be created from the server, and then they will be synchronized, so you will have to create additional databases to be banned from syncing
Inside the red line is the configuration you want to add
5: Log in to MySQL, and then check the status of the master, the value of the file and position in Jixian, which is used later from the service
Configuration from the server:
1: Also find the file of the MY.CNF
Log-bin=mysql-bin
Binlog_format=mixed
Server-id = 2 #这里是2 The primary server is 1, the following database needs to be synchronized what configuration is the same as the master server
binlog_do_db = Test #指定需要同步的数据库 (actual application is specified according to the actual situation)
binlog_ignore_db = MySQL #无需同步的数据库
binlog_ignore_db = Information_schema #无需同步的数据库
2: Go to MySQL, execute slave stop
Want to play cluster? Read and write separation? You need to know this first!