Master-slave replication is not more than a server! , one change, the other changes, the content is actually the same!
Principle:
Operation on the database will generate a file, Binlog (binary file), from the server configuration Relaylog file, used to read the master inside Binlog (it is necessary to open binlog, equivalent to backup), of course, to have permission to read it, it needs to use the last permission configuration! It's no different from normal login.
What action does the Lord make, and what action does it make?
At this point you need to pay attention to the main configuration file inside the Binlog-format, the value is row, the binary record is the disk change, the value is Statusment, if the UPDATE statement is executed, from the server will also record the UPDATE statement
If the statement is long and the disk changes small, use row
If the statement is small and the disk changes large, easy to use statusment
There is also a mixed, at which time the system analysis decides
1 Open the main server inside the configuration file
2 configuration from the server
3 Assign permissions and view the master status. Note the value of file and position, which is used when configuring the server from the back .
4 from the server by specifying the primary server to replicate
Mysql>change Master to aster_host= ' 192.168.1.201 ', master_user= ' repl ', master_password= ' q123456 ',
Master_log_file= ' mysql-bin.,000001 ', master_log_pos=106;
5 Checking the replication status from the server
Slave_io_running:yes//This status must be Yes
Slave_sql_running:yes//This status must be Yes
This is OK, very simple!
The so-called read and write separation, is the SQL statement judgment, through the program can be achieved.
MySQL Advanced master-slave replication