Redis 7 : Configure Redis Sentinel2024/06/11 |
Configure Redis Sentinel to provide high availability for Redis Servers.
This example is based on the environment like follows.
If Primary Node would be down, Master role will failover to other Replica Node. | +----------------------+ | +----------------------+ | [ Redis Sentinel ] |10.0.0.25 | 10.0.0.30| [ Redis Primary ] | | ctrl.srv.world +----------+----------+ dlp.srv.world | | | | | | +----------------------+ | +----------------------+ | +----------------------+ | +----------------------+ | [ Redis Replica#1 ] |10.0.0.51 | 10.0.0.52| [ Redis Replica#2 ] | | node01.srv.world +----------+----------+ node02.srv.world | | | | | +----------------------+ +----------------------+ |
[1] |
Configure replication Settings on all Primary and Replica Nodes, refer to here.
Points to be aware of regarding replication settings, it needs to set the same authentication password on all Nodes. |
[2] | Configure Sentinel Server. |
root@ctrl:~#
apt -y install redis-sentinel
root@ctrl:~#
vi /etc/redis/sentinel.conf # line 15 : change (start service) daemonize yes
# line 73 : change # [sentinel monitor (any name) (Primary's IP) (Primary's Port) (Quorum)] # Quorum ⇒ run failover when the specified number of Sentinel servers look Primary is down sentinel monitor mymaster 10.0.0.30 6379 1
# line 93 : authentication password for Primary Node
sentinel auth-pass mymaster password
# line 106 : the duration Sentinel server looks Primary is down (30 sec by default) # to change the parameter, uncomment the line and set your value # sentinel down-after-milliseconds <master-name> <milliseconds> # line 188 : add to set number of Replicas to be changed when running failover sentinel parallel-syncs mymaster 1
systemctl restart redis-sentinel |
[3] | That's OK, verify status on Sentinel server like follows. Furthermore, stop Redis manually on Primary Node and make sure Primary/Replica failover normally. |
root@ctrl:~# redis-cli -p 26379 # show Primary Node for [mymaster] 127.0.0.1:26379> sentinel get-master-addr-by-name mymaster 1) "10.0.0.30" 2) "6379" # show details of Primary Node for [mymaster] 127.0.0.1:26379> sentinel master mymaster 1) "name" 2) "mymaster" 3) "ip" 4) "10.0.0.30" 5) "port" 6) "6379" 7) "runid" 8) "ac5e23c88f1ca041f6d51968722df16764905dbe" 9) "flags" 10) "master" ..... ..... # show Replica Nodes for [mymaster] 127.0.0.1:26379> sentinel replicas mymaster 1) 1) "name" 2) "10.0.0.51:6379" 3) "ip" 4) "10.0.0.51" 5) "port" 6) "6379" 7) "runid" 8) "9978b28dedbe82fd93d90edc9bfc4e64d3986f9d" 9) "flags" 10) "slave" ..... ..... 2) 1) "name" 2) "10.0.0.52:6379" 3) "ip" 4) "10.0.0.52" 5) "port" 6) "6379" 7) "runid" 8) "d7c52d24263f1763151f1ea91933f68fffdf0ff0" 9) "flags" 10) "slave" ..... ..... |
Sponsored Link |
|