sentinel哨兵启动踩坑之路(持续更新)
通过命令启动redis-sentinel /etc/sentinel/5000.conf
,我是把sentinel.conf
放到了/etc/sentinel/
目录下,并且改了名字为5000.conf
,当然默认直接用:redis-sentinel sentinel.conf
启动即可
[root@eshop-cache02 init.d]# redis-sentinel /etc/sentinel/5000.conf
25645:X 11 Aug 23:03:01.257 * Increased maximum number of open files to 10032 (it was originally set to 1024).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.2.8 (00000000/0) 32 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in sentinel mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 5000
| `-._ `._ / _.-' | PID: 25645
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
25645:X 11 Aug 23:03:01.257 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
25645:X 11 Aug 23:03:01.257 # Sentinel ID is c2cf0a7da0a3d9de95d6d7b675c219a39fbf0eda
25645:X 11 Aug 23:03:01.257 # +monitor master mymaster 192.168.1.21 6379 quorum 2
25645:X 11 Aug 23:03:31.273 # +sdown master mymaster 192.168.1.21 6379
观察日志发现启动没多久,就发现master
宕机了。于是,我检查了下我的主从架构的master node
节点,发现没有问题呀,正常运行着,那为什么会直接sdown
呢?
我突然想到master node
节点上设置的有密码,也就是redis.conf
中requirepass
后面配置的密码,当然在slave node
节点上也是配置了masterauth
,用来连接master node
的。
这个时候就发现可能是因为没配置密码验证,所导致的sdown master
,检查了下配置,果然没有配置密码验证。
在sentinel.conf
中找到了sentinel auth-pass <master-name> <password>
,配置如下:
继续启动哨兵redis-sentinel /etc/sentinel/5000.conf
接下来又报错了,意思是没有指定名称的主机。
mymaster
本身就是自定义的,那为什么会没有找到mymaster
呢?
会不会有可能是没有连上master node
的机器呢?
于是看了下我的配置,如下:
sentinel monitor mymaster 192.168.1.21 6379 2 这里的配置的ip是master node的ip
仔细检查了下,也没错呀。这时忽然有个想法,就是会不会是加载顺序
的原因呢?
先找到对应机器的ip
,再走其他配置参数呢?下面我就调整了下顺序
再次启动哨兵redis-sentinel /etc/sentinel/5000.conf
[root@eshop-cache03 ~]# redis-sentinel /etc/sentinel/5000.conf
30674:X 12 Aug 11:56:40.644 * Increased maximum number of open files to 10032 (it was originally set to 1024).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.2.8 (00000000/0) 32 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in sentinel mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 5000
| `-._ `._ / _.-' | PID: 30674
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
30674:X 12 Aug 11:56:40.645 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
30674:X 12 Aug 11:56:40.645 # Sentinel ID is a90e0bf4763585e5ba107b724c57e4300aba2c8e
30674:X 12 Aug 11:56:40.645 # +monitor master mymaster 192.168.1.21 6379 quorum 2
30674:X 12 Aug 11:56:40.648 * +slave slave 192.168.1.22:6379 192.168.1.22 6379 @ mymaster 192.168.1.21 6379
30674:X 12 Aug 11:56:40.758 * +slave slave 192.168.1.23:6379 192.168.1.23 6379 @ mymaster 192.168.1.21 6379
这时候哨兵就监听到了master node
和slave node
了
接下来又遇到了个问题。先说下当时的场景:我用了三台机器,ip最后一位分别是21、22、23的机器。21部署的是master node,22、23部署的是slave node。三台机器上分别部署的有sentinel哨兵。
当时出现的问题是这样的,我启动了三个哨兵后,发现21、22机器都能互相检测到,只有23的机器不一会就sdwon了,于是就检查了所有23机器的sentinel.conf配置,发现没有问题,几乎跟22机器的配置一模一样。
那为什么会检测不到23机器呢?
最终发现是redis
默认开启保护模式,21和22都修改了,23忘记修改了,于是出现了上面的问题,21和22都检测不到23机器的sentinel和slave了。
更多推荐
所有评论(0)