进入容器redis-node-1并为6台机器构建集群关系

1.进入容器
    docker exec -it redis-node-1 /bin/bash
    
2.#注意,进入docker容器后才能执行一下命令,且注意自己的真实IP地址
    redis-cli --cluster create IP地址:6381 IP地址:6382                IP地址:6383 192.168.111.147:6384 IP地址:6385        IP地址:6386 --cluster-replicas 1
    #--cluster-replicas 1 表示为每个master创建一个slave节点
    
3.#3主3从搞定

运行结果

[root@localhost home]# docker exec -it redis-node-1 /bin/bash
root@localhost:/data# redis-cli --cluster create 192.168.153.138:6381 192.168.153.138:6382 192.168.153.138:6383 192.168.153.138:6384 192.168.153.138:6385    192.168.153.138:6386 --cluster-replicas 1
>>> Performing hash slots allocation on 6 nodes... #hash槽对这六个节点经行分配
Master[0] -> Slots 0 - 5460 #如上图对16384个槽位分配 0 - 5460 5461 - 10922 10923 - 16383
Master[1] -> Slots 5461 - 10922
Master[2] -> Slots 10923 - 16383
Adding replica 192.168.153.138:6385 to 192.168.153.138:6381
Adding replica 192.168.153.138:6386 to 192.168.153.138:6382
Adding replica 192.168.153.138:6384 to 192.168.153.138:6383
>>> Trying to optimize slaves allocation for anti-affinity
[WARNING] Some slaves are in the same host as their master
M: d9b335b44e89e3a46f30466e70867de7fdd3d5ad 192.168.153.138:6381 #主
   slots:[0-5460] (5461 slots) master
M: 7a876fd455a6e77923e0ab340335c430f25ed11f 192.168.153.138:6382 #主
   slots:[5461-10922] (5462 slots) master
M: fbacfaed169736db5278e4f685adf44a9bcd55ea 192.168.153.138:6383 #主
   slots:[10923-16383] (5461 slots) master
S: 798440dfeb0aa728aba2f4a9f783eb20edeaa09c 192.168.153.138:6384 #从
   replicates fbacfaed169736db5278e4f685adf44a9bcd55ea
S: 37299c5efbf061f019bf24780661144a171c24df 192.168.153.138:6385 #从
   replicates d9b335b44e89e3a46f30466e70867de7fdd3d5ad
S: ece2d11584c4d7a0b1d9699c90aa2016fcf75924 192.168.153.138:6386 #从
   replicates 7a876fd455a6e77923e0ab340335c430f25ed11f
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 192.168.153.138:6381)
M: d9b335b44e89e3a46f30466e70867de7fdd3d5ad 192.168.153.138:6381
   slots:[0-5460] (5461 slots) master
   1 additional replica(s)
S: ece2d11584c4d7a0b1d9699c90aa2016fcf75924 192.168.153.138:6386
   slots: (0 slots) slave
   replicates 7a876fd455a6e77923e0ab340335c430f25ed11f
M: fbacfaed169736db5278e4f685adf44a9bcd55ea 192.168.153.138:6383
   slots:[10923-16383] (5461 slots) master
   1 additional replica(s)
M: 7a876fd455a6e77923e0ab340335c430f25ed11f 192.168.153.138:6382
   slots:[5461-10922] (5462 slots) master
   1 additional replica(s)
S: 37299c5efbf061f019bf24780661144a171c24df 192.168.153.138:6385
   slots: (0 slots) slave
   replicates d9b335b44e89e3a46f30466e70867de7fdd3d5ad
S: 798440dfeb0aa728aba2f4a9f783eb20edeaa09c 192.168.153.138:6384
   slots: (0 slots) slave
   replicates fbacfaed169736db5278e4f685adf44a9bcd55ea
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

文章链接: https://www.mfisp.com/19028.html

文章标题:进入容器redis-node-1并为6台机器构建集群关系

文章版权:梦飞科技所发布的内容,部分为原创文章,转载请注明来源,网络转载文章如有侵权请联系我们!

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

给TA打赏
共{{data.count}}人
人已打赏
建站教程

edis集群配置

2023-3-29 13:55:30

建站教程

photoscan集群操作

2023-3-30 10:46:23

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索

梦飞科技 - 最新云主机促销服务器租用优惠