在window下搭建redis 集群

1:下载redis实例并安装https://github.com/MicrosoftArchive/redis/releases2. 下载 RubyInstaller下载地址:http://rubyinstaller.org/downloads/安装时,勾选:(所使用版本rubyinstaller-2.3.1-x64.exe)Ins...

1:下载redis实例并安装
https://github.com/MicrosoftArchive/redis/releases
2. 下载 RubyInstaller
下载地址:http://rubyinstaller.org/downloads/

安装时,勾选:(所使用版本rubyinstaller-2.3.1-x64.exe)

Install Td/Tk Support

Add Ruby executables to your PATH

Associate .rb and .rbw files with this Ruby installation
3. 下载 redis-trib.rb
下载redis 源码 的 src下 redis-trib.rb 文件copy到 redis 目录内
4.下载redis-3.2.1.gem
下载地址 https://rubygems.global.ssl.fastly.net/gems/redis-3.2.1.gem
5.将安装的redis目录复制5分 生成 6个节点
7.替换配置文件

新建记事本修改名称和扩展名:redis.windows-service.conf(注意文件编码要和安装redis后的配置文件编码一致)

编写其下内容(其中在bind是该机IP地址,文件名可改可不改)

绿色字体为开启集群功能

    port 999 #每个节点端口配置不同

    bind 192.168.0.111 #本机IP

    cluster-enabled yes

    cluster-config-file nodes-cache01.conf

    cluster-node-timeout 5000

    appendonly yes

    save 900 1

    save 300 10

    save 60 10000

    dbfilename dump.rdb

    maxmemory 3999mb

替换c:\Redis\ redis.windows-service.conf文件

重启Redis服务(任务管理器中)启动完成会在Redis文件夹下生成appendonly.aof文件和nodes-cache01文件
8.创建集群
启动所有Rredis的客户端
9. 输入命令创建集群

redis-trib.rb create --replicas1 192.168.0.71:999 192.168.0.109:999 192.168.0.148:999 192.168.0.187:999 192.168.0.240:999 192.168.0.25:999

--replicas 1 表示每个主数据库拥有从数据库个数为1。之前遇到错误提示master节点不能少于3个
10.最后测试
命令 redis-cli –c –h ”地址” –p "端口号"

本文标题为:在window下搭建redis 集群

基础教程推荐