Sentinel redis叢集配置

來源:互聯網
上載者:User

標籤:應用程式   master   監控   

1. Redis Sentinel功能

        Redis Sentinel是一套用於管理Redis執行個體的分布式系統,主要完成3項任務:

         1) Monitoring:持續監控Redis master或slave執行個體的運行情況是否符合預期

         2) Notification:若被監控的Redis執行個體運行異常,sentinel會通過API通知外界(人或程式)

         3) Automation failover:若master執行個體故障,sentinel會重新選主並啟動自動故障切換:選擇slave-priority最小的那個slave執行個體並將其提升為master,同時修改其它slave的配置,使其master配置項指向新的master,當old master恢複重啟後,會自動降級為new master的slave。最後,根據配置,Redis Sentinel還會將新的master地址通知給當前正在訪問Redis的應用程式。

2、部署情況

10.150.21.65 master

10.150.21.69 slave

10.150.21.66 Sentinel server

3、master,slave,Sentinel server 都要安裝redis;

4、在slave主機上執行

redis-cli slaveof 10.150.21.65 6379 ;/etc/init.d/redis stop;/etc/init.d/redis start

5、配置Sentinel server

 vim sentinel.conf 

#####################sentinel.conf #############

 port 26379

dir "/tmp"

sentinel monitor test1 10.150.21.65 6379 1 

sentinel config-epoch test1 2

sentinel leader-epoch test1 2

sentinel known-slave test1 10.150.21.69 6379

sentinel current-epoch 2 

#####################sentinel.conf #############

6、啟動Sentinel server

redis-server sentinel.conf --sentinel  &

7、Sentinel 常用命令

查詢master狀態

redis-cli -h 10.150.21.66 -p 26379 info Sentinel

以擷取到主IP地址

redis-cli  -h 127.0.0.7 -p 26379  info sentinel| awk -F ‘,‘ ‘/status/ {print $3}‘| awk -F ‘=‘ ‘{print $2}‘

查詢slave狀態

redis-cli -h 127.0.0.1 -p 26379 sentinel slaves test1

也可以查看即時資訊

watch redis-cli -h 127.0.0.1 -p 26379 sentinel slaves test1

 


本文出自 “有志者,事竟成” 部落格,請務必保留此出處http://wuxinglai.blog.51cto.com/9136815/1672036

Sentinel redis叢集配置

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.