关闭

`gem_original_require': no such file to load redis requires Ruby version >= 2.2.2.

61人阅读 评论(0) 收藏 举报
分类:
当前环境

CentsOS 6.7 (Santiago) 64bit

redis 3.2.11 64bit

使用./redis-trib.rb create --replicas创建redis时报错,错误码如下

#./redis-trib.rb create --replicas 1 10.10.10.150:6391 10.10.10.151:6392 10.10.10.1522:6391 10.10.10.153:6392 10.10.10.154:6391  10.10.10.155:6391
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- redis (LoadError)
        from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from ./redis-trib.rb:25
             
以上报错是由于ruby版本过低,使用ruby gem安装redis需要ruby的最低版本是2.2.2,否则使用gem安装redis时也会报以下的错误

#gem install redis
    ERROR:  Error installing redis:
            redis requires Ruby version >= 2.2.2.

弄清楚错误原因,通过升级ruby版本可以解决创建集群报错的问题

解决思路:

1.查看当前ruby版本

当前ruby版本1.8.7 确实是比较低的版本
# ruby --version
ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux]

2.采用rvm来更新ruby版本,参考 https://github.com/rvm/rvm/issues/3108 

#gpg2 --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
gpg: keyring `/root/.gnupg/secring.gpg' created
gpg: requesting key D39DC0E3 from hkp server keys.gnupg.net
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key D39DC0E3: public key "Michal Papis (RVM signing) <mpapis@gmail.com>" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)

3.利用curl下载安装rvm

# curl -L get.rvm.io | bash -s stable
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 24090  100 24090    0     0  13221      0  0:00:01  0:00:01 --:--:-- 48373
Downloading https://github.com/rvm/rvm/archive/1.29.3.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.3/1.29.3.tar.gz.asc
gpg: Signature made Mon 11 Sep 2017 04:59:21 AM CST using RSA key ID BF04FF17
gpg: Good signature from "Michal Papis (RVM signing) <mpapis@gmail.com>"
gpg:                 aka "Michal Papis <michal.papis@toptal.com>"
gpg:                 aka "[jpeg image of size 5015]"
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 409B 6B17 96C2 7546 2A17  0311 3804 BB82 D39D C0E3
     Subkey fingerprint: 62C9 E5F4 DA30 0D94 AC36  166B E206 C29F BF04 FF17
GPG verified '/usr/local/rvm/archives/rvm-1.29.3.tgz'
Creating group 'rvm'

Installing RVM to /usr/local/rvm/
            source /etc/profile
Installation of RVM in /usr/local/rvm/ is almost complete:

到此下载安装结束,rvm已经安装在 /usr/local/rvm/目录

  * First you need to add all users that will be using rvm to 'rvm' group,
    and logout - login again, anyone using rvm will be operating with `umask u=rwx,g=rwx,o=rx`.

  * To start using RVM you need to run `source /etc/profile.d/rvm.sh`
    in all your open shell windows, in rare cases you need to reopen all shell windows.
    
4.执行/etc/profile.d/rvm.sh 设置环境变量等操作,脚本执行后就可以直接执行rvm命令了
 
5.获得当前可以用的ruby版本

#rvm list known
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.10]
[ruby-]2.2[.7]
[ruby-]2.3[.4]
[ruby-]2.4[.1]
ruby-head

# for forks use: rvm install ruby-head-<name> --url https://github.com/github/ruby.git --branch 2.2

# JRuby
jruby-1.6[.8]
jruby-1.7[.27]
jruby[-9.1.13.0]
jruby-head

# Rubinius
rbx-1[.4.3]
rbx-2.3[.0]
rbx-2.4[.1]
rbx-2[.5.8]
rbx-3[.84]
rbx-head

# Opal
opal

# Minimalistic ruby implementation - ISO 30170:2012
mruby-1.0.0
mruby-1.1.0
mruby-1.2.0
mruby-1[.3.0]
mruby[-head]

# Ruby Enterprise Edition
ree-1.8.6
ree[-1.8.7][-2012.02]

# Topaz
topaz

# MagLev
maglev[-head]
maglev-1.0.0

# Mac OS X Snow Leopard Or Newer
macruby-0.10
macruby-0.11
macruby[-0.12]
macruby-nightly
macruby-head

# IronRuby
ironruby[-1.1.3]
ironruby-head

6.安装2.3.4版的ruby

# rvm install 2.3.4
Searching for binary rubies, this might take some time.
No binary rubies available for: centos/6/x86_64/ruby-2.3.4.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for centos.
Requirements installation successful.
Installing Ruby from source to: /usr/local/rvm/rubies/ruby-2.3.4, this may take a while depending on your cpu(s)...
ruby-2.3.4 - #downloading ruby-2.3.4, this may take a while depending on your connection...

curl: (35) SSL connect error
There was an error(35).
Checking fallback: https://ftp.ruby-lang.org/pub/ruby/2.3/ruby-2.3.4.tar.bz2
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 13.7M  100 13.7M    0     0  1838k      0  0:00:07  0:00:07 --:--:-- 1967k
ruby-2.3.4 - #extracting ruby-2.3.4 to /usr/local/rvm/src/ruby-2.3.4....
ruby-2.3.4 - #applying patch /usr/local/rvm/patches/ruby/ruby_2_3_gcc7.patch.
ruby-2.3.4 - #applying patch /usr/local/rvm/patches/ruby/2.3.4/fix_rb_thread_fd_close.patch.
ruby-2.3.4 - #applying patch /usr/local/rvm/patches/ruby/2.3.4/random_c_using_NR_prefix.patch.
ruby-2.3.4 - #configuring..........................................................
ruby-2.3.4 - #post-configuration..
ruby-2.3.4 - #compiling........................................................................................
ruby-2.3.4 - #installing...........................
ruby-2.3.4 - #making binaries executable..
ruby-2.3.4 - #downloading rubygems-2.6.14
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  751k  100  751k    0     0  26449      0  0:00:29  0:00:29 --:--:-- 34792
No checksum for downloaded archive, recording checksum in user configuration.
ruby-2.3.4 - #extracting rubygems-2.6.14....
ruby-2.3.4 - #removing old rubygems.........
ruby-2.3.4 - #installing rubygems-2.6.14...........................
ruby-2.3.4 - #gemset created /usr/local/rvm/gems/ruby-2.3.4@global
ruby-2.3.4 - #importing gemset /usr/local/rvm/gemsets/global.gems...............................................
ruby-2.3.4 - #generating global wrappers........
ruby-2.3.4 - #gemset created /usr/local/rvm/gems/ruby-2.3.4
ruby-2.3.4 - #importing gemsetfile /usr/local/rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.3.4 - #generating default wrappers........
ruby-2.3.4 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.3.4 - #complete 
Please be aware that you just installed a ruby that requires 3 patches just to be compiled on an up to date linux system.
This may have known and unaccounted for security vulnerabilities.
Please consider upgrading to ruby-2.4.1 which will have all of the latest security patches.
Ruby was built without documentation, to build it run: rvm docs generate-ri

7.查看当前ruby的版本

# ruby --version
ruby 2.3.4p301 (2017-03-30 revision 58214) [x86_64-linux]

8.设置默认版本2.3.4版本的ruby 
# rvm use 2.3.4
Using /usr/local/rvm/gems/ruby-2.3.4

# rvm use 2.3.4 --default
Using /usr/local/rvm/gems/ruby-2.3.4


9.使用gem安装redis

# gem install redis
Fetching: redis-4.0.1.gem (100%)
Successfully installed redis-4.0.1
Parsing documentation for redis-4.0.1
Installing ri documentation for redis-4.0.1
Done installing documentation for redis after 1 seconds
1 gem installed

安装完成后,再次执行./redis-trib.rb create --replicas 就不会报错了  

注:curl 

curl是利用URL语法在命令行方式下工作的开源文件传输工具。它被广泛应用在Unix、多种Linux发行版中,并且有DOS和Win32、Win64下的移植版本。

注:rvm

RVM 是一个命令行工具,可以提供一个便捷的多版本 Ruby 环境的管理和切换。

参考 https://rvm.io/

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:771999次
    • 积分:8687
    • 等级:
    • 排名:第2454名
    • 原创:137篇
    • 转载:45篇
    • 译文:9篇
    • 评论:43条
    简介
    此博客为笔者的DT工作记录,欢迎一起交流学习工作中的点滴,若博客文章观点存在原理的错误、纰漏,笔者非常欢迎各位不保留地指出
    最新评论