Redis哨兵機制

在主從架構(gòu)狀態(tài)下,如果master節(jié)點宕機,則不可以進行寫操作,所以需要引入哨兵機制,重新選取master節(jié)點,保證Redis主從架構(gòu)正常運行。

1.在三個節(jié)點上分別修改配置文件sentinel.conf

image.png

1.bind: 如果redis暴露在公網(wǎng),需要配置bind ip
2.修改# protected-mode no 為 protected-mode no
3.修改daemonize no 為 daemonize yes
4.logfile /usr/local/redis/sentinel/redis-sentinel.log
5.dir /usr/local/redis/sentinel/
6.sentinel monitor mymaster 127.0.0.1 6379 2
mymaster為sentinel的昵稱
127.0.0.1 為master的ip,需要根據(jù)自己的環(huán)境進行修改
2 為哨兵的數(shù)量
7.修改sentinel auth-pass mymaster ’password‘
8.修改# sentinel down-after-milliseconds <master-name> <milliseconds>
sentinel down-after-milliseconds mymaster 10000
9.sentinel parallel-syncs mymaster 1
10.sentinel failover-timeout mymaster 180000
主備切換時間

2.啟動哨兵

src/redis-sentinel sentinel.conf

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

友情鏈接更多精彩內(nèi)容