DEV Community

AL EMRAN
AL EMRAN

Posted on

Setup Redis Replica in Ubuntu/Linux

Redis is a powerful in-memory database that can handle a huge volume of data at high speeds. However, as your data grows, you may find that your Redis instance is struggling to keep up. This is where Redis replication comes in.

Redis replication allows you to scale your Redis database horizontally, without downtime. By configuring a replica server, you can create a copy of your master server that automatically updates itself whenever changes are made to the master. This means you can handle more read traffic and improve your database's fault tolerance.

Setting up Redis replication is easy. First, configure your master server with a password and a unique identifier. Then, create a replica server and use the replicaof command to specify the IP address and port number of the master server. Redis will handle the rest, automatically replicating data to the replica server in real-time.

With Redis replication, you can handle more traffic and keep your database running smoothly, all without downtime. So why not give it a try and see how it can improve your Redis performance?

setup Steps:

  1. Login to your Master Server

--Run

 nano /etc/redis/redis.conf 
Enter fullscreen mode Exit fullscreen mode

--Uncomment ‘requirepass’ and set a password like👇

  requirepass [password] 
Enter fullscreen mode Exit fullscreen mode

--restart redis

  1. Login to your replica server

--Run

  nano /etc/redis/redis.conf
Enter fullscreen mode Exit fullscreen mode

--Uncomment ‘replicaof’, 'masterauth' and set value like👇

  replicaof [master-server-private-ip] 6379  
  masterauth [master-requirepass]  
Enter fullscreen mode Exit fullscreen mode
  • restart redis

--Finally Run:

redis-cli
AUTH <master-requirepassword>
info replication
Enter fullscreen mode Exit fullscreen mode
  1. Verify: ss -antpl | grep redis

Done 😃 Follow me On Twitter

AL EMRAN
CTO at Besnik

Top comments (0)