Redis集群搭建

Redis集群搭建

1.下载Redis

https://redis.io/download

下载一个稳定(Stable)的版本,解压

2.设置配置文件

打开redis.windows-service.conf修改

bind 127.0.0.1
port 6379
protected-mode yes
requirepass 12345678
masterauth 12345678
daemonize yes
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
appendonly yes

将上述配置一一修改后,然后将所有文件放在6379文件夹中

3.创建多个端口

因为项目需要我部署了6个端口,所以将6379文件夹复制6份,改名成6380,6381,6382,6383,6384方便自己区分。
再分别更改每个文件夹中的redis.windows-service.conf修改port改为6380,6381,6382,6383,6384。

4.创建一个启动文件

Redis目录下创建一个stratall.bat文件,打开修改

cd 6379
del nodes.conf,appendonly.aof
start /b redis-server.exe redis.windows-service.conf
cd ..
cd 6380
del nodes.conf,appendonly.aof
start /b redis-server.exe redis.windows-service.conf
cd ..
cd 6381
del nodes.conf,appendonly.aof
start /b redis-server.exe redis.windows-service.conf
cd ..
cd 6382
del nodes.conf,appendonly.aof
start /b redis-server.exe redis.windows-service.conf
cd ..
cd 6383
del nodes.conf,appendonly.aof
start /b redis-server.exe redis.windows-service.conf
cd ..
cd 6384
del nodes.conf,appendonly.aof
start /b redis-server.exe redis.windows-service.conf
cd ..
ruby redis-trib.rb create –replicas 1 127.0.0.1:6379 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
pause

这个文件此时开启无法运行,我们还需要安装Ruby。

5.安装Ruby

由于Redis的集群使用Ruby脚本编写,所以系统需要有Ruby环境。
http://www.ruby-lang.org/en/downloads/
Stable releases选择一个需要的版本下载解压安装。
安装Ruby

然后我们需要一个Ruby写的集群脚本,打开下面的网站,复制内容,在Redis文件夹下创建一个redis-trib.rb文件,写入刚才复制的内容。
https://raw.githubusercontent.com/antirez/redis/unstable/src/redis-trib.rb
结果如图:文件布置

6.安装Ruby模块

下载地址https://rubygems.org/pages/download,下载后解压,然后在命令行执行

ruby setup.rb

当前目录切换到解压目录中,如 D:\Redis-x64-3.2.100\rubygems-2.6.11,安装后执行

gem install redis

安装服务。

7.启动Redis

启动之前写的startall.bat文件,当屏幕上出现如下提示时输入yes,保持命令行不要关闭。

Can I set the above configuration? (type ‘yes’ to accept):

停止调试,关闭服务的时候直接将命令行叉掉就可以了。

8.资源下载

在这里我将我的Redis配置上传,帮助大家更快的搭建Redis集群环境

https://download.csdn.net/download/demeng33/10319591

知识共享许可协议” style=
本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值