一、准备好有三个主节点的集群127.0.0.1:8000 cluster nodes8ce851252f32fcab268e77d3b3ed976d57d2f498 10.211.55.5:8000 myself,master - 0 0 1 connected 0-54606f4a31fc322725fc4ed453a588f344fed4f261bf 10....
一、准备好有三个主节点的集群
127.0.0.1:8000> cluster nodes
8ce851252f32fcab268e77d3b3ed976d57d2f498 10.211.55.5:8000 myself,master - 0 0 1 connected 0-5460
6f4a31fc322725fc4ed453a588f344fed4f261bf 10.211.55.5:8001 master - 0 1538582282356 2 connected 5461-10922
da7d09090520a0e6287ea12fe7f48225d6665f68 10.211.55.5:8002 master - 0 1538582283359 3 connected 10923-16383
测试了下,可以按key值转发到对应的槽道节点存放
127.0.0.1:8000> set name lihua
-> Redirected to slot [5798] located at 10.211.55.5:8001
OK
10.211.55.5:8001>
二、动态添加主节点
[root@cenos01 src]# ./redis-trib.rb add-node 10.211.55.5:8003 10.211.55.5:8000
Adding node 10.211.55.5:8003 to cluster 10.211.55.5:8000
Performing Cluster Check (using node 10.211.55.5:8000)
M: 8ce851252f32fcab268e77d3b3ed976d57d2f498 10.211.55.5:8000
slots:0-5460 (5461 slots) master
0 additional replica(s)
M: 6f4a31fc322725fc4ed453a588f344fed4f261bf 10.211.55.5:8001
slots:5461-10922 (5462 slots) master
0 additional replica(s)
M: da7d09090520a0e6287ea12fe7f48225d6665f68 10.211.55.5:8002
slots:10923-16383 (5461 slots) master
0 additional replica(s)
[OK] All nodes agree about slots configuration.Check for open slots…
Check slots coverage…
[OK] All 16384 slots covered.Send CLUSTER MEET to node 10.211.55.5:8003 to make it join the cluster.
[OK] New node added correctly.
注意:8003是新节点,8000是集群中的任意一个节点
三、添加成功后,查询集群节点信息,但此时还没有槽道
10.211.55.5:8001> cluster nodes
da23623c6e915de5256bb2252cd1057d4f29e558 10.211.55.5:8003 master - 0 1538583102565 0 connected
6f4a31fc322725fc4ed453a588f344fed4f261bf 10.211.55.5:8001 myself,master - 0 0 2 connected 5461-10922
8ce851252f32fcab268e77d3b3ed976d57d2f498 10.211.55.5:8000 master - 0 1538583103571 1 connected 0-5460
da7d09090520a0e6287ea12fe7f48225d6665f68 10.211.55.5:8002 master - 0 1538583104576 3 connected 10923-16383
10.211.55.5:8001>
四、动态添加从节点
把8004作为8001的从节点加入到集群中
–slave 指定当前节点以从节点角色添加到集群中
–master-id 后面跟随主节点的masterid值,cluster nodes可以查看
[root@cenos01 src]# ./redis-trib.rb add-node --slave --master-id 6f4a31fc322725fc4ed453a588f344fed4f261bf 10.211.55.5:8004 10.211.55.5:8000
五、添加完成后检查结果:
10.211.55.5:8001> cluster nodes
da23623c6e915de5256bb2252cd1057d4f29e558 10.211.55.5:8003 master - 0 1538583619331 0 connected
3f3049540ba60e30080847e78ccf832f94961da2 10.211.55.5:8004 slave 6f4a31fc322725fc4ed453a588f344fed4f261bf 0 1538583620339 2 connected
6f4a31fc322725fc4ed453a588f344fed4f261bf 10.211.55.5:8001 myself,master - 0 0 2 connected 5461-10922
8ce851252f32fcab268e77d3b3ed976d57d2f498 10.211.55.5:8000 master - 0 1538583622352 1 connected 0-5460
da7d09090520a0e6287ea12fe7f48225d6665f68 10.211.55.5:8002 master - 0 1538583621346 3 connected 10923-16383
以上就是redis集群的搭建过程。
为新添加的节点分配槽道信息见本人的下一篇博文
本文标题为:redis集群搭建及问题的决方法(二)
- 基于Python制作一个简单的文章搜索工具 2023-07-28
- 搭建单机Redis缓存服务的实现 2023-07-13
- 在阿里云CentOS 6.8上安装Redis 2023-09-12
- Mongodb启动报错完美解决方案:about to fork child process,waiting until server is ready for connections. 2023-07-16
- Numpy中如何创建矩阵并等间隔抽取数据 2023-07-28
- redis清除数据 2023-09-13
- Oracle 删除大量表记录操作分析总结 2023-07-23
- SQLSERVER调用C#的代码实现 2023-07-29
- MySQL8.0.28安装教程详细图解(windows 64位) 2023-07-26
- SQL Server 2022 AlwaysOn新特性之包含可用性组详解 2023-07-29