【Docker实战】性能与可靠性并重,Flexus X实例助力Redis三主三从集群高效运行

举报
wzsのcloud 发表于 2024/10/29 22:50:54 2024/10/29
【摘要】 在追求极致性能与可靠性的道路上,Flexus X实例以卓越的算力与智能调度,为Redis三主三从集群的高效运行保驾护航。此架构不仅实现了数据的高可用性,还通过负载均衡提升了整体性能,确保您的业务在海量数据面前依然游刃有余。

前言

在追求极致性能与可靠性的道路上,Flexus X实例以卓越的算力与智能调度,为Redis三主三从集群的高效运行保驾护航。此架构不仅实现了数据的高可用性,还通过负载均衡提升了整体性能,确保您的业务在海量数据面前依然游刃有余。华为云Flexus X实例携手Redis三主三从集群解决方案,为您带来前所未有的优惠与便捷,开启数据库高效运行的新篇章!

链接直达:华为云Flexus云服务器X实例

image.png

Redis集群介绍

Redis三主三从集群是提升数据库系统可用性、容错性和性能的关键部署模式。它由三个主节点处理读写请求,三个从节点复制主节点数据,确保数据高可用与冗余。通过自动故障转移机制,从节点能在主节点故障时自动接管,保障服务连续性。此外,读写分离与负载均衡策略进一步优化了系统性能,适用于电商、社交网络和实时数据分析等高要求场景。

集群的核心优势在于其高效的数据复制与同步机制,从节点无缝复制主节点数据,不阻塞主节点处理流程。同时,当主节点故障时,系统能迅速自动完成故障转移,无需人工干预,极大提升了系统的稳定性和可靠性。

Redis三主三从集群以其卓越的高可用性、容错能力和性能优化,成为复杂应用场景下数据存储与访问的首选方案。通过合理配置与部署,它能有效满足各类业务对数据存储的高要求,确保数据的安全、可靠与高效访问。

官方网站:https://redis.io/

官方文档:https://redis.io/docs/latest/

image.png

环境规划

操作系统 redis docker 连接方式
Huawei Cloud EulerOS 2.0 redis:6.0.8 27.1.1 本地==shell==

部署流程

需要了解:

拉取镜像

拉取镜像并创建网络

[root@flexusx-251f ~]# docker pull redis:6.0.8
6.0.8: Pulling from library/redis
bb79b6b2107f: Pull complete
1ed3521a5dcb: Pull complete
5999b99cee8f: Pull complete
3f806f5245c9: Pull complete
f8a4497572b2: Pull complete
eafe3b6b8d06: Pull complete
Digest: sha256:21db12e5ab3cc343e9376d655e8eabbdbe5516801373e95a8a9e66010c5b8819
Status: Downloaded newer image for redis:6.0.8
docker.io/library/redis:6.0.8

[root@flexusx-251f ~]# docker network create redis-cluster-net
4d9a413869dd2339ef196cf0b5611fbc6209d586c2c5fd5b2b8b8f02d1dd8203

部署主节点

[root@flexusx-251f ~]# docker run -itd --name redis-master1 --network redis-cluster-net -p 6379:6379 -v /data/redis/share/redis-node-1:/data redis:6.0.8 --cluster-enabled yes  --appendonly yes --port 6379
04c85ab05c718ace09a8eb56a77220edc9d068a5201125e23b3a222fc898c323

[root@flexusx-251f ~]# docker run -itd --name redis-master2 --network redis-cluster-net -p 6380:6379 -v /data/redis/share/redis-node-2:/data redis:6.0.8 --cluster-enabled yes  --appendonly yes --port 6379
a900e7ddf6c99313b4f1bfd068d8a6b735a4425ec3b055d5e0616a944bdd44e6

[root@flexusx-251f ~]# docker run -itd --name redis-master3 --network redis-cluster-net -p 6381:6379 -v /data/redis/share/redis-node-3:/data redis:6.0.8 --cluster-enabled yes  --appendonly yes --port 6379

部署从节点

[root@flexusx-251f ~]# docker run -itd --name redis-slave1 --network redis-cluster-net -p 6382:6379 -v /data/redis/share/redis-slave-1:/data redis:6.0.8 --cluster-enabled yes  --appendonly yes --port 6379
7f39daa7c0a7a5ca221db4a3e02ec495c82e69d3131e32b968be2cf7be3a93a4

[root@flexusx-251f ~]# docker run -itd --name redis-slave2 --network redis-cluster-net -p 6383:6379 -v /data/redis/share/redis-slave-2:/data  redis:6.0.8 --cluster-enabled yes  --appendonly yes --port 6379
4e615a412d19072e4dd233f92f062867ab9bc8bf59587aa6252e2c1bc9796690

[root@flexusx-251f ~]# docker run -itd --name redis-slave3 --network redis-cluster-net -p 6384:6379 -v /data/redis/share/redis-slave-3:/data  redis:6.0.8 --cluster-enabled yes  --appendonly yes --port 6379
56693d453988d23f1d477867e4a7b7dba5b2e6b9fd8a80724ae0a14f5c4deead

初始化redis集群

放行端口 6379,6380,6381,6382,6383,6384

image.png

查看Redis主机IP地址

[root@flexusx-251f ~]# docker inspect redis-master1 | grep -i ipadd
            "SecondaryIPAddresses": null,
            "IPAddress": "",
                    "IPAddress": "172.27.0.2",
[root@flexusx-251f ~]# docker inspect redis-master2 | grep -i ipadd
            "SecondaryIPAddresses": null,
            "IPAddress": "",
                    "IPAddress": "172.27.0.3",
[root@flexusx-251f ~]# docker inspect redis-master3 | grep -i ipadd
            "SecondaryIPAddresses": null,
            "IPAddress": "",
                    "IPAddress": "172.27.0.7",
[root@flexusx-251f ~]# docker inspect redis-slave1 | grep -i ipadd
            "SecondaryIPAddresses": null,
            "IPAddress": "",
                    "IPAddress": "172.27.0.6",
[root@flexusx-251f ~]# docker inspect redis-slave2 | grep -i ipadd
            "SecondaryIPAddresses": null,
            "IPAddress": "",
                    "IPAddress": "172.27.0.4",
[root@flexusx-251f ~]# docker inspect redis-slave3 | grep -i ipadd
            "SecondaryIPAddresses": null,
            "IPAddress": "",
                    "IPAddress": "172.27.0.5",

进入其中一个主节点的容器内部

[root@flexusx-251f ~]# docker exec -it redis-master1 /bin/bash       
root@04c85ab05c71:/data# 

注意将ip修改为自己的容器ip,端口对应之前创建的节点port

  • 在使用 redis-cli --cluster create 命令创建 Redis 集群时,Redis 会自动根据提供的节点数量和 --cluster-replicas 1 的参数来分配主节点和从节
[root@flexusx-251f ~]# docker exec -it redis-master1 /bin/bash       
root@04c85ab05c71:/data# redis-cli --cluster create \
      172.27.0.2:6379 \
      172.27.0.3:6379 \
      172.27.0.7:6379 \
      172.27.0.6:6379 \
      172.27.0.4:6379 \
      172.27.0.5:6379 \
      --cluster-replicas 1

当出现提示“Can I set the above configuration? (type 'yes' to accept):”的时候,输入yes即可;

>>> Performing hash slots allocation on 6 nodes...
Master[0] -> Slots 0 - 5460
Master[1] -> Slots 5461 - 10922
Master[2] -> Slots 10923 - 16383
Adding replica 172.27.0.4:6379 to 172.27.0.2:6379
Adding replica 172.27.0.5:6379 to 172.27.0.3:6379
Adding replica 172.27.0.6:6379 to 172.27.0.7:6379
M: 24b3c498fa142da2e7f49f1c60dde9d7b49c8694 172.27.0.2:6379
   slots:[0-5460] (5461 slots) master
M: 31292a53e00a7613e37621404bb3b9fe3da79fac 172.27.0.3:6379
   slots:[5461-10922] (5462 slots) master
M: 7921f3f2a93b319f0689f777f108ea871215a8f9 172.27.0.7:6379
   slots:[10923-16383] (5461 slots) master
S: ebebfbe22aafda4ab34621e336b87833229fb91b 172.27.0.6:6379
   replicates 7921f3f2a93b319f0689f777f108ea871215a8f9
S: 0ed3f67915347da7146eece57f4f7d52c1393065 172.27.0.4:6379
   replicates 24b3c498fa142da2e7f49f1c60dde9d7b49c8694
S: 8c3b43b00509c0a591862ed6ea561b873b0a5edd 172.27.0.5:6379
   replicates 31292a53e00a7613e37621404bb3b9fe3da79fac
Can I set the above configuration? (type 'yes' to accept): yes

这样我们的三主三从就部署成功了

image.png

查看集群状态

第一种方式,任意进入一个容器内部,然后进入6379端口的这个客户端,-c表示以集群的方式进入

[root@flexusx-251f ~]# docker exec -it redis-master1 /bin/bash  
root@04c85ab05c71:/data# redis-cli -p 6379 -c
127.0.0.1:6379> cluster info
cluster_state:ok                     # 正常
cluster_slots_assigned:16384
cluster_slots_ok:16384
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:6                # 6节点
cluster_size:3
cluster_current_epoch:6
cluster_my_epoch:1
cluster_stats_messages_ping_sent:269
cluster_stats_messages_pong_sent:305
cluster_stats_messages_sent:574
cluster_stats_messages_ping_received:300
cluster_stats_messages_pong_received:269
cluster_stats_messages_meet_received:5
cluster_stats_messages_received:574

第二种方式,通过cluster nodes查看

[root@flexusx-251f ~]# docker exec -it redis-master1 /bin/bash  
127.0.0.1:6379> cluster nodes
31292a53e00a7613e37621404bb3b9fe3da79fac 172.27.0.3:6379@16379 master - 0 1726211088655 2 connected 5461-10922
24b3c498fa142da2e7f49f1c60dde9d7b49c8694 172.27.0.2:6379@16379 myself,master - 0 1726211087000 1 connected 0-5460
7921f3f2a93b319f0689f777f108ea871215a8f9 172.27.0.7:6379@16379 master - 0 1726211088000 3 connected 10923-16383
ebebfbe22aafda4ab34621e336b87833229fb91b 172.27.0.6:6379@16379 slave 7921f3f2a93b319f0689f777f108ea871215a8f9 0 1726211087654 3 connected
8c3b43b00509c0a591862ed6ea561b873b0a5edd 172.27.0.5:6379@16379 slave 31292a53e00a7613e37621404bb3b9fe3da79fac 0 1726211087000 2 connected
0ed3f67915347da7146eece57f4f7d52c1393065 172.27.0.4:6379@16379 slave 24b3c498fa142da2e7f49f1c60dde9d7b49c8694 0 1726211086000 1 connected

第三种方式,通过redis-cli --cluster check 172.27.0.2:6379 查看(改成自己的ip)

[root@flexusx-251f ~]# docker exec -it redis-master1 /bin/bash 
root@04c85ab05c71:/data# redis-cli -p 6379 -c
root@04c85ab05c71:/data# redis-cli --cluster check 172.27.0.2:6379
172.27.0.2:6379 (24b3c498...) -> 2 keys | 5461 slots | 1 slaves.
172.27.0.3:6379 (31292a53...) -> 0 keys | 5462 slots | 1 slaves.
172.27.0.7:6379 (7921f3f2...) -> 0 keys | 5461 slots | 1 slaves.
[OK] 2 keys in 3 masters.
0.00 keys per slot on average.
>>> Performing Cluster Check (using node 172.27.0.2:6379)
M: 24b3c498fa142da2e7f49f1c60dde9d7b49c8694 172.27.0.2:6379
   slots:[0-5460] (5461 slots) master
   1 additional replica(s)
M: 31292a53e00a7613e37621404bb3b9fe3da79fac 172.27.0.3:6379
   slots:[5461-10922] (5462 slots) master
   1 additional replica(s)
M: 7921f3f2a93b319f0689f777f108ea871215a8f9 172.27.0.7:6379
   slots:[10923-16383] (5461 slots) master
   1 additional replica(s)
S: ebebfbe22aafda4ab34621e336b87833229fb91b 172.27.0.6:6379
   slots: (0 slots) slave
   replicates 7921f3f2a93b319f0689f777f108ea871215a8f9
S: 8c3b43b00509c0a591862ed6ea561b873b0a5edd 172.27.0.5:6379
   slots: (0 slots) slave
   replicates 31292a53e00a7613e37621404bb3b9fe3da79fac
S: 0ed3f67915347da7146eece57f4f7d52c1393065 172.27.0.4:6379
   slots: (0 slots) slave
   replicates 24b3c498fa142da2e7f49f1c60dde9d7b49c8694
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

数据存储测试

在主master2节点上存数据

[root@flexusx-251f ~]# docker exec -it redis-master2 /bin/bash
root@a900e7ddf6c9:/data# redis-cli -p 6379 -c
127.0.0.1:6379> set name zhangsan
OK
127.0.0.1:6379> set subject Math
OK

在从slave3上查看数据

[root@flexusx-251f ~]# docker exec -it redis-slave3 /bin/bash
root@4bc3876d311b:/data# redis-cli -p 6379 -c
127.0.0.1:6379> get name
-> Redirected to slot [5798] located at 172.27.0.3:6379
"zhangsan"
172.27.0.3:6379> get subject
"Math"

扩容测试

在创建两台节点容器

[root@flexusx-251f ~]# docker run -itd --name redis-master4 --network redis-cluster-net -p 6385:6379 -v /data/redis/share/redis-node-4:/data redis:6.0.8 --cluster-enabled yes  --appendonly yes --port 6379

[root@flexusx-251f ~]# docker run -itd --name redis-slave4 --network redis-cluster-net -p 6386:6379 -v /data/redis/share/redis-slave-4:/data  redis:6.0.8 --cluster-enabled yes  --appendonly yes --port 6379

查看节点ip地址

[root@flexusx-251f ~]# docker inspect redis-master4 | grep -i ipadd                                       "SecondaryIPAddresses": null,
            "IPAddress": "",
                    "IPAddress": "172.27.0.8",
[root@flexusx-251f ~]# docker inspect redis-slave4 | grep -i ipadd
            "SecondaryIPAddresses": null,
            "IPAddress": "",
                    "IPAddress": "172.27.0.9",

进入redis-master4节点,增加节点

[root@flexusx-251f ~]# docker exec -it redis-master4 /bin/bash

root@b77caa384727:/data# redis-cli --cluster  add-node 172.27.0.8:6379 172.27.0.2:6379
>>> Adding node 172.27.0.8:6379 to cluster 172.27.0.2:6379
>>> Performing Cluster Check (using node 172.27.0.2:6379)
M: 24b3c498fa142da2e7f49f1c60dde9d7b49c8694 172.27.0.2:6379
   slots:[0-5460] (5461 slots) master
   1 additional replica(s)
M: 31292a53e00a7613e37621404bb3b9fe3da79fac 172.27.0.3:6379
   slots:[5461-10922] (5462 slots) master
   1 additional replica(s)
M: 7921f3f2a93b319f0689f777f108ea871215a8f9 172.27.0.7:6379
   slots:[10923-16383] (5461 slots) master
   1 additional replica(s)
S: ebebfbe22aafda4ab34621e336b87833229fb91b 172.27.0.6:6379
   slots: (0 slots) slave
   replicates 7921f3f2a93b319f0689f777f108ea871215a8f9
S: 8c3b43b00509c0a591862ed6ea561b873b0a5edd 172.27.0.5:6379
   slots: (0 slots) slave
   replicates 31292a53e00a7613e37621404bb3b9fe3da79fac
S: 0ed3f67915347da7146eece57f4f7d52c1393065 172.27.0.4:6379
   slots: (0 slots) slave
   replicates 24b3c498fa142da2e7f49f1c60dde9d7b49c8694
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
>>> Send CLUSTER MEET to node 172.27.0.8:6379 to make it join the cluster.
[OK] New node added correctly.

查看主从状态

  • 可以看到只有主节点,还未分配从节点
root@b77caa384727:/data# redis-cli --cluster check 172.27.0.2:6379
172.27.0.2:6379 (24b3c498...) -> 2 keys | 5461 slots | 1 slaves.
172.27.0.3:6379 (31292a53...) -> 2 keys | 5462 slots | 1 slaves.
172.27.0.7:6379 (7921f3f2...) -> 0 keys | 5461 slots | 1 slaves.
172.27.0.8:6379 (290b2aa0...) -> 0 keys | 0 slots | 0 slaves.
[OK] 4 keys in 4 masters.
0.00 keys per slot on average.
>>> Performing Cluster Check (using node 172.27.0.2:6379)
M: 24b3c498fa142da2e7f49f1c60dde9d7b49c8694 172.27.0.2:6379
   slots:[0-5460] (5461 slots) master
   1 additional replica(s)
M: 31292a53e00a7613e37621404bb3b9fe3da79fac 172.27.0.3:6379
   slots:[5461-10922] (5462 slots) master
   1 additional replica(s)
M: 7921f3f2a93b319f0689f777f108ea871215a8f9 172.27.0.7:6379
   slots:[10923-16383] (5461 slots) master
   1 additional replica(s)
S: ebebfbe22aafda4ab34621e336b87833229fb91b 172.27.0.6:6379
   slots: (0 slots) slave
   replicates 7921f3f2a93b319f0689f777f108ea871215a8f9
S: 8c3b43b00509c0a591862ed6ea561b873b0a5edd 172.27.0.5:6379
   slots: (0 slots) slave
   replicates 31292a53e00a7613e37621404bb3b9fe3da79fac
S: 0ed3f67915347da7146eece57f4f7d52c1393065 172.27.0.4:6379
   slots: (0 slots) slave
   replicates 24b3c498fa142da2e7f49f1c60dde9d7b49c8694
M: 290b2aa0e79a9c9ad5ebdb6aa468176b61513283 172.27.0.8:6379
   slots: (0 slots) master
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

槽位分配:172.27.0.8:6379还没有分配槽位

root@b77caa384727:/data# redis-cli --cluster reshard 172.27.0.2:6379
>>> Performing Cluster Check (using node 172.27.0.2:6379)
M: 24b3c498fa142da2e7f49f1c60dde9d7b49c8694 172.27.0.2:6379
   slots:[0-5460] (5461 slots) master
   1 additional replica(s)
M: 31292a53e00a7613e37621404bb3b9fe3da79fac 172.27.0.3:6379
   slots:[5461-10922] (5462 slots) master
   1 additional replica(s)
M: 7921f3f2a93b319f0689f777f108ea871215a8f9 172.27.0.7:6379
   slots:[10923-16383] (5461 slots) master
   1 additional replica(s)
S: ebebfbe22aafda4ab34621e336b87833229fb91b 172.27.0.6:6379
   slots: (0 slots) slave
   replicates 7921f3f2a93b319f0689f777f108ea871215a8f9
S: 8c3b43b00509c0a591862ed6ea561b873b0a5edd 172.27.0.5:6379
   slots: (0 slots) slave
   replicates 31292a53e00a7613e37621404bb3b9fe3da79fac
S: 0ed3f67915347da7146eece57f4f7d52c1393065 172.27.0.4:6379
   slots: (0 slots) slave
   replicates 24b3c498fa142da2e7f49f1c60dde9d7b49c8694
M: 290b2aa0e79a9c9ad5ebdb6aa468176b61513283 172.27.0.8:6379
   slots: (0 slots) master
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
How many slots do you want to move (from 1 to 16384)? 4096
What is the receiving node ID? 290b2aa0e79a9c9ad5ebdb6aa468176b61513283
Please enter all the source node IDs.
  Type 'all' to use all the nodes as source nodes for the hash slots.
  Type 'done' once you entered all the source nodes IDs.
Source node #1: all

Ready to move 4096 slots.
  Source nodes:
    M: 24b3c498fa142da2e7f49f1c60dde9d7b49c8694 172.27.0.2:6379
       slots:[0-5460] (5461 slots) master
       1 additional replica(s)
    M: 31292a53e00a7613e37621404bb3b9fe3da79fac 172.27.0.3:6379
       slots:[5461-10922] (5462 slots) master
       1 additional replica(s)
    M: 7921f3f2a93b319f0689f777f108ea871215a8f9 172.27.0.7:6379
       slots:[10923-16383] (5461 slots) master
       1 additional replica(s)
  Destination node:
    M: 290b2aa0e79a9c9ad5ebdb6aa468176b61513283 172.27.0.8:6379
       slots: (0 slots) master
  Resharding plan:
    Moving slot 5461 from 31292a53e00a7613e37621404bb3b9fe3da79fac
.............

查看主从状态

root@b77caa384727:/data# redis-cli --cluster check 172.27.0.2:6379
172.27.0.2:6379 (24b3c498...) -> 1 keys | 4096 slots | 1 slaves.
172.27.0.3:6379 (31292a53...) -> 1 keys | 4096 slots | 1 slaves.
172.27.0.7:6379 (7921f3f2...) -> 0 keys | 4096 slots | 1 slaves.
172.27.0.8:6379 (290b2aa0...) -> 2 keys | 4096 slots | 0 slaves.
[OK] 4 keys in 4 masters.
0.00 keys per slot on average.
>>> Performing Cluster Check (using node 172.27.0.2:6379)
M: 24b3c498fa142da2e7f49f1c60dde9d7b49c8694 172.27.0.2:6379
   slots:[1365-5460] (4096 slots) master
   1 additional replica(s)
M: 31292a53e00a7613e37621404bb3b9fe3da79fac 172.27.0.3:6379
   slots:[6827-10922] (4096 slots) master
   1 additional replica(s)
M: 7921f3f2a93b319f0689f777f108ea871215a8f9 172.27.0.7:6379
   slots:[12288-16383] (4096 slots) master
   1 additional replica(s)
S: ebebfbe22aafda4ab34621e336b87833229fb91b 172.27.0.6:6379
   slots: (0 slots) slave
   replicates 7921f3f2a93b319f0689f777f108ea871215a8f9
S: 8c3b43b00509c0a591862ed6ea561b873b0a5edd 172.27.0.5:6379
   slots: (0 slots) slave
   replicates 31292a53e00a7613e37621404bb3b9fe3da79fac
S: 0ed3f67915347da7146eece57f4f7d52c1393065 172.27.0.4:6379
   slots: (0 slots) slave
   replicates 24b3c498fa142da2e7f49f1c60dde9d7b49c8694
M: 290b2aa0e79a9c9ad5ebdb6aa468176b61513283 172.27.0.8:6379
   slots:[0-1364],[5461-6826],[10923-12287] (4096 slots) master
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

172.27.0.8:6379分配从节点172.27.0.9:6379

# 172.27.0.8:6379节点的ID
root@b77caa384727:/data# redis-cli --cluster add-node 172.27.0.9:6379 172.27.0.8:6379 --cluster-slave --cluster-master-id 290b2aa0e79a9c9ad5ebdb6aa468176b61513283
>>> Adding node 172.27.0.9:6379 to cluster 172.27.0.8:6379
>>> Performing Cluster Check (using node 172.27.0.8:6379)
M: 290b2aa0e79a9c9ad5ebdb6aa468176b61513283 172.27.0.8:6379
   slots:[0-1364],[5461-6826],[10923-12287] (4096 slots) master
M: 24b3c498fa142da2e7f49f1c60dde9d7b49c8694 172.27.0.2:6379
   slots:[1365-5460] (4096 slots) master
   1 additional replica(s)
M: 31292a53e00a7613e37621404bb3b9fe3da79fac 172.27.0.3:6379
   slots:[6827-10922] (4096 slots) master
   1 additional replica(s)
M: 7921f3f2a93b319f0689f777f108ea871215a8f9 172.27.0.7:6379
   slots:[12288-16383] (4096 slots) master
   1 additional replica(s)
S: 8c3b43b00509c0a591862ed6ea561b873b0a5edd 172.27.0.5:6379
   slots: (0 slots) slave
   replicates 31292a53e00a7613e37621404bb3b9fe3da79fac
S: ebebfbe22aafda4ab34621e336b87833229fb91b 172.27.0.6:6379
   slots: (0 slots) slave
   replicates 7921f3f2a93b319f0689f777f108ea871215a8f9
S: 0ed3f67915347da7146eece57f4f7d52c1393065 172.27.0.4:6379
   slots: (0 slots) slave
   replicates 24b3c498fa142da2e7f49f1c60dde9d7b49c8694
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
>>> Send CLUSTER MEET to node 172.27.0.9:6379 to make it join the cluster.
Waiting for the cluster to join

>>> Configure node as replica of 172.27.0.8:6379.
[OK] New node added correctly.

扩容完成

root@b77caa384727:/data# redis-cli --cluster check 172.27.0.2:6379   
172.27.0.2:6379 (24b3c498...) -> 1 keys | 4096 slots | 1 slaves.
172.27.0.3:6379 (31292a53...) -> 1 keys | 4096 slots | 1 slaves.
172.27.0.7:6379 (7921f3f2...) -> 0 keys | 4096 slots | 1 slaves.
172.27.0.8:6379 (290b2aa0...) -> 2 keys | 4096 slots | 1 slaves.
[OK] 4 keys in 4 masters.
0.00 keys per slot on average.
>>> Performing Cluster Check (using node 172.27.0.2:6379)
M: 24b3c498fa142da2e7f49f1c60dde9d7b49c8694 172.27.0.2:6379
   slots:[1365-5460] (4096 slots) master
   1 additional replica(s)
S: c3abe3fa7ef3103d32e19f17c152250e3392c94f 172.27.0.9:6379
   slots: (0 slots) slave
   replicates 290b2aa0e79a9c9ad5ebdb6aa468176b61513283
M: 31292a53e00a7613e37621404bb3b9fe3da79fac 172.27.0.3:6379
   slots:[6827-10922] (4096 slots) master
   1 additional replica(s)
M: 7921f3f2a93b319f0689f777f108ea871215a8f9 172.27.0.7:6379
   slots:[12288-16383] (4096 slots) master
   1 additional replica(s)
S: ebebfbe22aafda4ab34621e336b87833229fb91b 172.27.0.6:6379
   slots: (0 slots) slave
   replicates 7921f3f2a93b319f0689f777f108ea871215a8f9
S: 8c3b43b00509c0a591862ed6ea561b873b0a5edd 172.27.0.5:6379
   slots: (0 slots) slave
   replicates 31292a53e00a7613e37621404bb3b9fe3da79fac
S: 0ed3f67915347da7146eece57f4f7d52c1393065 172.27.0.4:6379
   slots: (0 slots) slave
   replicates 24b3c498fa142da2e7f49f1c60dde9d7b49c8694
M: 290b2aa0e79a9c9ad5ebdb6aa468176b61513283 172.27.0.8:6379
   slots:[0-1364],[5461-6826],[10923-12287] (4096 slots) master
   1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

体验和感受

华为云Flexus X实例,以其卓越的算力、灵活的扩展性和智能的运维管理,为Redis三主三从集群的高效运行提供了强有力的支撑。Redis三主三从集群,作为业界公认的高可用、高性能解决方案,通过数据复制、自动故障转移和读写分离机制,确保了数据的安全性、一致性和系统的稳定性。而华为云Flexus X实例,凭借其出色的资源调度能力和优化的网络架构,进一步提升了集群的处理能力和响应速度。

【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。