Windows下搭建redis3.2.100集群

xingyun86 2019-11-10 2279

1.下载redis3.2.100的windows版本

https://github.com/microsoftarchive/redis/releases/download/win-3.2.100/Redis-x64-3.2.100.zip

首先:解压到D:\redis-cluster\目录下

然后:在D:\redis-cluster\目录下创建六个文件夹:mkdir 7000 7001 7002 7003 7004 7005,解压Redis-x64-3.2.100.zip解压到D:\redis-cluster\下的六个文件夹下

2.下载ruby工具

https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.5-1/rubyinstaller-2.6.5-1-x64.7z

解压安装到D:\rubyinstaller-2.6.5-1-x64\目录下

设置系统环境变量:PATH=%PATH%;D:\rubyinstaller-2.6.5-1-x64\

3.下载redis的ruby脚本

cmd命令行执行:gem install redis --version 4.1.3

4.下载redis-trib.rb

https://github.com/microsoftarchive/redis/blob/3.2/src/redis-trib.rb

下载到D:\redis-cluster\目录下

5.修改redis集群配置脚本

D:\redis-cluster\目录下的7000 7001 7002 7003 7004 7005六个目录下的redis.windows.conf修改为node.conf:

bind 127.0.0.1
port 7000 (当前目录的号码)
appendonly yes
cluster-enabled ye
cluster-config-file nodes-7000.conf
cluster-node-timeout 15000

6.修改redis启动脚本

D:\redis-cluster\目录的7000 7001 7002 7003 7004 7005六个目录下分别创建start.bat和stop.bat:

start.bat

@ECHO OFF
CD /D %~dp0
SET NAME=7000
TITLE %NAME%
@ECHO ON

NET STOP redis_server_%NAME%

redis-server.exe --service-uninstall --service-name redis_server_%NAME%

SC DELETE redis_server_%NAME%

redis-server.exe --service-install "%CD%\node.conf" --service-name redis_server_%NAME%

SC DESCRIPTION redis_server_%NAME% redis_server_%NAME%

NET START redis_server_%NAME%

@REM NET STOP redis_server_%NAME%
@REM SC DELETE redis_server_%NAME%
@REM redis-server.exe --service-uninstall --service-name redis_server_%NAME%
EXIT

stop.bat

@ECHO OFF
SET NAME=7000
TITLE %NAME%
CD /D %~dp0
@ECHO ON
redis-server.exe --service-uninstall --service-name redis_server_%NAME%
SC DELETE redis_server_%NAME%
NET STOP redis_server_%NAME%
EXIT

7.redis集群一键启动脚本创建

D:\redis-cluster\目录的cluster-create.bat、cluster-start.bat、cluster-stop.bat:

cluster-create.bat

@ECHO OFF
CD /D %~dp0
@REM gem uninstall redis
@REM choice /t 10 /d y /n >nul
@REM gem install redis --version 3.2.0
@REM choice /t 10 /d y /n >nul
SET HOST=127.0.0.1
ruby redis-trib.rb create --replicas 1 %HOST%:7000 %HOST%:7001 %HOST%:7002 %HOST%:7003 %HOST%:7004 %HOST%:7005

@ECHO ON

cluster-start.bat

@ECHO OFF
CD /D %~dp0
SET ROOT=%CD%
@ECHO ON
SET NAME=7000
START %ROOT%\%NAME%\start.bat
SET NAME=7001
START %ROOT%\%NAME%\start.bat
SET NAME=7002
START %ROOT%\%NAME%\start.bat
CD /D %ROOT%
SET NAME=7003
START %ROOT%\%NAME%\start.bat
CD /D %ROOT%
SET NAME=7004
START %ROOT%\%NAME%\start.bat
SET NAME=7005
START %ROOT%\%NAME%\start.bat

@ECHO &PAUSE

cluster-stop.bat

@ECHO OFF
SET ROOT=%~dp0
@ECHO ON
SET NAME=7000
@ECHO "%ROOT%%NAME%\stop.bat"
%COMSPEC% /C START %ROOT%%NAME%\stop.bat
SET NAME=7001
@ECHO "%ROOT%%NAME%\stop.bat"
%COMSPEC% /C START %ROOT%%NAME%\stop.bat
SET NAME=7002
@ECHO "%ROOT%%NAME%\stop.bat"
%COMSPEC% /C START %ROOT%%NAME%\stop.bat
SET NAME=7003
@ECHO "%ROOT%%NAME%\stop.bat"
%COMSPEC% /C START %ROOT%%NAME%\stop.bat
SET NAME=7004
@ECHO "%ROOT%%NAME%\stop.bat"
%COMSPEC% /C START %ROOT%%NAME%\stop.bat
SET NAME=7005
@ECHO "%ROOT%%NAME%\stop.bat"
%COMSPEC% /C START %ROOT%%NAME%\stop.bat

CHOICE /T 5 /D Y /N>NUL

DEL /S /Q dump.rdb
DEL /S /Q appendonly.aof
DEL /S /Q cluster-nodes.conf

@ECHO &PAUSE

7.启动步骤:

7.1 右键管理员权限启动cluster-start.bat

7.2 右键管理员权限启动cluster-create.bat


备注:

附件是已经创建好的文件结构,解压运行即可完成。

https://github.com/microsoftarchive/redis/releases/download/win-3.2.100/Redis-x64-3.2.100.zip

分别解压在:

Redis-x64-3.2.100-cluster目录下

Redis-x64-3.2.100-cluster\7000目录下

Redis-x64-3.2.100-cluster\7001目录下

Redis-x64-3.2.100-cluster\7002目录下

Redis-x64-3.2.100-cluster\7003目录下

Redis-x64-3.2.100-cluster\7004目录下

Redis-x64-3.2.100-cluster\7005目录下

上传的附件:
×
打赏作者
最新回复 (0)
只看楼主
全部楼主
返回