server 2개, sentinel 3개로 구성.
Redis server
# vi redis-master.conf
bind 127.0.0.1
port 6379
masterauth password
requirepass password
daemonize yes
# vi redis-slave.conf
bind 127.0.0.1
port 6380
replicaof 127.0.0.1 6379
masterauth password
requirepass password
daemonize yes
Redis sentinel
# vi sentinel-6379.conf
port 16379
sentinel monitor mymaster 127.0.0.1 6379 2
sentinel auth-pass mymaster password
sentinel down-after-milliseconds mymaster 30000
sentinel failover-timeout mymaster 180000
sentinel parallel-syncs mymaster 1
# vi sentinel-6380.conf
port 16380
sentinel monitor mymaster 127.0.0.1 6379 2
sentinel auth-pass mymaster password
sentinel down-after-milliseconds mymaster 30000
sentinel failover-timeout mymaster 180000
sentinel parallel-syncs mymaster 1
# vi sentinel-6381.conf
port 16381
sentinel monitor mymaster 127.0.0.1 6379 2
sentinel auth-pass mymaster password
sentinel down-after-milliseconds mymaster 30000
sentinel failover-timeout mymaster 180000
sentinel parallel-syncs mymaster 1
Redis server 시작
redis-server redis-master.conf
redis-server redis-slave.conf
Redis sentinel 시작
redis-sentinel sentinel-6379.conf
redis-sentinel sentinel-6380.conf
redis-sentinel sentinel-6381.conf
Failover Test
# master server shutdown
redis-cli -p 6379 -a password
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> shutdown
not connected>
# 감지 후 vote, switch master
14414:X 09 Apr 2021 17:29:53.103 # +sdown master mymaster 127.0.0.1 6379
14414:X 09 Apr 2021 17:29:53.196 # +new-epoch 1
14414:X 09 Apr 2021 17:29:53.196 # +vote-for-leader 7dca29a1696028dfa0ca8f9856e244c27e008c46 1
14414:X 09 Apr 2021 17:29:53.950 # +config-update-from sentinel 7dca29a1696028dfa0ca8f9856e244c27e008c46 127.0.0.1 16379 @ mymaster 127.0.0.1 6379
14414:X 09 Apr 2021 17:29:53.950 # +switch-master mymaster 127.0.0.1 6379 127.0.0.1 6380
# screenshots
###
server와 sentinel의 port 번호는
master : 6379, slave : 6380
sentinel 1 : 16379, sentinel 2 : 16380, sentinel 3 : 16381
각기 다르게 줄 것.
참고 :
https://coding-start.tistory.com/127
https://coding-start.tistory.com/126
'Dev > Linux' 카테고리의 다른 글
[Linux] Oracle JDK 설치 (0) | 2022.07.29 |
---|---|
[Linux] hostname 변경 (0) | 2022.07.28 |
[Linux] Timezone 설정 (0) | 2022.07.27 |
[Linux] VirtualBox에 CentOS7 설치 (0) | 2022.07.08 |
[CentOS 7] Oracle JDK 설치 (0) | 2021.04.11 |
댓글