0
0
Redisquery~5 mins

Why replication provides redundancy in Redis

Choose your learning style9 modes available
Introduction

Replication copies data from one place to another. This helps keep data safe if one copy is lost or broken.

You want to keep a backup of your data automatically.
You need your app to keep working even if one server stops.
You want to share data across different locations for faster access.
You want to avoid losing data during updates or crashes.
Syntax
Redis
replicaof <master-ip> <master-port>
This command sets a Redis server as a replica of another Redis server.
The replica will copy all data from the master and keep updating.
Examples
This makes the current Redis server a replica of the master at IP 192.168.1.100 on port 6379.
Redis
replicaof 192.168.1.100 6379
This stops replication and makes the server a master again.
Redis
replicaof no one
Sample Program

This example shows setting a key on the master Redis server. Then the replica server is told to copy from the master. Finally, the replica can read the same key.

Redis
# On master server
SET user:1 "Alice"

# On replica server
replicaof 127.0.0.1 6379

# After replication
GET user:1
OutputSuccess
Important Notes

Replication helps keep data safe by having copies in different places.

If the master fails, replicas can be promoted to keep the system running.

Summary

Replication copies data to create backups automatically.

This makes your data safer and your app more reliable.

Replicas update continuously to match the master data.