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

相关推荐
zlwool7 小时前
图纸管理选型避坑指南
数据库·erp·设备erp·非标机械
智购科技无人售货机厂家7 小时前
2026自动售货机制冷系统维护指南:从散热器清洁到压缩机换油的工程实践~YH
运维·redis·物联网·缓存·架构
小灰灰搞电子8 小时前
完全驾驭 Qt 与数据库:C++ ORM 框架 QxOrm 原理与实践指南
数据库·c++·qt
软件聚导航9 小时前
「聚小软 AI 助手」技术升级:从数据库检索到 RAG 知识库问答
前端·数据库·mysql·微信小程序·小程序·ai编程·rag
学习星球10 小时前
单调栈——从“找下一个更大的“到柱状图中的最大矩形
数据库·c++·算法·leetcode·xcode
GoppViper11 小时前
RDF资源描述框架深度解析:语义Web的数据基石与实战逻辑
前端·数据库
2601_9621741711 小时前
Redis 简介
数据库·redis·wpf
夜雪一千11 小时前
MySQL 各种数据同步方案全梳理:从简单复制到异构同步实战
数据库·mysql
Highcharts.js12 小时前
Highcharts 下钻(Drilldown)柱状图 Demo
数据库·信息可视化·hbase·highcharts·drilldown·js模块·下钻图表
翼龙云_cloud12 小时前
阿里云国际渠道代理商:如何在ECS上部署Flask应用?
运维·数据库·阿里云·flask·云计算