Windows中搭建Redis集群
- 从 http://rubyinstaller.org/downloads/ 下载Ruby2.2.5(x64)并安装,安装时勾选添加至路径变量中
- 命令行中执行gem source -a http://gems.ruby-china.org
- 安装ruby的redis支持环境:gem install redis
- 从 https://github.com/MSOpenTech/redis/releases 下载Redis-x64-3.2.100.msi并安装redis
- 拷贝6份Redis安装目录下的redis.windows-service.conf文件依次重命名为redis.windows-service-6380.conf、redis.windows-service-6381.conf、redis.windows-service-6382.conf、redis.windows-service-6383.conf、redis.windows-service-6384.conf、redis.windows-service-6385.conf。依次找出下面的配置,并修改如下(以redis.windows-service-6380.conf为例):
port 6380
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
- 注册Redis为Windows Service,依次执行如下命令(或者保存为批处理脚本执行):
redis-server --service-install redis.windows-service-6380.conf --service-name redis6380
redis-server --service-start --service-name Redis6380
redis-server --service-install redis.windows-service-6381.conf --service-name redis6381
redis-server --service-start --service-name Redis6381
redis-server --service-install redis.windows-service-6382.conf --service-name redis6382
redis-server --service-start --service-name Redis6382
redis-server --service-install redis.windows-service-6383.conf --service-name redis6383
redis-server --service-start --service-name Redis6383
redis-server --service-install redis.windows-service-6384.conf --service-name redis6384
redis-server --service-start --service-name Redis6384
redis-server --service-install redis.windows-service-6385.conf --service-name redis6385
redis-server --service-start --service-name Redis6385
- 创建Redis Cluster,下载 https://raw.githubusercontent.com/MSOpenTech/redis/3.0/src/redis-trib.rb 脚本到Redis安装目录,在命令行执行如下命令:
redis-trib.rb create --replicas 1 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 127.0.0.1:6385
拣尽寒枝不肯栖,寂寞沙洲冷。
郴江幸自绕郴山,为谁流下潇湘去?
欲将心事付瑶琴,知音少,弦断有谁听?
倩何人,唤取红巾翠袖,揾英雄泪!
零落成泥碾作尘,只有香如故!
郴江幸自绕郴山,为谁流下潇湘去?
欲将心事付瑶琴,知音少,弦断有谁听?
倩何人,唤取红巾翠袖,揾英雄泪!
零落成泥碾作尘,只有香如故!