Skip to content

Commit

Permalink
Additional configuration of sentinel
Browse files Browse the repository at this point in the history
  • Loading branch information
s7anley committed Apr 29, 2016
1 parent f74232b commit 5b9ee4b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
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`.

23 changes: 23 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 5b9ee4b

Please sign in to comment.