天天看点

Redis集群环境Ruby必须版本2.2以上解决

Redis集群环境中需要ruby环境,执行gem install redis时,提示如下错误:

[root@hadoop-node01 src]# gem install redis
ERROR:  Error installing redis:
    redis requires Ruby version >= 2.2.2.      

在centOS中yum源中对ruby的支持版本为2.0.0,可gem 安装redis需要最低是2.2.2,采用rvm来更新ruby

1.安装RVM

[root@hadoop-node01 ~]# gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A
1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

[root@hadoop-node01 ~]# curl -sSL https://get.rvm.io | bash -s stable

[root@hadoop-node01 ~]# find / -name rvm -print      

在执行curl命令的时候有可能报错如下:

[root@hadoop-node01 ~]# curl -sSL https://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: (35) SSL connect error

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

无法在服务器使用curl命令访问https域名,原因是nss版本有点旧了,yum -y update nss更新一下,重新curl即可!

命令执行完成后的输出结果

[root@hadoop-node01 ~]# find / -name rvm -print
/usr/local/rvm
/usr/local/rvm/scripts/rvm
/usr/local/rvm/lib/rvm
/usr/local/rvm/bin/rvm
/usr/local/rvm/src/rvm
/usr/local/rvm/src/rvm/scripts/rvm
/usr/local/rvm/src/rvm/lib/rvm
/usr/local/rvm/src/rvm/bin/rvm      

加载文件

[root@hadoop-node01 ~]# source /usr/local/rvm/scripts/rvm      

2.查看rvm库中已知的ruby版本

[root@hadoop-node01 ~]# rvm list known      
[root@hadoop-node01 ~]# 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[.10]
[ruby-]2.3[.8]
[ruby-]2.4[.5]
[ruby-]2.5[.3]
[ruby-]2.6[.0]
ruby-head
~      

3.安装一个ruby版本

[root@hadoop-node01 ~]# rvm install 2.4.5      
Redis集群环境Ruby必须版本2.2以上解决

4.使用一个ruby版本

[root@hadoop-node01 ~]# rvm use 2.4.5
Using /usr/local/rvm/gems/ruby-2.4.5      

5.设置默认版本

[root@hadoop-node01 ~]# rvm use 2.4.5 --default
Using /usr/local/rvm/gems/ruby-2.4.5      

6.卸载一个已知版本

[root@hadoop-node01 ~]# rvm remove 2.4.5       

7.查看ruby版本

[root@hadoop-node01 ~]# ruby --version
ruby 2.4.5p335 (2018-10-18 revision 65137) [x86_64-linux]      

继续阅读