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

来源:互联网 发布:58采集软件 编辑:程序博客网 时间:2024/05/21 17:39


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

 

1:下载源码包:

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

 

2:解压安装:

[plain] view plain copy
  1. tar xzvf ruby-2.2.3.tar.gz -C /root/redis  
  2. cd /root/redis/ruby-2.2.3/  
  3. ./configure   
  4. make  
  5. make install  

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

[plain] view plain copy
  1. ERROR:  Loading command: install (LoadError)  
  2.         cannot load such file -- zlib  
  3. ERROR:  While executing gem ... (NoMethodError)  
  4.     undefined method `invoke_with_build_args' for nil:NilClass  

解决方法:

[plain] view plain copy
  1. apt-get install zlib1g-dev  
  2. cd /root/redis/ruby-2.2.3/ext/zlib  
  3. ruby ./extconf.rb  
  4. make  
  5. make install  

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

[plain] view plain copy
  1. ERROR:  While executing gem ... (Gem::Exception)  
  2.     Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources  

解决方法:

[plain] view plain copy
  1. apt-get install libssl-dev  
  2. cd /root/redis/ruby-2.2.3/ext/openssl  
  3. ruby ./extconf.rb  
  4. ln -s /root/redis/ruby-2.2.3/include /  
  5. make  
  6. make install  

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

[plain] view plain copy
  1. Errno::ECONNRESET: Connection reset by peer  

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

[plain] view plain copy
  1. #gem sources --add https://ruby.taobao.org/ --remove https://rubygems.org/  
  2. https://ruby.taobao.org/ added to sources  
  3. https://rubygems.org/ removed from sources  
  4.   
  5. #gem sources -l  
  6. *** CURRENT SOURCES ***  
  7.   
  8. https://ruby.taobao.org/  

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


转自:http://blog.csdn.net/gqtcgq/article/details/50277419


原创粉丝点击