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

Configure redis Sentinel on centos7

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

1 configure three redis databases, one master and two slaves

Redis-6380.conf # Master

Redis-6381conf # from

Redis-6382.conf # from

Write down the following configuration file

Vim redis-6380.conf

Port 6380

Daemonize yes

Pidfile / data/6380/redis.pid

Loglevel notice

Logfile "/ data/6380/redis.log"

Dbfilename dump.rdb

Dir / data/6380

Protected-mode no

Create two more profiles 6381 and 6382

Sed "redis-6380.conf 6380 Compact 6381Universe" redis-6381.conf

Sed "redis-6380.conf 6380 Compact 6382 Universe g" redis-6382.conf

Create a data file directory

Mkdir-p / data/ {6380pr 6381pl 6382}

Add another line of configuration to two slave server profiles

Add this line configuration to the 6381 and 6382 configuration files, indicating that the primary server is specified as 6380

Slaveof 127.0.0.1 6380

2 start three redis databases to ensure the normal operation of master-slave replication

Redis-server redis-6380.conf

Redis-server redis-6381.conf

Redis-server redis-6382.conf

3 configure three sentinels

Cd / opt/redis/

Vim redis-sentinel-16380.conf

Vim redis-sentinel-16381.conf

Vim redis-sentinel-16382.conf

Write to the following configuration file

Port 16381

Dir "/ data/16381"

Logfile "16381.log"

Sentinel myid 3cf63a8e47b2372667013f8cdee7a3a5130d41fc

Sentinel deny-scripts-reconfig yes

Sentinel monitor qishimaster 127.0.0.1 6381 2

Sentinel down-after-milliseconds qishimaster 60000

Daemonize yes

Detailed description of the Sentinel configuration file (not in the step):

Port of the Sentinel node

Port 26379

Dir / var/redis/data/

Logfile "26379.log"

Sentinel announce-ip 127.0.0.1 # declares Sentinel IP. This configuration can only be added if Sentinel cannot be successfully configured with an IP other than 127.0.0.1. At the same time, the three servers of redis also need to modify IP synchronously.

The current Sentinel node monitors 127.0.0.1 6379 as the master node.

2 means that judging the failure of the primary node requires the consent of at least two Sentinel nodes.

Mymaster is an alias for the primary node

Sentinel monitor mymaster 127.0.0.1 6379 2

Each Sentinel node needs periodic PING commands to determine whether the Redis data node and the rest of the Sentinel nodes are reachable. If it exceeds 30000 milliseconds for 30s and there is no reply, it is determined to be unreachable.

Sentinel down-after-milliseconds mymaster 30000

When the Sentinel node set agrees on the failure determination of the master node, the Sentinel leader node will perform a failover operation and select a new master node, and the original slave node will initiate a replication operation to the new master node, limiting the number of slave nodes to the new master node to 1 at a time

Sentinel parallel-syncs mymaster 1

Failover timeout is 180000 milliseconds

Sentinel failover-timeout mymaster 180000

Daemonize yes

Create a directory for Sentinel files

Mkdir-p / data/ {16380 dint 16381 de 16382}

Activate three sentinels.

Redis-sentinel redis-sentinel-16380.conf

Redis-sentinel redis-sentinel-16381.conf

Redis-sentinel redis-sentinel-16382.conf

Check to see if the sentry communicated successfully.

Redis-cli-p 16380 info 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

Servers

Wechat

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

12
Report