about Redis master-slave replication
Redis supports synchronizing data to multiple slave libraries, a feature that is useful for improving read performance.
1) Master can have multiple slave.
2) In addition to multiple slave connected to the same master, slave can also connect other slave to form a graphic structure.
3) Master-slave replication does not block This means that when one or more slave and master synchronize the data for the first time
, Master can continue to process requests from clients. Conversely, slave will block when the data is first synchronized
the client's request cannot be processed.
4) Master-slave replication can be used to improve the scalability of the system, we can use multiple slave dedicated to the client's read
requests, such as the sort operation, can be handled using slave. can also be used to do simple data redundancy.
5) You can disable data persistence in master and only need to comment out all the save configurations in the master configuration file.
only Configure data persistence on slave.
Introduction to the process of Redis master-slave replication
when the slave server is set up, slave will establish a connection to master and then send the Sync command. Whether it is
The first time the connection is established or after the connection is disconnected, master initiates a background process that sets the data
The library snapshot is saved to a file, and the master master process starts collecting new write commands and caches them. Background process finished
After the file is written, Master sends the file to Slave,slave to save the file to disk and then loads it into the memory recovery
database snapshot to slave. The master then forwards the cached command to slave. and subsequent master receives
the Write command will be sent to slave by the connection that was established. Commands for synchronizing data from master to slave and from the guest
the commands sent by the client use the same protocol format. When master and slave are disconnected, slave can automatically re-
establish the connection. If master receives multiple slave simultaneous connection commands at the same time, only one process is started to write the number
the database is mirrored and then sent to all slave.
Configuring the Slave server is simple, just add the following configuration to the configuration file
slaveof 192.168.1.1 6379 #指定master IP and port
For more information, please pay attention to: bbs.superwu.cn attention to Superman Academy: Bj-crxy
Redis Master-Slave synchronization