Beim Betrieb von Redis im Master/Slave Modus muss darauf geachtet werden, dass:
1. Master und Slave sind nicht immer auf demselben Stand
Redis uses asynchronous replication. Starting with Redis 2.8, however, slaves will periodically acknowledge the amount of data processed from the replication stream.
D.h. bestimmte Daten müssen vom Master abgefragt werden, wie z.B. Session Daten
2. Safety of replication when master has persistence turned off
In setups where Redis replication is used, it is strongly advised to have persistence turned on in the master, or when this is not possible, for example because of latency concerns, instances should be configured to avoid restarting automatically.
To better understand why masters with persistence turned off configured to auto restart are dangerous, check the following failure mode where data is wiped from the master and all its slaves:
We have a setup with node A acting as master, with persistence turned down, and nodes B and C replicating from node A.
A crashes, however it has some auto-restart system, that restarts the process. However since persistence is turned off, the node restarts with an empty data set.
Nodes B and C will replicate from A, which is empty, so they’ll effectively destroy their copy of the data.When Redis Sentinel is used for high availability, also turning off persistence on the master, together with auto restart of the process, is dangerous. For example the master can restart fast enough for Sentinel to don’t detect a failure, so that the failure mode described above happens.
Every time data safety is important, and replication is used with master configured without persistence, auto restart of instances should be disabled.
d.h. die auto restart Funktion sollte für den Master deaktiviert werden, falls keine sofortige Persistierung auf der Festplatte aktiviert ist.
3. Master Ausfall
Wenn der Master ausfällt, sollte der Slave nach eine Karenzzeit sich zum Master erklären (z.B. nach 10 Minuten).