Xinxing analyzes master-slave replication in Redis, and Xinxing analyzes master-slave redis
First, let's briefly introduce the replication in Redis:
(1) the same master can synchronize multiple slave instances.
(2) Server Load balancer can also accept connections and synchronization requests from other Server Load balancer instances. This effectively shares the synchronization pressure on the master node.
(3) The master server provides services for slaves in a non-blocking manner. Therefore, during master-slave synchronization, the client can still submit query or modify requests.
(4) The slave server also completes Data Synchronization in a non-blocking manner. During synchronization, if a client submits a query request, Redis returns the data before synchronization.
(5) In order to share the read operation pressure on the master, the slave server can provide the read-only operation service for the client, and the write service must still be completed by the master.
(6) The master can save the data to slaves, thus avoiding the need for an independent process in the master to complete this operation.
How replication works:
After slave is started and connected to the master, it will send a SYNC command. After that, the master will start the background storage process and collect all commands received for modifying the dataset. After the background process is executed, the master will transmit the entire database file to the slave, to complete a full synchronization. The slave server saves the database files and loads them into the memory. After that, the master continues to send all the collected modification commands and new modification commands to slaves in sequence, and slaves will execute these data modification commands this time to achieve the final data synchronization. If the connection between the Server Load balancer instance and the master instance is disconnected, the Server Load balancer instance can automatically retrain the master instance. However, after the connection is successful, a full synchronization task is automatically executed.
Replication Configuration:
Remove the # In the # slaveof <masterip> <masterport> in the configuration file and modify it to the corresponding information.