首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >redis-哨兵抛出错误:“无法解析主实例主机名。”

redis-哨兵抛出错误:“无法解析主实例主机名。”
EN

Stack Overflow用户
提问于 2019-08-12 15:54:16
回答 4查看 5.1K关注 0票数 6

我正在使用以下配置启动redis和哨兵节点。我首先启动redis节点,当启动哨兵时,如果出现错误,则失败:

代码语言:javascript
复制
sentinel_node |
sentinel_node | *** FATAL CONFIG FILE ERROR ***
sentinel_node | Reading the configuration file, at line 1
sentinel_node | >>> 'sentinel monitor MasterRedis redis_node 6000 3'
sentinel_node | Can't resolve master instance hostname.
sentinel_node exited with code 1

红花组成

代码语言:javascript
复制
version: '2.1'
services:

redis:
    image: redis
    container_name: redis_node
    environment:
    - ALLOW_EMPTY_PASSWORD=yes
    ports:
    - 6000:6000
    volumes:
    - ./redis_startup.sh:/usr/local/bin/redis_startup.sh
    - ./redis_server_stop.sh:/usr/local/bin/redis_server_stop.sh
    command: ["redis_startup.sh", "-port", "6000"]

redis_startup.sh

代码语言:javascript
复制
redis-server --port ${port:-6000}

哨兵写作

代码语言:javascript
复制
version: '2.1'
services:

sentinel:
    image: redis
    container_name: sentinel_node
    ports:
    - 26379:26379
    volumes:
    # This is a read-only file on the host disk. It will be
    # used to create a rw file in this image
    - ./sentinel_node.conf:/usr/local/sentinel_node.conf
    - ./sentinel_startup.sh:/usr/local/bin/sentinel_startup.sh
    - ./redis_server_stop.sh:/usr/local/bin/redis_server_stop.sh
    command: ["sentinel_startup.sh", "-port", "6000", "-name", "sentinel_node"]

前哨启动脚本

代码语言:javascript
复制
redis-server /etc/sentinel_node.conf --sentinel

哨兵房

代码语言:javascript
复制
sentinel monitor MatserRedis redis_node 6000 3
sentinel down-after-milliseconds MatserRedis 3000
sentinel failover-timeout MatserRedis 10000
sentinel parallel-syncs MatserRedis 1

redis节点无错误地启动。

EN

回答 4

Stack Overflow用户

发布于 2021-09-09 08:00:56

只有版本高于6.2的哨兵才能解析主机名,但默认情况下不启用。将sentinel resolve-hostnames yes添加到sentinel.conf将有帮助。

如果哨兵的版本较早,则主机名redis_node应替换为和ip。

有关详细信息,请参阅Redis文档中的IP地址和DNS名称

票数 12
EN

Stack Overflow用户

发布于 2021-05-25 18:45:15

使用最新的redis版本,您只需在sentinel.conf中添加“哨兵解析-主机名是”。一切都很有魅力。

参考文献:https://redis.io/topics/sentinel

票数 3
EN

Stack Overflow用户

发布于 2019-09-05 16:13:10

我认为这可能是因为redis_node不解析IP地址。也许可以尝试将IP地址放在sentinel.conf中。

MatserRedissentinel.conf文件中的拼写也有问题。

票数 -3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57464443

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档