1. 程式人生 > >sentinel監控伺服器——redis

sentinel監控伺服器——redis

1. Sentinel工具完成監控--操作步驟

(1)redis解壓包中的sentinel.conf拷貝到redis的安裝目錄下:

[[email protected] redis]# cp /opt/redis-4.0.11/sentinel.conf ./

 

(2)修改配置檔案sentinel.conf,修改內容如下:

[[email protected] redis]# vi sentinel.conf

#sentinel monitor mymaster 127.0.0.1 6379 2

sentinel monitor mymaster 127.0.0.1 6379 1

sentinel down-after-milliseconds mymaster 30000

 

(3)啟動redis服務

 

[[email protected] redis]# ./bin/redis-server ./redis.conf

[[email protected] redis]# ./bin/redis-server ./redis6380.conf

[[email protected] redis]# ./bin/redis-server ./redis6381.conf

 

(4)啟動sentinel監控:

[[email protected]

redis]# ./bin/redis-server ./sentinel.conf --sentinel

 

(5)master宕掉:

127.0.0.1:6379> shutdown

(6)檢視sentinel監控的變化

 

(7)檢視從伺服器的變化

127.0.0.1:6380> info replication

# Replication

role:master

connected_slaves:1

slave0:ip=127.0.0.1,port=6381,state=online,offset=38168,lag=0

 

127.0.0.1:6381> info replication

# Replication

role:slave

master_host:127.0.0.1

master_port:6380

master_link_status:up