Let's start with a brief introduction to replication in Redis:
(1) The same master can synchronize multiple slave.
(2) Slave can also accept other slaves connection and synchronization request, which can effectively share the sync pressure of master.
(3) master server provides services for slaves in a non-blocking manner, so clients can still submit queries or modify requests during Master-slave synchronization.
(4) 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 master's read operation pressure, the slave server can provide the client with read-only service, and the write service must still be completed by master.
(6) Master can hand-save the data to slaves to complete, thus avoiding the need to have a separate process in master to complete this operation.
How replication works:
After the slave is started and connected to master, it will actively send a sync command. Master will then start the background disk process and collect all the received commands to modify the dataset, and master will transfer the entire database file to slave to complete a full synchronization once the background process has finished executing. The slave server then takes the database file and loads it into memory. After that, Master continues to pass all the modified commands and new modification commands that have been collected to slaves, and slaves will execute the data modification commands at this time to achieve final data synchronization. If there is a disconnection between slave and master, slave can automatically re-practice master, but once the connection is successful, a full synchronization will be performed automatically.
Configuration of replication:
Simply remove the # from the #slaveof <masterip> <masterport> in the configuration file and change it to the appropriate information.
Sinsing analysis of Master-slave replication in Redis