V
V
vyachin2017-08-09 22:26:51
Redis
vyachin, 2017-08-09 22:26:51

How to set up redis and sentinel?

We have 4 servers:
- 10.0.3.91
- 10.0.3.92
- 10.0.3.93
- 10.0.3.94
Each has redis installed with config

bind {{ ansible_default_ipv4.address }}  127.0.0.1
port 6379
dir /var/lib/redis
logfile /var/log/redis/redis.log
loglevel debug
# далее для мастера
requirepass mypass

#далее для slave
slaveof 10.0.3.91 6379
masterauth mypass

sentinel with config is installed on all servers
port 26379
dir /tmp
logfile "/var/log/redis/sentinel.log"

sentinel monitor mymaster 10.0.3.91 6379 2
sentinel down-after-milliseconds mymaster 10000
sentinel failover-timeout mymaster 60000
sentinel parallel-syncs mymaster 1
sentinel auth-pass mymaster mypass

servers are lxc containers, the network works fine no firewall no
start master
3169:M 09 Aug 19:19:04.261 * Background saving terminated with success
3169:M 09 Aug 19:19:04.261 * Synchronization with slave 10.0.3.92:6379 succeeded
3169:M 09 Aug 19:19:04.261 * Synchronization with slave 10.0.3.94:6379 succeeded
3169:M 09 Aug 19:19:04.261 * Synchronization with slave 10.0.3.93:6379 succeeded

sentinel starts on the master
3213:X 09 Aug 19:19:04.457 # Sentinel ID is c627d18a4ae8692b7bbca50d5f74b1735c155030
3213:X 09 Aug 19:19:04.457 # +monitor master mymaster 10.0.3.91 6379 quorum 2
3213:X 09 Aug 19:19:04.457 * +slave slave 10.0.3.92:6379 10.0.3.92 6379 @ mymaster 10.0.3.91 6379
3213:X 09 Aug 19:19:04.522 * +slave slave 10.0.3.94:6379 10.0.3.94 6379 @ mymaster 10.0.3.91 6379
3213:X 09 Aug 19:19:04.589 * +slave slave 10.0.3.93:6379 10.0.3.93 6379 @ mymaster 10.0.3.91 6379
3213:X 09 Aug 19:19:06.422 * +sentinel sentinel 4b379a69e8ec306676297185e79e5814381cfbe4 10.0.3.92 26379 @ mymaster 10.0.3.91 6379
3213:X 09 Aug 19:19:06.470 * +sentinel sentinel 53587213efa28e0f89994f5d53fd988ad5ba4e67 10.0.3.94 26379 @ mymaster 10.0.3.91 6379
3213:X 09 Aug 19:19:06.621 * +sentinel sentinel 99b62184268404737e73c263dbd935078bc0a936 10.0.3.93 26379 @ mymaster 10.0.3.91 6379
3213:X 09 Aug 19:19:16.448 # +sdown sentinel 4b379a69e8ec306676297185e79e5814381cfbe4 10.0.3.92 26379 @ mymaster 10.0.3.91 6379
3213:X 09 Aug 19:19:16.506 # +sdown sentinel 53587213efa28e0f89994f5d53fd988ad5ba4e67 10.0.3.94 26379 @ mymaster 10.0.3.91 6379
3213:X 09 Aug 19:19:16.670 # +sdown sentinel 99b62184268404737e73c263dbd935078bc0a936 10.0.3.93 26379 @ mymaster 10.0.3.91 6379

we start checking HA by turning off the redis master with the command
service redis stop
in the sentinela logs we see
3213:X 09 Aug 19:19:04.457 # Sentinel ID is c627d18a4ae8692b7bbca50d5f74b1735c155030
3213:X 09 Aug 19:19:04.457 # +monitor master mymaster 10.0.3.91 6379 quorum 2
3213:X 09 Aug 19:19:04.457 * +slave slave 10.0.3.92:6379 10.0.3.92 6379 @ mymaster 10.0.3.91 6379
3213:X 09 Aug 19:19:04.522 * +slave slave 10.0.3.94:6379 10.0.3.94 6379 @ mymaster 10.0.3.91 6379
3213:X 09 Aug 19:19:04.589 * +slave slave 10.0.3.93:6379 10.0.3.93 6379 @ mymaster 10.0.3.91 6379
3213:X 09 Aug 19:19:06.422 * +sentinel sentinel 4b379a69e8ec306676297185e79e5814381cfbe4 10.0.3.92 26379 @ mymaster 10.0.3.91 6379
3213:X 09 Aug 19:19:06.470 * +sentinel sentinel 53587213efa28e0f89994f5d53fd988ad5ba4e67 10.0.3.94 26379 @ mymaster 10.0.3.91 6379
3213:X 09 Aug 19:19:06.621 * +sentinel sentinel 99b62184268404737e73c263dbd935078bc0a936 10.0.3.93 26379 @ mymaster 10.0.3.91 6379
3213:X 09 Aug 19:19:16.448 # +sdown sentinel 4b379a69e8ec306676297185e79e5814381cfbe4 10.0.3.92 26379 @ mymaster 10.0.3.91 6379
3213:X 09 Aug 19:19:16.506 # +sdown sentinel 53587213efa28e0f89994f5d53fd988ad5ba4e67 10.0.3.94 26379 @ mymaster 10.0.3.91 6379
3213:X 09 Aug 19:19:16.670 # +sdown sentinel 99b62184268404737e73c263dbd935078bc0a936 10.0.3.93 26379 @ mymaster 10.0.3.91 6379
3213:X 09 Aug 19:21:30.090 # +sdown master mymaster 10.0.3.91 6379

actually everything. I expected that one of the slaves will become the master and everything will be fine, but no matter how much I wait, nothing happens.
What am I doing wrong ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
vyachin, 2017-08-09
@vyachin

the question is removed, in order to see the result of the work of sentinel, you need to add it to the data radish

S
Sergey, 2018-07-23
@mrmoney

Would you like to write any

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question