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-Sentinel Mode principle

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

After the master server exception downmachine, two original slave1,slave2 servers take over the service, such as slave1 becomes the new master server, and slave2 becomes the slave library of slave1.

The main parameters of the configuration file are explained:

Sentinel monitor mymaster 127.0.0.1 6379 1 several sentinels found that down was the real down.

How many milliseconds after sentinel down-after-milliseconds mymaster 30000 cannot be connected? master thinks it's disconnected.

Sentinel parallel-syncs mymaster 1 points several master to the new master machine at the same time.

Sentinel failover-timeout mymaster 180000 failed for more than a long time

Activate the sentinel.

[root@ZFRC-YW-YJF-TEST-370123 redis] # / bin/redis-server. / sentinel.conf-- sentinel

17400:X 28 Jun 17:17:32.853 # Not listening to IPv6: unsupproted

.

_.-_'. -. ''. Redis 3.2.13 (00000000Zet0) 64 bit

. -. ```\ / _., _'-. _ (.-`|`,) Running in sentinel mode | `-. _` -.-`_ _. -. |'`. -'| Port: 26379

| -. _. /. -'| PID: 17400

-. _. `-. /. -'. -'

| | `-. _ -. -'|

| -. _ -. . -'. -'| http://redis.io

`-. -. _. -'

| | -. _. -'_. -'| |. `-. . -'. -'|

-. _. -'. . -'

`-. _. -'

17400:X 28 Jun 17:17:32.854 # Sentinel ID is b81b851b02fec76bcfc7144b0a675fdedecf7188

17400 quorum X 28 Jun 17 quorum 17 32.854 # + monitor master mymaster 127.0.0.1 6379

17400 Jun 28 Jun 17 mymaster 32.854 + 127.0.0.1 mymaster 6380 127.0.0.1 6379

17400 Jun 28 Jun 17 mymaster 32.855 + 127.0.0.1 slave slave 6381 127.0.0.1 6381 @ mymaster

Test General master down to see if the Sentinel fails over

[root@ZFRC-YW-YJF-TEST-370123 ~] # cd / usr/local/redis/

[root@ZFRC-YW-YJF-TEST-370123 redis] #. / bin/redis-cli

127.0.0.1 purl 6379 > shutdown

Not connected >

The log prints out some enumerated processes, and the keyword switch is MasterMachine.

17400VX 28 Jun 17VOUR 19VR 03.363 # + sdown master mymaster 127.0.16379

17400 Jun 28 quorum 17 19 quorum 03.363 # + 127.0.0.1 # quorum 1

17400VR X 28 Jun 17RU 19VR 03.363 # + new-epoch 1

17400VX 28 Jun 17VOUR 19VR 03.363 # + try-failover master mymaster 127.0.16379

17400VR X 28 Jun 17VR 19VR 03.364 # + vote-for-leader b81b851b02fec76bcfc7144b0a675fdedecf7188 1

17400VX 28 Jun 17VOUR 19UR 03.364 # + elected-leader master mymaster 127.0.0.1 6379

17400VX 28 Jun 17VOUR 19UR 03.364 # + failover-state-select-slave master mymaster 127.0.0.1 6379

17400 Jun 28 Jun 17 mymaster 19 mymaster 03.464 # + 127.0.0.1 mymaster 6380 127.0.0.1 6379

17400 Jun 28 Jun 17 mymaster 19 mymaster 03.464 + 127.0.0.1 mymaster 6380 127.0.0.1

17400 Jun 28 Jun 17 mymaster 19 mymaster 03.564 + 127.0.0.1 mymaster 6380 127.0.0.1

17400 Jun 28 Jun 17 mymaster 1915 03.917 # + 127.0.0.1 mymaster 6380 127.0.0.1 6379

17400VX 28 Jun 17VOUR 19UR 03.917 # + failover-state-reconf-slaves master mymaster 127.0.0.1 6379

17400 Jun 28 Jun 17 mymaster 19 mymaster 04.006 + 127.0.0.1 mymaster 6381 127.0.0.1 6379

17400 Jun 28 Jun 17 mymaster 19 mymaster 04.982 + 127.0.0.1 mymaster 6381 127.0.0.1 6379

17400 Jun 28 Jun 17 mymaster 19 mymaster 04.982 + 127.0.0.1 mymaster 6381 127.0.0.1 6379

17400VX 28 Jun 17VOUR 19VERV 05.064 # + failover-end master mymaster 127.0.0.1 6379

17400 Jun 28 Jun 17 19V 05.064 # + switch-master mymaster 127.0.0.1 6379 127.0.0.1 6380

17400 Jun 28 Jun 17 mymaster 19V 05.064 + 127.0.0.1 mymaster 6381 127.0.0.1 6381 @ mymaster 127.0.0.1

17400 Jun 28 Jun 17 mymaster 19 mymaster 05.064 * + 127.0.0.1 mymaster 6379 127.0.0.1

17400 Jun 28 Jun 17 mymaster 1915. 080 # + 127.0.0.1 sdown slave 6379 127.0.0.1 6379 @ mymaster

Log in to the 6380 slave library at the same time to see if it is now the master master node.

127.0.0.1 6380 > info replication

Role:master

Connected_slaves:1

Slave0:ip=127.0.0.1,port=6381,state=online,offset=22858,lag=0

Master_repl_offset:22858

Repl_backlog_active:1

Repl_backlog_size:1048576

Repl_backlog_first_byte_offset:2

Repl_backlog_histlen:22857

127.0.0.1purl 6380 >

127.0.0.1purl 6381 > info replication

Role:slave

Master_host:127.0.0.1

Master_port:6380

Master_link_status:up

Master_last_io_seconds_ago:0

Master_sync_in_progress:0

Slave_repl_offset:35773

Slave_priority:100

Slave_read_only:1

Connected_slaves:0

Master_repl_offset:0

Repl_backlog_active:0

Repl_backlog_size:1048576

Repl_backlog_first_byte_offset:0

Repl_backlog_histlen:0

Sometimes the main library down, from the library to master is not a sequential promotion, such as master failed, 6381 as the main library. There is actually a parameter control, in the redis configuration file, not in the Sentinel configuration file.

Slave-priority 100The smaller the number. The higher the priority.

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

Database

Wechat

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

12
Report