Redis Cluster: Architecture and Replication
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
Start and enable the redis service for automatically start after boot
Check and confirm that the Redis server is up and running.
Configuring Redis Master Server Configuration
/etc/redis.conf : Default Configuration file
Now edit the /etc/redis.conf file
bind 127.0.0.1 192.168.43.100protected-mode noport 6379
Protected-mode : on (To allow the communication mode with replica)
Port : 6379 (Default Port of redis-server)
requirepass 123456789
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
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 :
Replica Node :
Next : We will cover How to Setup Redis For High Availability with Sentinel