我正在使用以下配置启动redis和哨兵节点。我首先启动redis节点,当我启动Sentinel时,如果失败并显示以下错误:
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
Redis撰写
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
redis-server --port ${port:-6000}
前哨组成
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"]
前哨启动脚本
redis-server /etc/sentinel_node.conf --sentinel
哨兵 session
sentinel monitor MatserRedis redis_node 6000 3
sentinel down-after-milliseconds MatserRedis 3000
sentinel failover-timeout MatserRedis 10000
sentinel parallel-syncs MatserRedis 1
redis节点启动无误。
最佳答案
我认为这可能是因为redis_node
无法解析为IP地址。也许尝试将IP地址放到sentinel.conf中。MatserRedis
文件中sentinel.conf
的拼写也令人怀疑。
关于docker - redis-sentinel引发错误: “Can' t解析主实例主机名。”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57464443/