“This is the 10th day of my participation in the November Gwen Challenge. See details of the event: The Last Gwen Challenge 2021”.
In this article, we briefly introduced the basic concept of Redis master-slave replication. To give you a clearer understanding of the concept, let’s take a look at the parameters of Redis master-slave replication.
REPLICATION
replicaof <masterip> <masterport>
By setting the IP address and port of the master, you can make the current Redis instance a copy of another Redis instance. When Redis starts, it automatically synchronizes data from the master.
- Redis replication is asynchronous. You can modify the configuration of the master. If the master does not connect to a given number of replicas, the host stops receiving writes.
- If the replication link is lost for a relatively short period of time, Redis Replica can resynchronize the replica with the master executable, which can be configured using reasonable backlog values (see below).
- Replication is automatic and requires no user intervention. After the network is partitioned, replica automatically tries to reconnect to the master and resynchronize with the master.
masterauth <master-password>
If password protection is set for the master, the password used by the Replica service to connect to the master
replica-read-only
You can set replica to whether the replica is read-only. Yes indicates that the replica is read-only and all write commands will be rejected. No indicates that data can be written. Since Redis 2.6, Replica supports read-only mode and is enabled by default. You can turn it on or off at any time at run time using CONFIG SET.
Writing to replica may help store some temporary data (since data written to Replica is easily deleted after resynchronizing with master), and computing a slow set or sort set operation and storing it to the local key is a use case for multiple observed writable copies. But it can also cause problems if the client writes data to it due to a configuration error.
Even though replica B nodes are writable in A cascading structure, sub-Replica C will not see the write of B, but will have the same data set as Master A.
Set to yes does not mean that the set operation cannot be performed when the client connects to the cluster through a replica. Moreover, the set operation data is not put in the replica slot but in the master slot.
Note: Read Replica is not designed to expose untrusted clients on the Internet, it is only a protective layer against instance misuse. By default, the read-only copy still exports all management commands, such as CONFIG and DEBUG. To some extent, you can use rename- Command to hide all administrative/danger commands, thereby increasing the security of read-only copies.
Redis configuration file configuration is more, we will be divided into several chapters to break, you remember to check the serial! If you have different opinions or better idea, welcome to contact AH Q, add AH Q can join the technical exchange group to participate in the discussion!