在一台机器上搭建redis集群 redis版本3.2

我这也是需要搭建然后网上找文档然最后总结的
参考:https://blog.csdn.net/u012042021/article/details/72818759

1,解压源码包安装redis

#安装需要的一些包
yum install ruby rubygem openssl #此步安装时候,是没有输出的,只要不报错慢慢等待就好了或者加 -V 参数看过程
gem install redis --version 3.0.0#解压安装
tar xf redis-3.2.9.tar.gz
cd redis-3.2.9
make
make install PREFIX=/usr/local/redis #把编译好的redis命令安装到这个目录下面

2,配置redis节点;redis3.x 最少需要6个节点[3主3从的模式]</p>

#配置节点目录
mkdir -p /opt/redis/ && cd /opt/redis
mkdir 7000 7001 7002 7003 7004 7005
cp -rf /usr/local/redis/bin 7000
cp -rf /usr/local/redis/bin 7001
cp -rf /usr/local/redis/bin 7002
cp -rf /usr/local/redis/bin 7003
cp -rf /usr/local/redis/bin 7004
cp -rf /usr/local/redis/bin 7005#节点配置文件
cd /opt/redis/7000
vim redis.conf
bind 192.168.16.186 127.0.0.1 #这里可以多个ip用空格分开
port 7000
daemonize yes
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
cluster-require-full-coverage no
appendonly yes
pidfile /var/run/redis_7000.pid
logfile /var/log/redis/redis_7000.log
dbfilename dump_7000.rdb
appendfilename "appendonly_7000.aof"
其他几个节点的配置文件和这个一样就行,需要注意需要改动对应端口和一些文件名称#创建日志目录
mkdir /var/log/redis#启动各节点
cd /opt/redis/7000
./bin/redis-server ./redis.conf
cd /opt/redis/7001
./bin/redis-server ./redis.conf
cd /opt/redis/7002
./bin/redis-server ./redis.conf
cd /opt/redis/7003
./bin/redis-server ./redis.conf
cd /opt/redis/7004
./bin/redis-server ./redis.conf
cd /opt/redis/7005
./bin/redis-server ./redis.conf

3,创建集群

#进去源码包目录下src目录下面,执行集群创建
cd redis-3.2.9/src/
./redis-trib.rb create --replicas 1 192.168.16.186:7000 192.168.16.186:7001 192.168.16.186:7002 192.168.16.186:7003 192.168.16.186:7004 192.168.16.186:7005
>>> Creating cluster
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: wrong element type nil at 0 (expected array)
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: ignoring wrong elements is deprecated, remove them explicitly
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: this causes ArgumentError in the next release
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: wrong element type nil at 19 (expected array)
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: ignoring wrong elements is deprecated, remove them explicitly
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: this causes ArgumentError in the next release
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: wrong element type nil at 20 (expected array)
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: ignoring wrong elements is deprecated, remove them explicitly
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: this causes ArgumentError in the next release
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: wrong element type nil at 25 (expected array)
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: ignoring wrong elements is deprecated, remove them explicitly
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: this causes ArgumentError in the next release
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: wrong element type nil at 26 (expected array)......此处省略....../usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: ignoring wrong elements is deprecated, remove them explicitly
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: this causes ArgumentError in the next release
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: wrong element type nil at 104 (expected array)
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: ignoring wrong elements is deprecated, remove them explicitly
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: this causes ArgumentError in the next release
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: wrong element type nil at 105 (expected array)
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: ignoring wrong elements is deprecated, remove them explicitly
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: this causes ArgumentError in the next release>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
192.168.16.186:7000
192.168.16.186:7001
192.168.16.186:7002
Adding replica 192.168.16.186:7003 to 192.168.16.186:7000
Adding replica 192.168.16.186:7004 to 192.168.16.186:7001
Adding replica 192.168.16.186:7005 to 192.168.16.186:7002
M: 346226a5653bfe33f6d887920e99609b9bbe94ec 192.168.16.186:7000slots:0-5460 (5461 slots) master
M: 5dc8c8fae8addd7321b9b613123bfc4b25608bbc 192.168.16.186:7001slots:5461-10922 (5462 slots) master
M: be357c14ac96528f86b5a6d5457086e307d05b7e 192.168.16.186:7002slots:10923-16383 (5461 slots) master
S: 99106ae5121c1127b53374e0d678b543cd54026b 192.168.16.186:7003replicates 346226a5653bfe33f6d887920e99609b9bbe94ec
S: 4b788f70b19969fb9f41a4b2b77265c02df3718e 192.168.16.186:7004replicates 5dc8c8fae8addd7321b9b613123bfc4b25608bbc
S: 9e9df80f856b6dd0e54da6f1c01bc4ea9f131ff2 192.168.16.186:7005replicates be357c14ac96528f86b5a6d5457086e307d05b7e
Can I set the above configuration? (type 'yes' to accept): yes
>>> Nodes configuration updated
>>> Assign a different config epoch to each node
>>> Sending CLUSTER MEET messages to join the cluster
Waiting for the cluster to join..
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: wrong element type nil at 0 (expected array)
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: ignoring wrong elements is deprecated, remove them explicitly
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: this causes ArgumentError in the next release
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: wrong element type nil at 19 (expected array)
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: ignoring wrong elements is deprecated, remove them explicitly
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: this causes ArgumentError in the next release
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: wrong element type nil at 20 (expected array)......此处省略....../usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: ignoring wrong elements is deprecated, remove them explicitly
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: this causes ArgumentError in the next release
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: wrong element type nil at 105 (expected array)
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: ignoring wrong elements is deprecated, remove them explicitly
/usr/local/share/gems/gems/redis-3.0.0/lib/redis.rb:182: warning: this causes ArgumentError in the next release
>>> Performing Cluster Check (using node 192.168.16.186:7000)
M: 346226a5653bfe33f6d887920e99609b9bbe94ec 192.168.16.186:7000slots:0-5460 (5461 slots) master1 additional replica(s)
S: 4b788f70b19969fb9f41a4b2b77265c02df3718e 192.168.16.186:7004slots: (0 slots) slavereplicates 5dc8c8fae8addd7321b9b613123bfc4b25608bbc
M: be357c14ac96528f86b5a6d5457086e307d05b7e 192.168.16.186:7002slots:10923-16383 (5461 slots) master1 additional replica(s)
M: 5dc8c8fae8addd7321b9b613123bfc4b25608bbc 192.168.16.186:7001slots:5461-10922 (5462 slots) master1 additional replica(s)
S: 9e9df80f856b6dd0e54da6f1c01bc4ea9f131ff2 192.168.16.186:7005slots: (0 slots) slavereplicates be357c14ac96528f86b5a6d5457086e307d05b7e
S: 99106ae5121c1127b53374e0d678b543cd54026b 192.168.16.186:7003slots: (0 slots) slavereplicates 346226a5653bfe33f6d887920e99609b9bbe94ec
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.


输入 yes

创建成功!
4,连接测试

[root@localhost ~]# redis-cli -c -p 7000 -h 192.168.16.186
192.168.16.186:7000> set testkey 123456
OK
192.168.16.186:7000> get testkey
"123456"
192.168.16.186:7000> exit
[root@localhost ~]# redis-cli -c -p 7005 -h 192.168.16.186
192.168.16.186:7005> get testkey
-> Redirected to slot [4757] located at 192.168.16.186:7000
"123456"
192.168.16.186:7000> exit#查看节点信息
[root@localhost ~]# redis-cli -c -p 7000 -h 192.168.16.186
192.168.16.186:7000> CLUSTER NODES
4b788f70b19969fb9f41a4b2b77265c02df3718e 192.168.16.186:7004 slave 5dc8c8fae8addd7321b9b613123bfc4b25608bbc 0 1522393285325 5 connected
be357c14ac96528f86b5a6d5457086e307d05b7e 192.168.16.186:7002 master - 0 1522393286828 3 connected 10923-16383
5dc8c8fae8addd7321b9b613123bfc4b25608bbc 192.168.16.186:7001 master - 0 1522393284824 2 connected 5461-10922
9e9df80f856b6dd0e54da6f1c01bc4ea9f131ff2 192.168.16.186:7005 slave be357c14ac96528f86b5a6d5457086e307d05b7e 0 1522393286828 6 connected
346226a5653bfe33f6d887920e99609b9bbe94ec 192.168.16.186:7000 myself,master - 0 0 1 connected 0-5460
99106ae5121c1127b53374e0d678b543cd54026b 192.168.16.186:7003 slave 346226a5653bfe33f6d887920e99609b9bbe94ec 0 1522393286328 4 connected

5,redis 集群的启动、停止[使用脚本]

启动
[root@localhost redis]# cat start-redis.sh
#!/bin/bash
#7000
cd /opt/redis/7000
./bin/redis-server ./redis.conf#7001
cd /opt/redis/7001
./bin/redis-server ./redis.conf#7002
cd /opt/redis/7002
./bin/redis-server ./redis.conf#7003
cd /opt/redis/7003
./bin/redis-server ./redis.conf#7004
cd /opt/redis/7004
./bin/redis-server ./redis.conf#7005
cd /opt/redis/7005
./bin/redis-server ./redis.conf#查看redis进程
ps -ef |grep redis#停止
[root@localhost redis]# cat stop-redis.sh
#!/bin/bash
/opt/redis/7000/bin/redis-cli -p 7000 -h 192.168.16.186 shutdown
/opt/redis/7001/bin/redis-cli -p 7001 -h 192.168.16.186 shutdown
/opt/redis/7002/bin/redis-cli -p 7002 -h 192.168.16.186 shutdown
/opt/redis/7003/bin/redis-cli -p 7003 -h 192.168.16.186 shutdown
/opt/redis/7004/bin/redis-cli -p 7004 -h 192.168.16.186 shutdown
/opt/redis/7005/bin/redis-cli -p 7005 -h 192.168.16.186 shutdown
ps -ef |grep redis


2台机器搭建集群
每台3个节点;配置大同小异这里就不在贴出过程了
1,同样道理安装不变,配置节点每台为3个就行,2台机器6个节点即可;端口一样不一样都可以
2,配置文件bind的IP地址修改,两台机器要互通
3,创建集群时在2台机器任意一台即可,注意节点地址和端口的变化

转载于:https://blog.51cto.com/jinchuang/2117482

redis3.2集群搭建相关推荐

  1. Redis-3.2主从复制与集群搭建

    一.Redis 主从搭建 1.下载并解压 yum install -y gcc gcc-c++ pcre zlib pcre-devel tcl wget http://download.redis. ...

  2. Redis-3.2主从复制与集群搭建 推荐

    Redis-3.2主从复制与集群搭建 一.Redis 主从搭建 1.下载并解压 yum install -y gcc gcc-c++ pcre zlib pcre-devel tcl wget htt ...

  3. 基于 Redis3.2.4 集群搭建说明

    摘要 用两台虚拟机(ip: 10.60.44.76.ip: 10.60.44.105)共 6 个节点,一台虚拟机 3 个节点,模拟出 3 master.3 salve 环境 redis 版本:redi ...

  4. redis 集群搭建_一文轻松搞懂redis集群原理及搭建与使用

    转载:https://juejin.im/post/5ad54d76f265da23970759d3 作者:SnailClimb 这里总结一下redis集群的搭建以便日后所需同时也希望能对你有所帮助. ...

  5. rabbitmq 集群搭建

    消息队列对于处理高并发还是非常不错的选择.所以电商必然会采取这种方式.废话不多说.贴代码先. 搭建环境: Mac OS X 10.10.5 VMware Fusion8 Centos 6.7 rabb ...

  6. redis集群搭建及设置账户(转)

    Redis集群搭建以及为集群设置密码 介绍安装环境与版本 用两台虚拟机模拟6个节点,一台机器3个节点,创建出3 master.3 salve 环境. redis 采用 redis-3.2.4 版本. ...

  7. Redis集群搭建-韩国庆

    认真一步一步搭建下来,就可以成功.... Redis-cluster集群架构讲解 redis集群专业名词称之为Redis-cluster,redis集群是从3.0版本以后才有的概念,也就是说在3.0之 ...

  8. redis-cluster集群搭建

    redis cluster集群搭建 1.环境说明 系统版本:CentOS Linux release 7.2.1511 (Core) Redis 版本:3.2.5 Ruby 版本:2.4.4 数据目录 ...

  9. redis集群搭建踩坑笔记

    推荐参考教程:https://blog.csdn.net/pucao_cug/article/details/69250101 错误: from /usr/lib/ruby/2.3.0/rubygem ...

最新文章

  1. OpenCV数字图像处理(5) 像素访问之添加椒盐实例 通道分离与合并
  2. 成功解决raise Py4JError py4j.protocol.Py4JError: py4j.protocol.Py4JError: Could not find py4j jar at
  3. HotSpot 自动内存管理笔记与实战
  4. T-SQL RAND()
  5. mysql优化参数设置_MySQL服务优化参数设置参考
  6. Java Web的web.xml文件作用及基本配置(转)
  7. Java企业面试算法新得体会之链表问题20问
  8. 【读书笔记《Android游戏编程之从零开始》】11.游戏开发基础(SurfaceView 游戏框架、View 和 SurfaceView 的区别)...
  9. Android 微信分享与QQ分享功能
  10. Red5流媒体服务器的搭建与使用
  11. **Mybatis怎么自动生成Mapper文件和实体类**
  12. Python爬虫之网易云歌单音频爬取(解决urlretrieve爬取文件不能播放问题)
  13. 论文书写之如何引用参考文献(简单明了)
  14. 使用vue+element开发一个谷歌插件
  15. Python之 函数笔记
  16. js与html和css的关系
  17. 如何在office2016(word2016)中安装mathtype6.9及相关问题解决方案
  18. True Positive和True Negative的含义
  19. 瑞星卡卡升级出现错误:kmon.dll.zip,错误代码:0x0/0x0(chech)
  20. IDEA项目中配置Maven镜像源(下载源)

热门文章

  1. 想去Google做AI?先看完这套面试指南(附面试题)
  2. 马斯克将Roadster送上太空,“宇宙第一跑车”诞生
  3. 国产最强开源 API 网关,没有之一,不接受任何反驳!
  4. 2021最新版 SpringBoot 速记教程
  5. 怎么去掉 IDEA 中 XML 显示的屎黄色
  6. Spring是如何运用设计模式的?
  7. Java 性能优化的 45 个细节
  8. 竞赛专题(四)特征工程-竞赛中的必杀技
  9. 非升即走的博士们日后该怎么办?院长给出这5点建议
  10. 最喜欢随机森林?周志华团队 DF21 后,TensorFlow 开源决策森林库 TF-DF