創(chuàng)建cluster目錄,在目錄下方創(chuàng)建6個文件淮逊,分別對應redis的6個服務袱耽,從7001-7006
把redis的數(shù)據(jù)分別復制到這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啟動成功執(zhí)行下面命令位衩,創(chuàng)建集群
.\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
執(zhí)行完成出現(xiàn)下面結果表示創(chuàng)建成功
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