利用docker轻松搭建Redis-Cluster集群环境( 二 )
创建redis-cluster集群6个redis容器创建好之后 , 选择其中的一个容器进入 , 进行redis-cluster集群创建
[root@mysql bin]# docker-enter f4c971ce2d84root@f4c971ce2d84:~# redis-cli -a 1234 --cluster create 192.168.112.136:8001 192.168.112.136:8002 192.168.112.136:8003 192.168.112.136:8004 192.168.112.136:8005 192.168.112.136:8006 --cluster-replicas 1Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.>>> Performing hash slots allocation on 6 nodes...Master[0] -> Slots 0 - 5460Master[1] -> Slots 5461 - 10922Master[2] -> Slots 10923 - 16383Adding replica 192.168.112.136:8005 to 192.168.112.136:8001Adding replica 192.168.112.136:8006 to 192.168.112.136:8002Adding replica 192.168.112.136:8004 to 192.168.112.136:8003>>> Trying to optimize slaves allocation for anti-affinity[WARNING] Some slaves are in the same host as their masterM: c9e549f4d04d4466d2550d1e027412304099b1f2 192.168.112.136:8001slots:[0-5460] (5461 slots) masterM: 0956927ee74737d5ff91a1885e77f94d531dab76 192.168.112.136:8002slots:[5461-10922] (5462 slots) masterM: d6321788b2717b4142390c158ba70ca758f70964 192.168.112.136:8003slots:[10923-16383] (5461 slots) masterS: 96d2cb55f163ecc13a714ba01d90348c1c3ad02f 192.168.112.136:8004replicates c9e549f4d04d4466d2550d1e027412304099b1f2S: 8a771c26a95e82d9a6818e372d7c0226937670ac 192.168.112.136:8005replicates 0956927ee74737d5ff91a1885e77f94d531dab76S: aa7c2f6173904973f041b35efc5200359188eb0f 192.168.112.136:8006replicates d6321788b2717b4142390c158ba70ca758f70964Can 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 clusterWaiting for the cluster to join.>>> Performing Cluster Check (using node 192.168.112.136:8001)M: c9e549f4d04d4466d2550d1e027412304099b1f2 192.168.112.136:8001slots:[0-5460] (5461 slots) master1 additional replica(s)M: 0956927ee74737d5ff91a1885e77f94d531dab76 192.168.112.136:8002slots:[5461-10922] (5462 slots) master1 additional replica(s)S: 96d2cb55f163ecc13a714ba01d90348c1c3ad02f 192.168.112.136:8004slots: (0 slots) slavereplicates c9e549f4d04d4466d2550d1e027412304099b1f2S: aa7c2f6173904973f041b35efc5200359188eb0f 192.168.112.136:8006slots: (0 slots) slavereplicates d6321788b2717b4142390c158ba70ca758f70964S: 8a771c26a95e82d9a6818e372d7c0226937670ac 192.168.112.136:8005slots: (0 slots) slavereplicates 0956927ee74737d5ff91a1885e77f94d531dab76M: d6321788b2717b4142390c158ba70ca758f70964 192.168.112.136:8003slots:[10923-16383] (5461 slots) master1 additional replica(s)[OK] All nodes agree about slots configuration.>>> Check for open slots...>>> Check slots coverage...[OK] All 16384 slots covered.
上述命令执行之后 , redis-cluster集群就搭建好了 , 下面是整个redis-cluster集群的架构图
文章插图
redis-cluster集群架构图
redis-cluster集群状态检查检查redis-cluster集群状态
root@f4c971ce2d84:~# redis-cli -a 1234 --cluster check 192.168.112.136:8001Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.192.168.112.136:8001 (c9e549f4...) -> 0 keys | 5461 slots | 1 slaves.192.168.112.136:8002 (0956927e...) -> 0 keys | 5462 slots | 1 slaves.192.168.112.136:8003 (d6321788...) -> 0 keys | 5461 slots | 1 slaves.[OK] 0 keys in 3 masters.0.00 keys per slot on average.>>> Performing Cluster Check (using node 192.168.112.136:8001)M: c9e549f4d04d4466d2550d1e027412304099b1f2 192.168.112.136:8001slots:[0-5460] (5461 slots) master1 additional replica(s)M: 0956927ee74737d5ff91a1885e77f94d531dab76 192.168.112.136:8002slots:[5461-10922] (5462 slots) master1 additional replica(s)S: 96d2cb55f163ecc13a714ba01d90348c1c3ad02f 192.168.112.136:8004slots: (0 slots) slavereplicates c9e549f4d04d4466d2550d1e027412304099b1f2S: aa7c2f6173904973f041b35efc5200359188eb0f 192.168.112.136:8006slots: (0 slots) slavereplicates d6321788b2717b4142390c158ba70ca758f70964S: 8a771c26a95e82d9a6818e372d7c0226937670ac 192.168.112.136:8005slots: (0 slots) slavereplicates 0956927ee74737d5ff91a1885e77f94d531dab76M: d6321788b2717b4142390c158ba70ca758f70964 192.168.112.136:8003slots:[10923-16383] (5461 slots) master1 additional replica(s)[OK] All nodes agree about slots configuration.>>> Check for open slots...>>> Check slots coverage...[OK] All 16384 slots covered.
检查redis集群节点信息
root@f4c971ce2d84:~# redis-cli -c -a 1234 -h 192.168.112.136 -p 8001192.168.112.136:8001> cluster nodes0956927ee74737d5ff91a1885e77f94d531dab76 192.168.112.136:8002@18002 master - 0 1603265855374 2 connected 5461-1092296d2cb55f163ecc13a714ba01d90348c1c3ad02f 192.168.112.136:8004@18004 slave c9e549f4d04d4466d2550d1e027412304099b1f2 0 1603265856080 4 connectedaa7c2f6173904973f041b35efc5200359188eb0f 192.168.112.136:8006@18006 slave d6321788b2717b4142390c158ba70ca758f70964 0 1603265855575 6 connected8a771c26a95e82d9a6818e372d7c0226937670ac 192.168.112.136:8005@18005 slave 0956927ee74737d5ff91a1885e77f94d531dab76 0 1603265855575 5 connectedd6321788b2717b4142390c158ba70ca758f70964 192.168.112.136:8003@18003 master - 0 1603265856382 3 connected 10923-16383c9e549f4d04d4466d2550d1e027412304099b1f2 192.168.112.136:8001@18001 myself,master - 0 1603265855000 1 connected 0-5460
- 作家|逾万名作家联名反对亚马逊有声书轻松退换政策
- 路由器|家里无线网经常断网、网速慢怎么办?教你几个小窍门,轻松解决
- 轻松|使用 GIMP 轻松地设置图片透明度
- 试试|手机内存不够用,咋办?试试关闭微信这两步操作,轻松腾出几个G
- 回收利用协|固废“零”时代产业如何共生?
- 不良|打开“无痕模式”就以为无人知?殊不知,“不良网站”正在利用你
- 销量|Redmi Note 9系列三剑客齐发力 首发销量轻松突破30万台!
- 机身|轻松使用一整天,OPPO K7x给你不断电体验
- 格式化|利用好这3个隐藏技巧,Power BI 开发体验更丝滑
- 告诉|阿里大佬告诉你如何一分钟利用Python在家告别会员看电影