一、软件环境&工具
1、 windows7
2、 Redis-x64-3.2.100.msi 安装包
redis-win-3.2.100.zip代码包
下载地址:https://github.com/MSOpenTech/redis/releases
3、 rubyinstaller-2.3.1-x64.exe
下载地址:http://dl.bintray.com/oneclick/rubyinstaller/
4、 redis-3.2.1.gem
下载地址:http://download.csdn.net/detail/lihcc/8722699
二、软件安装
1、 redis安装
执行Redis-x64-3.2.100.msi,安装到指定目录,为了后面方便操作,安装过程中我们设为E:\redisCluster。
安装完毕后目录下有以为文件:
2、 安装ruby
执行rubyinstaller-2.3.1-x64.exe,默认安装位置为C:\Ruby23-x64,安装过程中运行添加到环境变量。
安装完毕后,在cmd窗口中可以用ruby –v查看版本验证安装。
3、 安装ruby和redis的接口
在cmd窗口中,执行命令gem install –local [your path]/ redis-3.2.1.gem的方式,安装本地gem。
三、部署redis集群
1、 配置redis
在redis安装目录redisCluster下新建6个文件夹,分别命名为7001~7006,然后拷贝redis.windows-service.conf到7001中,修改配置文件中的以下几项:
port 7001 端口
cluster-enabled yes 允许集群
cluster-config-file nodes-7001.conf 配置文件
cluster-node-timeout 15000 超时时间
appendonly yes 立即存储
appendfilename "appendonly-7001.aof" 持久化文件
logfile "server_log_7001.txt" 日志文件
然后拷贝到其他几个文件夹,分别修改端口及配置文件。
2、启动redis
启动redis的6个节点,在cmd窗口中,进入redisCluster目录。启动方式:
后台模式:
start /b redis-server.exe 7001/redis-nodes-7001.conf
安装服务模式:
redis-server.exe --service-install --service-name redis7001 7001/redis-nodes-7001.conf
3、部署集群
redis-win-3.2.100.zip解压后,在src目录下有redis-trib.rb文件,拷贝到redisCluster目录,在cmd窗口中执行
redis-trib.rb create --replicas 1192.168.102.46:7001 192.168.102.46:7002 192.168.102.46:7003 192.168.102.46:7004192.168.102.46:7005 192.168.102.46:7006
检查集群:
redis-trib.rb check 192.168.102.46:7001
redis-trib.rb info 192.168.102.46:7001