How to implement Nginx proxy Redis sentinel master-slave configuration
1. Environment
Nginx version: 1.21.6
Center7.5 and above or Mas OS
Build Redis Sentinel master-slave mode
Springboot integrates Redis Sentinel master-slave mode
Tips: Nginx must install the upstream module
2. Configuration
There are three options for Nginx configuration (see subsequent content for details), among which: option 1 will use one port for all sentinel nodes to connect to the outside world. Mapping; Option 2 is to configure a corresponding mapped port for each sentinel port, and there is no difference between the normal sentinel configuration method; Option 3 is actually a combination of Option 1 and Option 2. Personally, I don’t think it makes much sense, and interested friends can try it on their own.
2.1. Option 1 (recommended)
# stream模块配置和http模块在相同级别 stream { upstream redis { server 127.0.0.1:26379 max_fails=3 fail_timeout=10s; server 127.0.0.1:26380 max_fails=3 fail_timeout=10s; server 127.0.0.1:26381 max_fails=3 fail_timeout=10s; } server { listen 5432; proxy_connect_timeout 30s; proxy_timeout 60s; proxy_pass redis; } }
2.2. Option 2
# stream模块配置和http模块在相同级别 stream { upstream redis { server 127.0.0.1:26379 max_fails=3 fail_timeout=10s; } upstream redis1 { server 127.0.0.1:26380 max_fails=3 fail_timeout=10s; } upstream redis2 { server 127.0.0.1:26381 max_fails=3 fail_timeout=10s; } server { listen 5432; proxy_connect_timeout 30s; proxy_timeout 60s; proxy_pass redis; } server { listen 5433; proxy_connect_timeout 30s; proxy_timeout 60s; proxy_pass redis1; } server { listen 5434; proxy_connect_timeout 30s; proxy_timeout 60s; proxy_pass redis2; } }
2.3. Option 3
# stream模块配置和http模块在相同级别 stream { upstream redis { server 127.0.0.1:26379 max_fails=3 fail_timeout=10s; server 127.0.0.1:26380 max_fails=3 fail_timeout=10s; server 127.0.0.1:26381 max_fails=3 fail_timeout=10s; } upstream redis1 { server 127.0.0.1:26380 max_fails=3 fail_timeout=10s; server 127.0.0.1:26379 max_fails=3 fail_timeout=10s; server 127.0.0.1:26381 max_fails=3 fail_timeout=10s; } upstream redis2 { server 127.0.0.1:26381 max_fails=3 fail_timeout=10s; server 127.0.0.1:26380 max_fails=3 fail_timeout=10s; server 127.0.0.1:26379 max_fails=3 fail_timeout=10s; } server { listen 5432; proxy_connect_timeout 30s; proxy_timeout 60s; proxy_pass redis; } server { listen 5433; proxy_connect_timeout 30s; proxy_timeout 60s; proxy_pass redis1; } server { listen 5434; proxy_connect_timeout 30s; proxy_timeout 60s; proxy_pass redis2; } }
The above is the detailed content of How to implement Nginx proxy Redis sentinel master-slave configuration. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Docker container startup steps: Pull the container image: Run "docker pull [mirror name]". Create a container: Use "docker create [options] [mirror name] [commands and parameters]". Start the container: Execute "docker start [Container name or ID]". Check container status: Verify that the container is running with "docker ps".

You can query the Docker container name by following the steps: List all containers (docker ps). Filter the container list (using the grep command). Gets the container name (located in the "NAMES" column).

Create a container in Docker: 1. Pull the image: docker pull [mirror name] 2. Create a container: docker run [Options] [mirror name] [Command] 3. Start the container: docker start [Container name]

Enable Redis slow query logs on CentOS system to improve performance diagnostic efficiency. The following steps will guide you through the configuration: Step 1: Locate and edit the Redis configuration file First, find the Redis configuration file, usually located in /etc/redis/redis.conf. Open the configuration file with the following command: sudovi/etc/redis/redis.conf Step 2: Adjust the slow query log parameters in the configuration file, find and modify the following parameters: #slow query threshold (ms)slowlog-log-slower-than10000#Maximum number of entries for slow query log slowlog-max-len

How does the Redis caching solution realize the requirements of product ranking list? During the development process, we often need to deal with the requirements of rankings, such as displaying a...

Laravel 8 provides the following options for performance optimization: Cache configuration: Use Redis to cache drivers, cache facades, cache views, and page snippets. Database optimization: establish indexing, use query scope, and use Eloquent relationships. JavaScript and CSS optimization: Use version control, merge and shrink assets, use CDN. Code optimization: Use Composer installation package, use Laravel helper functions, and follow PSR standards. Monitoring and analysis: Use Laravel Scout, use Telescope, monitor application metrics.

Redis plays a key role in data storage and management, and has become the core of modern applications through its multiple data structures and persistence mechanisms. 1) Redis supports data structures such as strings, lists, collections, ordered collections and hash tables, and is suitable for cache and complex business logic. 2) Through two persistence methods, RDB and AOF, Redis ensures reliable storage and rapid recovery of data.
