09安装运行redis-trib.rb所需的环境

        运行redis-trib.rb脚本配置Redis的cluster,需要安装ruby环境,这里采用源码安装:

 

1:下载源码包:

https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.3.tar.gz

 

2:解压安装:

tar xzvf ruby-2.2.3.tar.gz -C /root/redis
cd /root/redis/ruby-2.2.3/
./configure 
make
make install

3:安装Ruby之后,因redis-trib.rb依赖于gem包redis,因此需要执行命令:gem  install redis,报错:

ERROR:  Loading command: install (LoadError)
        cannot load such file -- zlib
ERROR:  While executing gem ... (NoMethodError)
    undefined method `invoke_with_build_args' for nil:NilClass

解决方法:

apt-get install zlib1g-dev
cd /root/redis/ruby-2.2.3/ext/zlib
ruby ./extconf.rb
make
make install

4:再次执行命令gem  install  redis,再次报错:

ERROR:  While executing gem ... (Gem::Exception)
    Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources

解决方法:

apt-get install libssl-dev
cd /root/redis/ruby-2.2.3/ext/openssl
ruby ./extconf.rb
ln -s /root/redis/ruby-2.2.3/include /
make
make install

5:再次执行命令gem  install  redis,竟然还是报错,错误信息是:

Errno::ECONNRESET: Connection reset by peer

查了一下原因,竟然是伟大的墙做的贡献(https://ruby.taobao.org/),解决办法如下:

#gem sources --add https://ruby.taobao.org/ --remove https://rubygems.org/
https://ruby.taobao.org/ added to sources
https://rubygems.org/ removed from sources

#gem sources -l
*** CURRENT SOURCES ***

https://ruby.taobao.org/

6:再次执行命令gem  install  redis,终于成功,此时,就可以运行redis-trib.rb脚本了。

你可能感兴趣的:(redis)