The role of master and slave
1. Real-time disaster recovery: a master database is down, and the slave database is enabled for failover
2. Read and write separation: the master server is only used for write operations, and the slave server is only used for reading, which supports greater concurrency
3. Backup: can solve the problem of data loss and avoid affecting business
Master-slave principle
1. The main library receives the update command, executes the update operation, and generates binlog
2. Open an I/0 thread from the library salve to establish a long connection between the main library dump_thread
3. After the master node receives the I/O request from the slave node, it returns the specified log and log information after the specified location through the dump thread, and returns it to the slave node
The main library dump_thread reads the binlog from the local and transmits it to the slave library