• 下载
 
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# wget http://download.redis.io/releases/redis-3.2.6.tar.gz
  • 编译安装
 
[root@localhost src]# tar zxvf redis-3.2.6.tar.gz -C /usr/local/soft/
[root@localhost src]# cd /usr/local/soft/
[root@localhost soft]# cd redis-3.2.6/
[root@localhost redis-3.2.6]# make && make install
[root@localhost redis-3.2.6]# cd /usr/local/soft/
[root@localhost soft]# mkdir redis_cluster
[root@localhost soft]# cd redis_cluster/
[root@localhost redis_cluster]# mkdir 7000 7001 7002
[root@localhost redis_cluster]# cp /usr/local/soft/redis-3.2.6/redis.conf /usr/local/soft/redis_cluster/7000
[root@localhost redis_cluster]# cp /usr/local/soft/redis-3.2.6/redis.conf /usr/local/soft/redis_cluster/7001
[root@localhost redis_cluster]# cp /usr/local/soft/redis-3.2.6/redis.conf /usr/local/soft/redis_cluster/7002
  • 修改配置文件
 
daemonize    yes                          //redis后台运行

pidfile  /var/run/redis_7000.pid          //pidfile文件对应7000,7002,7003

port  7000                                //端口7000,7002,7003

cluster-enabled  yes                      //开启集群  把注释#去掉

cluster-config-file  nodes_7000.conf      //集群的配置  配置文件首次启动自动生成 7000,7001,7002

cluster-node-timeout  5000                //请求超时  设置5秒够了
appendonly  yes
bind 真实ip地址
  • 关闭安全模式
 
redis-cli -p 7000 CONFIG SET protected-mode no
 
  • 启动redis
 
[root@localhost redis_cluster]# redis-server /usr/local/soft/redis_cluster/7000/redis.conf
[root@localhost redis_cluster]# redis-server /usr/local/soft/redis_cluster/7001/redis.conf
[root@localhost redis_cluster]# redis-server /usr/local/soft/redis_cluster/7002/redis.conf
[root@localhost redis_cluster]# ps -ef | grep redis
root       5842      1  0 19:41 ?        00:00:00 redis-server 127.0.0.1:7000 [cluster]                     
root       5862      1  0 19:42 ?        00:00:00 redis-server 127.0.0.1:7001 [cluster]                     
root       5866      1  0 19:42 ?        00:00:00 redis-server 127.0.0.1:7002 [cluster]                     
root       5871   2583  0 19:42 pts/0    00:00:00 grep redis
[root@localhost redis_cluster]# netstat -tnpl | grep redis
tcp        0      0 127.0.0.1:17000             0.0.0.0:*                   LISTEN      5842/redis-server 1
tcp        0      0 127.0.0.1:17001             0.0.0.0:*                   LISTEN      5862/redis-server 1
tcp        0      0 127.0.0.1:17002             0.0.0.0:*                   LISTEN      5866/redis-server 1
tcp        0      0 127.0.0.1:7000              0.0.0.0:*                   LISTEN      5842/redis-server 1
tcp        0      0 127.0.0.1:7001              0.0.0.0:*                   LISTEN      5862/redis-server 1
tcp        0      0 127.0.0.1:7002              0.0.0.0:*                   LISTEN      5866/redis-server 1
  • 创建集群
 
[root@localhost redis_cluster]# cd /usr/local/soft/redis-3.2.6/src/
[root@localhost src]# ./redis-trib.rb
/usr/bin/env: ruby: No such file or directory
  • 如果没有安装ruby,则安装
 
[root@localhost src]# yum -y install ruby ruby-devel rubygems rpm-build
  • 安装redis接口
 
[root@localhost src]# gem install redis
  • 查看ruby是否安装成功
 
[root@localhost src]# ./redis-trib.rb
Usage: redis-trib <command> <options> <arguments ...>
 
  rebalance       host:port
                  --threshold <arg>
                  --simulate
                  --weight <arg>
                  --timeout <arg>
                  --auto-weights
                  --pipeline <arg>
                  --use-empty-masters
  info            host:port
  check           host:port
  fix             host:port
                  --timeout <arg>
  add-node        new_host:new_port existing_host:existing_port
                  --master-id <arg>
                  --slave
  import          host:port
                  --replace
                  --copy
                  --from <arg>
  reshard         host:port
                  --to <arg>
                  --from <arg>
                  --yes
                  --timeout <arg>
                  --slots <arg>
                  --pipeline <arg>
  help            (show this help)
  call            host:port command arg arg .. arg
  set-timeout     host:port milliseconds
  del-node        host:port node_id
  create          host1:port1 ... hostN:portN
                  --replicas <arg>
 
For check, fix, reshard, del-node, set-timeout you can specify the host and port of any working node in the cluster.
  • 创建集群
 
[root@localhost src]# ./redis-trib.rb create --replicas 1 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002
>>> Creating cluster
*** ERROR: Invalid configuration for cluster creation.
*** Redis Cluster requires at least 3 master nodes.
*** This is not possible with 3 nodes and 1 replicas per node.
*** At least 6 nodes are required.
  • 新开一台机子, 配置如上, 端口号为 7003 7004 7005
  • 开放端口号 7000 7001 7002 7003 7004 7005 17000 17001 17002 17003 17004 17005
  • 再次创建集群
 
[root@localhost redis_cluster]# /usr/local/soft/redis-3.2.6/src/redis-trib.rb create --replicas 1 192.168.59.128:7000 192.168.59.128:7001 192.168.59.128:7002 192.168.59.129:7003 192.168.59.129:7004 192.168.59.129:7005
>>> Creating cluster
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
192.168.59.129:7003
192.168.59.128:7000
192.168.59.129:7004
Adding replica 192.168.59.128:7001 to 192.168.59.129:7003
Adding replica 192.168.59.129:7005 to 192.168.59.128:7000
Adding replica 192.168.59.128:7002 to 192.168.59.129:7004
M: bbf1f1150a661ec3adee9ecb37ab140c03290582 192.168.59.128:7000
   slots:5461-10922 (5462 slots) master
S: 046219f4f154a5a757877cd1dc0f186423942424 192.168.59.128:7001
   replicates ccd1c5d708b1844881c13ac4c6ac467574ff23f7
S: f5e01feb8dd6f085c3b25c35f25753f6b2fa750b 192.168.59.128:7002
   replicates c7af24dcbe0ea6c26aec9965573c82130e98718a
M: ccd1c5d708b1844881c13ac4c6ac467574ff23f7 192.168.59.129:7003
   slots:0-5460 (5461 slots) master
M: c7af24dcbe0ea6c26aec9965573c82130e98718a 192.168.59.129:7004
   slots:10923-16383 (5461 slots) master
S: 0b9385e4fb3a939414891a00585f65c2fa07c29b 192.168.59.129:7005
   replicates bbf1f1150a661ec3adee9ecb37ab140c03290582
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.59.128:7000)
M: bbf1f1150a661ec3adee9ecb37ab140c03290582 192.168.59.128:7000
   slots:5461-10922 (5462 slots) master
   1 additional replica(s)
S: 046219f4f154a5a757877cd1dc0f186423942424 192.168.59.128:7001
   slots: (0 slots) slave
   replicates ccd1c5d708b1844881c13ac4c6ac467574ff23f7
S: 0b9385e4fb3a939414891a00585f65c2fa07c29b 192.168.59.129:7005
   slots: (0 slots) slave
   replicates bbf1f1150a661ec3adee9ecb37ab140c03290582
M: ccd1c5d708b1844881c13ac4c6ac467574ff23f7 192.168.59.129:7003
   slots:0-5460 (5461 slots) master
   1 additional replica(s)
S: f5e01feb8dd6f085c3b25c35f25753f6b2fa750b 192.168.59.128:7002
   slots: (0 slots) slave
   replicates c7af24dcbe0ea6c26aec9965573c82130e98718a
M: c7af24dcbe0ea6c26aec9965573c82130e98718a 192.168.59.129:7004
   slots:10923-16383 (5461 slots) master
   1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
  • 下载
 
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# wget http://download.redis.io/releases/redis-3.2.6.tar.gz
  • 编译安装
 
[root@localhost src]# tar zxvf redis-3.2.6.tar.gz -C /usr/local/soft/
[root@localhost src]# cd /usr/local/soft/
[root@localhost soft]# cd redis-3.2.6/
[root@localhost redis-3.2.6]# make && make install
[root@localhost redis-3.2.6]# cd /usr/local/soft/
[root@localhost soft]# mkdir redis_cluster
[root@localhost soft]# cd redis_cluster/
[root@localhost redis_cluster]# mkdir 7000 7001 7002
[root@localhost redis_cluster]# cp /usr/local/soft/redis-3.2.6/redis.conf /usr/local/soft/redis_cluster/7000
[root@localhost redis_cluster]# cp /usr/local/soft/redis-3.2.6/redis.conf /usr/local/soft/redis_cluster/7001
[root@localhost redis_cluster]# cp /usr/local/soft/redis-3.2.6/redis.conf /usr/local/soft/redis_cluster/7002
  • 修改配置文件
 
daemonize    yes                          //redis后台运行

pidfile  /var/run/redis_7000.pid          //pidfile文件对应7000,7002,7003

port  7000                                //端口7000,7002,7003

cluster-enabled  yes                      //开启集群  把注释#去掉

cluster-config-file  nodes_7000.conf      //集群的配置  配置文件首次启动自动生成 7000,7001,7002

cluster-node-timeout  5000                //请求超时  设置5秒够了
appendonly  yes
bind 真实ip地址
  • 关闭安全模式
 
redis-cli -p 7000 CONFIG SET protected-mode no
 
  • 启动redis
 
[root@localhost redis_cluster]# redis-server /usr/local/soft/redis_cluster/7000/redis.conf
[root@localhost redis_cluster]# redis-server /usr/local/soft/redis_cluster/7001/redis.conf
[root@localhost redis_cluster]# redis-server /usr/local/soft/redis_cluster/7002/redis.conf
[root@localhost redis_cluster]# ps -ef | grep redis
root       5842      1  0 19:41 ?        00:00:00 redis-server 127.0.0.1:7000 [cluster]                     
root       5862      1  0 19:42 ?        00:00:00 redis-server 127.0.0.1:7001 [cluster]                     
root       5866      1  0 19:42 ?        00:00:00 redis-server 127.0.0.1:7002 [cluster]                     
root       5871   2583  0 19:42 pts/0    00:00:00 grep redis
[root@localhost redis_cluster]# netstat -tnpl | grep redis
tcp        0      0 127.0.0.1:17000             0.0.0.0:*                   LISTEN      5842/redis-server 1
tcp        0      0 127.0.0.1:17001             0.0.0.0:*                   LISTEN      5862/redis-server 1
tcp        0      0 127.0.0.1:17002             0.0.0.0:*                   LISTEN      5866/redis-server 1
tcp        0      0 127.0.0.1:7000              0.0.0.0:*                   LISTEN      5842/redis-server 1
tcp        0      0 127.0.0.1:7001              0.0.0.0:*                   LISTEN      5862/redis-server 1
tcp        0      0 127.0.0.1:7002              0.0.0.0:*                   LISTEN      5866/redis-server 1
  • 创建集群
 
[root@localhost redis_cluster]# cd /usr/local/soft/redis-3.2.6/src/
[root@localhost src]# ./redis-trib.rb
/usr/bin/env: ruby: No such file or directory
  • 如果没有安装ruby,则安装
 
[root@localhost src]# yum -y install ruby ruby-devel rubygems rpm-build
  • 安装redis接口
 
[root@localhost src]# gem install redis
  • 查看ruby是否安装成功
 
[root@localhost src]# ./redis-trib.rb
Usage: redis-trib <command> <options> <arguments ...>
 
  rebalance       host:port
                  --threshold <arg>
                  --simulate
                  --weight <arg>
                  --timeout <arg>
                  --auto-weights
                  --pipeline <arg>
                  --use-empty-masters
  info            host:port
  check           host:port
  fix             host:port
                  --timeout <arg>
  add-node        new_host:new_port existing_host:existing_port
                  --master-id <arg>
                  --slave
  import          host:port
                  --replace
                  --copy
                  --from <arg>
  reshard         host:port
                  --to <arg>
                  --from <arg>
                  --yes
                  --timeout <arg>
                  --slots <arg>
                  --pipeline <arg>
  help            (show this help)
  call            host:port command arg arg .. arg
  set-timeout     host:port milliseconds
  del-node        host:port node_id
  create          host1:port1 ... hostN:portN
                  --replicas <arg>
 
For check, fix, reshard, del-node, set-timeout you can specify the host and port of any working node in the cluster.
  • 创建集群
 
[root@localhost src]# ./redis-trib.rb create --replicas 1 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002
>>> Creating cluster
*** ERROR: Invalid configuration for cluster creation.
*** Redis Cluster requires at least 3 master nodes.
*** This is not possible with 3 nodes and 1 replicas per node.
*** At least 6 nodes are required.
  • 新开一台机子, 配置如上, 端口号为 7003 7004 7005
  • 开放端口号 7000 7001 7002 7003 7004 7005 17000 17001 17002 17003 17004 17005
  • 再次创建集群
 
[root@localhost redis_cluster]# /usr/local/soft/redis-3.2.6/src/redis-trib.rb create --replicas 1 192.168.59.128:7000 192.168.59.128:7001 192.168.59.128:7002 192.168.59.129:7003 192.168.59.129:7004 192.168.59.129:7005
>>> Creating cluster
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
192.168.59.129:7003
192.168.59.128:7000
192.168.59.129:7004
Adding replica 192.168.59.128:7001 to 192.168.59.129:7003
Adding replica 192.168.59.129:7005 to 192.168.59.128:7000
Adding replica 192.168.59.128:7002 to 192.168.59.129:7004
M: bbf1f1150a661ec3adee9ecb37ab140c03290582 192.168.59.128:7000
   slots:5461-10922 (5462 slots) master
S: 046219f4f154a5a757877cd1dc0f186423942424 192.168.59.128:7001
   replicates ccd1c5d708b1844881c13ac4c6ac467574ff23f7
S: f5e01feb8dd6f085c3b25c35f25753f6b2fa750b 192.168.59.128:7002
   replicates c7af24dcbe0ea6c26aec9965573c82130e98718a
M: ccd1c5d708b1844881c13ac4c6ac467574ff23f7 192.168.59.129:7003
   slots:0-5460 (5461 slots) master
M: c7af24dcbe0ea6c26aec9965573c82130e98718a 192.168.59.129:7004
   slots:10923-16383 (5461 slots) master
S: 0b9385e4fb3a939414891a00585f65c2fa07c29b 192.168.59.129:7005
   replicates bbf1f1150a661ec3adee9ecb37ab140c03290582
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.59.128:7000)
M: bbf1f1150a661ec3adee9ecb37ab140c03290582 192.168.59.128:7000
   slots:5461-10922 (5462 slots) master
   1 additional replica(s)
S: 046219f4f154a5a757877cd1dc0f186423942424 192.168.59.128:7001
   slots: (0 slots) slave
   replicates ccd1c5d708b1844881c13ac4c6ac467574ff23f7
S: 0b9385e4fb3a939414891a00585f65c2fa07c29b 192.168.59.129:7005
   slots: (0 slots) slave
   replicates bbf1f1150a661ec3adee9ecb37ab140c03290582
M: ccd1c5d708b1844881c13ac4c6ac467574ff23f7 192.168.59.129:7003
   slots:0-5460 (5461 slots) master
   1 additional replica(s)
S: f5e01feb8dd6f085c3b25c35f25753f6b2fa750b 192.168.59.128:7002
   slots: (0 slots) slave
   replicates c7af24dcbe0ea6c26aec9965573c82130e98718a
M: c7af24dcbe0ea6c26aec9965573c82130e98718a 192.168.59.129:7004
   slots:10923-16383 (5461 slots) master
   1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

redis3.2.6 集群安装的更多相关文章

  1. redis3.0.0 集群安装详细步骤

    Redis集群部署文档(centos6系统) Redis集群部署文档(centos6系统) (要让集群正常工作至少需要3个主节点,在这里我们要创建6个redis节点,其中三个为主节点,三个为从节点,对 ...

  2. redis3.0.5集群部署安装详细步骤

    Redis集群部署文档(centos6系统) (要让集群正常工作至少需要3个主节点,在这里我们要创建6个redis节点,其中三个为主节点,三个为从节点,对应的redis节点的ip和端口对应关系如下) ...

  3. CentOS下redis集群安装

    环境: 一台CentOS虚拟机上部署六个节点,创建3个master,3个slave节点 1.下载并解压 cd /root wget http://download.redis.io/releases/ ...

  4. redis离线集群安装

    用一个叫redis-trib.rb的ruby脚本.redis-trib.rb是redis官方推出的管理redis集群的工具,集成在redis的源码src目录下(redis-xxx/src/).是基于r ...

  5. 缓存系列之五:通过codis3.2实现redis3.2.8集群的管理

    通过codis3.2实现redis3.2.8集群 一:Codis 是一个分布式 Redis 解决方案, 对于上层的应用来说, 连接到 Codis Proxy 和连接原生的 Redis Server 没 ...

  6. Redis Sentinel 集群安装 step by step

    一. 准备材料 服务器 IP address 操作系统 位数 Redis 版本   CNT06CAH05 192.168.3.47 CentOS 6.5 x64 Redis-3.2.6 sentine ...

  7. Redis-3.2.1集群内网部署

    摘要: Redis-3.2.1集群内网部署 http://rubygems.org国内连不上时的一种Redis集群部署解决方案.不足之处,请广大网友指正,谢谢! 一. 关于redis cluster  ...

  8. redis cluster 集群 安装 配置 详解

    redis cluster 集群 安装 配置 详解 张映 发表于 2015-05-01 分类目录: nosql 标签:cluster, redis, 安装, 配置, 集群 Redis 集群是一个提供在 ...

  9. 【Oracle 集群】Oracle 11G RAC教程之集群安装(七)

    Oracle 11G RAC集群安装(七) 概述:写下本文档的初衷和动力,来源于上篇的<oracle基本操作手册>.oracle基本操作手册是作者研一假期对oracle基础知识学习的汇总. ...

随机推荐

  1. Java集合的区别和选择

              Collection |--List       有序,可重复 |--ArrayList 底层数据结构是数组,查询快,增删慢. 线程不安全,效率高 |--Vector 底层数据结构 ...

  2. C#图解教程-方法参数笔记(上)

    一晃大学四年要过去了,期间乱点了很多技能点, 导致每一项技能都只是处于入门阶段.为了将C#作为我的主要技能,准备恶补相关姿势(知识),通过各种技术论坛的推荐,找到了<C#图解教程>这本书. ...

  3. webstorm配置编译sass的输出目录

    关于这个的问题,虽说不是很难,但还是踩了点小坑,下面就来介绍下如何使用webstorm配置编译sass的输出目录. 1.下载Ruby 2.使用Ruby安装sass 3.检测是否安装成功. 前面的几步很 ...

  4. final修饰的变量是引用不能变还是对象的内容不能变?

    int a=1;此时a是变量: StringBuffer a=new StringBuffer();此时a就是引用变量,可以说是a引用String对象,通过a来操作String 对象 final St ...

  5. 使用Java语言开发微信公众平台(六)

    在上一节课程中,我们来学习了微信公众平台最基础的一个接口--access_token,并且能够从微信公众平台中取到access_token. 那么,在本节课程中,我们要以上节课获取到的access_t ...

  6. 结束C#2的讲解:最后的一些特性

    分部类型 可以在多个源文件中为一个类型编写代码.特别适合用于部分代码是自动生成,而其他部分的代码为手动类型. 多个源代码文件组成的类型为分部类型 #region 7-1演示分部类型的混合声明 part ...

  7. iOS 自动构建套件 - flow.ci + fir.im + Coding

    编者按:本文转载自 flow.ci 用户 GitHub@mzying2013 的实践分享,原文链接这里. 前言 相信很多最开始接触自动构建都是从 Jenkins 开始的.都是纯手工搭建,本地代码创库也 ...

  8. scala练手之数字转汉字小工具

    输入数字,转换成汉字,在统计数据量时很好用,而输入数字转成大写汉字,可以用于填写收据报销单哦 下载链接 https://pan.baidu.com/s/1nv3Ci6l 效果图如下: 直接上代码 ob ...

  9. Java中实现多线程关键词整理

    Java中的Runable,Callable,Future,FutureTask,ExecutorService,Excetor,Excutors,ThreadPoolExcetor在这里对这些关键词 ...

  10. 移动Web开发小结

    以下是做移动端Web开发过程中小结的几个事项:希望能够帮助到大家,同时也方便自己查看: 1,在移动开发页面中,主体盒子的max-width与min-width的设置原因: ①设置max-width是为 ...