创建cluster目录,在目录下方创建6个文件,分别对应redis的6个服务,从7001-7006
把redis的数据分别复制到这6个文件夹。
分别配置redis的每个配置文件,windows版本的redis,配置文件为 redis.windows.conf,在这个文件里面修改,需要修改的内容为:
cluster-enabled yes
cluster-config-file nodes-7001.conf
cluster-node-timeout 15000
port 7001
配置完成之后,配置一键启动的 bat文件
@echo off
setlocal
set REDIS_HOME=D:\tools\Redis
for /l %%i in (7001,1,7006) do (
start %REDIS_HOME%\%%i\redis-server.exe %REDIS_HOME%\%%i\redis.windows.conf
)
endlocal
redis启动成功执行下面命令,创建集群
.\redis-cli.exe --cluster create 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 127.0.0.1:7006 --cluster-replicas 1
执行完成出现下面结果表示创建成功
Performing Cluster Check (using node 127.0.0.1:7001)
M: 915b3f30b53e499de7e5dd5d62fd35fff2234d95 127.0.0.1:7001
slots:[0-5460] (5461 slots) master
1 additional replica(s)
M: d4ee93144c5c5e4715c50969d4c3dd8da2d439fa 127.0.0.1:7002
slots:[5461-10922] (5462 slots) master
1 additional replica(s)
S: ced9fd56bbd60eb43c67cf163a294e8096e5cc00 127.0.0.1:7004
slots: (0 slots) slave
replicates 915b3f30b53e499de7e5dd5d62fd35fff2234d95
M: 7d599869073cdbbf1569a716d979b97466913f5f 127.0.0.1:7003
slots:[10923-16383] (5461 slots) master
1 additional replica(s)
S: c75e2ecb5d332d6ce255a5af515bba6f01c9ba14 127.0.0.1:7005
slots: (0 slots) slave
replicates d4ee93144c5c5e4715c50969d4c3dd8da2d439fa
S: 725cc07e42e3bfbecebb1eed35498891b7e4f765 127.0.0.1:7006
slots: (0 slots) slave
replicates 7d599869073cdbbf1569a716d979b97466913f5f