Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Redis walkthrough (7) redis Sentinel for failover

2025-03-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

The book follows the above.

Only the redis master-slave environment is configured in. Two master-slave structures are configured respectively.

They are 1. Directed acyclic, 2-star model. It's very easy to configure. However, it left a tail and did not elaborate. What if master goes down? How does redis implement fail-over failover? In this article, I will focus on this piece. Main content

Manually implement the fail-over effect

Realization of automatic fail-over effect by sentinel

Manually implement the fail-over effect

# directed acyclic model (see redis exercise (6) Building content of redis master-slave mode) [root@hadoop2 redis] # ps-ef | grep redisroot 2495 1 2 20:06? 00:00:01 bin/redis-server *: 6379root 2503 1 1 20:06? 00:00:00 bin/redis-server *: 6381root 2508 1 1 20:06? 00:00:00 bin/redis-server * : 6380#Master (with one from 6380) 127.0.0.1 6379 > info Replication# Replicationrole:masterconnected_slaves:1slave0:ip=127.0.0.1 Port=6380,state=online,offset=99,lag=1master_repl_offset:99repl_backlog_active:1repl_backlog_size:1048576repl_backlog_first_byte_offset:2repl_backlog_histlen:98#Slave1 connection master 6379127.0.0.1 6380 > info Replication# Replicationrole:slavemaster_host:127.0.0.1master_port:6379master_link_status:upmaster_last_io_seconds_ago:5master_sync_in_progress:0slave_repl_offset:197slave_priority:100slave_read_only:1connected_slaves:1slave0:ip=127.0.0.1,port=6381,state=online Offset=197 Lag=0master_repl_offset:197repl_backlog_active:1repl_backlog_size:1048576repl_backlog_first_byte_offset:2repl_backlog_histlen:196#6380 from 127.0.0.1 to info Replication# Replicationrole:slavemaster_host:127.0.0.1master_port:6380master_link_status:upmaster_last_io_seconds_ago:6master_sync_in_progress:0slave_repl_offset:573slave_priority:100slave_read_only:1connected_slaves:0master_repl_offset:0repl_backlog 6381 _ active:0repl_backlog_size:1048576repl_backlog_first_byte_offset:0repl_backlog_histlen:0## simulates 6379 downtime # # [root@hadoop2 redis] # bin/redis-cli shutdown [root@ Hadoop2 redis] # bin/redis-cli-p 6379 shutdownCould not connect to Redis at 127.0.0.1 shutdownCould not connect to Redis at: Connection refused# observation Discover master_link_status:down It means that the Lord must have dropped 127.0.0.1 info Replication# Replicationrole:slavemaster_host:127.0.0.1master_port:6379master_link_status:downmaster_last_io_seconds_ago:-1master_sync_in_progress:0slave_repl_offset:1049master_link_down_since_seconds:42slave_priority:100slave_read_only:1connected_slaves:1slave0:ip=127.0.0.1,port=6381,state=online,offset=1105 6380 > Lag=0master_repl_offset:1105repl_backlog_active:1repl_backlog_size:1048576repl_backlog_first_byte_offset:2repl_backlog_histlen:1104# starts switching from master (6380-- > 6379) # simply execute the following two commands Switch the 6380 master to 127.0.0.1 sentinel 6380 > slaveof no oneOK127.0.0.1:6380 > config set slave-read-only noOK127.0.0.1:6380 > set title "sentinel" OK# to connect to the slave service, no problem 127.0.0.1 OK# 6381 > get title "sentinel"

Log (6379)

2495:M 05 Sep 20:06:23.615 # WARNING: The TCP backlog setting of 511 cannot be enforced because / proc/sys/net/core/somaxconn is set to the lower value of 128.

2495:M 05 Sep 20:06:23.615 # Server started, Redis version 3.2.3

2495:M 05 Sep 20:06:23.617 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory=1' to / etc/sysctl.conf and then reboot or run the command' sysctl vm.overcommit_memory=1' for this to take effect.

2495 seconds M 05 Sep 20 VR 06 seconds 24.815 * seconds

2495VR M 05 Sep 20V 06R R 24.816 The server is now ready to accept connections on port 6379

2495keys M 05 Sep 20 keys 06VR 24.816-DB 0: 20019 keys (0 volatile) in 32768 slots HT.

2495 slaves M 05 Sep 20 slaves 06 slaves 24.816-0 bytes in use

2495keys M 05 Sep 20 volatile 06 in 29.841-DB 0: 20019 keys (0 volatile) in 32768 slots HT.

2495 slaves M 05 Sep 20 slaves 06 slaves 29.841-0 bytes in use

2495keys M 05 Sep 20 keys 06Portuguese 34.867-DB 0: 20019 keys (0 volatile) in 32768 slots HT.

2495slaves M 05 Sep 20 slaves 06Portuguese 34.875-0 bytes in use (0 bytes in use)

2495keys M 05 Sep 20 volatile 06 keys 39.919-DB 0: 20019 keys (0 volatile) in 32768 slots HT.

2495 slaves M 05 Sep 20 slaves 06 slaves 39.921-0 bytes in use

2495keys M 05 Sep 20 keys 06VR 44.971-DB 0: 20019 keys (0 volatile) in 32768 slots HT.

2495 slaves M 05 Sep 20 slaves 06 slaves 44.971-0 bytes in use

2495keys M 05 Sep 20 keys 06V 50.022-DB 0: 20019 keys (0 volatile) in 32768 slots HT.

2495 slaves M 05 Sep 20 slaves 06 slaves 50.022-0 bytes in use

2495keys M 05 Sep 20 in 06 in 55.134-DB 0: 20019 keys (0 volatile) in 32768 slots HT.

2495slaves M 05 Sep 20 slaves 06lo 55.134-0 clients connected, 3764336 bytes in use

2495VR M 05 Sep 20V 06R 58.775-Accepted 127.0.0.1R 44408

2495asks for synchronization M 05 Sep 20V 06R * Slave 127.0.0.1 asks for synchronization

2495VR M 05 Sep 20V 06R 58.775 * Full resync requested by slave 127.0.0.1R 6380

2495VR M 05 Sep 20V 06R 58.775 * Starting BGSAVE for SYNC with target: disk

2495VR M 05 Sep 20V 06R 58.776 * Background saving started by pid 2511

2511 Sep C 05 20 06R 58.868 * DB saved on disk

2511 MB of memory used by copy-on-write C 05 Sep 20 MB of memory used by copy-on-write 06 MB of memory used by copy-on-write 58.870 * MB of memory used by copy-on-write

2495VR M 05 Sep 20R 06R R 58.916 * Background saving terminated with success

2495succeeded M 05 Sep 20 succeeded 06 succeeded * 127.0.0.1 succeeded

....

2495:M 05 Sep 20:19:19.471 # User requested shutdown...

2495 Sep M 05 20 on the AOF file 19 19. 471 * Calling fsync ().

2495 Sep M 05, 20 19, 19. 471 * Removing the pid file.

2495:M 05 Sep 20:19:19.472 # Redis is now ready to exit, bye bye...

Log (6380)

2508:S 05 Sep 20:06:58.714 # Server started, Redis version 3.2.3

2508:S 05 Sep 20:06:58.714 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory=1' to / etc/sysctl.conf and then reboot or run the command' sysctl vm.overcommit_memory=1' for this to take effect.

2508 S 05 Sep 20 seconds 06 seconds 58.775 * seconds

2508 S 05 Sep 20R 06R 58.775 * The server is now ready to accept connections on port 6380

2508 S 05 Sep 20 06R 58.775 * Connecting to MASTER 127.0.0.1R 6379

2508 S 05 Sep 20R 06R 58.775 * MASTER SLAVE sync started

2508 S 05 Sep 201R 06R * Non blocking connect for SYNC fired the event.

2508Rose S 05 Sep 20R 06Rd * Master replied to PING, replication can continue...

2508no cached master S 05 Sep 201R 06R * Partial resynchronization not possible (no cached master)

2508 S 05 Sep 20 8d0d86237c36a8d6ace4eed9b5f6e5871b40da29:1 06R 58.802 * 8d0d86237c36a8d6ace4eed9b5f6e5871b40da29:1

2508receiving S 05 Sep 20 bytes from master 06 receiving 58.917 * MASTER SLAVE sync:

2508Rose S 05 Sep 20R 06Rd * MASTER SLAVE sync: Flushing old data

2508 S 05 Sep 201R 06R * MASTER SLAVE sync: Loading DB in memory

2508Rose S 05 Sep 20Rd 06R * MASTER SLAVE sync: Finished with success

2508 Sep S 05 20 asks for synchronization 06 asks for synchronization 59.788 * 127.0.0.1 asks for synchronization

2508 S 05 Sep 20V 06R 59.788 * Full resync requested by slave 127.0.0.1R 6381

2508 S 05 Sep 20 disk 06R 59.788 * disk

2508 S 05 Sep 20R 06R 59.788 * Background saving started by pid 2512

2512VR C 05 Sep 20 06RV 59.832 * DB saved on disk

2512 MB of memory used by copy-on-write C 05 Sep 20 MB of memory used by copy-on-write 06 MB of memory used by copy-on-write 59.832 * MB of memory used by copy-on-write

2508 S 05 Sep 20R 06R 59.896 * Background saving terminated with success

2508 Sep S 05 20 succeeded 06 succeeded 59.899 * 127.0.1 succeeded

2508 Sep 05 changes in 20 seconds 10 seconds 46.786 * 10000. Saving...

2508Rose S 05 Sep 20RU 10RU 46.786 * Background saving started by pid 2595

2595Rose C 05 Sep 20RU 10RU 46.800 * DB saved on disk

2595 MB of memory used by copy-on-write C 05 Sep 20 MB of memory used by copy-on-write 10 Switzerland 46.801 * MB of memory used by copy-on-write

2508Rose S 05 Sep 20 Sep 10RV 46.887 * Background saving terminated with success

2508:S 05 Sep 20:19:19.472 # Connection with master lost.

2508 Sep S 05 20 Sep 19 19. 472 * Caching the disconnected master state.

2508 S 05 Sep 20 1919. 594 * Connecting to MASTER 127.0.0.1

2508Rose S 05 Sep 20Rd 19Rd 19.595 * MASTER SLAVE sync started

2508:S 05 Sep 20:19:19.595 # Error condition on socket for SYNC: Connection refused

2508 S 05 Sep 20 19V 20.619 * Connecting to MASTER 127.0.0.1R 6379

2508Rose S 05 Sep 20Rd 19Rd 20.619 * MASTER SLAVE sync started

...

2508:S 05 Sep 20:20:49.783 # Error condition on socket for SYNC: Connection refused

2508Rom 05 Sep 20 Sep 20Rd 50.283 * Discarding previously cached master state.

2508user request from M 05 Sep 20 user request from 20 id=6 addr=127.0.0.1:54717 fd=8 name= age=696 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=slaveof' 50.283 * MASTER MODE enabled)

2508 Sep 05 seconds 20 seconds 25 seconds 47.073 * 1. Saving...

2508Rom 05 Sep 20 Sep 25Rd 47.074 * Background saving started by pid 2722

2722 C 05 Sep 20 Sep 25 47.087 * DB saved on disk

2722 MB of memory used by copy-on-write C 05 Sep 20 MB of memory used by copy-on-write 25 purl 47.088 * MB of memory used by copy-on-write

2508Rose M 05 Sep 20 Sep 25Rd 47.176 * Background saving terminated with success

2508 Sep 05 changes in 20 seconds 40 seconds 48.064 * 1 Saving...

2508 Sep 05 Background saving started by pid 20 40 48.064 * Background saving started by pid 2813

2813 C 05 Sep 20 40 Fran 48.075 * DB saved on disk

2813 MB of memory used by copy-on-write C 05 Sep 20 MB of memory used by copy-on-write 40 Switzerland 48.075 * MB of memory used by copy-on-write

2508DV M 05 Sep 20RU 40PUR 48.165 * Background saving terminated with success

6381 Chronicles

2503 seconds S 05 Sep 20 seconds 06 seconds 54.667 * seconds

2503Rose S 05 Sep 20 06R 54.667 * The server is now ready to accept connections on port 6381

2503 S 05 Sep 20 06R 54.667 * Connecting to MASTER 127.0.1R 6380

2503 S 05 Sep 20R 06R R 54.667 * MASTER SLAVE sync started

2503:S 05 Sep 20:06:54.667 # Error condition on socket for SYNC: Connection refused

2503 S 05 Sep 20 06R 55.691 * Connecting to MASTER 127.0.0.1R 6380

2503 S 05 Sep 20R 06R 55.692 * MASTER SLAVE sync started

2503:S 05 Sep 20:06:55.692 # Error condition on socket for SYNC: Connection refused

2503 S 05 Sep 20 06R 56.716 * Connecting to MASTER 127.0.0.1R 6380

2503 S 05 Sep 20R 06R R 56.717 * MASTER SLAVE sync started

2503:S 05 Sep 20:06:56.717 # Error condition on socket for SYNC: Connection refused

2503 S 05 Sep 20 06R 57.741 * Connecting to MASTER 127.0.0.1R 6380

2503 S 05 Sep 20R 06R 57.742 * MASTER SLAVE sync started

2503:S 05 Sep 20:06:57.742 # Error condition on socket for SYNC: Connection refused

2503 S 05 Sep 20 06R 58.764 * Connecting to MASTER 127.0.0.1R 6380

2503 Sep S 05 20 06R 58.764 * MASTER SLAVE sync started

2503 Sep S 05 20 06 58.764 *.

2503Rose S 05 Sep 20R 06Rd * Master replied to PING, replication can continue...

2503Rose S 05 Sep 20Rd 06Rd * Partial resynchronization not possible (no cached master)

2503reply S 05 Sep 20 reply 06R * Master does not support PSYNC or is in error state (reply:-ERR Can't SYNC while not connected with my master)

2503 Sep S 05 20 06R 58.776 * Retrying with SYNC...

2503:S 05 Sep 20:06:58.803 # MASTER aborted replication with an error: ERR Can't SYNC while not connected with my master

2503Rose S 05 Sep 20 06R 59.786 * Connecting to MASTER 127.0.0.1R 6380

2503 S 05 Sep 20R 06R R 59.787 * MASTER SLAVE sync started

2503 Sep S 05 20 06 59.787 * Non blocking connect for SYNC fired the event.

2503Rose S 05 Sep 20 replication can continue... 06RV 59.787 * Master replied to PING

2503no cached master S 05 Sep 20 no cached master 06R 59.787 * Partial resynchronization not possible)

2503 S 05 Sep 20 e1bfca531c87795977333fca30c7a75eea64a1de:1 06Rose 59.788 * e1bfca531c87795977333fca30c7a75eea64a1de:1

2503receiving S 05 Sep 20 bytes from master 06 receiving 59.897 * MASTER SLAVE sync:

2503 S 05 Sep 20 Flushing old data 06Rose 59.900 * Flushing old data

2503 S 05 Sep 20 Loading DB in memory 06Rose 59.917 * Loading DB in memory

2503 S 05 Sep 20 Finished with success 06R 59.969 * Finished with success

Automatic switching of fail-over based on 2.sentinel

Copy sentinel.confcp / usr/local/src/redis-3.2.3/sentinel.conf / usr/local/redis/# from the source file to confirm the following parameter sentinel monitor mymaster 127.0.0.1 6379 1sentinel down-after-milliseconds mymaster 5000sentinel failover-timeout mymaster 180000sentinel parallel-syncs mymaster 1

Referenc

Http://www.redis.cn/topics/sentinel.html

Bin/redis-server redis.conf bin/redis-server redis6380.conf bin/redis-server redis6381.conf bin/redis-server sentinel.conf-sentinel port

Mark

6379

Master

6380

Slave

6381

Slave

Use sentinel to monitor (normal initialization status, use sentinel to monitor as follows)

2.1 Master status

127.0.0.1purl 26379 > sentinel masters

1) 1) "name"

2) "mymaster"

3) "ip"

4) "127.0.0.1"

5) "port"

6) "6379"

7) "runid"

8) "4d2b8e087e297f5d6347e1599a37c4998ad056d6"

9) "flags"

10) "master"

11) "link-pending-commands"

12) "0"

13) "link-refcount"

14) "1"

15) "last-ping-sent"

16) "0"

17) "last-ok-ping-reply"

18) "410"

19) "last-ping-reply"

20) "410"

21) "down-after-milliseconds"

22) "5000"

23) "info-refresh"

24) "7817"

25) "role-reported"

26) "master"

27) "role-reported-time"

28) "58045"

29) "config-epoch"

30) "0"

31) "num-slaves"

32) "2"

33) "num-other-sentinels"

34) "0"

35) "quorum"

36) "1"

37) "failover-timeout"

38) "180000"

39) "parallel-syncs"

40) "1"

You can know the port of Master, backup node and other information.

2.2 View initial Slave information

127.0.0.1purl 26379 > sentinel slaves mymaster

1) 1) "name"

2) "127.0.0.1purl 6380"

3) "ip"

4) "127.0.0.1"

5) "port"

6) "6380"

7) "runid"

8) "c344769d6d1cfd814437034b39f04b17851dca66"

9) "flags"

10) "slave"

11) "link-pending-commands"

12) "0"

13) "link-refcount"

14) "1"

15) "last-ping-sent"

16) "0"

17) "last-ok-ping-reply"

18) "693"

19) "last-ping-reply"

20) "693"

21) "down-after-milliseconds"

22) "5000"

23) "info-refresh"

24) "6445"

25) "role-reported"

26) "slave"

27) "role-reported-time"

28) "96788"

29) "master-link-down-time"

30) "0"

31) "master-link-status"

32) "ok"

33) "master-host"

34) "127.0.0.1"

35) "master-port"

36) "6379"

37) "slave-priority"

38) "100"

39) "slave-repl-offset"

40) "6058"

2) 1) "name"

2) "127.0.0.1purl 6381"

3) "ip"

4) "127.0.0.1"

5) "port"

6) "6381"

7) "runid"

8) "9f8666ce6e7b30d01449f6fb10d8556030a96186"

9) "flags"

10) "slave"

11) "link-pending-commands"

12) "0"

13) "link-refcount"

14) "1"

15) "last-ping-sent"

16) "0"

17) "last-ok-ping-reply"

18) "693"

19) "last-ping-reply"

20) "693"

21) "down-after-milliseconds"

22) "5000"

23) "info-refresh"

24) "6444"

25) "role-reported"

26) "slave"

27) "role-reported-time"

28) "96788"

29) "master-link-down-time"

30) "0"

31) "master-link-status"

32) "ok"

33) "master-host"

34) "127.0.0.1"

35) "master-port"

36) "6379"

37) "slave-priority"

38) "100"

39) "slave-repl-offset"

40) "6058"

At this time, the sentinel log is calm.

2847:X 07 Sep 21:01:27.567 # Sentinel ID is 1b9d1d720b11ecf5568c3dc0194305e86c47ed9a

2847quorum X 07 Sep 21 quorum 01 quorum 27.567 # + quorum 127.0.0.1 6379

2.3 simulated Master6379 downtime)

127.0.0.1 debug sleep 6379 >

OK

2.4 sentinel automatically switches over failover

View the sentinel log (sentinel specific work details)

2847quorum X 07 Sep 21 quorum 01 quorum 27.567 # + quorum 127.0.0.1 6379

2847 Sep X 07 21 03 49.117 # + sdown master mymaster 127.0.0.1 6379

2847 Sep X 07 quorum 21 purl 03 quorum 49.117 # + 127.0.0.1 6379 # quorum 1

2847 Sep X 07 21 03 49 117 # + new-epoch 4

2847 Sep X 07 21 03 49.117 # + try-failover master mymaster 127.0.0.1 6379

2847 Sep X 07 21 03 49 128 # + vote-for-leader 1b9d1d720b11ecf5568c3dc0194305e86c47ed9a 4

2847 Sep X 07 21 03 49.129 # + elected-leader master mymaster 127.0.0.1 6379

2847 Sep X 07 21 03 49.129 # + failover-state-select-slave master mymaster 127.0.0.1 6379

2847 Sep X 07 21 mymaster 03 mymaster 49.185 # + 127.0.0.1 mymaster 6381 127.0.0.1 6379

2847 Sep X 07 21 mymaster 03 mymaster 49.185 * + 127.0.0.1 mymaster 6381 127.0.0.1 6379

2847 Sep X 07 21 mymaster 03 mymaster 49.252 * + 127.0.0.1 mymaster 6381 127.0.0.1

2847 Sep 07 Sep 21 03 mymaster 50.262 # + 127.0.0.1 mymaster 6381 127.0.0.1 6379

2847 X 07 Sep 21V 03R 50.262 # + failover-state-reconf-slaves master mymaster 127.0.0.1 6379

2847 Sep X 07 21 mymaster 03 mymaster 50.315 * + 127.0.0.1 mymaster 6380 127.0.0.1 6379

2847 Sep X 07 21 mymaster 03 mymaster 51.308 * + 127.0.0.1 mymaster 6380 127.0.0.1

2847 Sep X 07 21 mymaster 03 mymaster 51.308 * + 127.0.0.1 mymaster 6380 127.0.0.1

2847 Sep 07 Sep 2115 03Flux 51.365 # + failover-end master mymaster 127.0.0.1 6379

2847 Sep X 07 21 03 Sep 51.365 # + switch-master mymaster 127.0.0.1 6379 127.0.0.1 6381

2847 Sep X 07 21 mymaster 03 mymaster 51.365 * + 127.0.0.1 mymaster 6380 127.0.0.1 6381

2847 Sep X 07 21 mymaster 03 mymaster 51.365 * + 127.0.0.1 mymaster 6379 127.0.0.1 6381

2847 Sep X 07 21 mymaster 03 Sep 56.399 # + 127.0.0.1 mymaster 6379 127.0.0.1 6381

2847 Sep X 07 Sep 21 purl 05Perv 23.708 #-sdown slave 127.0.0.1 mymaster 6379 127.0.0.1 6379 @ mymaster 127.0.0.1

2847 Sep X 07 21 mymaster 05 mymaster 33.730 * + 127.0.0.1 mymaster 6379 127.0.0.1 6381

Monitoring information after failover handover

127.0.0.1purl 26379 > sentinel masters

1) 1) "name"

2) "mymaster"

3) "ip"

4) "127.0.0.1"

5) "port"

6) "6381" (here it becomes 6381)

7) "runid"

8) "9f8666ce6e7b30d01449f6fb10d8556030a96186"

9) "flags"

10) "master"

11) "link-pending-commands"

12) "0"

13) "link-refcount"

14) "1"

15) "last-ping-sent"

16) "0"

17) "last-ok-ping-reply"

18) "190"

19) "last-ping-reply"

20) "190"

21) "down-after-milliseconds"

22) "5000"

23) "info-refresh"

24) "1905"

25) "role-reported"

26) "master"

27) "role-reported-time"

28) "42128"

29) "config-epoch"

30) "4"

31) "num-slaves"

32) "2"

33) "num-other-sentinels"

34) "0"

35) "quorum"

36) "1"

37) "failover-timeout"

38) "180000"

39) "parallel-syncs"

40) "1"

Reserve database information

127.0.0.1purl 26379 > sentinel slaves mymaster

1) 1) "name"

2) "127.0.0.1purl 6379"

3) "ip"

4) "127.0.0.1"

5) "port"

6) "6379"

7) "runid"

8) "

9) "flags"

10) "scurvy downgrading" (6379 is still in the sleep state at this time, which will be updated after sleep time)

11) "link-pending-commands"

12) "44"

13) "link-refcount"

14) "1"

15) "last-ping-sent"

16) "48488"

17) "last-ok-ping-reply"

18) "48488"

19) "last-ping-reply"

20) "48488"

21) "s-down-time"

22) "43454"

23) "down-after-milliseconds"

24) "5000"

25) "info-refresh"

26) "1473253479853"

27) "role-reported"

28) "slave"

29) "role-reported-time"

30) "48488"

31) "master-link-down-time"

32) "0"

33) "master-link-status"

34) "err"

35) "master-host"

36) "?

37) "master-port"

38) "0"

39) "slave-priority"

40) "100"

41) "slave-repl-offset"

42) "0"

2) 1) "name"

2) "127.0.0.1purl 6380"

3) "ip"

4) "127.0.0.1"

5) "port"

6) "6380"

7) "runid"

8) "c344769d6d1cfd814437034b39f04b17851dca66"

9) "flags"

10) "slave"

11) "link-pending-commands"

12) "0"

13) "link-refcount"

14) "1"

15) "last-ping-sent"

16) "0"

17) "last-ok-ping-reply"

18) "308"

19) "last-ping-reply"

20) "308"

21) "down-after-milliseconds"

22) "5000"

23) "info-refresh"

24) "8265"

25) "role-reported"

26) "slave"

27) "role-reported-time"

28) "48488"

29) "master-link-down-time"

30) "0"

31) "master-link-status"

32) "ok"

33) "master-host"

34) "127.0.0.1"

35) "master-port"

36) "6381"

37) "slave-priority"

38) "100"

39) "slave-repl-offset"

40) "11780"

127.0.0.1purl 26379 > sentinel slaves mymaster

1) 1) "name"

2) "127.0.0.1purl 6379"

3) "ip"

4) "127.0.0.1"

5) "port"

6) "6379"

7) "runid"

8) "4d2b8e087e297f5d6347e1599a37c4998ad056d6"

9) "flags"

10) "slave" s_down is gone

11) "link-pending-commands"

12) "0"

13) "link-refcount"

14) "1"

15) "last-ping-sent"

16) "0"

17) "last-ok-ping-reply"

18) "869"

19) "last-ping-reply"

20) "869"

21) "down-after-milliseconds"

22) "5000"

23) "info-refresh"

24) "3426"

25) "role-reported"

26) "slave"

27) "role-reported-time"

28) "3426"

29) "master-link-down-time"

30) "0"

31) "master-link-status"

32) "ok"

33) "master-host"

34) "127.0.0.1"

35) "master-port"

36) "6381"

37) "slave-priority"

38) "100"

39) "slave-repl-offset"

40) "16556"

...

Manually switch failover

127.0.0.1 SENTINEL failover mymasterOK# switch to 6379127.0.1 26379 > SENTINEL get-master-addr-by-name mymaster1) "127.0.0.1" 2) "6379"

2847 Sep X 07 21 46 46.793 # + switch-master mymaster 127.0.0.1 6381 127.0.0.1 6379

2847 Sep X 07 21 mymaster 46 mymaster 46.794 * + 127.0.0.1 mymaster 6380 127.0.0.1

2847 Sep X 07 21 mymaster 46 mymaster 46.794 * + 127.0.0.1 mymaster 6381 127.0.0.1

2847 Sep X 07 21 mymaster 46 mymaster 56.910 * + 127.0.0.1 mymaster 6381 127.0.0.1

When failover occurs in sentinel, the redis.conf file corresponding to the master / slave database will be updated.

6379 corresponding configuration file, added slaveof parameter

[root@hadoop2 redis] # cat redis.conf | grep slaveof

# Master-Slave replication. Use slaveof to make a Redis instance a copy of

# slaveof

Slaveof 127.0.0.1 6381

6380 corresponding configuration file, modified slaveof parameter

[root@hadoop2 redis] # cat redis6380.conf | grep slaveof

# Master-Slave replication. Use slaveof to make a Redis instance a copy of

Slaveof 127.0.0.1 6381

This is the end of the exercise.

3 other

3.1important quorum parameters.

The walkthrough sets up quorum=1 purely for simplicity, and the online environment cannot be important.

Four scenarios are provided for discussion in http://redis.io/topics/sentinel, which will be walkthrough and discussed later.

When you copy sentinel.conf, you need to process the information generated by sentinel, such as

Sentinel myid 575cb680ff3d3cbad55cdb978c1d6b5962abe7ac

Otherwise, there will be problems in communication between sentinel

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report