本文共 8829 字,大约阅读时间需要 29 分钟。
前段时间发布过一篇关于redis-dump的安装和简单实用文章博文地址:昨天因开发同事要求要给另外的一个项目的redis的数据做定时备份,原本想的直接照着之前发布的文档直接部署,但是尝试了几次,总是不成功。于是才有了今天的博文的小插曲,希望能够帮助到遇到同样问题的网友们。接下来让我们一起回顾具体的部署过程:
[root@MQ1-S ~]# cat /etc/redhat-release CentOS release 6.10 (Final)[root@MQ1-S ~]# uname -aLinux MQ1-S 2.6.32-642.el6.x86_64 #1 SMP Tue May 10 17:27:01 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
1.安装Ruby环境
yum -y install ruby ruby-develyum -y install rubygems
2.添加taobao Ruby镜像
添加淘宝ruby源;[root@MQ1-S ~]# gem sources --add https://ruby.taobao.org/ https://ruby.taobao.org/ added to sourcesError fetching https://ruby.taobao.org/: hostname was not match with the server certificate (https://gems.ruby-china.com/specs.4.8.gz)[root@MQ1-S ~]# gem sources --add http://gems.ruby-china.org --remove https://rubygems.org/Error fetching http://gems.ruby-china.org: hostname was not match with the server certificate (https://gems.ruby-china.com/specs.4.8.gz)source https://rubygems.org/ not present in cache[root@MQ1-S ~]# gem sources -l*** CURRENT SOURCES ***http://rubygems.org/
开始报错了,网上各种百度无解。有点小郁闷啊。
于是参照https://blog.51cto.com/wujianwei/2105124 这博文跳过添加淘宝ruby源这一步,继续后面的安装步骤
3.安装curl
yum install curl -y 4.安装rvm管理工具rvm是一个便捷的多版本ruby环境的管理和切换工具[root@MQ1-S archives]# curl -L get.rvm.io | bash -s stable % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed100 24361 100 24361 0 0 6735 0 0:00:03 0:00:03 --:--:-- 13778Downloading https://github.com/rvm/rvm/archive/1.29.4.tar.gzDownloading https://github.com/rvm/rvm/releases/download/1.29.4/1.29.4.tar.gz.ascgpg: 于 2018年07月02日 星期一 03时41分26秒 CST 创建的签名,使用 RSA,钥匙号 BF04FF17gpg: 无法检查签名:No public keyWarning, RVM 1.26.0 introduces signed releases and automated check of signatures when GPG software found. Assuming you trust Michal Papis import the mpapis public key (downloading the signatures).GPG signature verification failed for '/usr/local/rvm/archives/rvm-1.29.4.tgz' - 'https://github.com/rvm/rvm/releases/download/1.29.4/1.29.4.tar.gz.asc'! Try to install GPG v2 and then fetch the public key: gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3or if it fails: command curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -the key can be compared with: https://rvm.io/mpapis.asc https://keybase.io/mpapisNOTE: GPG version 2.1.17 have a bug which cause failures during fetching keys from remote server. Please downgrade or upgrade to newer version (if available) or use the second method described above.
安装报错,提示没有public key,于是照着提示,继续下面的操作
[root@MQ1-S archives]# gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3gpg: 钥匙环‘/root/.gnupg/secring.gpg’已建立gpg: 下载密钥‘D39DC0E3’,从 hkp 服务器 keys.gnupg.netgpg: /root/.gnupg/trustdb.gpg:建立了信任度数据库gpg: 密钥 D39DC0E3:公钥“Michal Papis (RVM signing)”已导入gpg: 没有找到任何绝对信任的密钥gpg: 合计被处理的数量:1gpg: 已导入:1 (RSA: 1)[root@MQ1-S archives]# curl -L get.rvm.io | bash -s stable % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed100 24361 100 24361 0 0 8580 0 0:00:02 0:00:02 --:--:-- 36359Downloading https://github.com/rvm/rvm/archive/1.29.4.tar.gzcurl: (35) SSL connect errorCould not download 'https://github.com/rvm/rvm/archive/1.29.4.tar.gz'. curl returned status '35'.Downloading https://bitbucket.org/mpapis/rvm/get/1.29.4.tar.gzDownloading https://bitbucket.org/mpapis/rvm/downloads/1.29.4.tar.gz.ascgpg: 于 2018年07月02日 星期一 03时41分26秒 CST 创建的签名,使用 RSA,钥匙号 BF04FF17gpg: 完好的签名,来自于“Michal Papis (RVM signing) ”gpg: 亦即“Michal Papis ”gpg: 亦即“[jpeg image of size 5015]”gpg: 警告:这把密钥未经受信任的签名认证!gpg: 没有证据表明这个签名属于它所声称的持有者。主钥指纹: 409B 6B17 96C2 7546 2A17 0311 3804 BB82 D39D C0E3子钥指纹: 62C9 E5F4 DA30 0D94 AC36 166B E206 C29F BF04 FF17GPG verified '/usr/local/rvm/archives/rvm-1.29.4.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!
[root@MQ1-S archives]# ll /usr/local/rvm/scripts/rvm-rwxrwxr-x. 1 root rvm 7615 7月 23 12:20 /usr/local/rvm/scripts/rvm[root@MQ1-S archives]#
到此处说明ruby环境的管理和切换工具rvm安装成功
加载rvm和列出可安装的 ruby 版本
加载rvm[root@MQ1-S archives]# source /usr/local/rvm/scripts/rvm列出可安装的 ruby 版本:[root@MQ1-S archives]# 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[.7][ruby-]2.4[.4][ruby-]2.5[.1][ruby-]2.6[.0-preview2]ruby-head#for forks use: rvm install ruby-head---url https://github.com/github/ruby.git --branch 2.2# JRubyjruby-1.6[.8]jruby-1.7[.27]jruby-9.1[.17.0]jruby[-9.2.0.0]jruby-head# Rubiniusrbx-1[.4.3]rbx-2.3[.0]rbx-2.4[.1]rbx-2[.5.8]rbx-3[.100]rbx-head# TruffleRubytruffleruby[-1.0.0-rc2]# Opalopal# Minimalistic ruby implementation - ISO 30170:2012mruby-1.0.0mruby-1.1.0mruby-1.2.0mruby-1.3.0mruby-1[.4.0]mruby[-head]# Ruby Enterprise Editionree-1.8.6ree[-1.8.7][-2012.02]# Topaztopaz# MagLevmaglev-1.0.0maglev-1.1[RC1]maglev[-1.2Alpha4]maglev-head# Mac OS X Snow Leopard Or Newermacruby-0.10macruby-0.11macruby[-0.12]macruby-nightlymacruby-head# IronRubyironruby[-1.1.3]ironruby-head[root@MQ1-S archives]#
安装一个ruby版本
#rvm install 2.3.7[root@MQ1-S archives]# rvm install 2.3.7Searching for binary rubies, this might take some time.No binary rubies available for: centos/6/x86_64/ruby-2.3.7.Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.Checking requirements for centos.Installing requirements for centos.Installing required packages: libffi-devel, readline-devel, sqlite-devel......Requirements installation successful.Installing Ruby from source to: /usr/local/rvm/rubies/ruby-2.3.7, this may take a while depending on your cpu(s)...ruby-2.3.7 - #downloading ruby-2.3.7, this may take a while depending on your connection... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 16 13.7M 16 2272k 0 0 1290 0 3:06:19 0:30:02 2:36:17 0Warning: Transient problem: timeout Will retry in 2 seconds. 3 retries left.Throwing away 2326528 bytes100 13.7M 100 13.7M 0 0 2057k 0 0:00:06 0:00:06 --:--:-- 3181kruby-2.3.7 - #extracting ruby-2.3.7 to /usr/local/rvm/src/ruby-2.3.7.....ruby-2.3.7 - #configuring...........................................................ruby-2.3.7 - #post-configuration..ruby-2.3.7 - #compiling................................................................................................ruby-2.3.7 - #installing...........................ruby-2.3.7 - #making binaries executable..ruby-2.3.7 - #downloading rubygems-2.7.7 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 3 894k 3 31800 0 0 148 0 1:43:08 0:03:33 1:39:35 0
使用一个ruby版本
rvm use 2.3.7或者如下:rvm --create ruby-2.3.7卸载一个已知版本:
rvm remove 2.0.0查看当前的ruby的版本号:ruby --version[root@MQ1-S ~]# ruby --versionruby 2.3.7p456 (2018-03-28 revision 63024) [x86_64-linux]
[root@MQ1-S ~]# gem install redis-dumpFetching: redis-4.0.1.gem (100%)Successfully installed redis-4.0.1Fetching: uri-redis-0.4.2.gem (100%)Successfully installed uri-redis-0.4.2Fetching: drydock-0.6.9.gem (100%)Successfully installed drydock-0.6.9Fetching: redis-dump-0.4.0.gem (100%)Successfully installed redis-dump-0.4.0Parsing documentation for redis-4.0.1Installing ri documentation for redis-4.0.1Parsing documentation for uri-redis-0.4.2Installing ri documentation for uri-redis-0.4.2Parsing documentation for drydock-0.6.9Installing ri documentation for drydock-0.6.9Parsing documentation for redis-dump-0.4.0Installing ri documentation for redis-dump-0.4.0Done installing documentation for redis, uri-redis, drydock, redis-dump after 1 seconds4 gems installed
到此处redis-dump安装完成
转载于:https://blog.51cto.com/wujianwei/2150208