`

9.Redis 3.0.0 Cluster Redis集群的其他操作

阅读更多

安装部分参考 http://sgq0085.iteye.com/blog/2198597

一.对集群进行重新分片 redis-trib.rb reshard

对集群中共有的16384 slot(哈希槽)重新分片,是Redis集群维护的基础,添加和删除节点都涉及到该部分内容;

 

1.查看节点状态,slot(哈希槽)状态和节点ID并记录下节点ID

./redis-trib.rb check 127.0.0.1:6379

 

2.发起重新分配 slot(哈希槽)请求

# 可以指定任意一个节点(M/S均可)
./redis-trib.rb reshard 127.0.0.1:7382
# 指定移动多少个 slot(哈希槽)
How many slots do you want to move (from 1 to 16384)? 250
# 指定接收的节点
What is the receiving node ID? 0e910bc1ae0c16d1f6e754b2759cbb23897a0c6e
# 指定取 slot(哈希槽)的节点 
# 第一种ALL,除接收节点外,其他节点平均分配取slot
# 第二种 指定节点ID,输入done结束
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:538274656289381c0e488e95aaf6cd30731457eb
Source node #2:done

 

二.添加Master节点 redis-trib.rb add-node

1.第一步添加一个空节点

参考http://sgq0085.iteye.com/blog/2198597

 

(1)启用新的端口添加配置文件

cp redis.conf /etc/redis/6383.conf

 

(2)根据端口号创建本地数据库存放路径

mkdir /var/redis/6383

 

(3)启动节点

redis-server /etc/redis/6383.conf 

 

2.加入空节点到集群

add-node  将一个节点添加到集群里面, 第一个是新节点ip:port, 第二个是任意一个已存在节点ip:port

./redis-trib.rb add-node 127.0.0.1:6383 127.0.0.1:6380

 

3.给新节点分配slot(哈希槽)

 

How many slots do you want to move (from 1 to 16384)? 4096
What is the receiving node ID? 04e7c3cbea818d16bbc76080234ef6a2205f4199
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

 

 

(6)检查节点状态

 

./redis-trib.rb check 127.0.0.1:6383

 

 

三.添加slave节点 cluster replicate

1.添加并启动一个新节点

2.加入空节点到集群

 

./redis-trib.rb add-node 127.0.0.1:7383 127.0.0.1:6383
./redis-trib.rb check 127.0.0.1:7383
 

 

3.将该节点设置为其它Master节点的slave从节点

(1)连接该节点

 

redis-cli -h 127.0.0.1 -p 7383
 

 

(2)设置master

cluster replicate 对应master的node-id

 

cluster replicate 04e7c3cbea818d16bbc76080234ef6a2205f4199
 在线添加slave 时,需要dump整个master进程,并传递到slave,再由 slave加载rdb文件到内存,rdb传输过程中Master可能无法提供服务,整个过程消耗大量io,小心操作.

 

 

 

四.删除一个Slave节点 redis-trib.rb del-node

 

#redis-trib del-node ip:port '<node-id>'  
./redis-trib.rb del-node 127.0.0.1:7383 '7e5ee6d373563d97825a69caee95e6f0e4ed591d' 
 

 

五.删除一个Master节点

1.将要删除的节点通过 redis-trib.rb reshard ,将slot(哈希槽)全部分配给其它节点

 

./redis-trib.rb reshard 127.0.0.1:6383
./redis-trib.rb check 127.0.0.1:6380

 

2.删除空节点

 

./redis-trib.rb del-node 127.0.0.1:6383 '04e7c3cbea818d16bbc76080234ef6a2205f4199'
 

 

 

分享到:
评论

相关推荐

    1.2.6版StackExchange.Redis

    1.2.6版StackExchange.Redis。 StackExchange.Redis是.net下的Redis客户端之一,目前是免费的。而用户量比较多的ServiceStack.Redis现在是收费的。把下载的三个文件(StackExchange.Redis.dll、StackExchange.Redis....

    redis安装包,Linux版.redis-3.0.0.tar.gz

    redis安装包,Linux版.redis-3.0.0.tar.gz

    redis-3.0.0.tar和redis-3.0.0.gem.rar

    Redis在CentOS系统中创建集群可能会用到的安装包, 其中redis-3.0.0.tar是Redis服务, redis-3.0.0.gem是Redis通过ruby创建集群要用到的包

    ServiceStack.Redis-5.8无限制.zip

    ServiceStack.Redis-5.8无限制.zip

    ServiceStack .Redis3.9.60 Redis.NET客户端无限制版

    Redis推荐的最好的.Net客户端。 ServiceStack.Redis 4.0 已经收费 并且有每小时6000次插入的限制。这个是ServiceStack.Redis 3系版本的最终最新版本3.9.60,无使用限制, Redis.NET客户端无限制版

    StackExchange.Redis.dll

    最近需要在C#中使用Redis,ServiceStack.Redis的4.0版本已开始收费,之前版本Bug较多。建议使用StackExchange.Redis,支持异步的客户端,据说性能比ServiceStack.Redis更好,而且据说Stack Overflow也是使用的这个...

    StackExchange.Redis Redis客户端

    最近需要在C#中使用Redis,在Redis的官网找到了ServiceStack.Redis,最后在测试的时候发现这是个坑,4.0已上已经收费,后面只好找到3系列的最终版本,最后测试发现还是有BUG或者是我不会用。没有办法,最好找到了...

    StackExchange.Redis .NET4.0

    StackExchange.Redis .NET4.0,StackExchange.Redis.net4.0的工具类

    redis3.0.0集群搭建

    redis集群搭建所必须的软件,参考教程 https://blog.csdn.net/haobindayi/article/details/82290972

    C# StackExchange.Redis 操作封装类库

    C# StackExchange.Redis 操作封装类库,分别封装了Redis五大数据结构(String,Hash,List,Set,ZSet)的增删改查的操作方法,支持Async异步操作。​支持Redis分库操作。支持信息队列操作。 带有单元测试,为每个...

    ServiceStack.Redis 4.5.0.0破解版去除次数限制

    ServiceStack.Redis 4.5.0.0 已解除license限制

    redis-3.0.0.gem

    redis-3.0.0.gem redis-3.0.0.gem redis-3.0.0.gem redis-3.0.0.gem redis-3.0.0.gem

    StackExchange.Redis-1.2.6精简,附64位dll

    C#下非常好用的开源Redis客户端工具,包括内存数据库和pub/sub功能等。 精简工程目录后只包括StackExchange.Redis。代码未做更改。 64位dll在bin目录下。

    ServiceStack.Redis破除每小时访问6000次的限制

    ServiceStack.Redis版本:5.14.0 使用方法:替换nuget包中ServiceStack.Text.dll即可

    redis-cluster redis伪集群文件

    搭建redis集群文件,内含六个redis,文件配置已经全部修改好了,1、先在服务器安装下yum install ruby 和 yum install rubygems 2、然后解压文件上传到linux服务器 3、./redis-cluster-start-all.sh 开启reids 4、...

    redis安装集群用redis-3.0.0.gem

    redis-3.0.0.gem 执行gem install redis /usr/local/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- redis (LoadError) from /usr/local/lib/ruby/2.3.0/...

    StackExchange.Redis 操作 Redis Demo示例

    发现用StackExchange.Redis代替收费项目ServiceStack.Redis是个不错的选择,只有一个dll,并且代码开源,很不错。...代码只做简单演示用StackExchange.Redis操作Redis数据库。 测试写入100万个key用时43秒。

    redis-5.0.5.tar.gz

    redis-5.0.5.redis-5.0.5.redis-5.0.5.redis-5.0.5.redis-5.0.5.redis-5.0.5.redis-5.0.5.redis-5.0.5.redis-5.0.5.redis-5.0.5.redis-5.0.5.redis-5.0.5.redis-5.0.5.redis-5.0.5.redis-5.0.5.redis-5.0.5.redis-...

    封装StackExchange.Redis

    把redis几种存储的操作分别封装在一个类中;分别增加了单例以及共享控制;同时为服务端程序增加了配置及自动关闭策略,都很简单,共享出来希望能够为大家提供帮助;RedisClietProxy为主要类,创建该类实例,使用里面...

    Hangfire.Pro.Redis.2.2.2

    Hangfire Pro comes with Hangfire.Pro.Redis package that uses Redis server to persist background jobs and other data. Redis is well known for its outstanding performance and here are the results of ...

Global site tag (gtag.js) - Google Analytics