Mysql advanced master-slave replication, mysql master-slave
Master-slave replication is more than multiple servers !, One change changes the other, and the content is actually the same!
Principle:
Operations on the database will generate a file, binlog (binary file), and configure the relaylog file from the server to read the binlog in the master (it is necessary to enable binlog, which is equivalent to backup ), of course, you must have the permission to read data. This requires the last permission configuration! It is no different from normal logon.
What actions the master makes and what actions it also makes.
In this case, you need to pay attention to the binlog-format in the main configuration file, where the nominal value is row, the binary record is disk change, and the value is statusment. If the update statement is executed, the slave server also records the update statement.
If the statement is long and the disk changes little, easy to use row
Easy to use statusment
There is also a mixed, which is determined by system analysis.
1. Open the configuration file in the master server.
2. Configure slave server
3. Assign permissions and view the master status. Write down the value of FILE and Position, which will be used later When configuring slave server
4. Specify the master server to be copied from the server
Mysql> change master to aster_host = '192. 168.1.201 ', master_user = 'repl', master_password = 'q123456 ',
Master_log_file = 'mysql-bin., 100', master_log_pos = 000001;
5. Check the replication status of the slave 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/write splitting is the judgment of SQL statements, which can be achieved through programs.