注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

Oracle、MySQL资料及经验

.

 
 
 

日志

 
 

redis cluster 添加节点  

2016-07-29 17:00:01|  分类: hadoop与nosql |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
给之前的三对主从节点的redis cluster 添加一个主从节点

1. 准备一个两个节点并启动
[root@server2 etc]# redis-server redis_7300.conf
[root@server2 etc]# redis-server redis_7301.conf

2. 添加一个主节点到集群
语法:redis-trib.rb    add-node        new_host:new_port existing_host:existing_port
[root@server2 ~]# redis-trib.rb add-node 10.1.20.38:7300 10.1.20.33:6300
>>> Adding node 10.1.20.38:7300 to cluster 10.1.20.33:6300
Connecting to node 10.1.20.33:6300: OK
Connecting to node 10.1.20.38:6300: OK
Connecting to node 10.1.20.35:6300: OK
Connecting to node 10.1.20.35:6301: OK
Connecting to node 10.1.20.38:6301: OK
Connecting to node 10.1.20.33:6301: OK
>>> Performing Cluster Check (using node 10.1.20.33:6300)
M: 4868d433cd4db8e76e9d4b83ee77f623f93bfce8 10.1.20.33:6300
   slots:10923-16383 (5461 slots) master
   1 additional replica(s)
M: ec59102a299531c9e4f7717953823804f1d742d2 10.1.20.38:6300
   slots:0-5460 (5461 slots) master
   1 additional replica(s)
M: 3fc4390e9f13a5555ef5055df056c5966661638c 10.1.20.35:6300
   slots:5461-10922 (5462 slots) master
   1 additional replica(s)
S: a082694077593ae517fa92ba28eb6640ee448576 10.1.20.35:6301
   slots: (0 slots) slave
   replicates ec59102a299531c9e4f7717953823804f1d742d2
S: a9e4a28842682363abdbfa4e21cb5b48b69b5355 10.1.20.38:6301
   slots: (0 slots) slave
   replicates 3fc4390e9f13a5555ef5055df056c5966661638c
S: 94827af28db9344a233e5598d4a22f2a12c68193 10.1.20.33:6301
   slots: (0 slots) slave
   replicates 4868d433cd4db8e76e9d4b83ee77f623f93bfce8
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
Connecting to node 10.1.20.38:7300: OK
>>> Send CLUSTER MEET to node 10.1.20.38:7300 to make it join the cluster.
[OK] New node added correctly.

查看现在的节点情况:
已经有了4个master,3个slave
10.1.20.35:6300> cluster nodes
ec59102a299531c9e4f7717953823804f1d742d2 10.1.20.38:6300 master - 0 1469779668742 3 connected 0-5460
a082694077593ae517fa92ba28eb6640ee448576 10.1.20.35:6301 slave ec59102a299531c9e4f7717953823804f1d742d2 0 1469779668539 3 connected
94827af28db9344a233e5598d4a22f2a12c68193 10.1.20.33:6301 slave 4868d433cd4db8e76e9d4b83ee77f623f93bfce8 0 1469779661605 4 connected
3fc4390e9f13a5555ef5055df056c5966661638c 10.1.20.35:6300 myself,master - 0 0 2 connected 5461-10922
4868d433cd4db8e76e9d4b83ee77f623f93bfce8 10.1.20.33:6300 master - 0 1469779666703 1 connected 10923-16383
a9e4a28842682363abdbfa4e21cb5b48b69b5355 10.1.20.38:6301 slave 3fc4390e9f13a5555ef5055df056c5966661638c 0 1469779667725 6 connected
10eb5ee502bc5ebfdb29d3d021532eb436150ebf 10.1.20.38:7300 master - 0 1469779665681 0 connected

3. 给刚才的主节点添加从节点
语法:add-node        new_host:new_port         existing_host:existing_port               --master-id <arg>                  --slave
10.1.20.38:7301是需要新加的从节点,10.1.20.33:6300是集群已存在的任意节点,--master-id 指定这个从节点的主节点ID,--slave 指定要加的是从节点。
[root@server ~]# redis-trib.rb add-node  --slave  10.1.20.38:7301    10.1.20.33:6300   --master-id 10eb5ee502bc5ebfdb29d3d021532eb436150ebf
[ERR] Wrong number of arguments for specified sub command   
--很奇怪必须改一下顺序才能执行成功,如下:
[root@server ~]# redis-trib.rb add-node --slave --master-id 10eb5ee502bc5ebfdb29d3d021532eb436150ebf   10.1.20.38:7301    10.1.20.33:6300
>>> Adding node 10.1.20.38:7301 to cluster 10.1.20.33:6300
Connecting to node 10.1.20.33:6300: OK
Connecting to node 10.1.20.38:6300: OK
Connecting to node 10.1.20.35:6300: OK
Connecting to node 10.1.20.35:6301: OK
Connecting to node 10.1.20.38:6301: OK
Connecting to node 10.1.20.38:7300: OK
Connecting to node 10.1.20.33:6301: OK
>>> Performing Cluster Check (using node 10.1.20.33:6300)
M: 4868d433cd4db8e76e9d4b83ee77f623f93bfce8 10.1.20.33:6300
   slots:10923-16383 (5461 slots) master
   1 additional replica(s)
M: ec59102a299531c9e4f7717953823804f1d742d2 10.1.20.38:6300
   slots:0-5460 (5461 slots) master
   1 additional replica(s)
M: 3fc4390e9f13a5555ef5055df056c5966661638c 10.1.20.35:6300
   slots:5461-10922 (5462 slots) master
   1 additional replica(s)
S: a082694077593ae517fa92ba28eb6640ee448576 10.1.20.35:6301
   slots: (0 slots) slave
   replicates ec59102a299531c9e4f7717953823804f1d742d2
S: a9e4a28842682363abdbfa4e21cb5b48b69b5355 10.1.20.38:6301
   slots: (0 slots) slave
   replicates 3fc4390e9f13a5555ef5055df056c5966661638c
M: 10eb5ee502bc5ebfdb29d3d021532eb436150ebf 10.1.20.38:7300
   slots: (0 slots) master
   0 additional replica(s)
S: 94827af28db9344a233e5598d4a22f2a12c68193 10.1.20.33:6301
   slots: (0 slots) slave
   replicates 4868d433cd4db8e76e9d4b83ee77f623f93bfce8
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
Connecting to node 10.1.20.38:7301: OK
>>> Send CLUSTER MEET to node 10.1.20.38:7301 to make it join the cluster.
Waiting for the cluster to join.
>>> Configure node as replica of 10.1.20.38:7300.
[OK] New node added correctly.


4. 迁移一些slot给新节点
语法:  reshard         host:port  
                  --to <arg>
                  --yes
                  --from <arg>
                  --slots <arg>
[root@server1 ~]# redis-trib.rb reshard 10.1.20.33:6300
Connecting to node 10.1.20.33:6300: OK
Connecting to node 10.1.20.38:6300: OK
Connecting to node 10.1.20.35:6300: OK
Connecting to node 10.1.20.38:7301: OK
Connecting to node 10.1.20.35:6301: OK
Connecting to node 10.1.20.38:6301: OK
Connecting to node 10.1.20.38:7300: OK
Connecting to node 10.1.20.33:6301: OK
>>> Performing Cluster Check (using node 10.1.20.33:6300)
M: 4868d433cd4db8e76e9d4b83ee77f623f93bfce8 10.1.20.33:6300
   slots:10923-16383 (4096 slots) master
   1 additional replica(s)
M: ec59102a299531c9e4f7717953823804f1d742d2 10.1.20.38:6300
   slots:0-5460 (4096 slots) master
   1 additional replica(s)
M: 3fc4390e9f13a5555ef5055df056c5966661638c 10.1.20.35:6300
   slots:5461-10922 (4096 slots) master
   1 additional replica(s)
S: 5823180fc82e4765aaad8497a53ea2baba11b4c9 10.1.20.38:7301
   slots: (0 slots) slave
   replicates 10eb5ee502bc5ebfdb29d3d021532eb436150ebf
S: a082694077593ae517fa92ba28eb6640ee448576 10.1.20.35:6301
   slots: (0 slots) slave
   replicates ec59102a299531c9e4f7717953823804f1d742d2
S: a9e4a28842682363abdbfa4e21cb5b48b69b5355 10.1.20.38:6301
   slots: (0 slots) slave
   replicates 3fc4390e9f13a5555ef5055df056c5966661638c
M: 10eb5ee502bc5ebfdb29d3d021532eb436150ebf 10.1.20.38:7300
   slots: (0 slots) master
   1 additional replica(s)
S: 94827af28db9344a233e5598d4a22f2a12c68193 10.1.20.33:6301
   slots: (0 slots) slave
   replicates 4868d433cd4db8e76e9d4b83ee77f623f93bfce8
[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  --共16384个slot,原来3个节点,每个节点上5461个slot,现在4个节点,可以每个节点平均4096个slot。
What is the receiving node ID? 5ef18f95f75756891aa948ea1f200044f1d3947c  #设置接收这4096个slot的节点ID,也就是刚才新加的10.1.20.38:7301的ID
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:4868d433cd4db8e76e9d4b83ee77f623f93bfce8   #设置这4096slot的来源ID,把这个ID前4096/3=1365的slot取出给新加入的10.1.20.38:7301
Source node #2:ec59102a299531c9e4f7717953823804f1d742d2    #设置这4096slot的来源ID,把这个ID前4096/3=1365的slot取出给新加入的10.1.20.38:7301
Source node #3:3fc4390e9f13a5555ef5055df056c5966661638c      #设置这4096slot的来源ID,把这个ID前4096/3=1365的slot取出给新加入的10.1.20.38:7301
Source node #4:done   #输入done开始做一些初始化操作
此处省略
Do you want to proceed with the proposed reshard plan (yes/no)? yes  输入yes确认开始迁移slot

5. 查看slot的分布情况
10.1.20.33:6300> cluster nodes
ec59102a299531c9e4f7717953823804f1d742d2 10.1.20.38:6300 master - 0 1469781936652 3 connected 1365-5460
3fc4390e9f13a5555ef5055df056c5966661638c 10.1.20.35:6300 master - 0 1469781939714 2 connected 6827-10922
5823180fc82e4765aaad8497a53ea2baba11b4c9 10.1.20.38:7301 slave 10eb5ee502bc5ebfdb29d3d021532eb436150ebf 0 1469781938695 7 connected
a082694077593ae517fa92ba28eb6640ee448576 10.1.20.35:6301 slave ec59102a299531c9e4f7717953823804f1d742d2 0 1469781936038 5 connected
a9e4a28842682363abdbfa4e21cb5b48b69b5355 10.1.20.38:6301 slave 3fc4390e9f13a5555ef5055df056c5966661638c 0 1469781937674 6 connected
4868d433cd4db8e76e9d4b83ee77f623f93bfce8 10.1.20.33:6300 myself,master - 0 0 1 connected 12288-16383
10eb5ee502bc5ebfdb29d3d021532eb436150ebf 10.1.20.38:7300 master - 0 1469781935628 7 connected 0-1364 5461-6826 10923-12287  --显示分别从之前的三个节点中取了1365个slot。
94827af28db9344a233e5598d4a22f2a12c68193 10.1.20.33:6301 slave 4868d433cd4db8e76e9d4b83ee77f623f93bfce8 0 1469781934603 4 connected

  评论这张
 
阅读(139)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017