当前位置:网站首页>搭建redis哨兵
搭建redis哨兵
2022-08-04 05:35:00 【郝老三】
最近公司里需要进行开发和测试环境的redis的升级,由原来的单机模式,扩展成集群模式,通过今天的摸索,成功的完成了这个任务。下面出一个教程,讲一讲怎么从单机升级到哨兵模式。
一:redis分类
redis从简单到复杂分别是。
- 单机模式
- 主从模式
- 哨兵模式
- 集群模式
每个模式都是在之前的基础上演变而来的。
二:单机搭建
- 将下载好的redis安装包放到安装目录下。
- 解压安装包 tar -zxvf redis-5.0.7.tar.gz
- 安装gcc编译环境 yum install gcc-c++
- 打开解压的redis文件
- 输入命令进行安装 make make install
- 修改配置文件 redis.conf
## 修改1:注释如下行,注释以后redis不可以接收任意ip的连接
# bind 127.0.0.1
## 修改2:关闭保护模式(如果设置为yes,那么只允许我们在本机的回环连接,其他机器无法连接。)
protected-mode no
## 修改3:开启redis服务后台运行
daemonize yes
## 修改4:添加日志路径,便于排查问题
logfile “/home/admin/redis/redis-5.0.7/redis.log”
① 开启防火墙
systemctl start firewalld.service
②开放指定端口号
查看已开放端口号
firewall-cmd --list-ports
开放指定端口号,下方示例端口号为6379
firewall-cmd --zone=public --add-port=6379/tcp --permanent
③重启防火墙
端口号才算开放成功
firewall-cmd --reload
④启动服务
./redis-server /home/admin/redis/redis-5.0.7/theRedisConf/redis.conf
三:搭建主从模式哨兵
①编辑从机配置文件
vi /home/admin/redis/redis-5.0.7/theRedisConf/redis.conf
添加上master的IP或主机及端口号
replicaof 192.168.xxx.xxx 6379
四:搭建哨兵模式
①修改配置文件
vi /home/admin/redis/redis-5.0.7/redisSentinel/sentinel.conf
## 修改1:让sentinel服务后台运行
daemonize yes
## 修改2:增加日志文件路径
logfile “/home/admin/redis/redis-5.0.7/sentinel.log”
## 修改3:增加redis主节点信息和需要进行选举的法定个数(2代表只有2个哨兵节点同时认为master节点时效时,才算真正的失效)
把sentinel monitor mymaster 127.0.0.1 6379 2改成
sentinel monitor mymaster 192.168.60.83 6379 2
边栏推荐
- 沉浸式体验参加网络安全培训班,学习过程详细到底!
- Detailed explanation of DenseNet and Keras reproduction code
- 元素的增删克隆以及利用增删来显示数据到页面上
- A priori box (Anchor) in target detection
- 学好网络安全看这篇文章让你少走弯路
- 冰歇webshell初探
- Online public account article content to audio file practical gadget
- A semi-supervised Laplace skyhawk optimization depth nuclear extreme learning machine for classification
- YOLOv3详解:从零开始搭建YOLOv3网络
- 安全漏洞是如何被发现的?
猜你喜欢

Based on the EEMD + + MLR GRU helped time series prediction

matlab的2DCNN、1DCNN、BP、SVM故障诊断与结果可视化

狗都能看懂的CenterNet讲解及代码复现

Microsoft Store 微软应用商店无法连接网络,错误代码:0x80131500

LeetCode刷题

无一技之长学什么可以做到月入上万?

Interpretation of EfficientNet: Composite scaling method of neural network (based on tf-Kersa reproduction code)

解决腾讯云DescribeInstances api查询20条记录以上的问题

网络技巧:教你给路由器装上电池,断电照样可以上网!

DropBlock: 卷积层的正则化方法及复现代码
随机推荐
有且仅有的三种处理JSON的方法
Operating System Kernel
av_read_frame 阻塞,基于回调的解决办法
Uos统信系统 Postfix-smtps & Dovecot-imaps
Database: Organize Four Practical SQL Server Scripting Functions
MySQL stored procedure study notes (based on 8.0)
数据库JDBC DAO层方法
注册表设置默认浏览器 win7,winserver 2008,winserver 2012
Based on the EEMD + + MLR GRU helped time series prediction
EL expression
YOLOv3详解:从零开始搭建YOLOv3网络
Computer software: recommend a disk space analysis tool - WizTree
基于EEMD+GRU+MLR的时间序列预测
IoU, GIoU, DIoU and CIoU in target detection
读取JDBC配置文件
硬件描述语言Verilog HDL学习笔记之模块介绍
Memory Management
QT signals 保存到 QMap
RuntimeError: You called this URL via POST, but the URL doesn‘t end in a slash and you have APPEND_S
Online public account article content to audio file practical gadget