首页 > 编程开发 > 数据库教程 > redis教程

redis新增集群节点-redis集群管理

2016-07-21 22:18:40| 发布: | 浏览: 1024

新增一个节点6383,并启动


执行redis-trib.rb add-node命令添加节点

redis-trib.rb add-node  new_host:new_port existing_host:existing_port
[root@master redis-cluster]# /opt/redis/redis-3.2.1/src/redis-trib.rb add-node 192.168.56.101:6383 192.168.56.101:6380
>>> Adding node 192.168.56.101:6383 to cluster 192.168.56.101:6380
>>> Performing Cluster Check (using node 192.168.56.101:6380)
M: ecaef90fb93d61edd7522221136be88ae66ad3bc 192.168.56.101:6380
   slots:0-5460 (5461 slots) master
   0 additional replica(s)
M: 52953677dbc82dc4f17b33a922b38462944b002c 192.168.56.101:6382
   slots:10923-16383 (5461 slots) master
   0 additional replica(s)
M: c6e6b65324fac0711a22439d264cca141d2e5082 192.168.56.101:6381
   slots:5461-10922 (5462 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 192.168.56.101:6383 to make it join the cluster.
[OK] New node added correctly.


查看集群信息:

192.168.56.101:6382> cluster nodes
03596d92625f1b778f29eb4a9128d92809dfd79a 192.168.56.101:6381 master - 0 1468853934619 2 connected 5461-10922
e6d316a0dcd7cfcc98de645d86989d5527e86e55 192.168.56.101:6383 master - 0 1468853932181 0 connected
b1939026deb80fedde7bdb22c1df3ecfaa72f608 192.168.56.101:6380 master - 0 1468853933604 1 connected 0-5460
6aa027917d223b8fedd42893a89fb0e2c07c8b27 192.168.56.101:6382 myself,master - 0 0 3 connected 10923-16383


发现刚添加进来的6383没有插槽数,接下来给新添加的6383分配插槽,将集群中的一部分(1000个)插槽分配给6383

[root@master redis-cluster]# /opt/redis/redis-3.2.1/src/redis-trib.rb reshard 192.168.56.101:6380
>>> Performing Cluster Check (using node 192.168.56.101:6380)
M: b1939026deb80fedde7bdb22c1df3ecfaa72f608 192.168.56.101:6380
   slots:0-5460 (5461 slots) master
   0 additional replica(s)
M: 6aa027917d223b8fedd42893a89fb0e2c07c8b27 192.168.56.101:6382
   slots:10923-16383 (5461 slots) master
   0 additional replica(s)
M: 03596d92625f1b778f29eb4a9128d92809dfd79a 192.168.56.101:6381
   slots:5461-10922 (5462 slots) master
   0 additional replica(s)
M: e6d316a0dcd7cfcc98de645d86989d5527e86e55 192.168.56.101:6383
   slots: (0 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.
How many slots do you want to move (from 1 to 16384)? 1000【要移动的插槽数】
What is the receiving node ID? e6d316a0dcd7cfcc98de645d86989d5527e86e55【接收节点】
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.【数据要提到slot的节点ID,最后用done结束】
Source node #1:all
......
Do you want to proceed with the proposed reshard plan (yes/no)? yes
......





重新查看集群节点信息

192.168.56.101:6382> cluster nodes
03596d92625f1b778f29eb4a9128d92809dfd79a 192.168.56.101:6381 master - 0 1468855258984 2 connected 5795-10922
e6d316a0dcd7cfcc98de645d86989d5527e86e55 192.168.56.101:6383 master - 0 1468855261016 4 connected 0-332 5461-5794 10923-11255
b1939026deb80fedde7bdb22c1df3ecfaa72f608 192.168.56.101:6380 master - 0 1468855260001 1 connected 333-5460
6aa027917d223b8fedd42893a89fb0e2c07c8b27 192.168.56.101:6382 myself,master - 0 0 3 connected 11256-16383


书生参考网络整理


如非特别注明,本站内容均为领悟书生原创,转载请务必注明作者和原始出处。
本文地址:http://www.656463.com/redis/qMR3Mv.htm

相关专题

  • redis教程

    redis教程

    REmote DIctionary Server(Redis) 是一个由Salvatore Sanfilippo写的key-value存储系统。 Redis是一个开源的使用ANSI C语言编写、遵守BSD协议、支持网络、可基于内存亦可持久化的日志型、Key-Value数据库,并提供多种语言的API。 它通常被称为数据结构服务器,因为值(value)可以是 字符串(String), 哈希(Map), 列表(list), 集合(sets) 和 有序集合(sorted sets)等类型。