Thursday, February 17, 2022

Setup Redis Sentinel

 in This Tutorial you will Learn " How To Setup Redis Sentinel On Rocky Linux 8.5
Redis sentinel is the high availability solution offered by Redis.
Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache, and message broker.

If Primary Node would be down, Master role will failover to other Replica Node.
  [ Redis Sentinel ]                               [ Redis Primary ]  
    192.168.1.20     +----------+----------+     192.168.1.80  
                              [ Redis Replica ]  
                                  192.168.1.40
_________________________________________________________________________________________
[ Redis Sentinel ] - 192.168.1.20
cat /etc/system-release ; sestatus ; hostname -I ; dnf groupinstall "Development Tools" -y
dnf module -y install redis:6
gedit  /etc/redis-sentinel.conf &>/dev/null
daemonize yes
sentinel monitor mymaster 192.168.1.80 6379 1                                                                                            
sentinel auth-pass mymaster password     
                                                                                                                                                                         
systemctl enable --now redis-sentinel ; systemctl restart redis-sentinel
firewall-cmd --zone=public --permanent --add-port=26379/tcp ; firewall-cmd --reload
redis-cli -p 26379
sentinel get-master-addr-by-name mymaster
sentinel master mymaster
sentinel slaves mymaster

redis-cli -p 26379 sentinel get-master-addr-by-name mymaster
redis-cli -p 26379 info sentinel
_________________________________________________________________________________________
[ Redis Primary ] 192.168.1.80
_________________________________________________________________________________________
cat /etc/system-release ; sestatus ; dnf groupinstall "Development Tools" -y
dnf module -y install redis:6
gedit  /etc/redis.conf &>/dev/null
bind 0.0.0.0  || daemonize yes | requirepass password
min-replicas-to-write 1
min-replicas-max-lag 10
firewall-cmd --add-service=redis --permanent ; firewall-cmd --reload ; systemctl restart redis
hostname -I
systemctl restart redis
_________________________________________________________________________________________
Redis Replica# 192.168.1.40
_________________________________________________________________________________________
hostname -I ; cat /etc/system-release ; sestatus ; dnf groupinstall "Development Tools" -y
dnf module -y install redis:6
gedit  /etc/redis.conf &>/dev/null
bind 0.0.0.0  | daemonize yes |replicaof 192.168.1.80 6379 |masterauth password |# requirepass password
firewall-cmd --add-service=redis --permanent ; firewall-cmd --reload ; systemctl restart redis
_________________________________________________________________________________________

No comments:

Post a Comment