一、 呼唤集群
Why?
QPS = 执行10w次命令 / S
并发量:OPS
数据量:“大数据”
Redis Cluster is released in 2015 Redis3.0 version
二、 数据分区 方式对比
分布式数据库 - 数据分区 顺序分布-哈希分布对比图 数据分布对比图1. 哈希分布
1)节点取余分区
节点取余 3个节点的Redis集群 3个节点 -> 4个节点,key数据所在节点发生变化而迁移 翻倍扩容:扩容后的节点数是原来节点的倍数对节点的key进行hash运算然后 %3取余
第一个分区:余数 = 0
第二个分区:余数 = 1
第三个分区:余数 = 2
总结:
(1)客户端分配:哈希 + 取余
(2)节点伸缩:数据节点关系变化,导致数据迁移
(3)迁移数量和添加节点数量有关,建议翻倍扩容
(4)不建议使用这种,较古老
2) 一致性哈希分区(对节点取余分区的优化)
在token值闭环中顺时针找最近的节点 无法将Redis中的数据迁移到node5,只能从DB中再查一次。数据只会影响node1和node2之间的原数据,不会影响其他节点间的数据,适合节点多的情况总结:
(1)客户端分片:哈希 + 顺时针(优化取余)
(2)节点伸缩:只影响临近节点,但还是有数据迁移
(3)翻倍伸缩:保证最小迁移数据和负载均衡:每个相邻节点间都塞一个新节点
3) 虚拟槽分区(Redis Cluster使用的分区方式)
(1)预设虚拟槽:每个槽映射一个数据子集,一般比节点数大
(2)良好的哈希函数:例如CRC16
(3)服务端管理节点、槽、数据:例如Redis Cluster
- 槽范围0 ~ 16383,有5个node节平均分配槽
- 使用CRC16哈希算法对key进行哈希 然后取余16383
- 将key - value发送给任意一个node节点,然后对比第2步骤取余的结果是否对应本node节点的槽范围
- 符合则放到本node中的相应的槽位置;若不符合本Node所属槽范围,由于Redis Cluster之间是共享消息的模式,即每个Node都知道其它Node负责哪些范围的槽。然后本Node返回给你个结果Node节点,告诉你该去那个节点去取或存放。Redis Cluster不会帮你去跳转,只是告诉你目标节点的结果,然后你自己去做跳转。问题是性能不够高,当节点多的时候命中率不高,这种情况下需要智能客户端,即客户端知道所有的节点以及负责的槽区域,当槽发生变化的时候客户端也要知道。
- 前2种分区方式都存在数据迁移,会存在丢数据的可能性,所以只能作为缓存的场景使用。而虚拟槽不存在这样的问题。因为每个节点槽的范围是固定的,当你加入一个新的节点,也没有把其它节点的槽的范围抢过去,必须是我这个节点把我的槽和数据的权利分配给你,这样就不存在丢数据的情况。
三、 搭建集群
1. 单机架构 与 分布式架构对比
客户端访问单机架构图解 分布式架构访问图解,每个节点都负责读和写,且节点间互相通信
2. Redis Cluster 架构概述
1)节点配置开启集群模式
cluster-enable yes
2)节点间相互meet
meet:3个节点 Meet:6个节点(ping - pong)3)指派槽
指派槽 客户端与指派槽4) 复制
5)高可用
6) 分片
3. 两种安装配置实现方式
0)集群相关操作命令初识
$ redis-cli -p 7000 cluster help
1) CLUSTER <subcommand> arg arg ... arg. Subcommands are:
2) ADDSLOTS <slot> [slot ...] -- Assign slots to current node.
3) BUMPEPOCH -- Advance the cluster config epoch.
4) COUNT-failure-reports <node-id> -- Return number of failure reports for <node-id>.
5) COUNTKEYSINSLOT <slot> - Return the number of keys in <slot>.
6) DELSLOTS <slot> [slot ...] -- Delete slots information from current node.
7) FAILOVER [force|takeover] -- Promote current replica node to being a master.
8) FORGET <node-id> -- Remove a node from the cluster.
9) GETKEYSINSLOT <slot> <count> -- Return key names stored by current node in a slot.
10) FLUSHSLOTS -- Delete current node own slots information.
11) INFO - Return onformation about the cluster.
12) KEYSLOT <key> -- Return the hash slot for <key>.
13) MEET <ip> <port> [bus-port] -- Connect nodes into a working cluster.
14) MYID -- Return the node id.
15) NODES -- Return cluster configuration seen by node. Output format:
16) <id> <ip:port> <flags> <master> <pings> <pongs> <epoch> <link> <slot> ... <slot>
17) REPLICATE <node-id> -- Configure current node as replica to <node-id>.
18) RESET [hard|soft] -- Reset current node (default: soft).
19) SET-config-epoch <epoch> - Set config epoch of current node.
20) SETSLOT <slot> (importing|migrating|stable|node <node-id>) -- Set slot state.
21) REPLICAS <node-id> -- Return <node-id> replicas.
22) SLOTS -- Return information about slots range mappings. Each range is made of:
23) start, end, master and replicas IP addresses, ports and ids
1) 原生命令安装 - 理解架构
(1)修改配置文件
port 7000
daemonize yes
protected-mode no
pidfile "/var/run/redis-cluster-7000.pid"
logfile "redis-cluster-7000.log"
dbfilename "dump-cluster-7000.rdb"
dir "/usr/local/redis/data/"
cluster-enabled yes
cluster-node-timeout 15000
# 每个集群节点都有一个相对应的集群配置文件,
# 这个文件不打算被手动编辑,它是被Redis节点创建和编辑的。
# 确保在跑同一个系统中的实例不会出现集群配置文件重名的现象。
cluster-config-file redis-cluster-nodes-7000.conf
# 必须是所有节点全部启动着,才认为是OK的,要不然就挂掉了
cluster-require-full-coverage no
(2)替换复制生成另外5个node节点的配置文件
sed 's/7000/7001/g' redis-7000.conf > redis-7001.conf
sed 's/7000/7002/g' redis-7000.conf > redis-7002.conf
sed 's/7000/7003/g' redis-7000.conf > redis-7003.conf
sed 's/7000/7004/g' redis-7000.conf > redis-7004.conf
sed 's/7000/7005/g' redis-7000.conf > redis-7005.conf
(3)开启6个节点(3主3从,此时尚未配置谁主谁从)
redis-server redis-7000.conf
redis-server redis-7001.conf
redis-server redis-7002.conf
redis-server redis-7003.conf
redis-server redis-7004.conf
redis-server redis-7005.conf
(4)查看进程,每个节点后都带有【cluster】 标识
ps aux | grep redis
--------------
806 ?? 0:00.72 redis-server *:7000 [cluster]
810 ?? 0:00.52 redis-server *:7001 [cluster]
812 ?? 0:00.53 redis-server *:7002 [cluster]
814 ?? 0:00.51 redis-server *:7003 [cluster]
816 ?? 0:00.50 redis-server *:7004 [cluster]
818 ?? 0:00.53 redis-server *:7005 [cluster]
(5)此时未分配槽,尚不能访问节点保存数据
$redis-cli -p 7000
127.0.0.1:7000> keys *
(empty list or set)
127.0.0.1:7000> set key1 value1
(error) CLUSTERDOWN Hash slot not served
(6)查看cluster node节点信息:
cat redis-cluster-nodes-7000.conf
f305584aa40908b60d887448ba986b51114bb927 :0@0 myself,master - 0 0 0 connected
vars currentEpoch 0 lastVoteEpoch 0
---------------两种方式约等于-----------------
redis-cli -p 7000 cluster nodes
f305584aa40908b60d887448ba986b51114bb927 :7000@17000 myself,master - 0 0 0 connected
$ redis-cli -p 7000 cluster info
cluster_state:fail #集群状态是失败,因为尚未分配槽
cluster_slots_assigned:0
cluster_slots_ok:0
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:1 #知道节点个数:1(自己)
cluster_size:0
cluster_current_epoch:0
cluster_my_epoch:0
cluster_stats_messages_sent:0
cluster_stats_messages_received:0
xiaochao-Air:data xiaochao$
(7)meet
cluster meet ip port
redis-cli -h 127.0.0.1 -p 7000 cluster meet 127.0.0.1 7001
redis-cli -h 127.0.0.1 -p 7000 cluster meet 127.0.0.1 7002
redis-cli -h 127.0.0.1 -p 7000 cluster meet 127.0.0.1 7003
redis-cli -h 127.0.0.1 -p 7000 cluster meet 127.0.0.1 7004
redis-cli -h 127.0.0.1 -p 7000 cluster meet 127.0.0.1 7005
不用排列组合,它们互相之间即可相互感知。
(8)meet结果查看
$ redis-cli -p 7002 cluster nodes
f6f6251a4cb3abef4a5a74fd9f6ef86792d50cdb 127.0.0.1:7002@17002 myself,master - 0 1558774606000 0 connected
892a7952ba9566477e859ef45f07dfc61d69ca53 127.0.0.1:7003@17003 master - 0 1558774608672 3 connected
71091770809d06bd60b132fe09222de51744fdcc 127.0.0.1:7005@17005 master - 0 1558774606000 5 connected
3d78c231d691b1ac5f76c14f8b76af1ba48a3adb 127.0.0.1:7004@17004 master - 0 1558774607661 4 connected
f305584aa40908b60d887448ba986b51114bb927 127.0.0.1:7000@17000 master - 0 1558774608000 2 connected
6ed15572ddfd509486c1f580e10cb936920acd6b 127.0.0.1:7001@17001 master - 0 1558774607000 1 connected
每meet一个新节点,cluster-nodes.conf中便会新增一条记录,即代表节点间已经互相感知
(9)节点信息查看
$ redis-cli -p 7002 cluster info
cluster_state:fail #集群状态是失败,因为尚未分配槽
cluster_slots_assigned:0
cluster_slots_ok:0
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:6 #知道节点个数
cluster_size:0
cluster_current_epoch:5
cluster_my_epoch:0
cluster_stats_messages_ping_sent:191
cluster_stats_messages_pong_sent:173
cluster_stats_messages_sent:364
cluster_stats_messages_ping_received:168
cluster_stats_messages_pong_received:191
cluster_stats_messages_meet_received:5
cluster_stats_messages_received:364
整个集群互相握手工作已经完成,节点间已经互通,但是仍然不能存数据
$ redis-cli -p 7000
127.0.0.1:7000> set hello world
(error) CLUSTERDOWN Hash slot not served
(10)给3个主节点指(分)派槽 【16384 / 3 均分】
redis-cli -h 127.0.0.1 -p 7000 cluster addslots {0...5461}
redis-cli -h 127.0.0.1 -p 7001 cluster addslots {5462...10922}
redis-cli -h 127.0.0.1 -p 7002 cluster addslots {10923...16383}
编写脚本实现
#!/bin/sh
start=$1
end=$2
port=$3
for slot in `seq ${start} ${end}`
do
echo "slot:${slot}"
# 此处进行了end次redis-cli连接,及其耗时
redis-cli -p ${port} cluster addslots ${slot}
done
sudo chmod +x addSlots.sh
./addSlots.sh 0 5461 7000 | tee addSlots7000.log
./addSlots.sh 5462 10922 7001| tee addSlots7001.log
./addSlots.sh 10923 16383 7002| tee addSlots7002.log
当只执行了7000节点的分配:
查看nodes节点后面的输出,发现7000 节点后面有0-5461
redis-cli -p 7000 cluster nodes
3d78c231d691b1ac5f76c14f8b76af1ba48a3adb 127.0.0.1:7004@17004 master - 0 1558777477000 4 connected
f6f6251a4cb3abef4a5a74fd9f6ef86792d50cdb 127.0.0.1:7002@17002 master - 0 1558777476212 0 connected
71091770809d06bd60b132fe09222de51744fdcc 127.0.0.1:7005@17005 master - 0 1558777478234 5 connected
6ed15572ddfd509486c1f580e10cb936920acd6b 127.0.0.1:7001@17001 master - 0 1558777477223 1 connected
f305584aa40908b60d887448ba986b51114bb927 127.0.0.1:7000@17000 myself,master - 0 1558777476000 2 connected 0-5461
892a7952ba9566477e859ef45f07dfc61d69ca53 127.0.0.1:7003@17003 master - 0 1558777475199 3 connected
查看集群状态
redis-cli -p 7000 cluster info # 端口号改为[7001 ...... 7005] ,结果皆是如此
cluster_state:ok # 集群状态由fail变为OK
cluster_slots_assigned:5462 # assigned 英[əˈsaɪnd] 分配(某物); 分派,布置(工作、任务等); 指定; 指派; 委派; 派遣;
cluster_slots_ok:5462
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:6
cluster_size:1 # 分配了槽的节点个数(三条分配命令都执行完后就变成了3)
cluster_current_epoch:5
cluster_my_epoch:2
cluster_stats_messages_ping_sent:3294
cluster_stats_messages_pong_sent:3182
cluster_stats_messages_meet_sent:5
cluster_stats_messages_sent:6481
cluster_stats_messages_ping_received:3182
cluster_stats_messages_pong_received:3299
cluster_stats_messages_received:6481
分配槽的节点可用
#当只给7000分配了槽,连接7000节点set值成功,其它节点不成功,因为我们设置了:
#cluster-require-full-coverage no
$ redis-cli -p 7000
127.0.0.1:7000> set hello world
OK
127.0.0.1:7000> get hello
"world"
127.0.0.1:7000> exit
$ redis-cli -p 7001
127.0.0.1:7001> set key1 value1
(error) CLUSTERDOWN Hash slot not served
给7000、7001、7002分配了槽后再查看
$ redis-cli -p 7000 cluster nodes
f305584aa40908b60d887448ba986b51114bb927 127.0.0.1:7000@17000 myself,master - 0 1558779092000 2 connected 0-5461
6ed15572ddfd509486c1f580e10cb936920acd6b 127.0.0.1:7001@17001 master - 0 1558779092044 1 connected 5462-10922
f6f6251a4cb3abef4a5a74fd9f6ef86792d50cdb 127.0.0.1:7002@17002 master - 0 1558779093056 0 connected 10923-16383
892a7952ba9566477e859ef45f07dfc61d69ca53 127.0.0.1:7003@17003 master - 0 1558779095085 3 connected
3d78c231d691b1ac5f76c14f8b76af1ba48a3adb 127.0.0.1:7004@17004 master - 0 1558779092000 4 connected
71091770809d06bd60b132fe09222de51744fdcc 127.0.0.1:7005@17005 master - 0 1558779094070 5 connected
( 5)设置主从
cluster replicate node-id
redis-cli -h 127.0.0.1 -p 7003 cluster replicate ${node-id-7000}
redis-cli -h 127.0.0.1 -p 7004 cluster replicate ${node-id-7001}
redis-cli -h 127.0.0.1 -p 7005 cluster replicate ${node-id-7002}
主从查看
redis-cli -p 7000 cluster nodes
f305584aa40908b60d887448ba986b51114bb927 127.0.0.1:7000@17000 myself,master - 0 1558784503000 2 connected 0-5461
6ed15572ddfd509486c1f580e10cb936920acd6b 127.0.0.1:7001@17001 master - 0 1558784502000 1 connected 5462-10922
f6f6251a4cb3abef4a5a74fd9f6ef86792d50cdb 127.0.0.1:7002@17002 master - 0 1558784503773 0 connected 10923-16383
892a7952ba9566477e859ef45f07dfc61d69ca53 127.0.0.1:7003@17003 slave f305584aa40908b60d887448ba986b51114bb927 0 1558784500000 3 connected
3d78c231d691b1ac5f76c14f8b76af1ba48a3adb 127.0.0.1:7004@17004 slave 6ed15572ddfd509486c1f580e10cb936920acd6b 0 1558784502762 4 connected
71091770809d06bd60b132fe09222de51744fdcc 127.0.0.1:7005@17005 slave f6f6251a4cb3abef4a5a74fd9f6ef86792d50cdb 0 1558784501750 5 connected
redis-cli -p 7000 cluster slots
1) 1) (integer) 10923
2) (integer) 16383
3) 1) "127.0.0.1"
2) (integer) 7002
3) "f6f6251a4cb3abef4a5a74fd9f6ef86792d50cdb"
4) 1) "127.0.0.1"
2) (integer) 7005
3) "71091770809d06bd60b132fe09222de51744fdcc"
2) 1) (integer) 5462
2) (integer) 10922
3) 1) "127.0.0.1"
2) (integer) 7001
3) "6ed15572ddfd509486c1f580e10cb936920acd6b"
4) 1) "127.0.0.1"
2) (integer) 7004
3) "3d78c231d691b1ac5f76c14f8b76af1ba48a3adb"
3) 1) (integer) 0
2) (integer) 5461
3) 1) "127.0.0.1"
2) (integer) 7000
3) "f305584aa40908b60d887448ba986b51114bb927"
4) 1) "127.0.0.1"
2) (integer) 7003
3) "892a7952ba9566477e859ef45f07dfc61d69ca53"
集群模式的客户端访问:
$ redis-cli -c -p 7000
127.0.0.1:7000> keys *
1) "hello"
127.0.0.1:7000> set world hello
-> Redirected to slot [9059] located at 127.0.0.1:7001 #被重定向到7001节点了
OK
127.0.0.1:7001> keys *
1) "world"
127.0.0.1:7001> set key1 value1
OK
127.0.0.1:7001> set 1 1
OK
127.0.0.1:7001> set aaa aaa
OK
127.0.0.1:7001> set wohao wohao
OK
127.0.0.1:7001> exit
guchunchaodeMacBook-Air:data guchunchao$ redis-cli -c -p 7000
127.0.0.1:7000> keys *
1) "hello"
127.0.0.1:7000> exit
guchunchaodeMacBook-Air:data guchunchao$ redis-cli -c -p 7001
127.0.0.1:7001> keys *
1) "aaa"
2) "world"
3) "key1"
4) "1"
5) "wohao"
127.0.0.1:7001> exit
# 7004节点主从复制了7001节点
guchunchaodeMacBook-Air:data guchunchao$ redis-cli -c -p 7004
127.0.0.1:7004> keys *
1) "1"
2) "wohao"
3) "key1"
4) "world"
5) "aaa"
本例子是以一台机器操作演练。实际生产环境一般一台机器部署一个节点
若是机器不够,比如6个节点,3台机器:可以如下设计
主 从
10.0.0.1 7000 10.0.0.2 7003
10.0.0.2 7001 10.0.0.3 7004
10.0.0.3 7002 10.0.0.4 7005
2) 官方Ruby工具安装
(1)Ruby环境准备
- 下载、编译、安装Ruby
wget https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.3.tar.gz
tar -zxvf ruby-2.6.3.tar.gz
./configure -prefix=/usr/local/ruby
make
make install
cd /usr/local/ruby
cp bin/ruby /usr/local/bin
cp bin/gem /usr/local/bin
- 安装Rubygem redis
- 安装 redis-trib.rb
cp redis-5.0.4/src/redis-trib.rb /usr/local/bin
开启新的redis集群
- 安装 redis-trib.rb
#内容和之前的7000*.conf无差别,此处换成800*只为与前面区分
redis-server redis-8000.conf
redis-server redis-8001.conf
redis-server redis-8002.conf
redis-server redis-8003.conf
redis-server redis-8004.conf
redis-server redis-8005.conf
或者关闭现有的所有700*.conf的Redis server,删除掉所有DB,文件,只保留配置文件,然后重新redis-server开启服务
# 查看所有开启的redis服务
ps -ef | grep redis-server | grep 700
501 815 1 0 7:39上午 ?? 0:00.32 redis-server *:7000 [cluster]
501 817 1 0 7:39上午 ?? 0:00.28 redis-server *:7001 [cluster]
501 820 1 0 7:39上午 ?? 0:00.26 redis-server *:7002 [cluster]
501 822 1 0 7:39上午 ?? 0:00.23 redis-server *:7003 [cluster]
501 825 1 0 7:39上午 ?? 0:00.22 redis-server *:7004 [cluster]
501 828 1 0 7:39上午 ?? 0:00.20 redis-server *:7005 [cluster]
# 查看上面的第二列
$ ps -ef | grep redis-server | grep 700 | awk '{print $2}'
815
817
820
822
825
828
# 杀死这些进程号的进程
ps -ef | grep redis-server | grep 700 | awk '{print $2}' | xargs kill
# 删除所有的DB文件
cd /usr/local/redis/data/
rm -rf *
开启安装命令(已过时):
# --replicas 1 代表每个主节点有一个从节点,前三个节点是主节点,后三个是从节点
redis-trib.rb create --replicas 1 127.0.0.1:8000 127.0.0.1:8001 127.0.0.1:8002 127.0.0.1:8003 127.0.0.1:8004 127.0.0.1:8005
#执行后提示redis-trib.rb功能已经移植到了redis-cli
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: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 --cluster-replicas 1
To get help about all subcommands, type:
redis-cli --cluster help
根据提示调用集群配置命令
redis-cli --cluster create 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 --cluster-replicas 1
>>> Performing hash slots allocation on 6 nodes...
Master[0] -> Slots 0 - 5460
Master[1] -> Slots 5461 - 10922
Master[2] -> Slots 10923 - 16383
Adding replica 127.0.0.1:7004 to 127.0.0.1:7000
Adding replica 127.0.0.1:7005 to 127.0.0.1:7001
Adding replica 127.0.0.1:7003 to 127.0.0.1:7002
>>> Trying to optimize slaves allocation for anti-affinity
[WARNING] Some slaves are in the same host as their master
M: 1ac9fbbfe11362e151204132e3d110b18139a1d9 127.0.0.1:7000
slots:[0-5460] (5461 slots) master
M: a3c0d3b42da023dc402faf439d4f93a1cb44d402 127.0.0.1:7001
slots:[5461-10922] (5462 slots) master
M: a89a427b5fe8b2b0ef07ac8c6252dc3c8efa1f77 127.0.0.1:7002
slots:[10923-16383] (5461 slots) master
S: 2d19dda2a8a790d5636a664fe3ed54aa3dd7677c 127.0.0.1:7003
replicates 1ac9fbbfe11362e151204132e3d110b18139a1d9
S: 5a4f085dee8400093f45ce2cfa42cbd206167f73 127.0.0.1:7004
replicates a3c0d3b42da023dc402faf439d4f93a1cb44d402
S: 09792d31e728ad714a5a90bc7639f277d817fb4e 127.0.0.1:7005
replicates a89a427b5fe8b2b0ef07ac8c6252dc3c8efa1f77
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: 1ac9fbbfe11362e151204132e3d110b18139a1d9 127.0.0.1:7000
slots:[0-5460] (5461 slots) master
1 additional replica(s)
S: 2d19dda2a8a790d5636a664fe3ed54aa3dd7677c 127.0.0.1:7003
slots: (0 slots) slave
replicates 1ac9fbbfe11362e151204132e3d110b18139a1d9
S: 5a4f085dee8400093f45ce2cfa42cbd206167f73 127.0.0.1:7004
slots: (0 slots) slave
replicates a3c0d3b42da023dc402faf439d4f93a1cb44d402
M: a89a427b5fe8b2b0ef07ac8c6252dc3c8efa1f77 127.0.0.1:7002
slots:[10923-16383] (5461 slots) master
1 additional replica(s)
M: a3c0d3b42da023dc402faf439d4f93a1cb44d402 127.0.0.1:7001
slots:[5461-10922] (5462 slots) master
1 additional replica(s)
S: 09792d31e728ad714a5a90bc7639f277d817fb4e 127.0.0.1:7005
slots: (0 slots) slave
replicates a89a427b5fe8b2b0ef07ac8c6252dc3c8efa1f77
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
# 查看结果,和之前配置的一样
$redis-cli -p 7000 cluster nodes
$redis-cli -p 7000 cluster info
思考
Redis5.0版本已经把redis cluster的集群配置命令集成到redis-cli工具中,也行不再需要安装ruby环境来执行了,有待验证。
若是系统很大,有很多节点,比如:100+,那么使用这种方式也不是很好。好的方式是使用一个(云)平台,来对资源进行管理,包括原始信息(nodeId等)的管理
总结
1. 原生命令安装
- 理解Redis Cluster 架构
- 生成环境不使用(繁琐,容易出错)
2. 官方工具安装
- 简单、高效、准确
- 生成环境可以使用
3. 其它方式
- web可视化部署