I'm starting up redis and sentinel nodes using the below configurations. I start the redis node first and when I start Sentinel, if fails with the error:
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 Compose
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}
sentinel compose
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"]
sentinel startup script
redis-server /etc/sentinel_node.conf --sentinel
sentinel conf
sentinel monitor MatserRedis redis_node 6000 3
sentinel down-after-milliseconds MatserRedis 3000
sentinel failover-timeout MatserRedis 10000
sentinel parallel-syncs MatserRedis 1
The redis node starts up without error.
Only sentinel with version above 6.2 can resolve host names, but this is not enabled by default. Adding sentinel resolve-hostnames yes to sentinel.conf will help.
If your sentinel has older versions, the hostname redis_node should be replaced by and ip.
For more details, check out IP Addresses and DNS names in Redis document
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With