redis哨兵模式

1禁止aof:

复制代码
vim  redis.conf 将 appendonly yes 改为 appendonly no。
(其中daemonize yes这是设置redis,后台启动。)

2.创建多个redis主、从配置文件:

复制代码
vim redis-6379.conf
内容:

include /root/myredis/redis.conf   #redis使用的文件夹。(因为配置环境变量后,只有复制redis.conf就可以在不同文件下创建redis)

pidfile /var/run/redis_6379.pid
port 6379  #端口号,不同端口号视为不同redis服务。
dbfilename dump6379.rdb # rdb文件名,即6379这个redis的数据文件。

vim redis-6380.conf
内容:

include /root/myredis/redis.conf  #redis使用的文件夹。(因为配置环境变量后,只有复制redis.conf就可以在不同文件下创建redis)

pidfile /var/run/redis_6380.pid
port 6380  #端口号,不同端口号视为不同redis服务。
dbfilename dump6380.rdb # rdb文件名,即6380这个redis的数据文件。

vim redis-6381.conf
内容:

include /root/myredis/redis.conf    #redis使用的文件夹。(因为配置环境变量后,只有复制redis.conf就可以在不同文件下创建redis)

pidfile /var/run/redis_6381.pid
port 6381  #端口号,不同端口号视为不同redis服务。
dbfilename dump6381.rdb # rdb文件名,即6381这个redis的数据文件。

············

3.开启服务:

复制代码
redis-server redis-6379.conf
redis-server redis-6380.conf
redis-server redis-6381.conf

4.为哨兵模式准备配置文件:

4-1在redis使用目录下新建sentinel.conf 配置文件中放入如下内容

复制代码
sentinel monitor xxxx 127.0.0.1 6379 1   #xxx为哨兵名字   IP地址   redis服务端口号 哨兵个数(一个文件一个哨兵)

5.启动哨兵

5-1在redis使用目录下使用哨兵

复制代码
redis-sentinel sentinel.conf

6.这样就完成哨兵,在主从模式下主机down机会自动在子机中选出新主机。待旧主机复活后成为子机。其中 在主从配置中添加replica-priority 10意思为0-100 哨兵模式下,选举的时候,有用!谁的值小谁优先级高!谁当主机 !!(可以不设置)

相关推荐
Wang's Blog15 小时前
Java 接入Redis: 服务启动停止与后台运行配置
java·服务器·redis
Hrain-AI16 小时前
多 Agent 并行不打架:worktree 隔离与反馈回流落地(附脚本)
网络·数据库·人工智能·架构
净水深流17 小时前
中央厨房冷链技术实践:多温区改造、WMS落地与IoT温控架构
大数据·数据库·人工智能·冷库冷链
l1t17 小时前
测试DuckDB 2.1的match_recognize模式匹配语句
数据库·duckdb
IpdataCloud18 小时前
AI智能体调用工具怎么核验来源IP?归属地、网络类型与代理风险识别(含Python代码)
数据库·python·tcp/ip
曹牧18 小时前
Java:SQL 注入漏洞
数据库
程序员JerrySUN19 小时前
Jetson Edge AI 实战01:Nano、Xavier、Orin 怎么选?Jetson 硬件选型详解【视频讲解】
java·数据库·redis·安全·mybatis
oradh19 小时前
Oracle Undo问题总结(ORA-600 [4xxx] 系列错误)
数据库·oracle
达梦数据19 小时前
DMDRS辅助表生成规则与作用
数据库·oracle
‎ദ്ദിᵔ.˛.ᵔ₎20 小时前
MySQL 表约束
数据库·mysql