After a review of multi-party data, it was found yesterday Sentinel write the configuration mode is on is wrong, embarrassing. . .
Today re-configure it, of course, to avoid problems, to sort out the next idea, collated information
Sentinel node monitor mode at least three, yesterday monitoring the two is not enough, so once again I copy a redis.conf
Server Type | If the primary server | IP addresses | The port number |
Redis | Yes | 192.168.200.128 | 6379 |
Redis | no | 192.168.200.128 | 6380 |
Redis | no | 192.168.200.128 | 6381 |
Sentinel | - | 192.168.200.128 | 26379 |
Sentinel | - | 192.168.200.128 | 26380 |
Sentinel | - | 192.168.200.128 | 26381 |
The above is my three nodes and three Sentinel port configuration mode, because of limited resources, it Dounong in a virtual machine on a
Nonsense is not to say, did open
Configure the master server, modify redis-6379.conf, add the following configuration
# Set master password
requirepass " 123456"
# outside the network can access the main database
bind 0.0.0.0
2 from the server also need to configure, modify redis-6380.conf and redis-6381.conf, plus the following configuration
# Specify the main server slaveof 192.168 . 200.128 6379 # master password masterauth 123456
After configuring the two, let's configure Sentinel, there are 3 nodes, you need a 3 Sentry
First, set the first sentry, sentries other are the same
port 26379 daemonize yes logfile "26379.log" dir "/usr/local/redis/bin" sentinel deny-scripts-reconfig yes sentinel monitor mymaster 192.168.200.128 6379 2 sentinel failover-timeout mymaster 15000 sentinel auth-pass mymaster 123456 bind 192.168.200.128 127.0.0.1 # Generated by CONFIG REWRITE protected-mode no sentinel config-epoch mymaster 0 sentinel leader-epoch mymaster 0 sentinel current-epoch 0
Next to start the primary server, start from the server, you can finally start three sentinels
We have to test, we suddenly stopped the main server to see if the Sentinel can complete failover
# Find master can not connect a 2722 : the X- 29 Jul 2019 19 : 13 : 01.161 # + SDOWN master mymaster 192.168 . 200.128 6379 # After the vote, there are three sentinel discovery master can not use 2722 : the X- 29 Jul 2019 19 : 13 : 01.219 Master mymaster odown + # 192.168 . 200.128 6379 #quorum . 3 / 2 # current configuration is updated version 2722 : X- 29 Jul- 2019 . 19 : 13 is : 01.219+ # New new -epoch 1 # to reach a failover condition, waiting for the election of other sentinel of 2722 : the X- 29 Jul 2019 19 : 13 : 01.219 # + the try -failover Master mymaster 192.168 . 200.128 6379 # start voting slave server 2722 : the X- 29 Jul 2019 . 19 : 13 is : 01.221 # + vote- for -leader 0a15116eb684859ad0405cd5878f7a3996d7b9d0 . 1 2722 : X- 29 Jul- 2019 . 19 : 13 is :01.225 # 108dfb973098e0bafe67f8500d45b742b5c257eb voted for 0a15116eb684859ad0405cd5878f7a3996d7b9d0 1 2722:X 29 Jul 2019 19:13:01.226 # 0decb1582394f4c013012c7df1693138cfd26f20 voted for 0a15116eb684859ad0405cd5878f7a3996d7b9d0 1 2722:X 29 Jul 2019 19:13:01.312 # +elected-leader master mymaster 192.168.200.128 6379 2722:X 29 Jul 2019 19: 13 : 01.313 # + failover-state- the SELECT -slave master mymaster 192.168 . 200.128 6379 # elected to the identity of the slave master switch 2722 : the X- 29 Jul 2019 19 : 13 : 01.398 # + the Selected slave-slave 192.168 . 200.128 : 6381 192.168 . 200.128 6381 @ mymaster 192.168 . 200.128 6379 2722 : the X- 29 Jul 2019 19 : 13 :01.398 * +failover-state-send-slaveof-noone slave 192.168.200.128:6381 192.168.200.128 6381 @ mymaster 192.168.200.128 6379 2722:X 29 Jul 2019 19:13:01.499 * +failover-state-wait-promotion slave 192.168.200.128:6381 192.168.200.128 6381 @ mymaster 192.168.200.128 6379 2722:X 29 Jul 2019 . 19 : 13 is : 02.334 # + Promoted-Slave Slave 192.168 . 200.128 : 6381 192.168 . 200.128 6381 @ mymaster 192.168 . 200.128 6379 # the failover failover change reconf. - slaves 2722 : X- 29 Jul- 2019 . 19 : 13 is : 02.334 # + failover reconf. Master-slaves-the -state mymaster 192.168 . 200.128 6379 #sentinel slaveof send commands to port 6380 resynchronize 6379master 2722 : the X- 29Jul- 2019 . 19 : 13 is : 02.434 * + Slave Slave-reconf. Sent- 192.168 . 200.128 : 6380 192.168 . 200.128 6380 @ mymaster 192.168 . 200.128 6379 # leaving master unavailable 2722 : X- 29 Jul- 2019 . 19 : 13 is : 03.353 # -odown mymaster master 192.168 . 200.128 6379 #slave is reconfigured as master of another slave, but the data has not occurred 2722 : X- 29 Jul- 2019 . 19: 13 is : 03.353 * + Slave Slave-reconf. Inprog- 192.168 . 200.128 : 6380 192.168 . 200.128 6380 @ mymaster 192.168 . 200.128 6379 # data synchronization with the Master 2722 : X- 29 Jul- 2019 . 19 : 13 is : 03.353 * + Slave-reconf- Slave DONE 192.168 . 200.128 : 6380 192.168 . 200.128 6380 mymaster @ 192.168 . 200.128 6379 # failover completion 2722 : X- 29 Jul- 2019 . 19 : 13 is : 03.423 # + failover-End Master mymaster 192.168 . 200.128 6379 #MASTER address change 2722 : X- 29 Jul- 2019 . 19 : 13 is : 03.423 # + Switch -master mymaster 192.168 . 200.128 6379 192.168 . 200.128 6381 # detect slave and slave added to the list of 2722 : the X- 29 Jul 2019 19 : 13 :03.423 * +slave slave 192.168.200.128:6380 192.168.200.128 6380 @ mymaster 192.168.200.128 6381 2722:X 29 Jul 2019 19:13:03.423 * +slave slave 192.168.200.128:6379 192.168.200.128 6379 @ mymaster 192.168.200.128 6381
After passing through log parsing above, we found that the success of a failover, then the sentry mode configuration also came to an end