大网数据广告活动
服务器运维问答

Redis Sentinel Configuration and Hostnames

· 52CE 我爱测

I have 2 sentineles and 2 redis servers. I want to configure sentinels using hostnames of redis servers. Currently, I define each hostname in hosts file like this. 10.22.20.156 clsupport1 10.22.20.157 clsupport2 And I try to conf…

问题原文

原帖链接 · bhdrkn · CC BY-SA 3.0

I have 2 sentineles and 2 redis servers. I want to configure sentinels using hostnames of redis servers. Currently, I define each hostname in hosts file like this.

10.22.20.156    clsupport1  
10.22.20.157    clsupport2

And I try to configure sentinel like this.

daemonize yes
pidfile "/var/run/redis_sentinel_26379.pid"
loglevel notice
logfile "/var/log/redis_sentinel_26379.log"

port 26379
dir "/tmp"

sentinel monitor redis-prod clsupport2 6379 1
sentinel config-epoch redis-prod 3
sentinel leader-epoch redis-prod 4
sentinel known-slave redis-prod clsupport1 6379

After I started my sentinel, It automatically replaces hostnames with ip addresses. After restart.

daemonize yes
pidfile "/var/run/redis_sentinel_26379.pid"
loglevel notice
logfile "/var/log/redis_sentinel_26379.log"

port 26379
dir "/tmp"

sentinel monitor redis-prod 10.22.20.157 6379 1
sentinel config-epoch redis-prod 3
sentinel leader-epoch redis-prod 4
sentinel known-slave redis-prod 10.22.20.156 6379
# Generated by CONFIG REWRITE
...

But I want to keep hostnames. How can I achieve that?

已采纳解答

原帖链接 · Tilman Schmidt · CC BY-SA 3.0

Redis Sentinel needs to dynamically rewrite its configuration file, recreating the monitor commands. It does not have provisions to insert host names instead of IP addresses in the commands it generates. This is also why the Sentinel documentation explicitly stipulates an IP address in this position.

So what you are asking for is not possible with the current version of Sentinel. I suggest you reassess the requirement to use hostnames for the configuration.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2015-08-31)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。