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 哨兵模式下,选举的时候,有用!谁的值小谁优先级高!谁当主机 !!(可以不设置)

相关推荐
这个DBA有点耶11 分钟前
信创场景下数据同步软件怎么选?对比开源CDC与原生闭环工具的结构性差异
数据库·mysql·架构
多客:duokelijie1 小时前
代练订单系统选型思路:跨品类游戏接入、订单分层管理、自动结算逻辑拆解!
数据库·mysql·微信小程序·前端框架·uni-app·php·持续部署
PingCAP1 小时前
平凯星辰上榜!2026 年胡润全球独角兽企业
数据库
PingCAP1 小时前
轨道交通 AFC 系统升级,平凯 Loop 把跨部门协同变成可追溯闭环
数据库
java_logo2 小时前
Docker 部署 CloudBeaver:轻松搭建网页数据库管理平台
数据库·docker·容器·数据库管理·dbeaver·轩辕镜像·cloudbeaver
李白客3 小时前
AI 数据库落地 NL2SQL:准确率卡在四成,问题在表注释不在模型
数据库
FluxDB3 小时前
FluxDB vs DBX vs DBeaver:GPUI、Tauri、Eclipse 三种技术栈实测
数据库·mysql
杨航 AI4 小时前
JEV的用法
java·前端·数据库
用户094248568034 小时前
第19章:库存扣减与秒杀系统:Redis 扛峰值流量
redis·架构·源码
数据库小学妹4 小时前
MySQL分页结果不稳定:唯一键兜底与游标分页
数据库·mysql·dba