redis cluster安装遇到的坑

514 阅读2分钟

redis cluster安装遇到的坑

www.aililan.cn/?p=50

redis官网看到5.0以后 cluster简单很多 直接redis-cli命令支持 不用ruby 简直不要不要的~~

The first example, that is, the cluster creation, will be shown using both redis-cli in Redis 5 and redis-trib in Redis 3 and 4. However all the next examples will only use redis-cli, since as you can see the syntax is very similar, and you can trivially change one command line into the other by using redis-trib.rb help to get info about the old syntax. Important: note that you can use Redis 5 redis-cli against Redis 4 clusters without issues if you wish.

To create your cluster for Redis 5 with redis-cli simply type:

redis-cli --cluster create 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 \
--cluster-replicas 1

Using redis-trib.rb for Redis 4 or 3 type:

./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

以下适用于redis5.0以下

yum安装

yum install -y ruby
yum install -y rubygems
gem install redis
  1. yum安装的ruby为1.8版本 第三步gem时报错须ruby>2.2.2
gem install redis
   ERROR:  Error installing redis:
           redis requires Ruby version >= 2.2.2.

yum list |grep ruby没有2.2以上版本

  1. 百度用rvm替换ruby版本 但 bash时一直报错 识别不了版本号
curl -sSL https://get.rvm.io | bash -s stable
[root@eshop-cache01 ruby-2.3.1]#  curl -L get.rvm.io | bash -s stable
.
.
.

Downloading https://github.com/rvm/rvm/archive/.tar.gz
curl: (35) SSL connect error

Could not download 'https://github.com/rvm/rvm/archive/.tar.gz'.
  curl returned status '35'.

Downloading https://bitbucket.org/mpapis/rvm/get/.tar.gz
curl: (7) Failed to connect to 2406:da00:ff00::22c0:3470: Network is unreachable

Could not download 'https://bitbucket.org/mpapis/rvm/get/.tar.gz'.
  curl returned status '7'.


2. 一怒之下转源码安装

wget https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.gz
tar -zxvf ruby-2.3.1.tar.gz
./configure -prefix=/usr/local/ruby
make && make install
cd /usr/local/ruby
cp bin/ruby /usr/local/bin
cp bin/gem /usr/local/bin

wget http://rubygems.org/downloads/redis-3.3.0.gem
gem install -l ./redis-3.3.0.gem
gem list 
  1. ruby -v不能识别 因为目录不对 用ln建立映射
ruby -v
-bash: /usr/bin/ruby: No such file or directory
ln -s /usr/local/bin/ruby /usr/bin/ruby
ln -s /usr/local/bin/gem /usr/bin/gem
[root@eshop-cache01 bin]# ./ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [i686-linux]
  1. gem 报错zlib
ERROR:  Loading command: install (LoadError)
    cannot load such file -- zlib
ERROR:  While executing gem ... (NoMethodError)
    undefined method `invoke_with_build_args' for nil:NilClass

ruby没有zlib插件 进入ruby源码目录ext安装 /usr/local/ruby-2.3.1

cd ext/zlib
ruby ./extconf.rb
make
make install
  1. gem报错openssl
Unable to require openssl,install OpenSSL and rebuild ruby (preferred) or use

ruby没有ssl插件 进入ruby源码目录ext安装 /usr/local/ruby-2.3.1

cd ext/openssl
ruby ./extconf.rb
make
make install
  1. openssl make时报错
make: *** No rule to make target /include/ruby.h', needed byossl.o’. Stop.

打开Makefile文件,在顶部添加 top_srcdir = …/…

vi Makefile


#### Start of system configuration section. ####
top_srcdir=../..
srcdir = .

gem install redis 终于成功 可以跑redis cluster了 后记:没有银弹

搞了2个小时 最后是通过源码安装好的 感觉通过yum rvm也可以安装好ruby2.2.2+
源码安装感觉更麻烦 还是没有银弹 选了条路出错了就要google走下去
rvm那个网络问题 应该也可以修复好往下走