美文网首页
Redis-学习之旅(13)-redis-集群的配置过程

Redis-学习之旅(13)-redis-集群的配置过程

作者: William_Wei007 | 来源:发表于2018-09-20 15:58 被阅读8次

1. 首先还是安装redis

参见系列文章(一) redis的安装

2. 开始创建集群

  1. 新建集群文件夹
位置按照自己习惯来弄:我是都放在了/usr/local/..下面了

    mkdir redis_cluster

    cd redis_cluster

    mkdir 7000 7001 7002 7003 7004 7005 


[root@xxx redis_cluster]# ll
总用量 24
drwxr-xr-x 2 root root 4096 9月  20 12:01 7000
drwxr-xr-x 2 root root 4096 9月  20 13:52 7001
drwxr-xr-x 2 root root 4096 9月  20 13:53 7002
drwxr-xr-x 2 root root 4096 9月  20 14:03 7003
drwxr-xr-x 2 root root 4096 9月  20 13:55 7004
drwxr-xr-x 2 root root 4096 9月  20 13:56 7005

  1. 然后将redis.conf分别拷贝到 :文件7000 至 7005文件夹中,并修改相应配置

7000

port  7000                  //端口7000,7002,7003        
bind 本机ip                  //默认ip为127.0.0.1 需要改为其他节点机器可访问的ip 否则创建集群时无法访问对应的端口,无法创建集群
daemonize    yes                       //redis后台运行
pidfile  /var/run/redis_7000.pid       //pidfile文件对应7000,7001,7002
cluster-enabled  yes             //开启集群  把注释#去掉
cluster-config-file  nodes_7000.conf      //集群的配置  配置文件首次启动自动生成 7000,7001,7002
cluster-node-timeout  15000          //请求超时  默认15秒,可自行设置
appendonly  yes                //aof日志开启  有需要就开启,它会每次写操作都记录一条日志

7001

port  7001                  //端口7000,7002,7003        
bind 本机ip                  //默认ip为127.0.0.1 需要改为其他节点机器可访问的ip 否则创建集群时无法访问对应的端口,无法创建集群
daemonize    yes                       //redis后台运行
pidfile  /var/run/redis_7001.pid       //pidfile文件对应7000,7001,7002
cluster-enabled  yes             //开启集群  把注释#去掉
cluster-config-file  nodes_7001.conf      //集群的配置  配置文件首次启动自动生成 7000,7001,7002
cluster-node-timeout  15000          //请求超时  默认15秒,可自行设置
appendonly  yes                //aof日志开启  有需要就开启,它会每次写操作都记录一条日志

7002~7005 同上配置,端口修改一下就可以。

  1. 启动各个节点
[root@xxxx bin]# ./redis-server ../../redis_cluster/7002/redis.conf 
24719:C 20 Sep 13:59:39.289 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
24719:C 20 Sep 13:59:39.289 # Redis version=4.0.2, bits=64, commit=00000000, modified=0, pid=24719, just started
24719:C 20 Sep 13:59:39.289 # Configuration loaded

7000

7001  

7003  

7004

7005

启动节点.png
  1. 创建集群

我们在安装redis,解压之后,将会在src中发现一个执行文件 “redis-trib.rb” 此处就会用到了。

./redis-trib.rb create --replicas 1 127.0.0.1:7000 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


由于我的机器内没有安装ruby相关,所以此处报错了

/usr/bin/env: ruby: 没有那个文件或目录

所以需要安装ruby相关的插件等

  执行命令  yum install ruby ruby-dev rubygems
  
  [root@xxx local]# yum install ruby ruby-dev rubygems
已加载插件:fastestmirror
base                                                                                                              | 3.6 kB  00:00:00     
epel                                                                                                              | 3.2 kB  00:00:00     
extras                                                                                                            | 3.4 kB  00:00:00     
mongodb-org-3.4                                                                                                   | 2.5 kB  00:00:00     
updates                                                                                                           | 3.4 kB  00:00:00     
(1/2): epel/x86_64/primary                                                                                        | 3.6 MB  00:00:00     
(2/2): epel/x86_64/updateinfo                                                                                     | 945 kB  00:00:00     
Loading mirror speeds from cached hostfile
epel                                                                                                                         12685/12685
没有可用软件包 ruby-dev。
正在解决依赖关系
--> 正在检查事务
---> 软件包 ruby.x86_64.0.2.0.0.648-33.el7_4 将被 安装
--> 正在处理依赖关系 ruby-libs(x86-64) = 2.0.0.648-33.el7_4,它被软件包 ruby-2.0.0.648-33.el7_4.x86_64 需要
--> 正在处理依赖关系 rubygem(bigdecimal) >= 1.2.0,它被软件包 ruby-2.0.0.648-33.el7_4.x86_64 需要
--> 正在处理依赖关系 libruby.so.2.0()(64bit),它被软件包 ruby-2.0.0.648-33.el7_4.x86_64 需要
---> 软件包 rubygems.noarch.0.2.0.14.1-33.el7_4 将被 安装
--> 正在处理依赖关系 rubygem(rdoc) >= 4.0.0,它被软件包 rubygems-2.0.14.1-33.el7_4.noarch 需要
--> 正在处理依赖关系 rubygem(psych) >= 2.0.0,它被软件包 rubygems-2.0.14.1-33.el7_4.noarch 需要
--> 正在处理依赖关系 rubygem(io-console) >= 0.4.2,它被软件包 rubygems-2.0.14.1-33.el7_4.noarch 需要
--> 正在检查事务
---> 软件包 ruby-libs.x86_64.0.2.0.0.648-33.el7_4 将被 安装
---> 软件包 rubygem-bigdecimal.x86_64.0.1.2.0-33.el7_4 将被 安装
---> 软件包 rubygem-io-console.x86_64.0.0.4.2-33.el7_4 将被 安装
---> 软件包 rubygem-psych.x86_64.0.2.0.0-33.el7_4 将被 安装
--> 正在处理依赖关系 libyaml-0.so.2()(64bit),它被软件包 rubygem-psych-2.0.0-33.el7_4.x86_64 需要
---> 软件包 rubygem-rdoc.noarch.0.4.0.0-33.el7_4 将被 安装
--> 正在处理依赖关系 ruby(irb) = 2.0.0.648,它被软件包 rubygem-rdoc-4.0.0-33.el7_4.noarch 需要
--> 正在处理依赖关系 rubygem(json) >= 1.7.7,它被软件包 rubygem-rdoc-4.0.0-33.el7_4.noarch 需要
--> 正在检查事务
---> 软件包 libyaml.x86_64.0.0.1.4-11.el7_0 将被 安装
---> 软件包 ruby-irb.noarch.0.2.0.0.648-33.el7_4 将被 安装
---> 软件包 rubygem-json.x86_64.0.1.7.7-33.el7_4 将被 安装
--> 解决依赖关系完成

依赖关系解决

=========================================================================================================================================
 Package                                架构                       版本                                   源                        大小
=========================================================================================================================================
正在安装:
 ruby                                   x86_64                     2.0.0.648-33.el7_4                     base                      71 k
 rubygems                               noarch                     2.0.14.1-33.el7_4                      base                     219 k
为依赖而安装:
 libyaml                                x86_64                     0.1.4-11.el7_0                         base                      55 k
 ruby-irb                               noarch                     2.0.0.648-33.el7_4                     base                      92 k
 ruby-libs                              x86_64                     2.0.0.648-33.el7_4                     base                     2.8 M
 rubygem-bigdecimal                     x86_64                     1.2.0-33.el7_4                         base                      83 k
 rubygem-io-console                     x86_64                     0.4.2-33.el7_4                         base                      54 k
 rubygem-json                           x86_64                     1.7.7-33.el7_4                         base                      79 k
 rubygem-psych                          x86_64                     2.0.0-33.el7_4                         base                      82 k
 rubygem-rdoc                           noarch                     4.0.0-33.el7_4                         base                     322 k

事务概要
=========================================================================================================================================
安装  2 软件包 (+8 依赖软件包)

总下载量:3.8 M
安装大小:13 M
Is this ok [y/d/N]: y
Downloading packages:
(1/10): libyaml-0.1.4-11.el7_0.x86_64.rpm                                                                         |  55 kB  00:00:00     
(2/10): ruby-irb-2.0.0.648-33.el7_4.noarch.rpm                                                                    |  92 kB  00:00:00     
(3/10): ruby-2.0.0.648-33.el7_4.x86_64.rpm                                                                        |  71 kB  00:00:00     
(4/10): rubygem-bigdecimal-1.2.0-33.el7_4.x86_64.rpm                                                              |  83 kB  00:00:00     
(5/10): rubygem-io-console-0.4.2-33.el7_4.x86_64.rpm                                                              |  54 kB  00:00:00     
(6/10): rubygem-json-1.7.7-33.el7_4.x86_64.rpm                                                                    |  79 kB  00:00:00     
(7/10): rubygem-psych-2.0.0-33.el7_4.x86_64.rpm                                                                   |  82 kB  00:00:00     
(8/10): ruby-libs-2.0.0.648-33.el7_4.x86_64.rpm                                                                   | 2.8 MB  00:00:00     
(9/10): rubygem-rdoc-4.0.0-33.el7_4.noarch.rpm                                                                    | 322 kB  00:00:00     
(10/10): rubygems-2.0.14.1-33.el7_4.noarch.rpm                                                                    | 219 kB  00:00:00     
-----------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                      11 MB/s | 3.8 MB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : ruby-libs-2.0.0.648-33.el7_4.x86_64                                                                                 1/10 
  正在安装    : libyaml-0.1.4-11.el7_0.x86_64                                                                                       2/10 
  正在安装    : rubygem-bigdecimal-1.2.0-33.el7_4.x86_64                                                                            3/10 
  正在安装    : rubygem-json-1.7.7-33.el7_4.x86_64                                                                                  4/10 
  正在安装    : rubygem-psych-2.0.0-33.el7_4.x86_64                                                                                 5/10 
  正在安装    : rubygem-io-console-0.4.2-33.el7_4.x86_64                                                                            6/10 
  正在安装    : rubygems-2.0.14.1-33.el7_4.noarch                                                                                   7/10 
  正在安装    : ruby-2.0.0.648-33.el7_4.x86_64                                                                                      8/10 
  正在安装    : ruby-irb-2.0.0.648-33.el7_4.noarch                                                                                  9/10 
  正在安装    : rubygem-rdoc-4.0.0-33.el7_4.noarch                                                                                 10/10 
  验证中      : ruby-2.0.0.648-33.el7_4.x86_64                                                                                      1/10 
  验证中      : ruby-libs-2.0.0.648-33.el7_4.x86_64                                                                                 2/10 
  验证中      : rubygem-bigdecimal-1.2.0-33.el7_4.x86_64                                                                            3/10 
  验证中      : rubygems-2.0.14.1-33.el7_4.noarch                                                                                   4/10 
  验证中      : rubygem-json-1.7.7-33.el7_4.x86_64                                                                                  5/10 
  验证中      : rubygem-rdoc-4.0.0-33.el7_4.noarch                                                                                  6/10 
  验证中      : libyaml-0.1.4-11.el7_0.x86_64                                                                                       7/10 
  验证中      : rubygem-psych-2.0.0-33.el7_4.x86_64                                                                                 8/10 
  验证中      : rubygem-io-console-0.4.2-33.el7_4.x86_64                                                                            9/10 
  验证中      : ruby-irb-2.0.0.648-33.el7_4.noarch                                                                                 10/10 

已安装:
  ruby.x86_64 0:2.0.0.648-33.el7_4                                  rubygems.noarch 0:2.0.14.1-33.el7_4                                 

作为依赖被安装:
  libyaml.x86_64 0:0.1.4-11.el7_0                ruby-irb.noarch 0:2.0.0.648-33.el7_4           ruby-libs.x86_64 0:2.0.0.648-33.el7_4    
  rubygem-bigdecimal.x86_64 0:1.2.0-33.el7_4     rubygem-io-console.x86_64 0:0.4.2-33.el7_4     rubygem-json.x86_64 0:1.7.7-33.el7_4     
  rubygem-psych.x86_64 0:2.0.0-33.el7_4          rubygem-rdoc.noarch 0:4.0.0-33.el7_4          

完毕!

以上 ruby 安装成功。

  1. 创建集群 ruby 依赖 :

redis集群安装需要通过gem install redis来安装相关依赖

[root@iZ2ze6j9cwd5tl65vsk5wqZ local]# gem install redis



Fetching: redis-4.0.2.gem (100%)
ERROR:  Error installing redis:
    redis requires Ruby version >= 2.2.2.
    
发现报错了   

这句话的意思是,安装redis需要ruby版本最低是2.2.2,而centos yum库中ruby版本支持到2.0.0。所以,无法满足需求。

如何解决呢,执行下面步骤:

安装RVM

(1) 开始安装

执行命令: gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

[root@iZ2ze6j9cwd5tl65vsk5wqZ bin]#  gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB 
gpg: 已创建目录‘/root/.gnupg’
gpg: 新的配置文件‘/root/.gnupg/gpg.conf’已建立
gpg: 警告:在‘/root/.gnupg/gpg.conf’里的选项于此次运行期间未被使用
gpg: 钥匙环‘/root/.gnupg/secring.gpg’已建立
gpg: 钥匙环‘/root/.gnupg/pubring.gpg’已建立
gpg: 下载密钥‘D39DC0E3’,从 hkp 服务器 keys.gnupg.net
gpg: 下载密钥‘39499BDB’,从 hkp 服务器 keys.gnupg.net
gpg: /root/.gnupg/trustdb.gpg:建立了信任度数据库
gpg: 密钥 D39DC0E3:公钥“Michal Papis (RVM signing) <mpapis@gmail.com>”已导入
gpg: 密钥 39499BDB:公钥“Piotr Kuczynski <piotr.kuczynski@gmail.com>”已导入
gpg: 没有找到任何绝对信任的密钥
gpg: 合计被处理的数量:2
gpg:           已导入:2  (RSA: 2)


执行命令:curl -sSL https://get.rvm.io | bash -s stable
[root@xxx bin]# curl -sSL https://get.rvm.io | bash -s stable
Downloading https://github.com/rvm/rvm/archive/1.29.4.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.4/1.29.4.tar.gz.asc
gpg: 于 2018年07月02日 星期一 03时41分26秒 CST 创建的签名,使用 RSA,钥匙号 BF04FF17
gpg: 完好的签名,来自于“Michal Papis (RVM signing) <mpapis@gmail.com>”
gpg:               亦即“Michal Papis <michal.papis@toptal.com>”
gpg:               亦即“[jpeg image of size 5015]”
gpg: 警告:这把密钥未经受信任的签名认证!
gpg:       没有证据表明这个签名属于它所声称的持有者。
主钥指纹: 409B 6B17 96C2 7546 2A17  0311 3804 BB82 D39D C0E3
子钥指纹: 62C9 E5F4 DA30 0D94 AC36  166B E206 C29F BF04 FF17
GPG verified '/usr/local/rvm/archives/rvm-1.29.4.tgz'
Creating group 'rvm'
Installing RVM to /usr/local/rvm/
Installation of RVM in /usr/local/rvm/ is almost complete:

  * First you need to add all users that will be using rvm to 'rvm' group,
    and logout - login again, anyone using rvm will be operating with `umask u=rwx,g=rwx,o=rx`.

  * To start using RVM you need to run `source /etc/profile.d/rvm.sh`
    in all your open shell windows, in rare cases you need to reopen all shell windows.
  * Please do NOT forget to add your users to the rvm group.
     The installer no longer auto-adds root or users to the rvm group. Admins must do this.
     Also, please note that group memberships are ONLY evaluated at login time.
     This means that users must log out then back in before group membership takes effect!
 

(2)、使 配置 生效

    source /usr/local/rvm/scripts/rvm

(3)查看 rvm 的提供的版本"rvm list known"

    rvm list known

(4)执行安装命令 "rvm install 2.4.1"

[root@xxxx bin]# rvm install 2.4.1
Searching for binary rubies, this might take some time.
Found remote file https://rvm_io.global.ssl.fastly.net/binaries/centos/7/x86_64/ruby-2.4.1.tar.bz2
Checking requirements for centos.
Installing requirements for centos.
Installing required packages: libffi-devel, sqlite-devel.....
Requirements installation successful.
ruby-2.4.1 - #configure
ruby-2.4.1 - #download
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 14.1M  100 14.1M    0     0  76652      0  0:03:12  0:03:12 --:--:-- 77939
No checksum for downloaded archive, recording checksum in user configuration.
ruby-2.4.1 - #validate archive
ruby-2.4.1 - #extract
ruby-2.4.1 - #validate binary
ruby-2.4.1 - #setup
ruby-2.4.1 - #gemset created /usr/local/rvm/gems/ruby-2.4.1@global
ruby-2.4.1 - #importing gemset /usr/local/rvm/gemsets/global.gems.............................................
ruby-2.4.1 - #generating global wrappers.......
ruby-2.4.1 - #gemset created /usr/local/rvm/gems/ruby-2.4.1
ruby-2.4.1 - #importing gemsetfile /usr/local/rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.4.1 - #generating default wrappers.......

(5)可以查看一下ruby的版本

[root@xxxx bin]# ruby --version
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]

(6)此时再次创建集群 ruby 依赖 (安装redis-ruby):

[root@xxxx bin]# gem install redis
Fetching: redis-4.0.2.gem (100%)
Successfully installed redis-4.0.2
Parsing documentation for redis-4.0.2
Installing ri documentation for redis-4.0.2
Done installing documentation for redis after 1 seconds
1 gem installed

成功了

此时我们可以创建集群了。

[root@xxxx bin]# ./redis-trib.rb create --replicas 1 127.0.0.1:7000 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
>>> Creating cluster
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
127.0.0.1:7000
127.0.0.1:7001
127.0.0.1:7002
Adding replica 127.0.0.1:7003 to 127.0.0.1:7000
Adding replica 127.0.0.1:7004 to 127.0.0.1:7001
Adding replica 127.0.0.1:7005 to 127.0.0.1:7002
M: a238ae59122936cb222861aaa6d8a85ead97d477 127.0.0.1:7000
   slots:0-5460 (5461 slots) master
M: e9590dfd0a89d8b9d3cf8b50521cfd39632382af 127.0.0.1:7001
   slots:5461-10922 (5462 slots) master
M: 86f8ae4d7f645b2f40d6823ccb8df7b283a3929d 127.0.0.1:7002
   slots:10923-16383 (5461 slots) master
S: 94e8b56a10460238a7bf859f5e59ecb10abf0260 127.0.0.1:7003
   replicates a238ae59122936cb222861aaa6d8a85ead97d477
S: e17f4209c42d708931748dc8418bac57ef36ebc0 127.0.0.1:7004
   replicates e9590dfd0a89d8b9d3cf8b50521cfd39632382af
S: 6edcc2f984cffbeac80698412a23403369e46f53 127.0.0.1:7005
   replicates 86f8ae4d7f645b2f40d6823ccb8df7b283a3929d
   

创建成功 标志

命令的意义如下:

给定 redis-trib.rb 程序的命令是 create , 这表示我们希望创建一个新的集群。
选项 --replicas 1 表示我们希望为集群中的每个主节点创建一个从节点。
之后跟着的其他参数则是实例的地址列表, 我们希望程序使用这些地址所指示的实例来创建新集群。

简单来说, 以上命令的意思就是让 redis-trib 程序创建一个包含三个主节点和三个从节点的集群。

1.png

接着,redis-trib 会打印出一份预想中的配置给你看, 如果觉得没问题的话, 就可以输入 yes , redis-trib 就会将这份配置应用到集群当中:

Can I set the above configuration? (type 'yes' to accept): yes
>>> Nodes configuration updated
>>> Assign a different config epoch to each node
>>> Sending CLUSTER MEET messages to join the cluster
Waiting for the cluster to join....
>>> Performing Cluster Check (using node 127.0.0.1:7000)
M: a238ae59122936cb222861aaa6d8a85ead97d477 127.0.0.1:7000
   slots:0-5460 (5461 slots) master
   1 additional replica(s)
M: e9590dfd0a89d8b9d3cf8b50521cfd39632382af 127.0.0.1:7001
   slots:5461-10922 (5462 slots) master
   1 additional replica(s)
S: 94e8b56a10460238a7bf859f5e59ecb10abf0260 127.0.0.1:7003
   slots: (0 slots) slave
   replicates a238ae59122936cb222861aaa6d8a85ead97d477
M: 86f8ae4d7f645b2f40d6823ccb8df7b283a3929d 127.0.0.1:7002
   slots:10923-16383 (5461 slots) master
   1 additional replica(s)
S: e17f4209c42d708931748dc8418bac57ef36ebc0 127.0.0.1:7004
   slots: (0 slots) slave
   replicates e9590dfd0a89d8b9d3cf8b50521cfd39632382af
S: 6edcc2f984cffbeac80698412a23403369e46f53 127.0.0.1:7005
   slots: (0 slots) slave
   replicates 86f8ae4d7f645b2f40d6823ccb8df7b283a3929d
[OK] All nodes agree about slots configuration.

如果一切正常的话, redis-trib 将输出以下信息:

>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

这表示集群中的 16384 个槽都有至少一个主节点在处理, 集群运作正常。

3、LAST:集群结果测试:

启动集群客户端:

  ./redis-server -c - p 端口
  
  
  ./redis-cli -c -p 7000
    ....
  ./redis-cli -c -p 7005  
  
 

查看启动的redis 相关的线程

  [root@iZ2ze6j9cwd5tl65vsk5wqZ redis_cluster]# ps -ef| grep redis
root     24715     1  0 13:59 ?        00:00:04 ./redis-server 127.0.0.1:7002 [cluster]
root     24790     1  0 14:01 ?        00:00:04 ./redis-server 127.0.0.1:7001 [cluster]
root     24796     1  0 14:01 ?        00:00:04 ./redis-server 127.0.0.1:7004 [cluster]
root     24801     1  0 14:01 ?        00:00:04 ./redis-server 127.0.0.1:7005 [cluster]
root     24849     1  0 14:03 ?        00:00:04 ./redis-server 127.0.0.1:7003 [cluster]
root     29827     1  0 14:32 ?        00:00:03 ./redis-server 127.0.0.1:7000 [cluster]
root     31045 29894  0 15:30 pts/8    00:00:00 ./redis-cli -c -p 7005
root     31214 29485  0 15:39 pts/6    00:00:00 ./redis-cli -c -p 7004
root     31215 29220  0 15:39 pts/0    00:00:00 ./redis-cli -c -p 7001
root     31218 21900  0 15:39 pts/1    00:00:00 ./redis-cli -c -p 7000
root     31221 29363  0 15:39 pts/5    00:00:00 ./redis-cli -c -p 7002
root     31242 22009  0 15:40 pts/4    00:00:00 ./redis-cli -c -p 7003
root     31244 24696  0 15:40 pts/3    00:00:00 grep --color=auto redis
  

可以看到5个服务端节点、5个客户端节点

在任意一个节点客户以输入redis 相关命令;

在从节点执行

127.0.0.1:7004> set key7004 value7004
-> Redirected to slot [6901] located at 127.0.0.1:7001
OK

这个时候 会指向它对应的主槽(这个概念还不知道问啥)

127.0.0.1:7001> get key7004
"value7004"

在自己的节点查询可以正常展示,我们去别的节点看看。 

在 7000 节点 查看
127.0.0.1:7000> get key7004
-> Redirected to slot [6901] located at 127.0.0.1:7001
"value7004"
127.0.0.1:7001> 

依然可以正常获取key7004 对应的value , 此时执行的节点指向了7001主(7004从)


验证完成。。。

Other

cluster nodes 命令可以查看当前的集群节点

127.0.0.1:7005> cluster nodes
94e8b56a10460238a7bf859f5e59ecb10abf0260 127.0.0.1:7003@17003 master - 0 1537428648000 7 connected 0-5460
e17f4209c42d708931748dc8418bac57ef36ebc0 127.0.0.1:7004@17004 slave e9590dfd0a89d8b9d3cf8b50521cfd39632382af 0 1537428650748 5 connected
86f8ae4d7f645b2f40d6823ccb8df7b283a3929d 127.0.0.1:7002@17002 master - 0 1537428649746 3 connected 10923-16383
e9590dfd0a89d8b9d3cf8b50521cfd39632382af 127.0.0.1:7001@17001 master - 0 1537428649000 2 connected 5461-10922
a238ae59122936cb222861aaa6d8a85ead97d477 127.0.0.1:7000@17000 slave 94e8b56a10460238a7bf859f5e59ecb10abf0260 0 1537428648000 7 connected
6edcc2f984cffbeac80698412a23403369e46f53 127.0.0.1:7005@17005 myself,slave 86f8ae4d7f645b2f40d6823ccb8df7b283a3929d 0 1537428648000 6 connected


参考资料:
1、 redis-集群安装: https://blog.csdn.net/xx123698/article/details/53396921
2、执行 gem install redis 命令出错: http://www.cnblogs.com/PatrickLiu/p/8454579.html

  gem install redis  
  出现 ERROR:  Error installing redis:
     redis requires Ruby version >= 2.2.2. 错误的时候:

相关文章

  • Redis-学习之旅(13)-redis-集群的配置过程

    1. 首先还是安装redis 参见系列文章(一) redis的安装 2. 开始创建集群 新建集群文件夹 然后将...

  • springboot 集成culster-redis集群 doc

    doker搭建redis- culster集群 下载doker等过程不再介绍 本文搭建环境是mac os 与cen...

  • redis-集群

    redis3.0版本开始支持集群功能,当我第一次学习它的时候,感觉它是我看到的第一个智能系统,后来发现很多同学的吐...

  • Redis-集群

    演变过程:单机-主从-哨兵(解决主机宕机问题)-cluster(解决故障转移时系统无法使用问题) 主从模式 在 R...

  • Redis-集群

    集群 by shihang.mai redis单节点 AKF分析 主备:client只能访问主,master挂了,...

  • Redis-集群

    哈希槽Redis集群没有采用一致性hash,而是引入了哈希槽的概念。Redis集群有16384个哈希槽,每个key...

  • 使用过Redis,我竟然还不知道Rdb

    使用过Redis,那就先说说使用过那些场景吧 字符串缓存 //举例$redis->set();$redis->ge...

  • Redis学习之路(12)- 杂记

    Redis-过期删除策略 Redis-删除策略: 1、定时删除:对内存友好, 但是占用cpu 2、惰性删除:对cp...

  • redis  操作相关

    $redis = new Redis(); $redis->connect('127.0.0.1',6379); ...

  • redis-配置

    1.设置监听外部ip 在配置文件中,更改配置为bind 0.0.0.0 2.设置密码 配置 ,requirepas...

网友评论

      本文标题:Redis-学习之旅(13)-redis-集群的配置过程

      本文链接:https://www.haomeiwen.com/subject/wbrnnftx.html