DB/Redis

[Redis]sentinel 원하는 Master로 지정승격하기,승격우선순위

으르리 2021. 6. 23. 16:25

Redis sentinel 을 사용하면 outo failover 를 사용할 수 있게 되지요.

기본옵션으로 사용하게되면 failover시 sentinel간의 투표를 통해 failover를 진행합니다.

 

conf 파일에서 replica-priority 지정으로 failover시 내가 원하는 replica를 master로 승격시킬 수 있습니다.

# The replica priority is an integer number published by Redis in the INFO
# output. It is used by Redis Sentinel in order to select a replica to promote
# into a master if the master is no longer working correctly.
#
# A replica with a low priority number is considered better for promotion, so
# for instance if there are three replicas with priority 10, 100, 25 Sentinel
# will pick the one with priority 10, that is the lowest.
#
# However a special priority of 0 marks the replica as not able to perform the
# role of master, so a replica with priority of 0 will never be selected by
# Redis Sentinel for promotion.
#
# By default the priority is 100.
replica-priority 100

우선 순위 번호가 낮은 복제본은 승격에 더 적합한 것으로 간주됩니다. 


예를 들어 우선 순위가 10, 100, 25 인 복제본이 3 개있는 경우 Sentinel은 우선 순위가 가장 낮은 복제본을 선택합니다.
즉 값이10인 복제본이 master로 승격이될것입니다.

 

그러나 특별 우선 순위 0은 복제본이 마스터 역할을 수행 할 수 없음을 표시하므로 우선 순위가 0 인 복제본은 승격을 위해 Redis Sentinel에서 절대 선택하지 않습니다.

 

replica-priority 옵션은 온라인으로도 변경이 가능하기 때문에, sentinel이 투표를 진행하여 동작하는 시간으로 원래의 mater를 복귀시킬 수 있습니다.

127.0.0.1:6379> CONFIG GET replica-priority
1) "replica-priority"
2) "100"
127.0.0.1:6379> CONFIG SET replica-priority 80
OK
127.0.0.1:6379> CONFIG GET replica-priority
1) "replica-priority"
2) "80"

 

반응형