接上述安装文档(1)

添加slave节点
添加的slave节点配置在另一个服务器上,首先配置config文件
这里我们计算一下
本来是两重冗余,8个节点集群,也就是一共16个conf文件
现在是三重冗余,8个节点集群,也就是一共24个conf文件,现在要把他分配到4个主机上,也就是每个主机6个conf文件。也就是在原来的基础上增加两个conf文件
此时就是有顺序的填数独

主机1
[root@T1 config]# vi redis-26381.conf
include /tmp/redis-3.2.0/config/redis-common.conf
port 26381
logfile "/tmp/redis-3.2.0/log/redis-26381.log"
maxmemory 100m
# volatile-lru -> remove the key with an expire set using an LRU algorithm
# allkeys-lru -> remove any key accordingly to the LRU algorithm
# volatile-random -> remove a random key with an expire set
# allkeys-random -> remove a random key, any key
# volatile-ttl -> remove the key with the nearest expire time (minor TTL)
# noeviction -> don't expire at all, just return an error on write operations
maxmemory-policy allkeys-lru
appendfilename "appendonly-26381.aof"
dbfilename dump-26381.rdb
dir /tmp/redis-3.2.0/data
cluster-config-file nodes-26381.conf
auto-aof-rewrite-percentage 80-100
[root@T1 config]# vi redis-26384.conf
include /tmp/redis-3.2.0/config/redis-common.conf
port 26384
logfile "/tmp/redis-3.2.0/log/redis-26384.log"
maxmemory 100m
# volatile-lru -> remove the key with an expire set using an LRU algorithm
# allkeys-lru -> remove any key accordingly to the LRU algorithm
# volatile-random -> remove a random key with an expire set
# allkeys-random -> remove a random key, any key
# volatile-ttl -> remove the key with the nearest expire time (minor TTL)
# noeviction -> don't expire at all, just return an error on write operations
maxmemory-policy allkeys-lru
appendfilename "appendonly-26384.aof"
dbfilename dump-26384.rdb
dir /tmp/redis-3.2.0/data
cluster-config-file nodes-26384.conf
auto-aof-rewrite-percentage 80-100
~                                   
主机2
[root@T2 config]# vi redis-26382.conf
include /tmp/redis-3.2.0/config/redis-common.conf
port 26382
logfile "/tmp/redis-3.2.0/log/redis-26382.log"
maxmemory 100m
# volatile-lru -> remove the key with an expire set using an LRU algorithm
# allkeys-lru -> remove any key accordingly to the LRU algorithm
# volatile-random -> remove a random key with an expire set
# allkeys-random -> remove a random key, any key
# volatile-ttl -> remove the key with the nearest expire time (minor TTL)
# noeviction -> don't expire at all, just return an error on write operations
maxmemory-policy allkeys-lru
appendfilename "appendonly-26382.aof"
dbfilename dump-26382.rdb
dir /tmp/redis-3.2.0/data
cluster-config-file nodes-26382.conf
auto-aof-rewrite-percentage 80-100
[root@T2 config]# vi redis-26383.conf
include /tmp/redis-3.2.0/config/redis-common.conf
port 26383
logfile "/tmp/redis-3.2.0/log/redis-26383.log"
maxmemory 100m
# volatile-lru -> remove the key with an expire set using an LRU algorithm
# allkeys-lru -> remove any key accordingly to the LRU algorithm
# volatile-random -> remove a random key with an expire set
# allkeys-random -> remove a random key, any key
# volatile-ttl -> remove the key with the nearest expire time (minor TTL)
# noeviction -> don't expire at all, just return an error on write operations
maxmemory-policy allkeys-lru
appendfilename "appendonly-26383.aof"
dbfilename dump-26383.rdb
dir /tmp/redis-3.2.0/data
cluster-config-file nodes-26383.conf
auto-aof-rewrite-percentage 80-100
~                                      
主机3
[root@T3 config]# vi redis-26379.conf
include /tmp/redis-3.2.0/config/redis-common.conf
port 26379
logfile "/tmp/redis-3.2.0/log/redis-26379.log"
maxmemory 100m
# volatile-lru -> remove the key with an expire set using an LRU algorithm
# allkeys-lru -> remove any key accordingly to the LRU algorithm
# volatile-random -> remove a random key with an expire set
# allkeys-random -> remove a random key, any key
# volatile-ttl -> remove the key with the nearest expire time (minor TTL)
# noeviction -> don't expire at all, just return an error on write operations
maxmemory-policy allkeys-lru
appendfilename "appendonly-26379.aof"
dbfilename dump-26379.rdb
dir /tmp/redis-3.2.0/data
cluster-config-file nodes-26379.conf
auto-aof-rewrite-percentage 80-100
[root@T3 config]# vi redis-26386.conf
include /tmp/redis-3.2.0/config/redis-common.conf
port 26386
logfile "/tmp/redis-3.2.0/log/redis-26386.log"
maxmemory 100m
# volatile-lru -> remove the key with an expire set using an LRU algorithm
# allkeys-lru -> remove any key accordingly to the LRU algorithm
# volatile-random -> remove a random key with an expire set
# allkeys-random -> remove a random key, any key
# volatile-ttl -> remove the key with the nearest expire time (minor TTL)
# noeviction -> don't expire at all, just return an error on write operations
maxmemory-policy allkeys-lru
appendfilename "appendonly-26386.aof"
dbfilename dump-26386.rdb
dir /tmp/redis-3.2.0/data
cluster-config-file nodes-26386.conf
auto-aof-rewrite-percentage 80-100
主机4
[root@T4 config]# vi redis-26380.conf
include /tmp/redis-3.2.0/config/redis-common.conf
port 26380
logfile "/tmp/redis-3.2.0/log/redis-26380.log"
maxmemory 100m
# volatile-lru -> remove the key with an expire set using an LRU algorithm
# allkeys-lru -> remove any key accordingly to the LRU algorithm
# volatile-random -> remove a random key with an expire set
# allkeys-random -> remove a random key, any key
# volatile-ttl -> remove the key with the nearest expire time (minor TTL)
# noeviction -> don't expire at all, just return an error on write operations
maxmemory-policy allkeys-lru
appendfilename "appendonly-26380.aof"
dbfilename dump-26380.rdb
dir /tmp/redis-3.2.0/data
cluster-config-file nodes-26380.conf
auto-aof-rewrite-percentage 80-100
[root@T4 config]# vi redis-26385.conf
include /tmp/redis-3.2.0/config/redis-common.conf
port 26385
logfile "/tmp/redis-3.2.0/log/redis-26385.log"
maxmemory 100m
# volatile-lru -> remove the key with an expire set using an LRU algorithm
# allkeys-lru -> remove any key accordingly to the LRU algorithm
# volatile-random -> remove a random key with an expire set
# allkeys-random -> remove a random key, any key
# volatile-ttl -> remove the key with the nearest expire time (minor TTL)
# noeviction -> don't expire at all, just return an error on write operations
maxmemory-policy allkeys-lru
appendfilename "appendonly-26385.aof"
dbfilename dump-26385.rdb
dir /tmp/redis-3.2.0/data
cluster-config-file nodes-26385.conf
auto-aof-rewrite-percentage 80-100
启动冗余slave
主机1
[root@T1 config]# redis-server redis-26381.conf 
[root@T1 config]# redis-server redis-26384.conf 
主机2
[root@T2 config]# redis-server redis-26382.conf 
[root@T2 config]# redis-server redis-26383.conf 
主机3
[root@T3 config]# redis-server redis-26379.conf 
[root@T3 config]# redis-server redis-26386.conf 
主机4
[root@T4 config]# redis-server redis-26380.conf 
[root@T4 config]# redis-server redis-26385.conf 
增加冗余slave节点到集群
(注意:add-node的使用方法为new_host:new_port existing_host:existing_port,前面是新添加的节点信息,后面是已存在的节点信息)
增加了新的节点之后,这个新的节点可以成为主节点或者是从节点
[root@T1 config]# redis-trib.rb add-node --slave 172.16.57.54:26381 172.16.57.56:6381
>>> Adding node 172.16.57.54:26381 to cluster 172.16.57.56:6381
>>> Performing Cluster Check (using node 172.16.57.56:6381)
M: a15269fef298a4e62fb10b3b1bd4ec7178760c34 172.16.57.56:6381
slots:2048-4095 (2048 slots) master
1 additional replica(s)
S: 2d832131cf4196c83557d0a153775ee63605ed90 172.16.57.57:16383
slots: (0 slots) slave
replicates a15269fef298a4e62fb10b3b1bd4ec7178760c34
S: 2f1c88c822a81d22ebeddc3a0816b62997a16dbe 172.16.57.55:16379
slots: (0 slots) slave
replicates 3ea77504768534438608cc8282409ad0380cc230
M: 27dae6d2fcf9a294de7c6c5c10f10c97cb9dc44c 172.16.57.57:6382
slots:0-2047 (2048 slots) master
1 additional replica(s)
M: 450e56c837a409ac25b3aaae01fb561699654098 172.16.57.56:6385
slots:10240-12287 (2048 slots) master
1 additional replica(s)
S: 4d6ee6db3875c75fb0f44e1c93106da5b43bd5ba 172.16.57.56:16384
slots: (0 slots) slave
replicates be75716373aa05a16e890427386950e59c917d1f
S: b1ead2f5918bf1ceb71c6a34ddb57017dbffd7bd 172.16.57.55:16386
slots: (0 slots) slave
replicates adcdcd04c6d77a0dfa6fbacff68c668f42a727fb
M: c1137994639200525ef7f561ce291b3ce38079b3 172.16.57.55:6380
slots:4096-6143 (2048 slots) master
1 additional replica(s)
M: 3ea77504768534438608cc8282409ad0380cc230 172.16.57.54:6379
slots:6144-8191 (2048 slots) master
1 additional replica(s)
S: a94b11d778ffd22c3643ee0debcb0e8d52cae037 172.16.57.54:16385
slots: (0 slots) slave
replicates c1137994639200525ef7f561ce291b3ce38079b3
S: e9b7be308399f30dd25f0d63b4befa536e91fe60 172.16.57.57:16381
slots: (0 slots) slave
replicates 450e56c837a409ac25b3aaae01fb561699654098
M: 46f9543f054435dea90aded227f5a53a1383dee2 172.16.57.55:6384
slots:12288-14335 (2048 slots) master
1 additional replica(s)
M: be75716373aa05a16e890427386950e59c917d1f 172.16.57.57:6386
slots:8192-10239 (2048 slots) master
1 additional replica(s)
M: adcdcd04c6d77a0dfa6fbacff68c668f42a727fb 172.16.57.54:6383
slots:14336-16383 (2048 slots) master
1 additional replica(s)
S: ec8ea752576da5eea8bc3934544826d8730e1dfd 172.16.57.56:16380
slots: (0 slots) slave
replicates 27dae6d2fcf9a294de7c6c5c10f10c97cb9dc44c
S: 2c3b29c266cdd2796314f785891bf7dbf39c1764 172.16.57.54:16382
slots: (0 slots) slave
replicates 46f9543f054435dea90aded227f5a53a1383dee2
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
Automatically selected master 172.16.57.56:6381
>>> Send CLUSTER MEET to node 172.16.57.54:26381 to make it join the cluster.
Waiting for the cluster to join.........
>>> Configure node as replica of 172.16.57.56:6381.
[OK] New node added correctly.
[root@T1 config]# redis-trib.rb add-node --slave 172.16.57.54:26384 172.16.57.55:6384
主机2
[root@T2 config]# redis-trib.rb add-node --slave 172.16.57.55:26382 172.16.57.57:6382
[root@T2 config]# redis-trib.rb add-node --slave 172.16.57.55:26383 172.16.57.54:6383
主机3
[root@T3 config]# redis-trib.rb add-node --slave 172.16.57.56:26379 172.16.57.54:6379、
[root@T3 config]# redis-trib.rb add-node --slave 172.16.57.56:26386 172.16.57.57:6386
主机4
[root@T4 config]# redis-trib.rb add-node --slave 172.16.57.57:26380 172.16.57.55:6380
[root@T4 config]# redis-trib.rb add-node --slave 172.16.57.57:26385 172.16.57.56:6385
查看集群情况
[root@T1 config]# redis-cli -h 172.16.57.54 -p 6379
172.16.57.54:6379> cluster nodes
2c3b29c266cdd2796314f785891bf7dbf39c1764 172.16.57.54:16382 slave 46f9543f054435dea90aded227f5a53a1383dee2 0 1463739296841 15 connected
2d832131cf4196c83557d0a153775ee63605ed90 172.16.57.57:16383 slave a15269fef298a4e62fb10b3b1bd4ec7178760c34 0 1463739294838 10 connected
a94b11d778ffd22c3643ee0debcb0e8d52cae037 172.16.57.54:16385 slave c1137994639200525ef7f561ce291b3ce38079b3 0 1463739297844 14 connected
3ad4c7bba432e075d5508011843396eb964fced7 172.16.57.57:26385 slave 450e56c837a409ac25b3aaae01fb561699654098 0 1463739297844 6 connected
926e094caebf5f63bb7f06be8d8973f618e8621e 172.16.57.56:26386 slave be75716373aa05a16e890427386950e59c917d1f 0 1463739297844 8 connected
7eeb792ba02384f2a7f77c15ba24a64b5aa31c48 172.16.57.56:26379 slave 3ea77504768534438608cc8282409ad0380cc230 0 1463739299846 1 connected
2fe7b552ad5a5bf21a1ce8a3383c6ca0d2ed4e04 172.16.57.57:26380 slave c1137994639200525ef7f561ce291b3ce38079b3 0 1463739295339 3 connected
0a2445ba6f45192ee69db944bbaed06922df1e15 172.16.57.55:26382 slave 27dae6d2fcf9a294de7c6c5c10f10c97cb9dc44c 0 1463739296842 7 connected
4d6ee6db3875c75fb0f44e1c93106da5b43bd5ba 172.16.57.56:16384 slave be75716373aa05a16e890427386950e59c917d1f 0 1463739298846 12 connected
853d26575f80de4ff21a48b1946075a338a1cee2 172.16.57.55:26383 slave adcdcd04c6d77a0dfa6fbacff68c668f42a727fb 0 1463739297341 2 connected
b1ead2f5918bf1ceb71c6a34ddb57017dbffd7bd 172.16.57.55:16386 slave adcdcd04c6d77a0dfa6fbacff68c668f42a727fb 0 1463739298846 16 connected
3ea77504768534438608cc8282409ad0380cc230 172.16.57.54:6379 myself,master - 0 0 1 connected 6144-8191
e2440e0cb2205adad154dc7d00d4213cc4e430f0 172.16.57.54:26381 slave a15269fef298a4e62fb10b3b1bd4ec7178760c34 0 1463739296340 5 connected
2f1c88c822a81d22ebeddc3a0816b62997a16dbe 172.16.57.55:16379 slave 3ea77504768534438608cc8282409ad0380cc230 0 1463739300850 9 connected
be75716373aa05a16e890427386950e59c917d1f 172.16.57.57:6386 master - 0 1463739295841 8 connected 8192-10239
69cc0aff83e9743a2cb558f8453bfb04b1d6c6f2 172.16.57.54:26384 slave 46f9543f054435dea90aded227f5a53a1383dee2 0 1463739299846 4 connected
a15269fef298a4e62fb10b3b1bd4ec7178760c34 172.16.57.56:6381 master - 0 1463739294838 5 connected 2048-4095
46f9543f054435dea90aded227f5a53a1383dee2 172.16.57.55:6384 master - 0 1463739301851 4 connected 12288-14335
c1137994639200525ef7f561ce291b3ce38079b3 172.16.57.55:6380 master - 0 1463739301349 3 connected 4096-6143
adcdcd04c6d77a0dfa6fbacff68c668f42a727fb 172.16.57.54:6383 master - 0 1463739299345 2 connected 14336-16383
450e56c837a409ac25b3aaae01fb561699654098 172.16.57.56:6385 master - 0 1463739299345 6 connected 10240-12287
ec8ea752576da5eea8bc3934544826d8730e1dfd 172.16.57.56:16380 slave 27dae6d2fcf9a294de7c6c5c10f10c97cb9dc44c 0 1463739299345 11 connected
e9b7be308399f30dd25f0d63b4befa536e91fe60 172.16.57.57:16381 slave 450e56c837a409ac25b3aaae01fb561699654098 0 1463739295841 13 connected
27dae6d2fcf9a294de7c6c5c10f10c97cb9dc44c 172.16.57.57:6382 master - 0 1463739299345 7 connected 0-2047
数据分片
加入新的节点后,需要将其他的节点中的hash slot移动到新的节点中,以达到负载均衡的效果,指定集群中其中一个节点的地址
[root@T1 config]# redis-trib.rb reshard 172.16.57.54:6379
How many slots do you want to move (from 1 to 16384)?4096  --16384/4=4096.master建议为基数
What is the receiving node ID? 89be535ff56586dcec56f14122add80d89a57bb3  --新加的主节点ID注意必须是主节点
Source node #1:all  --从所有其他master节点均匀把slot移动到新加的主节点
Do you want to proceed with the proposed reshard plan (yes/no)? yes

多余的冗余步骤略,至此增加整个集群冗余度完成

redis-集群安装(2)变两重冗余为三重相关推荐

  1. Redis集群安装问题记录 RVM

    Redis集群安装问题记录 RVM 1.问题描述 2.问题分析 3.问题解决 4.总结 1.问题描述   使用gem安装redis出现以下错误. ERROR: Error installing red ...

  2. Redis集群安装及配置步骤

    运行环境:CentOS 7(版本号:1503) Redis版本:3.0.5 参考文档:① http://www.redis.cn/topics/cluster-tutorial.html ② http ...

  3. redis集群安装和java应用

    首先是在linux下装redis3.0 以下是我在centos 6.5安装成功的.内容主要是http://redisdoc.com/topic/cluster-tutorial.html 的内容加上走 ...

  4. Redis集群安装介绍

    安装Redis3.0 yum -y install cpp binutils glibc glibc-kernheaders glibc-common glibc-devel gcc make gcc ...

  5. django连接redis 集群(安装redis的相关包的时候亲测)

    本地环境: python3.7 Django== 2.2.3 django-cluster-redis== 1.0.5 django-redis== 4.10.0 redis== 3.0.1 redi ...

  6. redis-4.0.10集群安装(3台机器,6个node),以及在Spring项目中的集成,redis操作工具类

    1 Redis安装 redis高可用的三种常见的集群方式:redis sentinel .redis cluster(多主机+分布式).redis sharding.接下来主要介绍redis sent ...

  7. redis 集群 实操 (史上最全、5w字长文)

    文章很长,建议收藏起来慢慢读! 总目录 博客园版 为大家准备了更多的好文章!!!! 推荐:尼恩Java面试宝典(持续更新 + 史上最全 + 面试必备)具体详情,请点击此链接 尼恩Java面试宝典,34 ...

  8. Docker Compose——搭建Redis集群

    环境配置 Docker 18.x Docker-Compose 3.7 Redis 6.2.5 主从(Master-Slave)模式 主从复制模式中包含一个主数据库实例(master)与一个或多个从数 ...

  9. 本地搭建虚拟机并部署redis集群(新手向超详细)

    最近学习redis集群安装,没有服务器资源,所以本地安装一个虚拟机来熟悉,本人也是新手慢慢摸索,记录一下过程供学习 1-3是虚拟机安装,4-11是redis部分 目录 1.安装VMware 2.VMw ...

最新文章

  1. 【LDA学习系列】Gibbs采样python代码
  2. 两个栈来实现一个队列的C++代码
  3. java spring上传_SpringMVC上传文件的三种方式
  4. 很多人问,到底要不要转管理
  5. 牛客-乃爱与城市拥挤程度【树形dp】
  6. web服务器文档根目录在哪里,web服务器根目录在哪
  7. 并发编程-Atomic的compareAndSet
  8. 【问答集锦】联邦学习让隐私保护和海量数据学习兼得!
  9. mac idea命令精简使用版常用指令
  10. oracle 11g crs stat,Oracle 11g RAC CRS磁盘丢失后恢复
  11. 交流电机数字控制系统_干货 | 简述伺服电机和步进电机的六大性能差异
  12. c语言数组题库答案,C语言数组百道练习题含答案.pdf
  13. python编程*三角形图形创意图片_Python图形编程探索系列-04-网上图片与标签组件的结合...
  14. 2000G视频资料送带资源账号
  15. 《万国觉醒》之游戏战报FreeMarker模板引擎实现
  16. 创建和管理图书管理系统数据库
  17. 常见鸟的种类及特点_鸟的种类(常见鸟的名字大全)
  18. 如何去掉桌面图标快捷方式的小箭头(小技巧)
  19. python风格logo_Python十分钟制作属于你自己的个性logo
  20. 超声波模块SRF05

热门文章

  1. 以身试法!盗版XP黑屏实测 教你一招:WGA新版破解方法[转自太平台电脑网]
  2. 软妹音程序员鼓励师24小时在线,只需一个VSCode插件,还能帮忙吐槽产品经理...
  3. Delegation Token
  4. python的语言特点软测工程师经历的各个阶段_测试开发相关JD
  5. 取得鼎新Workflow ERP系统产品结构BOM明细的SQL语句
  6. pikachu靶场RCE的学习
  7. IntelliJ IDEA使用-图(Diagrams)的使用
  8. 操作系统——控制进程并发,高效并发正确誊抄
  9. 算法设计和分析课程设计报告
  10. Java之JMX获取应用进程CPU/内存使用率,监控GC回收