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

How to build sentinel Sentinel Mechanism in redis

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

Share

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

How does redis build the sentinel sentinel mechanism? I believe that most people have not yet learned this skill, in order to let you learn, to give you a summary of the following content, do not say much, let's move on.

1.redis master-slave creation (one master and two slaves):

Execute on the slave node: ip address and port of slaveof 192.168.56.201 6379 # master

You can also configure it in the configuration file:

Slaveof 192.168.56.201 6379

Confirm:

[root@db1 ~] # redis-cli

127.0.0.1 purl 6379 > info replication

# Replication

Role:master

Connected_slaves:2

Slave0:ip=192.168.56.202,port=6379,state=online,offset=1344537,lag=0

Slave1:ip=192.168.56.203,port=6379,state=online,offset=1344537,lag=0

Master_replid:78461067504e80e7adf61bd14ea1a385c38ca20c

Master_replid2:0000000000000000000000000000000000000000

Master_repl_offset:1344688

Second_repl_offset:-1

Repl_backlog_active:1

Repl_backlog_size:10485760

Repl_backlog_first_byte_offset:1

Repl_backlog_histlen:1344688

two。 Create a directory:

Mkdir-p / data/redis-26379/logs/

Mkdir-p / data/redis-26379/run

3. Edit Sentinel parameters (scp are the other two machines):

Vim / data/redis-26379/26379.conf

Port 26379

Daemonize yes

Dir / data/redis-26379/

Pidfile / data/redis-26379/redis_26379.pid

Logfile / data/redis-26379/logs/26379.log

# bind enter native ip address and 127.0.0.1

Bind 192.168.56.201 127.0.0.1

Sentinel monitor master-monitor1 192.168.56.201 6379 2

Sentinel down-after-milliseconds master-monitor1 10000

Sentinel parallel-syncs master-monitor1 1

Sentinel failover-timeout master-monitor1 180000

4. Start the Sentinel node:

Redis-sentinel / data/redis-26379/26379.conf

Log in to view information:

Redis-cli-p 26379

127.0.0.1purl 26379 > info sentinel

# Sentinel

Sentinel_masters:1

Sentinel_tilt:0

Sentinel_running_scripts:0

Sentinel_scripts_queue_length:0

Sentinel_simulate_failure_flags:0

Master0:name=master-monitor1,status=ok,address=192.168.56.201:6379,slaves=2,sentinels=3

When you see that the Sentinel configuration file has changed, slave is automatically discovered:

[root@db1 redis-26379] # cat 26379.conf

Port 26379

Daemonize yes

Dir "/ data/redis-26379"

Pidfile "/ data/redis-26379/redis_26379.pid"

Logfile "/ data/redis-26379/logs/26379.log"

# enter local ip address and 127.0.0.1 for bind information

Bind 192.168.56.201 127.0.0.1

Sentinel myid 6ba1b2245916983baabaacf1be1eb0303a2a1b8b

Sentinel deny-scripts-reconfig yes

Sentinel monitor master-monitor1 192.168.56.202 6379 2

Sentinel down-after-milliseconds master-monitor1 10000

# Generated by CONFIG REWRITE

Sentinel config-epoch master-monitor1 2

Sentinel leader-epoch master-monitor1 2

Sentinel known-slave master-monitor1 192.168.56.201 6379

Sentinel known-slave master-monitor1 192.168.56.203 6379

Sentinel known-sentinel master-monitor1 192.168.56.203 26379 67202a457efa3d68e5ada2912375e40a0c9b5262

Sentinel known-sentinel master-monitor1 192.168.56.202 26379 7a089d3c9e68851cc70c6c24c51df829a910195e

After reading this article, have you learned how to build the sentinel sentinel mechanism by redis? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel. Thank you for reading.

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