当前位置:网站首页>windows下Redis-cluster集群搭建
windows下Redis-cluster集群搭建
2022-07-05 04:26:00 【十一姐】
一、下载安装
需要下载如下三个:
Redis、Ruby语言运行环境、Redis的Ruby驱动redis-3.2.2.gem1、Redis-x64-5.0.14.1.zip 下载, 6 台 redis 服务器,搭建伪集群,并运行在不同的端口 6380-6385

2、Ruby下载,ruby脚本来实现集群搭建,一路next,最后取消勾选,finish,然后cmd里面输出
ruby -v代表安装成功


3、安装Redis的Ruby驱动rubygems下载,是一个用于对 Ruby组件进行打包的 Ruby 打包系统;下载后解压,然后打开命令窗口切换到解压目录中,执行命令
ruby setup.rb

二、搭建Redis集群
要让集群正常运作至少需要3个主节点,建议配置3个主节点,其余3个作为各个主节点的从节点(也是官网推荐的模式),通过同一台电脑不同端口模拟
1、新建一个文件夹Redis-cluster,并将前面下载的
Redis-x64-5.0.14.1.zip进行解压,并将文件夹重命名为6380
2、打开6380目录下的文件
redis.windows.conf,修改里面的端口号port为6380,主要改了如下五处,1. port 6380 //修改为与当前文件夹名字一样的端口号 2. appendonly yes //指定是否在每次更新操作后进行日志记录,Redis在 默认情况下是异步的把数据写入磁盘,如果不开启,可能会在断电时导4. 致一段时间内的数据丢失。 yes表示:存储方式,aof,将写操作记录保存到日志中 3. cluster-enabled yes //开启集群模式 4. cluster-config-file nodes-6380.conf //保存节点配置,自动创建,自动更新(建议命名时加上端口号) 5. cluster-node-timeout 15000 //集群超时时间,节点超过这个时间没反应就断定是宕机
3、在6380目录下新建文件
start.bat,内容如下,用来进入每个端口命名的文件夹下启动服务title redis-6380 redis-server.exe redis.windows.conf
4、复制6380文件夹,并分别重命名为6381-6385,同时修改各自目录下的
redis.windows.con与start.bat文件里面的端口号,将6380替换成对应的6381-6385
5、打开任意cmd窗口执行
gem install redis
6、构建集群脚本,从6380目录下复制粘贴
redis-cli.exe到Redis-cluster目录下,同时6380~6385每个目录下的start.bat文件双击运行并不要关闭!!!

7、然后在当前Redis-cluster目录下打开cmd窗口,执行如下命令,到此集群构建完毕
redis-cli --cluster create 127.0.0.1:6380 127.0.0.1:6381 127.0.0.1:6382 127.0.0.1:6383 127.0.0.1:6384 127.0.0.1:6385 --cluster-replicas 1
三、集群环境测试
- 参考文档
redis-cli -c -h 127.0.0.1 -p 6380- 查看集群信息:
cluster info - 查看主从关系:
info replication, 集群节点按照从主到从的方式从左到右依次排列6个redis 节点,因此也可以看出6380,6381,6382三个是主节点,6383,6384,6385是三个从节点,对应关系是:主6380从6383 - 查看各个节点分配slot:
cluster nodes
四、将redis-cluster注册生windows服务
控制台启动redis server如果控制台关闭了之后redis server也会一同被关闭,那么我们就需要让redis在后台运行需要将redis server注册为windows服务,然后再start
所以我们用如下方式可以解决上面的问题,到6380-6385目录下分别重命名服务,并启动,
请至少保证三个主节点服务已经启动在后台,否则会导致连接上redis-cluster,但是连不上里面的db0# 通过service-name启动redis服务: redis-server --service-install redis.windows.conf --service-name redis6380 --loglevel verbose redis-server --service-start --service-name redis6380 # 通过service-name停止redis服务: redis-server --service-stop --service-name redis6380

如果服务启动失败,以管理员身份打开cmd执行
SC delete 服务名称,然后当对应目录重新建服务
五、打开redis可视化工具,如图连接成功
- 如图,测试连接成功

- 默认是127.0.0.1可以访问,如下修改.conf,可以修改bind指定局域网ip访问,
修改配置后,需要重启服务方可生效

边栏推荐
- American 5g open ran suffered another major setback, and its attempt to counter China's 5g technology has failed
- A application wakes up B should be a fast method
- 概率论与数理统计考试重点复习路线
- Observable time series data downsampling practice in Prometheus
- 指针函数(基础)
- 函数(易错)
- 美国5G Open RAN再遭重大挫败,抗衡中国5G技术的图谋已告失败
- Neural network and deep learning Chapter 1: introduction reading questions
- Neural networks and deep learning Chapter 4: feedforward neural networks reading questions
- 线上故障突突突?如何紧急诊断、排查与恢复
猜你喜欢

About the project error reporting solution of mpaas Pb access mode adapting to 64 bit CPU architecture

About the prompt loading after appscan is opened: guilogic, it keeps loading and gets stuck. My personal solution. (it may be the first solution available in the whole network at present)

Threejs rendering obj+mtl model source code, 3D factory model

函数(易错)

kubernetes集群之调度系统

线上故障突突突?如何紧急诊断、排查与恢复

Sequence diagram of single sign on Certification Center

自动语音识别(ASR)研究综述

CSDN正文自动生成目录

Network layer - forwarding (IP, ARP, DCHP, ICMP, network layer addressing, network address translation)
随机推荐
After the deployment of web resources, the navigator cannot obtain the solution of mediadevices instance (navigator.mediadevices is undefined)
level18
根据入栈顺序判断出栈顺序是否合理
kubernetes集群之调度系统
Common features of ES6
【虚幻引擎UE】打包报错出现!FindPin错误的解决办法
Threejs loads the city obj model, loads the character gltf model, and tweetjs realizes the movement of characters according to the planned route
[illusory engine UE] method to realize close-range rotation of operating objects under fuzzy background and pit recording
Technical tutorial: how to use easydss to push live streaming to qiniu cloud?
OWASP top 10 vulnerability Guide (2021)
MacBook安装postgreSQL+postgis
【UNIAPP】系统热更新实现思路
Managed service network: application architecture evolution in the cloud native Era
What are the building energy-saving software
Live broadcast preview | container service ack elasticity prediction best practice
How to carry out "small step reconstruction"?
This is an age of uncertainty
蛇形矩阵
PR video clip (project packaging)
Key review route of probability theory and mathematical statistics examination