当前位置:网站首页>搭建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
边栏推荐
- Uos统信系统控制台欢迎登陆后消息及所处区域配置
- MAML原理讲解和代码实现
- 冰歇webshell初探
- Uos统信系统 CA根证书搭建
- Memory limit should be smaller than already set memoryswap limit, update the memoryswap at the same
- 益智小游戏- 算算总共多少正方形
- 数据库技巧:整理SQLServer非常实用的脚本
- 水平垂直居中的12种方法,任意插入节点的方法,事件的绑定的三种方法和解绑的方法,事件对象,盒子模型
- 天鹰优化的半监督拉普拉斯深度核极限学习机用于分类
- Database Skills: Organize SQL Server's Very Practical Scripts
猜你喜欢
随机推荐
基于子空间结构保持的迁移学习方法MLSSM
JUC锁框架——CountDownLatch、CyclicBarrier和Semaphore
狗都能看懂的CenterNet讲解及代码复现
桌面右键的NVIDIA去除与恢复
复杂格式的json转递
Interpretation of EfficientNet: Composite scaling method of neural network (based on tf-Kersa reproduction code)
Database: Organize Four Practical SQL Server Scripting Functions
A semi-supervised Laplace skyhawk optimization depth nuclear extreme learning machine for classification
以太网 ARP
FCN——语义分割的开山鼻祖(基于tf-Kersa复现代码)
JUC锁框架——初识AQS
Gramm Angle field GAF time-series data into the image and applied to the fault diagnosis
数据库实体类对应daoimpl,基础的增删改查。
狗都能看懂的Vision Transformer的讲解和代码实现
键盘扫描码
读取JDBC配置文件
把DocumentsandSettings迁移到别的盘
Logical Address & Physical Address
Visualization and Animation Technology (Computer Animation)
Uos统信系统 CA根证书搭建









