Home  >  Article  >  Database  >  How to use redis sentinel client

How to use redis sentinel client

(*-*)浩
(*-*)浩Original
2019-11-28 10:45:322377browse

How to use redis sentinel clientRedis Sentinel is a distributed architecture (distributed here refers to an architecture in which Redis data nodes, Sentinel node collections, and clients are distributed across multiple physical nodes), which includes several Sentinel nodes and Redis data points. Each Sentinel node will monitor the data node and other Sentinel nodes. When it finds that the node is unreachable, it will mark the node offline. (Recommended learning: Redis video tutorial)

If the identified master node is, it will also "negotiate" with other Sentinel nodes. When most Sentinel nodes think that the master node is unavailable, When that happens, they will elect a Sentinel node to complete automatic failover and notify the Redis application of this change in real time.

The entire process is completely automatic and does not require manual intervention, so this solution effectively solves the high availability problem of Redis.

Redis Sentinel has the following functions:

Monitoring: The Sentinel node will regularly detect whether the Redis data node (including master and slave) and other Sentinel nodes are Reachable.

Notification: The Sentinel node will notify the application of the failover result.

Automatic failover: When the master fails to work properly, Sentinel will promote the slave node to the master node and maintain the subsequent correct master-slave relationship.

Configuration provider.: In the Redis Sentinel structure, the client connects to the Sentinel node collection during initialization and obtains the master node information from it.

Redis & Redis Sentinel startup

Modified in the configuration file. Generally, at least three sentinels are needed to monitor redis. We can start multiple sentinel services by modifying the port.

Configure the IP and port of the main server. We change the listening port to 6380 and add a weight of 2. The weight here is used to calculate which server we need to Upgrade the master server.

After Redis is installed, we can start Redis and Redis Sentinel (Sentinel) through the following commands

# 使用默认的配置文件
./src/redis-server ../redis.conf
# 使用默认的配置文件
./src/redis-sentinel ../sentinel.conf

For more Redis-related technical articles, please visit Redis Getting Started Tutorialcolumn for learning!

The above is the detailed content of How to use redis sentinel client. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn