redis节点管理-新增从节点
原文:http://blog.sina.com.cn/s/blog_53b45c4d0102wg12.html
新增从节点
新增一个节点7008节点,使用add-node --slave命令。
- [root@localhost redis-cluster]# cp -r redis01/ redis08
- [root@localhost redis-cluster]# cd redis08/
- [root@localhost redis08]# sed -i "s/7001/7008/g" ./redis.conf
- [root@localhost redis08]# ./redis-server redis.conf
redis-trib增加从节点的命令为:
- ./redis-trib.rb add-node --slave --master-id $[nodeid] 127.0.0.1:7008 127.0.0.1:7000
nodeid为要加到master主节点的node id,127.0.0.1:7008为新增的从节点,127.0.0.1:7000为集群的一个节点(集群的任意节点都行),用来辨识是哪个集群;如果没有给定那个主节点--master-id的话,redis-trib将会将新增的从节点随机到从节点较少的主节点上。
现在我们添加一下7008,看是否会自动加到没有从节点的7007主节点上。
- [root@localhost redis-cluster]# ./redis-trib.rb add-node --slave 127.0.0.1:7008 127.0.0.1:7001>>> Adding node 127.0.0.1:7008 to cluster 127.0.0.1:7001
- >>> Performing Cluster Check (using node 127.0.0.1:7001)
- M: dd19221c404fb2fc4da37229de56bab755c76f2b 127.0.0.1:7001
- slots:1365-5460 (4096 slots) master
- 1 additional replica(s)
- M: ee3efb90e5ac0725f15238a64fc60a18a71205d7 127.0.0.1:7007
- slots:0-1364,5461-6826,10923-12287 (4096 slots) master
- 0 additional replica(s)
- M: a5db243087d8bd423b9285fa8513eddee9bb59a6 127.0.0.1:7005
- slots:6827-10922 (4096 slots) master
- 1 additional replica(s)
- S: 8bb3ede48319b46d0015440a91ab277da9353c8b 127.0.0.1:7006
- slots: (0 slots) slave
- replicates f9886c71e98a53270f7fda961e1c5f730382d48f
- M: f9886c71e98a53270f7fda961e1c5f730382d48f 127.0.0.1:7003
- slots:12288-16383 (4096 slots) master
- 1 additional replica(s)
- S: 1f07d76585bfab35f91ec711ac53ab4bc00f2d3a 127.0.0.1:7002
- slots: (0 slots) slave
- replicates a5db243087d8bd423b9285fa8513eddee9bb59a6
- S: 50ce1ea59106b4c2c6bc502593a6a7a7dabf5041 127.0.0.1:7004
- slots: (0 slots) slave
- replicates dd19221c404fb2fc4da37229de56bab755c76f2b
- [OK] All nodes agree about slots configuration.
- >>> Check for open slots...
- >>> Check slots coverage...
- [OK] All 16384 slots covered.
- Automatically selected master 127.0.0.1:7007
- >>> Send CLUSTER MEET to node 127.0.0.1:7008 to make it join the cluster.
- Waiting for the cluster to join.
- >>> Configure node as replica of 127.0.0.1:7007.
- [OK] New node added correctly.
- [root@localhost redis-cluster]#
可以看到自动选择了127.0.0.1:7007为master主节点,并且添加成功。
可以check一下7008:
- [root@localhost redis-cluster]# ./redis-trib.rb check 127.0.0.1:7008
- >>> Performing Cluster Check (using node 127.0.0.1:7008)
- S: 2ab1b061c36f30ae35604e9a171ae3afdc3c87e5 127.0.0.1:7008
- slots: (0 slots) slave
- replicates ee3efb90e5ac0725f15238a64fc60a18a71205d7
- M: a5db243087d8bd423b9285fa8513eddee9bb59a6 127.0.0.1:7005
- slots:6827-10922 (4096 slots) master
- 1 additional replica(s)
- M: dd19221c404fb2fc4da37229de56bab755c76f2b 127.0.0.1:7001
- slots:1365-5460 (4096 slots) master
- 1 additional replica(s)
- S: 8bb3ede48319b46d0015440a91ab277da9353c8b 127.0.0.1:7006
- slots: (0 slots) slave
- replicates f9886c71e98a53270f7fda961e1c5f730382d48f
- M: ee3efb90e5ac0725f15238a64fc60a18a71205d7 127.0.0.1:7007
- slots:0-1364,5461-6826,10923-12287 (4096 slots) master
- 1 additional replica(s)
- S: 50ce1ea59106b4c2c6bc502593a6a7a7dabf5041 127.0.0.1:7004
- slots: (0 slots) slave
- replicates dd19221c404fb2fc4da37229de56bab755c76f2b
- M: f9886c71e98a53270f7fda961e1c5f730382d48f 127.0.0.1:7003
- slots:12288-16383 (4096 slots) master
- 1 additional replica(s)
- S: 1f07d76585bfab35f91ec711ac53ab4bc00f2d3a 127.0.0.1:7002
- slots: (0 slots) slave
- replicates a5db243087d8bd423b9285fa8513eddee9bb59a6
- [OK] All nodes agree about slots configuration.
- >>> Check for open slots...
- >>> Check slots coverage...
- [OK] All 16384 slots covered.
- [root@localhost redis-cluster]#
可以看到7008作为了7007的从节点。
再测试一下指定主节点添加从节点,给7007增加7009从节点。
- [root@localhost redis-cluster]# cp -r redis01/ redis09
- [root@localhost redis-cluster]# cd redis09
- [root@localhost redis09]# sed -i "s/7001/7009/g" ./redis.conf
- [root@localhost redis09]# ./redis-server redis.conf
添加7007主节点上
- [root@localhost redis-cluster]# ./redis-trib.rb add-node --slave --master-id ee3efb90e5ac0725f15238a64fc60a18a71205d7 127.0.0.1:7009 127.0.0.1:7001
- >>> Adding node 127.0.0.1:7009 to cluster 127.0.0.1:7001
- >>> Performing Cluster Check (using node 127.0.0.1:7001)
- M: dd19221c404fb2fc4da37229de56bab755c76f2b 127.0.0.1:7001
- slots:1365-5460 (4096 slots) master
- 1 additional replica(s)
- S: 2ab1b061c36f30ae35604e9a171ae3afdc3c87e5 127.0.0.1:7008
- slots: (0 slots) slave
- replicates ee3efb90e5ac0725f15238a64fc60a18a71205d7
- M: ee3efb90e5ac0725f15238a64fc60a18a71205d7 127.0.0.1:7007
- slots:0-1364,5461-6826,10923-12287 (4096 slots) master
- 1 additional replica(s)
- M: a5db243087d8bd423b9285fa8513eddee9bb59a6 127.0.0.1:7005
- slots:6827-10922 (4096 slots) master
- 1 additional replica(s)
- S: 8bb3ede48319b46d0015440a91ab277da9353c8b 127.0.0.1:7006
- slots: (0 slots) slave
- replicates f9886c71e98a53270f7fda961e1c5f730382d48f
- M: f9886c71e98a53270f7fda961e1c5f730382d48f 127.0.0.1:7003
- slots:12288-16383 (4096 slots) master
- 1 additional replica(s)
- S: 1f07d76585bfab35f91ec711ac53ab4bc00f2d3a 127.0.0.1:7002
- slots: (0 slots) slave
- replicates a5db243087d8bd423b9285fa8513eddee9bb59a6
- S: 50ce1ea59106b4c2c6bc502593a6a7a7dabf5041 127.0.0.1:7004
- slots: (0 slots) slave
- replicates dd19221c404fb2fc4da37229de56bab755c76f2b
- [OK] All nodes agree about slots configuration.
- >>> Check for open slots...
- >>> Check slots coverage...
- [OK] All 16384 slots covered.
- >>> Send CLUSTER MEET to node 127.0.0.1:7009 to make it join the cluster.
- Waiting for the cluster to join.
- >>> Configure node as replica of 127.0.0.1:7007.
- [OK] New node added correctly.
- [root@localhost redis-cluster]#
显示从节点7009节点添加到7007主节点,可以看一下7007的从节点,如下:
- [root@localhost redis-cluster]# cd ./redis07
- [root@localhost redis07]# ./redis-cli -c -p 7007 cluster nodes | grep ee3efb90e5ac0725f15238a64fc60a18a71205d7
- 1f51443ede952b98724fea2a12f61fe710ab6cb1 127.0.0.1:7009 slave ee3efb90e5ac0725f15238a64fc60a18a71205d7 0 1462962710266 8 connected
- ee3efb90e5ac0725f15238a64fc60a18a71205d7 127.0.0.1:7007 myself,master - 0 0 8 connected 0-1364 5461-6826 10923-12287
- 2ab1b061c36f30ae35604e9a171ae3afdc3c87e5 127.0.0.1:7008 slave ee3efb90e5ac0725f15238a64fc60a18a71205d7 0 1462962711607 8 connected
- [root@localhost redis07]#
maser 7007有2个slave 7008,7009。
我们测试一下7007节点挂掉,看7008和7009那个成为主节点。
- [root@localhost redis-cluster]# ps -ef | grep redis
- root 7950 1 0 12:50 ? 00:02:05 ./redis-server 127.0.0.1:7001 [cluster]
- root 7956 1 0 12:50 ? 00:02:11 ./redis-server 127.0.0.1:7003 [cluster]
- root 7960 1 0 12:50 ? 00:01:47 ./redis-server 127.0.0.1:7004 [cluster]
- root 7964 1 0 12:50 ? 00:02:07 ./redis-server 127.0.0.1:7005 [cluster]
- root 7966 1 0 12:50 ? 00:01:46 ./redis-server 127.0.0.1:7006 [cluster]
- root 12070 1 0 15:14 ? 00:01:08 ./redis-server 127.0.0.1:7002 [cluster]
- root 13441 1 0 16:09 ? 00:01:25 ./redis-server 127.0.0.1:7007 [cluster]
- root 15939 1 0 17:41 ? 00:00:20 ./redis-server 127.0.0.1:7008 [cluster]
- root 16623 1 0 18:07 ? 00:00:10 ./redis-server 127.0.0.1:7009 [cluster]
- root 17295 10581 0 18:37 pts/2 00:00:00 grep --color=auto redis
- [root@localhost redis-cluster]# kill -9 13441
- [root@localhost redis-cluster]# cd ./redis08
- [root@localhost redis08]# ./redis-cli -c -p 7008
- 127.0.0.1:7008> get name
- -> Redirected to slot [5798] located at 127.0.0.1:7009
- "andy"
- 127.0.0.1:7009> cluster nodes
- ee3efb90e5ac0725f15238a64fc60a18a71205d7 127.0.0.1:7007 master,fail - 1462963082317 1462963080194 8 disconnected
- 50ce1ea59106b4c2c6bc502593a6a7a7dabf5041 127.0.0.1:7004 slave dd19221c404fb2fc4da37229de56bab755c76f2b 0 1462963170968 1 connected
- f9886c71e98a53270f7fda961e1c5f730382d48f 127.0.0.1:7003 master - 0 1462963168525 3 connected 12288-16383
- dd19221c404fb2fc4da37229de56bab755c76f2b 127.0.0.1:7001 master - 0 1462963164466 1 connected 1365-5460
- 2ab1b061c36f30ae35604e9a171ae3afdc3c87e5 127.0.0.1:7008 slave 1f51443ede952b98724fea2a12f61fe710ab6cb1 0 1462963167508 9 connected
- 1f51443ede952b98724fea2a12f61fe710ab6cb1 127.0.0.1:7009 myself,master - 0 0 9 connected 0-1364 5461-6826 10923-12287
- 1f07d76585bfab35f91ec711ac53ab4bc00f2d3a 127.0.0.1:7002 slave a5db243087d8bd423b9285fa8513eddee9bb59a6 0 1462963170564 7 connected
- 8bb3ede48319b46d0015440a91ab277da9353c8b 127.0.0.1:7006 slave f9886c71e98a53270f7fda961e1c5f730382d48f 0 1462963167915 3 connected
- a5db243087d8bd423b9285fa8513eddee9bb59a6 127.0.0.1:7005 master - 0 1462963169538 7 connected 6827-10922
- 127.0.0.1:7009>
可以看到7009代替7007成了主节点。
重启7007之后,会自动变成7009的从节点。
- [root@localhost redis-cluster]# cd redis07
- [root@localhost redis07]# ./redis-server redis.conf
- [root@localhost redis07]# cd ../
- [root@localhost redis-cluster]# ./redis-trib.rb check 127.0.0.1:7007
- >>> Performing Cluster Check (using node 127.0.0.1:7007)
- S: ee3efb90e5ac0725f15238a64fc60a18a71205d7 127.0.0.1:7007
- slots: (0 slots) slave
- replicates 1f51443ede952b98724fea2a12f61fe710ab6cb1
- S: 50ce1ea59106b4c2c6bc502593a6a7a7dabf5041 127.0.0.1:7004
- slots: (0 slots) slave
- replicates dd19221c404fb2fc4da37229de56bab755c76f2b
- M: 1f51443ede952b98724fea2a12f61fe710ab6cb1 127.0.0.1:7009
- slots:0-1364,5461-6826,10923-12287 (4096 slots) master
- 2 additional replica(s)
- S: 8bb3ede48319b46d0015440a91ab277da9353c8b 127.0.0.1:7006
- slots: (0 slots) slave
- replicates f9886c71e98a53270f7fda961e1c5f730382d48f
- M: dd19221c404fb2fc4da37229de56bab755c76f2b 127.0.0.1:7001
- slots:1365-5460 (4096 slots) master
- 1 additional replica(s)
- M: a5db243087d8bd423b9285fa8513eddee9bb59a6 127.0.0.1:7005
- slots:6827-10922 (4096 slots) master
- 1 additional replica(s)
- S: 1f07d76585bfab35f91ec711ac53ab4bc00f2d3a 127.0.0.1:7002
- slots: (0 slots) slave
- replicates a5db243087d8bd423b9285fa8513eddee9bb59a6
- M: f9886c71e98a53270f7fda961e1c5f730382d48f 127.0.0.1:7003
- slots:12288-16383 (4096 slots) master
- 1 additional replica(s)
- S: 2ab1b061c36f30ae35604e9a171ae3afdc3c87e5 127.0.0.1:7008
- slots: (0 slots) slave
- replicates 1f51443ede952b98724fea2a12f61fe710ab6cb1
- [OK] All nodes agree about slots configuration.
- >>> Check for open slots...
- >>> Check slots coverage...
- [OK] All 16384 slots covered.
- [root@localhost redis-cluster]#
redis节点管理-新增从节点的更多相关文章
- redis节点管理-新增主节点
原文:http://blog.sina.com.cn/s/blog_53b45c4d0102wg11.html 集群节点添加 节点新增包括新增主节点.从节点两种情况.以下分别做一下测试: 1.新增主节 ...
- redis 集群添加新节点
准备好需要添加的节点:如何创建节点 启动创建的节点: 启动成功: 添加新节点:redis-cli --cluster add-node 127.0.0.1:7006 127.0.0.1:7000 第 ...
- Redis服务之集群节点管理
上一篇博客主要聊了下redis cluster的部署配置,以及使用redis.trib.rb工具所需ruby环境的搭建.使用redis.trib.rb工具创建.查看集群相关信息等,回顾请参考https ...
- redis 集群新增节点,slots槽分配,删除节点, [ERR] Calling MIGRATE ERR Syntax error, try CLIENT (LIST | KILL | GET...
redis reshard 重新分槽(slots) https://github.com/antirez/redis/issues/5029 redis 官方已确认该bug redis 集群重新(re ...
- redis cluster节点管理测试
####redis v3.2.0###添加节点:1.添加master节点 170 ./redis-trib.rb add-node 127.0.0.1:7007 127.0.0.1:7001 171 ...
- redis集群添加删除节点
Redis3.0集群添加节点 1:首先把需要添加的节点启动 cd /usr/local/cluster/ mkdir 7006 cp /usr/local/cluster/redis.conf /u ...
- Redis 集群环境添加节点失败问题
最近在给公司网管系统Redis集群环境添加节点时候遇到一个问题,提示新增的Node不为空: [root@node00 src]# ./redis-trib.rb add-node --slave -- ...
- redis cluster 添加 删除 重分配 节点
redis cluster配置好,并运行一段时间后,我们想添加节点,或者删除节点,该怎么办呢. 一,redis cluster命令 //集群(cluster) CLUSTER INFO 打印集群的信 ...
- element-ui组件,全选树节点,新增数据子节点数据,出现回填问题
案情分析:全选后父节点被选中保存,在这个树节点下新增数据时,就会出现,也被选中,事实上数据是没有被选中,也就意味着权限未被配置,而显示是已经配置了,显然这个是一个bug 1.处理前,直接用下面的方法很 ...
随机推荐
- xshell+xming连接服务器虚拟机启动mininet网络
困于vnc连实验室的服务器虚拟机,一直出现页面不稳定的情况,然后本机虚拟机又带不起来,今天跟学弟交流,知道了ssh连接服务器的办法,心情好晴朗! xshell下载和安装,xshell使用 xshell ...
- Win10默认图片查看器更改
Win10自带的图片查看器不是很习惯,其背景乌漆嘛黑,宽扁的额头让人想起了黑边火腿肠手机,无法直视.怀念Win7和Win8.1的图片查看器,一个鼠标滚轮缩放自如的酸爽感觉.但却遗憾地发现,并不能直观地 ...
- springboot基础知识学习
一.springboot中常用的注解: 原文链接:http://blog.csdn.net/lafengwnagzi/article/details/53034369 原文链接:http://www. ...
- FineReport——自定义登录页
统一的接口: http://localhost:8075/WebReport/ReportServer?op=fs_load&cmd=sso&fr_username=XX&fr ...
- Struts2学习笔记04 之 拦截器
一.创建拦截器组件 1. 创建一个类,实现Interceptor接口,并实现intercept方法 2.注册拦截器 3.引用拦截器 二.拦截器栈 预置拦截器: 默认引用拦截器 拦截器调用顺序: Fil ...
- 【转】Jmeter-----函数引用和函数重定向
详见内文
- AC日记——【模板】分块/带修改莫队(数颜色) 洛谷 P1903
[模板]分块/带修改莫队(数颜色) 思路: 带修改莫队: (伏地膜xxy): 代码: #include <bits/stdc++.h> using namespace std; #defi ...
- C#使用NOPI生成excel要点记载
很久没动手写博客了,最近由于公司比较忙,接触了不同类容,对自己的技术和业务理解有了更深入的理解.今天有点小空,将前段时间所运用到的一些知识点记录下来. 由于公司业务需要统计一些数据,所以对于我们来说, ...
- php5.5 安装
1.php安装 wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo yum install zl ...
- Python urllib2 设置超时时间并处理超时异常
可以使用 except: 捕获任何异常,包括 SystemExit 和 KeyboardInterupt,不过这样不便于程序的调试和使用 最简单的情况是捕获 urllib2.URLError try: ...