window里快速搭建redis集群

Window中的Redis集群搭建

 

 

一、下载并配制redis

redis下载地址   https://github.com/MSOpenTech/redis/releases ;  下载Redis-x64-3.0.5.zip。

 

集群规划有三个节点的集群,每个节点有一主一备。需要6台虚拟机,这里建6个文件,模仿6台虚拟机。

注:redis集群最少得三个节点,三台机器

 

把 redis 解压后,再复制出 5 份,配置 三主三从集群。 由于 redis 默认端口号为 7001,那么其它5份的端口可以为7002,7003,7004,7005,7006。 并且把目录使用端口号命名

把redis主目下的redis.windows.conf 复制到7001文件,修改里面的端口号,并修改对应参数

具体如下

Port 7001

cluster-enabled yes
cluster-config-file nodes-7001.conf
cluster-node-timeout 5000
appendonly yes

 

把修改过的文件复制到其它五个文件里,修改 7001为对应的文件名,如7002、7003.。。。

二、安装ruby

redis的集群使用 ruby脚本编写,所以系统需要有 Ruby 环境 ,

下载地址 http://dl.bintray.com/oneclick/rubyinstaller/:rubyinstaller-2.3.3-x64.exe

 

安装时3个选项都勾选。

三、安装Redis的Ruby驱动redis-xxxx.gem

下载地址 https://rubygems.org/pages/download, 下载后解压,当前目录切换到解压目录中,如 E:\软件\redis\cluster\ruby-gem 然后在命令行执行  ruby setup.rb。

四、安装集群脚本redis-trib

http://download.redis.io/releases/  这里下载对应的redis版本,把redis-trib.rb文件拷贝到redis的解压目录即可

  • 五、启动单个redis节点

 

redis-server.exe ../cluster/7001/redis.windows.conf

用类似方法启动其它五个节点

 

六、创建集群

执行

redis-trib.rb create --replicas 1 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

在出现 Can I set the above configuration? (type 'yes' to accept):   请确定并输入 yes 。

如有以下

 

E:\软件\redis\3.5-64>redis-trib.rb create --replicas 1 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

报错

dos命令窗口执行创建集群命令,出现以下提示:

E:\软件\redis\3.5-64>redis-trib.rb create --replicas 1 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

WARNING: redis-trib.rb is not longer available!

You should use redis-cli instead.

 

All commands and features belonging to redis-trib.rb have been moved

to redis-cli.

In order to use them you should call redis-cli with the --cluster

option followed by the subcommand name, arguments and options.

 

Use the following syntax:

redis-cli --cluster SUBCOMMAND [ARGUMENTS] [OPTIONS]

 

Example:

redis-cli --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

 

To get help about all subcommands, type:

redis-cli --cluster help

 

原因是redis-trib.rb的链接指向官网最新的版本。从对应版本(redis3.0.5即可)的源码压缩包中src文件夹下找到对应的redis-trib.rb文件使用,即可解决问题。

下载redis源码版压缩包:http://download.redis.io/releases/

 

 

七、测试

使用Redis客户端Redis-cli.exe来查看数据记录数,以及集群相关信息

命令 redis-cli –c –h ”地址” –p "端口号" ;  c 表示集群

 

 

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值