当前位置:网站首页>Windows下Redis哨兵模式搭建
Windows下Redis哨兵模式搭建
2022-07-26 09:23:00 【跑马的汉子睡眠不足】
Windows下Redis哨兵模式搭建
一主(master)二从(slave)三sentinel的架构模式:
- master ip:127.0.0.1 port:6379
- slave1 ip:127.0.0.1 port:6479
- slave2 ip:127.0.0.1 port:6579
1. 下载Reids文件
下载地址:https://github.com/tporadowski/redis/releases
按需下载即可,我这里下载的Redis-x64-5.0.10.zip
2. 将下载Reids文件解压并复制3份,修改文件夹名(按端口命名)如下:
3. 分别修改各文件夹下的redis.windows.conf文件
由于我们采用的是一主二从三sentinel的模式,所以我们需要6个配置文件:
6379 配置文件redis.windows.conf内容如下:
6479 配置文件redis.windows.conf内容如下:
6579 配置文件redis.windows.conf内容如下:
redis.windows.conf配置说明:
- port:端口号
- bind:绑定的IP
- daemonize yes #启用守护模式
- protected-mode no #protected-mode 是3.2 之后加入的新特性,为了禁止公网访问redis cache,加强redis安全的。根据自己需要配置,它启用的条件,有两个,没有bind IP 以及没有设置访问密码。
- databases:数据库的个数
- requirepass:连接密码
- masterauth 123456 #主从认证密码,否则主从不能同步
- loglevel:日志级别
- logfile:指定日志的保持路径,默认是创建在redis安装目录下,如果有子目录需要手动创建,如此处的logs目录
- slaveof:设置当本机为slav服务时,设置master服务的IP地址及端口,在Redis启动时,它会自动从master进行数据同步
- masterauth:主服务的连接密码
- slaveof 127.0.0.1 6379 #启用主从模式只有Redis Slave 添加一行,启动服务主从就配置好了。
4. 分别在各文件夹下创建sentinel.conf文件
6379 配置文件sentinel.conf内容如下:
6479 配置文件sentinel.conf内容如下:
6579 配置文件sentinel.conf内容如下:
sentinel.conf配置说明:
- port:当前Sentinel服务运行的端口
- protected-mode: 受保护模式
- sentinel monitor mymaster 127.0.0.1 6379 2:Sentinel去监视一个名为mymaster的主redis实例,这个主实例的IP地址为本机地址127.0.0.1,端口号为6379,而将这个主实例判断为失效至少需要2个 Sentinel进程的同意,只要同意Sentinel的数量不达标,自动failover就不会执行
- sentinel down-after-milliseconds mymaster 5000:5s内mymaster无响应,则认为mymaster宕机了
- sentinel parallel-syncs mymaster 1:指定了在执行故障转移时,最多可以有多少个从Redis实例在同步新的主实例,在从Redis实例较多的情况下这个数字越小,同步的时间越长,完成故障转移所需的时间就越长
- sentinel failover-timeout mymaster 15000:如果15秒后,mysater仍没启动过来,则启动failover
- sentinel auth-pass mymaster 123456:mymaster的主redis实例的连接密码
5. 安装服务并启动(安装为windows服务)
- 安装服务命令:
CMD下切换到redis目录,然后依次执行以下命令:
E:\redis\6379\redis-server.exe --service-install E:\redis\6379\redis.windows.conf --service-name redis6379 --port 6379
E:\redis\6479\redis-server.exe --service-install E:\redis\6479\redis.windows.conf --service-name redis6479 --port 6479
E:\redis\6579\redis-server.exe --service-install E:\redis\6579\redis.windows.conf --service-name redis6579 --port 6579
E:\redis\6379\redis-server.exe --service-install E:\redis\6379\sentinel.conf --sentinel --service-name sentinel26379 --port 26379
E:\redis\6479\redis-server.exe --service-install E:\redis\6479\sentinel.conf --sentinel --service-name sentinel26479 --port 26479
E:\redis\6579\redis-server.exe --service-install E:\redis\6579\sentinel.conf --sentinel --service-name sentinel26579 --port 26579
注意: 安装哨兵服务命令中间有个 --sentinel ,如果少了这个,当启动哨兵服务的时候就会启动失败,错误日志信息显示:sentinel directive while not in sentinel mode
安装成功后,可在电脑服务里找到对应服务
- 启动服务命令:
E:\redis\6379\redis-server.exe --service-start --service-name Redis6379
E:\redis\6479\redis-server.exe --service-start --service-name Redis6479
E:\redis\6579\redis-server.exe --service-start --service-name Redis6579
E:\redis\6379\redis-server.exe --service-start --service-name sentinel26379
E:\redis\6479\redis-server.exe --service-start --service-name sentinel26479
E:\redis\6579\redis-server.exe --service-start --service-name sentinel26579
注意:启动的顺序。首先是主机的Redis服务进程,然后启动从机的服务进程,最后启动3个哨兵的服务进程。
边栏推荐
- OnTap 9 file system limitations
- 839. 模拟堆
- Sending and receiving of C serialport
- 【线上问题】Timeout waiting for connection from pool 问题排查
- JVM触发minor gc的条件
- [MySQL] how to execute an SQL statement (2)
- 神经网络与深度学习-6- 支持向量机1 -PyTorch
- Ext4 file system opens dir_ After nlink feature, link_ Use link after count exceeds 65000_ Count=1 means the quantity is unknown
- Object 的Wait Notify NotifyAll 源码解析
- Basic use of ArcGIS 1
猜你喜欢
Basic use of Arc GIS 2
arcgis的基本使用4
【Mysql】redo log,undo log 和binlog详解(四)
Paper notes: knowledge map kgat (unfinished temporary storage)
神经网络与深度学习-6- 支持向量机1 -PyTorch
Study notes of dataX
Polynomial open root
docker配置mysql集群
NTT(快速数论变换)多项式求逆 一千五百字解析
[MySQL] detailed explanation of redo log, undo log and binlog (4)
随机推荐
js中树与数组的相互转化(树的子节点若为空隐藏children字段)
I'm faded
Android implements the caching mechanism and caches multiple data types
Use of off heap memory
opencv图像处理
756. Serpentine matrix
arc-gis的基本使用2
When you click input, the border is not displayed!
字节缓冲流&字符流详解
Cat installation and use
Processing of inconsistent week values obtained by PHP and MySQL
Windows通过命令备份数据库到本地
多项式开根
【Mysql】redo log,undo log 和binlog详解(四)
您的登录IP不在管理员配置的登录掩码范围内
Windows backs up the database locally by command
What are CSDN spaces represented by
Announcement | FISCO bcos v3.0-rc4 is released, and the new Max version can support massive transactions on the chain
对象型的集合按某个属性的值进行去重
LeetCode三数之和问题