ready:
"" Download redis archive Redis-x64-3.2.100.zip, decompression can be used directly, download path:
https://github.com/MSOpenTech/redis/releases/
"" Configuration environment variable
1) Under the new profile directory redis redis.6380.conf, redis.6381.conf, redis.6382.conf, as follows: Note .aof and corresponding .conf file names can not be repeated, otherwise it will lead to Step 8) execution , the emergence of a long wait
port 6380
loglevel notice
logfile "D:/CommonTools/Redis/Logs/redis6380_log.txt"
appendonly yes
appendfilename "appendonly.6380.aof"
cluster-enabled yes
cluster-config-file nodes.6380.conf
cluster-node-timeout 15000
cluster-slave-validity-factor 10
cluster-migration-barrier 1
cluster-require-full-coverage yes
2) D: Logs new directory / CommonTools / Redis / paths, for storing the generated log file
3) Start services over 6380-6382, the command:
redis-server.exe --service-install D:/CommonTools/Redis/redis.6380.conf --service-name redis6380
redis-server.exe --service-install D:/CommonTools/Redis/redis.6381.conf --service-name redis6381
redis-server.exe --service-install D:/CommonTools/Redis/redis.6382.conf --service-name redis6382
4) Check to start the service, the default does not start, then manually start
5) to download and install ruby, download path:
http://dl.bintray.com/oneclick/rubyinstaller/rubyinstaller-2.2.4-x64.exe
double-click to install their own custom installation path (my installation to D: \ CommonTools \ Ruby \) , the installation process can be checked added to the environment variable, the installation is complete to verify ruby --help input window in cmd
6) ruby in redis environment driver download, download path:
https://rubygems.org/gems/redis/versions/3.2.2
downloaded into driver redis-3.2.2.gem Ruby22-x64 installation directory, the installation drive command as follows:
gem install --local D:\CommonTools\Ruby\Ruby22-x64\redis-3.2.2.gem
安装成功如下图
7)下载redis官方提供的创建redis集群的ruby脚本文件redis-trib.rb,下载路径:
https://raw.githubusercontent.com/MSOpenTech/redis/3.0/src/redis-trib.rb
打开后是一个页面,将页面内容保存为redis-trib.rb至Redis目录下,注意文件图标
说明:因为redis-trib.rb是ruby代码,必须用ruby来打开,若redis-trib.rb无法识别,需要手动选择该文件的打开方式,文件图标也会随之变化
8)创建集群,到Redis目录下,使用redis-trib.rb来创建
redis-trib.rb create --replicas 0 127.0.0.1:6380 127.0.0.1:6381 127.0.0.1:6382
中间需要输入一次yes,然后等待join结束
①ctrl+c停止后,检查redis.6380.conf、redis.6381.conf、redis.6382.conf文件内指向的节点文件等是否冲突(重名)
a)如果冲突修改之,然后将redis.6380.conf、redis.6381.conf、redis.6382.conf、redis-trib.rb、Logs文件和文件夹临时转移
b)清除掉redis目录下所有文件或目录,重新解压
c)再将redis.6380.conf、redis.6381.conf、redis.6382.conf、redis-trib.rb、Logs文件和文件夹转移回来
d)重复2)、3)步骤。
e)还是没有解决?尝试在.conf文件中加入一行,示例:bind 192.168.1.100(本地网卡获取的IP,非127.0.0.1),重复以上操作
②进一步的验证见步骤9)
9)验证
输入:redis-trib.rb check 127.0.0.1:6380
打印如下说明创建的redis集群正常
Other operations:
Connecting clusters: redis-cli.exe -c -p 6380 // -c represents a cluster
View Total Records: dbsize // connect
to view cluster information: cluster info // connect
redis clusters password:
Method 1: Modify All documents redis.conf Redis cluster added
masterauth psw123456
requirepass psw123456
need to restart the node
way: entering the various examples set
Redis CLI -C -p-7000
config sET masterauth psw123456
config sET requirepass psw123456
config the rewrite
without rebooting node