redis3.0.0 集群安装详细步骤
Redis集群部署文档(centos6系统)
Redis集群部署文档(centos6系统)
(要让集群正常工作至少需要3个主节点,在这里我们要创建6个redis节点,其中三个为主节点,三个为从节点,对应的redis节点的ip和端口对应关系如下)
127.0.0.1:7000
127.0.0.1:7001
127.0.0.1:7002
127.0.0.1:7003
127.0.0.1:7004
127.0.0.1:7005
1:下载redis。官网下载3.0.0版本,之前2.几的版本不支持集群模式
下载地址:https://github.com/antirez/redis/archive/3.0.0-rc2.tar.gz
2:上传服务器,解压,编译
tar -zxvf redis-3.0.0-rc2.tar.gz
mv redis-3.0.0-rc2.tar.gz redis3.0
cd /usr/local/redis3.0
make
make install
3:创建集群需要的目录
mkdir -p /usr.local/cluster
cd /usr.local/cluster
mkdir 7000
mkdir 7001
mkdir 7002
mkdir 7003
mkdir 7004
mkdir 7005
4:修改配置文件redis.conf
cp /usr/local/redis3.0/redis.conf /usr.local/cluster
vi redis.conf
##修改配置文件中的下面选项
port 7000
daemonize yes
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
appendonly yes
##修改完redis.conf配置文件中的这些配置项之后把这个配置文件分别拷贝到7000/7001/7002/7003/7004/7005目录下面
cp /usr/local/cluster/redis.conf /usr/local/cluster/7000
cp /usr/local/cluster/redis.conf /usr/local/cluster/7001
cp /usr/local/cluster/redis.conf /usr/local/cluster/7002
cp /usr/local/cluster/redis.conf /usr/local/cluster/7003
cp /usr/local/cluster/redis.conf /usr/local/cluster/7004
cp /usr/local/cluster/redis.conf /usr/local/cluster/7005
##注意:拷贝完成之后要修改7001/7002/7003/7004/7005目录下面redis.conf文件中的port参数,分别改为对应的文件夹的名称
5:分别启动这6个redis实例
cd /usr/local/cluster/7000
redis-server redis.conf
cd /usr/local/cluster/7001
redis-server redis.conf
cd /usr/local/cluster/7002
redis-server redis.conf
cd /usr/local/cluster/7003
redis-server redis.conf
cd /usr/local/cluster/7004
redis-server redis.conf
cd /usr/local/cluster/7005
redis-server redis.conf
##启动之后使用命令查看redis的启动情况ps -ef|grep redis
如下图显示则说明启动成功
6:执行redis的创建集群命令创建集群
cd /usr/local/redis3.0/src
./redis-trib.rb create --replicas 1 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005
6.1执行上面的命令的时候会报错,因为是执行的ruby的脚本,需要ruby的环境
错误内容:/usr/bin/env: ruby: No such file or directory
所以需要安装ruby的环境,这里推荐使用yum install ruby安装
yum install ruby
6.2然后再执行第6步的创建集群命令,还会报错,提示缺少rubygems组件,使用yum安装
错误内容:
./redis-trib.rb:24:in `require': no such file to load -- rubygems (LoadError)
from ./redis-trib.rb:24
yum install rubygems
6.3再次执行第6步的命令,还会报错,提示不能加载redis,是因为缺少redis和ruby的接口,使用gem 安装
错误内容:
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- redis (LoadError)
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from ./redis-trib.rb:25
gem install redis
6.4 再次执行第6步的命令,正常执行
输入yes,然后配置完成。
至此redis集群即搭建成功!
7:使用redis-cli命令进入集群环境
redis-cli -c -p 7000
##修改完redis.conf配置文件中的这些配置项之后把这个配置文件分别拷贝到7000/////7005目录下面
cp /usr/local/cluster/redis.conf /usr/local/cluster/
cp /usr/local/cluster/redis.conf /usr/local/cluster/
cp /usr/local/cluster/redis.conf /usr/local/cluster/
cp /usr/local/cluster/redis.conf /usr/local/cluster/
cp /usr/local/cluster/redis.conf /usr/local/cluster/
cp /usr/local/cluster/redis.conf /usr/local/cluster/
##注意:拷贝完成之后要修改7001////7005目录下面redis.conf文件中的port参数,分别改为对应的文件夹的名称 :分别启动这6个redis实例 cd /usr/local/cluster/ redis-server redis.conf cd /usr/local/cluster/ redis-server redis.conf cd /usr/local/cluster/ redis-server redis.conf cd /usr/local/cluster/ redis-server redis.conf cd /usr/local/cluster/ redis-server redis.conf cd /usr/local/cluster/ redis-server redis.conf ##启动之后使用命令查看redis的启动情况ps -ef|grep redis 如下图显示则说明启动成功 :执行redis的创建集群命令创建集群 cd /usr/local/redis3./src ./redis-trib.rb create --replicas 127.0.0.1: 127.0.0.1: 127.0.0.1: 127.0.0.1: 127.0.0.1: 127.0.0.1: .1执行上面的命令的时候会报错,因为是执行的ruby的脚本,需要ruby的环境 错误内容:/usr/bin/env: ruby: No such file or directory 所以需要安装ruby的环境,这里推荐使用yum install ruby安装 yum install ruby .2然后再执行第6步的创建集群命令,还会报错,提示缺少rubygems组件,使用yum安装 错误内容: ./redis-trib.rb::in `require': no such file to load -- rubygems (LoadError) from ./redis-trib.rb: yum install rubygems .3再次执行第6步的命令,还会报错,提示不能加载redis,是因为缺少redis和ruby的接口,使用gem 安装 错误内容: /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb::in `gem_original_require': no such file to load -- redis (LoadError) from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb::in `require' from ./redis-trib.rb: gem install redis
6.4 再次执行第6步的命令,正常执行
输入yes,然后配置完成。
至此redis集群即搭建成功!
:使用redis-cli命令进入集群环境
redis-cli -c -p 本文出自 “智能化未来_XFICC” 博客,请务必保留此出处http://xficc.blog.51cto.com/1189288/1707366
http://download.redis.io/releases/redis-3.0.2.tar.gz
##启动之后使用命令查看redis的启动情况ps -ef|grep redis |
6:执行redis的创建集群命令创建集群
6:09:33] PWD => /usr/local
40># ~/redis-3.0.2/src/redis-trib.rb create --replicas 192.168.7.232:7000 192.168.7.239:7000 192.168.7.246:7000 192.168.7.232:7001 192.168.7.239:7001 192.168.7.246:7001
/root/redis-3.0.2/src/redis-trib.rb:24:in `require': no such file to load -- rubygems (LoadError)
from /root/redis-3.0.2/src/redis-trib.rb:24
报错了,提示缺少rubygems组件,使用yum安装
yum -y install rubygems
安装好后还是报错
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- redis (LoadError)
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /root/redis-3.0.2/src/redis-trib.rb:25
提示不能加载redis,是因为缺少redis和ruby的接口,使用gem 安装
# gem install redis
# ~/redis-3.0.2/src/redis-trib.rb create --replicas 192.168.7.232:7000 192.168.7.237:7000 192.168.7.246:7000 192.168.7.232:7001 192.168.7.237:7001 192.168.7.246:7001
>>> Creating cluster
Connecting to node 192.168.7.237:7000: OK
Connecting to node 192.168.7.246:7000: OK
Connecting to node 192.168.7.232:7001: OK
Connecting to node 192.168.7.237:7001: OK
Connecting to node 192.168.7.246:7001: OK
*** ERROR: Invalid configuration for cluster creation.
*** Redis Cluster requires at least 3 master nodes.
*** This is not possible with 5 nodes and 192 replicas per node.
*** At least 579 nodes are required.
居然只连接5个,奇怪了,后来检查才发现在--replicas 后面要加一个数字才可以
6:23:23] PWD => /usr/local
52># ~/redis-3.0.2/src/redis-trib.rb create --replicas 1 192.168.7.232:7000 192.168.7.237:7000 192.168.7.246:7000 192.168.7.232:7001 192.168.7.237:7001 192.168.7.246:7001
>>> Creating cluster
Connecting to node 192.168.7.232:7000: OK
Connecting to node 192.168.7.237:7000: OK
Connecting to node 192.168.7.246:7000: OK
Connecting to node 192.168.7.232:7001: OK
Connecting to node 192.168.7.237:7001: OK
Connecting to node 192.168.7.246:7001: OK
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
192.168.7.246:7000
192.168.7.237:7000
192.168.7.232:7000
Adding replica 192.168.7.237:7001 to 192.168.7.246:7000
Adding replica 192.168.7.246:7001 to 192.168.7.237:7000
Adding replica 192.168.7.232:7001 to 192.168.7.232:7000
M: e538aeff6aa194f52c706238448a3f48c561174c 192.168.7.232:7000
slots:10923-16383 (5461 slots) master
M: 834632a4e4f2af3a824623928b4b85203cd2df11 192.168.7.237:7000
slots:5461-10922 (5462 slots) master
M: e538aeff6aa194f52c706238448a3f48c561174c 192.168.7.246:7000
slots:0-5460 (5461 slots) master
S: 2aabb6d31a8c4310aedbe98b43d8ae1725265eac 192.168.7.232:7001
replicates e538aeff6aa194f52c706238448a3f48c561174c
S: 80ad1ce65e5d1ab60eef58cf3d8e001cc0cbc11d 192.168.7.237:7001
replicates e538aeff6aa194f52c706238448a3f48c561174c
S: 4c37e13f1339db30699586e8d6a38f2778606908 192.168.7.246:7001
replicates 834632a4e4f2af3a824623928b4b85203cd2df11
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.......................................
在这里的时候卡了很久没过去,我就结束了想重新再试下
Connecting to node 192.168.7.232:7000: OK
[ERR] Node 192.168.7.232:7000 is not empty. Either the node already knows other nodes (check with CLUSTER NODES) or contains some key in database 0.
提示有数据了,我想是开始初始化的时候有写数据进去了
把7000目录下生成的appendonly.aof nodes.conf 删除掉重启启动服务,
想起来我是把7.232上面的服务启动后把7000 7001 直接传到237 和246上面去的,为了节省建目录和copy配置文件的操作,这样导致机器加入集群的时候一直在等待,
把3台机器的6个服务的appendonly.aof nodes.conf都删了 重新启动服务再执行
# ~/redis-3.0.2/src/redis-trib.rb create --replicas 1 192.168.7.232:7000 192.168.7.237:7000 192.168.7.246:7000 192.168.7.232:7001 192.168.7.237:7001 192.168.7.246:7001
>>> Creating cluster
Connecting to node 192.168.7.232:7000: OK
Connecting to node 192.168.7.237:7000: OK
Connecting to node 192.168.7.246:7000: OK
Connecting to node 192.168.7.232:7001: OK
Connecting to node 192.168.7.237:7001: OK
Connecting to node 192.168.7.246:7001: OK
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
192.168.7.246:7000
192.168.7.237:7000
192.168.7.232:7000
Adding replica 192.168.7.237:7001 to 192.168.7.246:7000
Adding replica 192.168.7.246:7001 to 192.168.7.237:7000
Adding replica 192.168.7.232:7001 to 192.168.7.232:7000
M: d8003ec51e97f8135b55e6c318e1bcf7b940e668 192.168.7.232:7000
slots:10923-16383 (5461 slots) master
M: 594a3e1a587c4fb67fc224f0593993918c0360af 192.168.7.237:7000
slots:5461-10922 (5462 slots) master
M: 9ebe5263d08594bfd5d218a36df8315c5ce3f0dd 192.168.7.246:7000
slots:0-5460 (5461 slots) master
S: 1d716af8951061e412fcc0b6e92e4212a8730000 192.168.7.232:7001
replicates d8003ec51e97f8135b55e6c318e1bcf7b940e668
S: 30882cbdf6ab715aea7928e0adf25b96fc67aa87 192.168.7.237:7001
replicates 9ebe5263d08594bfd5d218a36df8315c5ce3f0dd
S: 4754be547328d05b986bf94fe9d77a4cd32b1f68 192.168.7.246:7001
replicates 594a3e1a587c4fb67fc224f0593993918c0360af
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...
>>> Performing Cluster Check (using node 192.168.7.232:7000)
M: d8003ec51e97f8135b55e6c318e1bcf7b940e668 192.168.7.232:7000
slots:10923-16383 (5461 slots) master
M: 594a3e1a587c4fb67fc224f0593993918c0360af 192.168.7.237:7000
slots:5461-10922 (5462 slots) master
M: 9ebe5263d08594bfd5d218a36df8315c5ce3f0dd 192.168.7.246:7000
slots:0-5460 (5461 slots) master
slots:0-5460 (5461 slots) master
M: 1d716af8951061e412fcc0b6e92e4212a8730000 192.168.7.232:7001
slots: (0 slots) master
replicates d8003ec51e97f8135b55e6c318e1bcf7b940e668
M: 30882cbdf6ab715aea7928e0adf25b96fc67aa87 192.168.7.237:7001
slots: (0 slots) master
replicates 9ebe5263d08594bfd5d218a36df8315c5ce3f0dd
M: 4754be547328d05b986bf94fe9d77a4cd32b1f68 192.168.7.246:7001
slots: (0 slots) master
replicates 594a3e1a587c4fb67fc224f0593993918c0360af
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
使用redis-cli命令进入集群环境
redis-cli -c -p 7000 127.0.0.1:7000> get testkey001 (nil) 127.0.0.1:7000> set testkey002 testvalue002 -> Redirected to slot [401] located at 192.168.7.246:7000 OK 192.168.7.246:7000> get testkey002 "testvalue002" 192.168.7.246:7000> set testkey003 testvalue003 OK 192.168.7.246:7000> exit |
redis3.0.0 集群安装详细步骤的更多相关文章
- hadoop 2.2.0集群安装详细步骤(简单配置,无HA)
安装环境操作系统:CentOS 6.5 i586(32位)java环境:JDK 1.7.0.51hadoop版本:社区版本2.2.0,hadoop-2.2.0.tar.gz 安装准备设置集群的host ...
- KafKa集群安装详细步骤
最近在使用Spring Cloud进行分布式微服务搭建,顺便对集成KafKa的方案做了一些总结,今天详细介绍一下KafKa集群安装过程: 1. 在根目录创建kafka文件夹(service1.serv ...
- Redis集群安装详细步骤
环境: Centos7 redis3.0 三台虚拟机主机名分别为 master node1 node2 如果单机的时候设置过密码最好把密码去掉,避免位置的错误. 拍个快照方便恢复. 1.创 ...
- 菜鸟玩云计算之十九:Hadoop 2.5.0 HA 集群安装第2章
菜鸟玩云计算之十九:Hadoop 2.5.0 HA 集群安装第2章 cheungmine, 2014-10-26 在上一章中,我们准备好了计算机和软件.本章开始部署hadoop 高可用集群. 2 部署 ...
- 菜鸟玩云计算之十八:Hadoop 2.5.0 HA 集群安装第1章
菜鸟玩云计算之十八:Hadoop 2.5.0 HA 集群安装第1章 cheungmine, 2014-10-25 0 引言 在生产环境上安装Hadoop高可用集群一直是一个需要极度耐心和体力的细致工作 ...
- Redis Cluster 4.0.9 集群安装搭建
Redis Cluster 4.0.9集群搭建步骤:yum install -y gcc g++ gcc-c++ make openssl cd redis-4.0.9 make mkdir -p / ...
- Storm入门教程 第三章Storm集群安装部署步骤、storm开发环境
一. Storm集群组件 Storm集群中包含两类节点:主控节点(Master Node)和工作节点(Work Node).其分别对应的角色如下: 主控节点(Master Node)上运行一个被称为N ...
- Linux单机环境下HDFS伪分布式集群安装操作步骤v1.0
公司平台的分布式文件系统基于Hadoop HDFS技术构建,为开发人员学习及后续项目中Hadoop HDFS相关操作提供技术参考特编写此文档.本文档描述了Linux单机环境下Hadoop HDFS伪分 ...
- Storm集群安装部署步骤【详细版】
作者: 大圆那些事 | 文章可以转载,请以超链接形式标明文章原始出处和作者信息 网址: http://www.cnblogs.com/panfeng412/archive/2012/11/30/how ...
随机推荐
- js的DOM对象
1.js的Array对象 ** 创建数组(三种) - var arr1 = [1,2,3]; ...
- 单选框的回显c:if
<input type="radio" name="sex" value="boy" <c:if test="${te ...
- Navicat For Mysql快捷键
1.ctrl+q 打开查询窗口 2.ctrl+/ 注释sql语句 3.ctrl+shift +/ 解除注释 4.ctrl+r 运行查询窗 ...
- 关于帧中继和ppp的补充笔记
帧中继: · 两个设备都要启用 帧中继功能, 否则是不能 ping通的 · 两个设备上的接口serial要 no shutdown · · 一定要配置dlci地址(号). 否则就不能起来pvc 可以 ...
- hdu4951 Multiplication table (乘法表的奥秘)
http://acm.hdu.edu.cn/showproblem.php?pid=4951 2014多校 第八题 1008 2014 Multi-University Training Contes ...
- PHP获取MAC地址的函数代码
获取网卡的MAC地址原码;目前支持WIN/LINUX系统 获取机器网卡的物理(MAC)地址 复制代码 代码如下: <?php /** 获取网卡的MAC地址原码:目前支持WIN/LINUX系统 ...
- oracle 中的Ipad()函数
本文基于转载: lpad函数从左边对字符串使用指定的字符进行填充.lpad意思是从左边填充的意思. 语法格式如下: lpad( string, padded_length, [ pad_string ...
- ASP.NET Core -- 安装版
首先安装的→Visual Studio Community 原文地址 本来觉得安装了vs 就可以了,,结果一直报错,,,太天真... 接下来还要安装 →NuGet.Tools.vsix →DotNet ...
- iOS分类、延展和子类的区别
iOS分类.延展和子类的区别 类别.延展.子类的区别 类别 延展 子类 功能 为类添加方法,不用知道类的源码,添加变量(通过运行时,具体参考下面注解) 为类添加私有变量和私有方法,在类的源文件中书 ...
- Java并发包源码学习之AQS框架(一)概述
AQS其实就是java.util.concurrent.locks.AbstractQueuedSynchronizer这个类. 阅读Java的并发包源码你会发现这个类是整个java.util.con ...