这条路走得有点坎坷,果然运维同事真的很伟大。
本人亲测网上的多套方案搭建ruby,只有第四种方案是可行的,其余的都遇到了各种问题。
1、通过下载安装包
ruby-2.3.1.tar.gz
redis-3.3.0.gem
2、通过wget命令
wget https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.gz
wget http://rubygems.org/downloads/redis-3.3.0.gem
1跟2都会先出现 zlib包不存在以及openssl不存在的问题
zlib可以通过如下方式解决
yum -y install zlib-devel
进入ruby源码文件夹,安装ruby自身提供的zlib包
cd ruby-2.3.1/ext/zlib
ruby ./extconf.rb
make
make install
————————————————————————————————
3、通过yum install
默认安装的ruby版本低于2.2,无法创建redis集群,可以安装了之后再通过rvm工具升级,还不如直接使用rvm
4、通过ruby的版本管理工具rvm
4.1 curl -L get.rvm.io | bash -s stable
4.2 yum install -y crul(如果发现curl没有安装,则执行这个之后再执行4.1)
4.3 如果遇到CURLE_SSL_CONNECT_ERROR return status(35)的错误,执行yum -y update nss,再重新执行4.1
4.4 此时打印信息
Downloading https://github.com/rvm/rvm/archive/1.29.7.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.7/1.29.7.tar.gz.asc
gpg: Signature made Thu 03 Jan 2019 05:01:48 PM EST using RSA key ID 39499BDB
gpg: Can't check signature: No public key
GPG signature verification failed for '/usr/local/rvm/archives/rvm-1.29.7.tgz' - 'https://github.com/rvm/rvm/releases/download/1.29.7/1.29.7.tar.gz.asc'! Try to install GPG v2 and then fetch the public key:
gpg2 --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
or if it fails:
command curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
command curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -
In case of further problems with validation please refer tohttps://rvm.io/rvm/security
4.5 通过以上信息,需要try to install GPG v2再 fetch the public key
因此执行 command curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
再执行 4.1
4.6 此时打印信息
Downloading https://github.com/rvm/rvm/archive/1.29.7.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.7/1.29.7.tar.gz.asc
gpg: Signature made Thu 03 Jan 2019 05:01:48 PM EST using RSA key ID 39499BDB
gpg: Good signature from "Piotr Kuczynski <piotr.kuczynski@gmail.com>"
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: 7D2B AF1C F37B 13E2 069D 6956 105B D0E7 3949 9BDB
GPG verified '/usr/local/rvm/archives/rvm-1.29.7.tgz'
Creating group 'rvm'
Installing RVM to /usr/local/rvm/
Installation of RVM in /usr/local/rvm/ is almost complete:
* 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.
* Please do NOT forget to add your users to the rvm group.
The installer no longer auto-adds root or users to the rvm group. Admins must do this.
Also,please note that group memberships are ONLY evaluated at login time.
This means that users must log out then back in before group membership takes effect!
4.7 此时rvm已经安装成功,使配置文件生效
执行 find / -name rvm.sh
输出结果/etc/profile.d/rvm.sh
再执行 source /etc/profile.d/rvm.sh 使配置生效
4.8 接下来就可以随意安装任意版本的ruby了
执行 rvm install 2.3.3
再执行 ruby -v 返回结果说明安装成功
执行gem -v 返回结果说明安装ruby的时候也安装了gem(用来安装redis)
执行gem install redis
此时用来搭建redis集群的基础设施已全部到位,剩下的就是配置redis集群了。
4.9 /usr/local/bin是环境变量的路径,这个文件夹的命令是可以直接执行的,因此把redis里面的命令拷贝一份放到该路径下 ,执行 cp /usr/local/redis-3.3.0/src/redis-trib.rb /usr/local/bin,再执行 redis-trib.rb create --replicas 1 192.168.0.149:7001 192.168.0.149:7002 192.168.0.150:7003 192.168.0.150:7004 192.168.0.151:7005 192.168.0.151:7006,返回结果输入yes 再回车,执行redis-trib.rb check 192.168.0.149:7001查看集群状态