CentOS7安装Redis4.0集群
2018-01-18 13:41
603 查看
环境
CentOS 7, Redis 4.0.6, Oracle VM VirtualBoxRedis集群要求最少3主3从,主机使用虚拟主机(192.168.1.81 - 192.168.1.86)
备注:使用redis-trib安装reids4.0.6集群需要ruby版本>2.2.2,但是yum源默认是2.0版本,所以需要修改yum源安装2.3版本
配置一台虚拟机
IP:192.168.1.81安装 gcc wgetyum install wget gcc -y
安装redis
wget http://download.redis.io/releases/redis-4.0.6.tar.gz tar xzf redis-4.0.6.tar.gz mv redis-4.0.6 /usr/local/redis cd redis-4.0.6 /usr/local/redis mv redis.conf redis.conf.bak vi redis.confredis.conf中添加如下内容
port 6379 bind 192.168.1.81 //不同主机IP不同 cluster-enabled yes cluster-config-file nodes-6379.conf cluster-node-timeout 5000 pidfile /var/run/redis_6379.pid appendonly yes
安装好后复制5台虚拟机(192.168.1.82-192.168.1.86)
启动6台虚拟机的redis
[root@redis01 ~]# /usr/local/redis/src/redis-server /usr/local/redis/redis.conf
安装ruby
备注:一台安装即可,我是在192.168.1.81上安装yum install centos-release-scl-rhyum install rh-ruby23 -y
scl enable rh-ruby23 bash
组成集群
gem install redis /usr/local/redis/src/redis-trib.rb create --replicas 1 192.168.1.81:6379 192.168.1.82:6379 192.168.1.83:6379 192.168.1.84:6379 192.168.1.85:6379 192.168.1.86:6379显示信息如下
[root@redis01 local]# /usr/local/redis/src/redis-trib.rb create --replicas 1 192.168.1.81:6379 192.168.1.82:6379 192.168.1.83:6379 192.168.1.84:6379 192.168.1.85:6379 192.168.1.86:6379 >>> Creating cluster >>> Performing hash slots allocation on 6 nodes... Using 3 masters: 192.168.1.81:6379 192.168.1.82:6379 192.168.1.83:6379 Adding replica 192.168.1.84:6379 to 192.168.1.81:6379 Adding replica 192.168.1.85:6379 to 192.168.1.82:6379 Adding replica 192.168.1.86:6379 to 192.168.1.83:6379 M: d303fbc7f6f7d216e7eb3bdbbe1a136123fe78ab 192.168.1.81:6379 slots:0-5460 (5461 slots) master M: 6b413b265a5574c675085c1d37eea7ffd2935919 192.168.1.82:6379 slots:5461-10922 (5462 slots) master M: a121164f525855ae7d6b5e95911f9f6639f3b38a 192.168.1.83:6379 slots:10923-16383 (5461 slots) master S: b34636a7a84357a3c069d6c75efc3f1c7b9be7c2 192.168.1.84:6379 replicates d303fbc7f6f7d216e7eb3bdbbe1a136123fe78ab S: 21cf50a1d11233c4963f156a0dc0e4b24db34f8e 192.168.1.85:6379 replicates 6b413b265a5574c675085c1d37eea7ffd2935919 S: d512b1467a1f7a91e953660f7302a1952ea1afe2 192.168.1.86:6379 replicates a121164f525855ae7d6b5e95911f9f6639f3b38a 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.1.81:6379) M: d303fbc7f6f7d216e7eb3bdbbe1a136123fe78ab 192.168.1.81:6379 slots:0-5460 (5461 slots) master 1 additional replica(s) M: a121164f525855ae7d6b5e95911f9f6639f3b38a 192.168.1.83:6379 slots:10923-16383 (5461 slots) master 1 additional replica(s) S: d512b1467a1f7a91e953660f7302a1952ea1afe2 192.168.1.86:6379 slots: (0 slots) slave replicates a121164f525855ae7d6b5e95911f9f6639f3b38a S: b34636a7a84357a3c069d6c75efc3f1c7b9be7c2 192.168.1.84:6379 slots: (0 slots) slave replicates d303fbc7f6f7d216e7eb3bdbbe1a136123fe78ab M: 6b413b265a5574c675085c1d37eea7ffd2935919 192.168.1.82:6379 slots:5461-10922 (5462 slots) master 1 additional replica(s) S: 21cf50a1d11233c4963f156a0dc0e4b24db34f8e 192.168.1.85:6379 slots: (0 slots) slave replicates 6b413b265a5574c675085c1d37eea7ffd2935919 [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered.
相关文章推荐
- centos7安装redis-3.0.4集群
- centos7安装redis-4.0.1集群
- Redis(二)CentOS7安装Redis4.0.10与集群搭建
- centos7/rhel7下安装redis4.0集群
- Centos7安装Redis-3.2.5集群
- CentOS7 下载并安装Redis3.0集群详细步骤(一)单节点的安装
- centos7安装redis3.2.5集群
- Centos7下安装redis实战(单机版以及集群)
- CentOS7下载,安装Redis集群详细步骤,并测试
- 阿里云ECS centos7 安装Redis4.0
- redis4.0集群安装配置(双节点)
- centos7安装redis 配置集群
- centos7安装redis-4.0.1集群
- Centos7中安装Redis3.2.3集群
- Centos7安装Redis单机版和集群
- CentOS7 下载并安装Redis3.0集群详细步骤(二)redis集群的安装
- centos7安装redis3.2.5集群
- Centos7搭建redis集群及安装sentinel
- Centos7安装Redis集群
- CentOS7安装配置redis-3.0.0