From 5b9ee4b7a32364f2a479ae7e93689ab421a0e215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Ko=C5=A1=C4=8Do?= <3k.stanley@gmail.com> Date: Fri, 29 Apr 2016 15:14:39 +0200 Subject: [PATCH] Additional configuration of sentinel --- README.md | 15 ++++++++++++++- docker-entrypoint.sh | 23 +++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6f45698..5372363 100644 --- a/README.md +++ b/README.md @@ -36,4 +36,17 @@ Default value is `2`. In case of mapping, configure IP address of sentinel server. Read more in [documentation](Sentinel, Docker, NAT, and possible issues). ###`ANNOUNCE_PORT` -In case of mapping, configure mapped port of sentinel server. Read more in [documentation](Sentinel, Docker, NAT, and possible issues). \ No newline at end of file +In case of mapping, configure mapped port of sentinel server. Read more in [documentation](Sentinel, Docker, NAT, and possible issues). + +###`DOWN_AFTER` +Time in milliseconds an instance should not be reachable for a Sentinel starting to think it is down. Default value `1500`. + +###`FAILOVER_TIMEOUT` +Wait time before failover retry of the same master. Default value `30000`. + +###`PARALLEL_SYNCS` +Sets the number of slaves that can be reconfigured to use the new master after a failover at the same time. Default value `1`. + +###`SLAVES` +Manually configure all the slaves of monitored master. Expected format: `ip_address:host;ip_address:host`. + diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 8d6afe4..0ad10b8 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -13,6 +13,15 @@ GROUP_NAME=$GROUP_NAME MASTER_PORT=$MASTER_PORT : ${MASTER_PORT:=6379} +DOWN_AFTER=$DOWN_AFTER +: ${DOWN_AFTER:=1500} + +FAILOVER_TIMEOUT=$FAILOVER_TIMEOUT +: ${FAILOVER_TIMEOUT:=30000} + +PARALLEL_SYNCS=$PARALLEL_SYNCS +: ${PARALLEL_SYNCS:=1} + echo "port 26379" >> $SENTINEL_CONFIGURATION_FILE if [ "$ANNOUNCE_IP" ]; then @@ -24,5 +33,19 @@ if [ "$ANNOUNCE_PORT" ]; then fi echo "sentinel monitor $GROUP_NAME $MASTER_IP $MASTER_PORT $QUORUM" >> $SENTINEL_CONFIGURATION_FILE +echo "sentinel down-after-milliseconds $GROUP_NAME $DOWN_AFTER" >> $SENTINEL_CONFIGURATION_FILE +echo "sentinel failover-timeout $GROUP_NAME $FAILOVER_TIMEOUT" >> $SENTINEL_CONFIGURATION_FILE +echo "sentinel parallel-syncs $GROUP_NAME $PARALLEL_SYNCS" >> $SENTINEL_CONFIGURATION_FILE + +if [ "$SLAVES" ]; then + for SLAVE in $(echo $SLAVES | tr ";" "\n") + do + if [ "$SLAVE" ]; then + HOST=${SLAVE%:*} + PORT=${SLAVE#*:} + echo "sentinel known-slave $GROUP_NAME $HOST $PORT" >> $SENTINEL_CONFIGURATION_FILE + fi + done +fi redis-server $SENTINEL_CONFIGURATION_FILE --sentinel \ No newline at end of file