REDIS-sentinel測試環境搭建(MAC)
阿新 • • 發佈:2017-11-27
usr lov rbo 當我 mas 恢復 環境 log dmi 最近在搭建Redis-Sentinel測試時,將遇到的問題在這標註下.
部署:
三個Sentinel實例,端口為:36379,36380,36381,將Sentinel配置文件放在同一目錄下.結果運行Sentinel masters得到的Other sentinels一直為0.
在網上找了下原因,沒有找到.然後我截圖向同事求助,截圖後發現三個Sentinel實現的ID竟然一致.如下圖所示.
初步懷疑是Sentinel不支持同一目錄,於是我手工修改sentinel.conf文件的[sentinel myid] 配置項,使用Sentinel masters可以看到other sentinels為2了.一切正常.
然而當我KILL掉mastera時,使用Sentinel get-master-addr-by-name mastera得到的master沒有變化.懷疑又是相同目錄原因,後我將配置文件置於3個目錄,Sentinel主從切換恢復正常.
下面我將配置文件列出.
port 36379
dir "/usr/local/etc/redis"
sentinel monitor mastera 127.0.0.1 16380 2
sentinel failover-timeout mastera 6000
sentinel auth-pass mastera xxxxxxxxx
另外兩個配置文件只是端口號不同
redis配置文件如下:
drwxr-xr-x 22 wangtingwei admin 748B 11 26 09:46 .
drwxrwxr-x 8 wangtingwei admin 272B 11 24 16:39 ..
-rw-r--r-- 1 wangtingwei admin 84K 11 26 09:44 16379stdout
-rw-r--r-- 1 wangtingwei admin 483K 11 26 09:46 16380stdout
-rw-r--r-- 1 wangtingwei admin 405K 11 26 09:46 16381stdout
-rw-r--r-- 1 wangtingwei admin 157B 11 22 18:12 dump.rdb
-rw-r--r-- 1 wangtingwei admin 211B 11 26 09:44 redis-16369.rdb
-rw-r--r-- 1 wangtingwei admin 428B 11 24 17:11 redis-16379.conf
-rw-r--r-- 1 wangtingwei admin 404B 11 26 09:45 redis-16380.conf
-rw-r--r-- 1 wangtingwei admin 211B 11 26 09:46 redis-16380.rdb
-rw-r--r-- 1 wangtingwei admin 435B 11 26 09:45 redis-16381.conf
-rw-r--r-- 1 wangtingwei admin 211B 11 26 09:46 redis-16381.rdb
-rw-r--r-- 1 wangtingwei admin 373B 11 24 14:21 redis-26379.conf
-rw-r--r-- 1 wangtingwei admin 160B 11 24 16:47 redis-26379.rdb
-rw-r--r-- 1 wangtingwei admin 409B 11 24 14:21 redis-26380.conf
-rw-r--r-- 1 wangtingwei admin 160B 11 24 16:53 redis-26380.rdb
-rw-r--r-- 1 wangtingwei admin 414B 11 24 16:52 redis-26381.conf
-rw-r--r-- 1 wangtingwei admin 160B 11 22 22:28 redis-26381.rdb
drwxr-xr-x 3 wangtingwei admin 102B 11 27 18:22 sentinel-36379
drwxr-xr-x 3 wangtingwei admin 102B 11 26 09:36 sentinel-36380
drwxr-xr-x 3 wangtingwei admin 102B 11 26 09:36 sentinel-36381
-rw-r--r-- 1 wangtingwei admin 26M 11 24 17:07 stdout
daemonize no
pidfile /usr/local/etc/redis/redis-16369.pid
port 16379
#bind 127.0.0.1
timeout 300
loglevel verbose
logfile 16379stdout
databases 16
save 900 1
save 300 10
save 60 100000
rdbcompression yes
dbfilename redis-16369.rdb
dir /usr/local/etc/redis
masterauth xxxxx
requirepass xxxxx
maxclients 128
maxmemory 0
appendonly no
appendfilename append-16369.aof
appendfsync everysec
#vm-enabled no
#glueoutputbuf yes
daemonize no
pidfile "/usr/local/etc/redis/redis-16380.pid"
port 16380
#bind 0.0.0.0
timeout 300
loglevel debug
logfile "16380stdout"
databases 16
save 900 1
save 300 10
save 60 10000
rdbcompression yes
dbfilename "redis-16380.rdb"
dir "/usr/local/etc/redis"
masterauth "xxxxx"
requirepass "xxxxx"
maxclients 128
maxmemory 0
appendonly no
appendfilename "append-16380.aof"
appendfsync everysec
REDIS-sentinel測試環境搭建(MAC)