Redis Cluster: Architecture and Replication

Sourabh Dey
4 min readFeb 16, 2022
Redis-Server Configuration

What is Redis ?

Redis (Remote Dictionary Server) is a very popular and widely-used open source, fast, distributed and efficient in-memory key-value database/data structure server.

Being a NO SQL or non-relational database, Redis offers some performance benefits over traditional database systems (such as MySQL/MariaDB, PostgreSQL, etc.), because all its data resides or is stored in memory making it easily accessible to an application, while traditional databases have to write all data to or read from disk or an external source.

Lab Environment Setup

192.168.43.100 Master

192.168.43.101 Replica1

192.168.43.102 Replica2

Installation of Redis-Server in Red Hat and Cent OS

It will installed the redis Packages
It will installed the Packages with it’s Dependencies

Start and enable the redis service for automatically start after boot

Check and confirm that the Redis server is up and running.

As you can see it’s running on port 6379

Configuring Redis Master Server Configuration

/etc/redis.conf : Default Configuration file

Backup the file in-case anything goes wrong

Now edit the /etc/redis.conf file

bind 127.0.0.1 192.168.43.100protected-mode noport 6379
By default redis-server runs on loop-back address but you need to change or add your Master Server IP for better and enhance connection

Protected-mode : on (To allow the communication mode with replica)

Port : 6379 (Default Port of redis-server)

requirepass  123456789
Set Auth Password for redis-server
loglevel  notice
logfile /var/log/redis/redis.log

Redis logs are stored in the /var/log/redis/redis.log file

supervised systemd

systemd is the default system and service manager in rhel and Centos

systemctl daemon-reload
systemctl restart redis
systemctl status redis
netstat -tulnp 
redis-cli
firewall-cmd --zone=public --permanent --add-port=6379/tcp 
firewall-cmd --reload

Configuring Redis Replica/Slave Servers ( Keep in mind After these line every Conifiguration should be done one every replica servers)

redis-cli
127.0.0.1:6379> REPLICAOF 192.168.43.100 6379
# replica1
bind 127.0.0.1 192.168.43.101

# replica2
bind 127.0.0.1 192.168.43.102
Replica 1 Configuration
Replica 2 Configuration
replicaof 192.168.43.100 6379
masterauth 123456789
systemctl restart redis
 firewall-cmd --zone=public --permanenent --add-port=6379/tcp
firewall-cmd --reload
redis-cli
127.0.0.1:6379> AUTH 123456789
127.0.0.1:6379> info replication
redis-cli
127.0.0.1:6379> info replication

Check Our Replication :

I am going to add a key value on master node and if our configuration is correct it should be replicate to replica

Master Node :

Master Node Entry

Replica Node :

Replica Node

Next : We will cover How to Setup Redis For High Availability with Sentinel

--

--

Sourabh Dey

Trying To learn as much as possible about different Techonology. About me I am just a normal Boy who lives in terminal