MySQL cluster tutorial (i)
Master-Slave Replication overview
In the actual production, the importance of data is self-evident, providing safe and reliable data protection is the responsibility of the technology and Operations Department;
If our database has only one server, then it is easy to create a single point of failure, such as the server access pressure is too large to respond or crash, then the service is not available, such as the hard disk of this server is broken, then the entire database data is lost, this is a major security incident;
In order to avoid service unavailability and ensure the security and reliability of data, we need to deploy at least two or more servers to store database data, that is, we need to copy multiple copies of data deployed on multiple different servers, even if one server fails, other servers can continue to provide services;
MySQL provides master-slave replication capabilities to improve service availability and data security and reliability;
Master-slave replication refers to the server sub-primary server and from the server, the primary server is responsible for reading and writing, from the server is only responsible for reading, master-slave replication is also called Master/slave,master is the main, slave is from;
Master-Slave Replication architecture:
Master-Slave replication principle:
When the data on the master master server changes, it is written into the binary log file;
Salve from the server will be in a certain time interval to the Master master server on the binary log detection, detect whether it has changed;
If the binary log that detects the master master server has changed, start an I/O Thread to request the master binary event;
At the same time, the Master master server initiates a dump thread for each I/O thread, which is used to send binary events to it;
Slave the received binary events from the server to their local relay log files;
Salve from the server will start the SQL Thread from the secondary log to read the binary log, the local replay, so that its data and the primary server consistent;
The last I/O thread and SQL thread will go to sleep, waiting for the next wake-up;
MySQL master-slave replication schematic:
More commonly said: MySQL to do the master-slave replication, is a service to do their own additions and deletions are recorded in the log, B database based on the above operation in their own body to operate again, so that the implementation of the master-slave replication;
Next: Construction of the environment
MySQL cluster tutorial (i)