1. 程式人生 > >CentOS6.10安裝redis-dump小插曲

CentOS6.10安裝redis-dump小插曲

但是 定時備份 ranch ive group top implement fig vision

前段時間發布過一篇關於redis-dump的安裝和簡單實用文章
博文地址:http://blog.51cto.com/wujianwei/2105124
昨天因開發同事要求要給另外的一個項目的redis的數據做定時備份,原本想的直接照著之前發布的文檔直接部署,但是嘗試了幾次,總是不成功。於是才有了今天的博文的小插曲,希望能夠幫助到遇到同樣問題的網友們。接下來讓我們一起回顧具體的部署過程:

一、服務器的環境:

[root@MQ1-S ~]# cat /etc/redhat-release 
CentOS release 6.10 (Final)
[root@MQ1-S ~]# uname -a
Linux 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

二、安裝ruby

1.安裝Ruby環境

yum -y install ruby ruby-devel
yum -y install rubygems

2.添加taobao Ruby鏡像
添加淘寶ruby源;

[root@MQ1-S ~]# gem sources --add https://ruby.taobao.org/   https://ruby.taobao.org/ added to sources
Error 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/

開始報錯了,網上各種百度無解。有點小郁悶啊。

於是參照http://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  Speed
100 24361  100 24361    0     0   6735      0  0:00:03  0:00:03 --:--:-- 13778
Downloading https://github.com/rvm/rvm/archive/1.29.4.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.4/1.29.4.tar.gz.asc
gpg: 於 2018年07月02日 星期一 03時41分26秒 CST 創建的簽名,使用 RSA,鑰匙號 BF04FF17
gpg: 無法檢查簽名:No public key
Warning, 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 409B6B1796C275462A1703113804BB82D39DC0E3

or 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/mpapis

NOTE: 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 409B6B1796C275462A1703113804BB82D39DC0E3
gpg: 鑰匙環‘/root/.gnupg/secring.gpg’已建立
gpg: 下載密鑰‘D39DC0E3’,從 hkp 服務器 keys.gnupg.net
gpg: /root/.gnupg/trustdb.gpg:建立了信任度數據庫
gpg: 密鑰 D39DC0E3:公鑰“Michal Papis (RVM signing) <[email protected]>”已導入
gpg: 沒有找到任何絕對信任的密鑰
gpg: 合計被處理的數量:1
gpg:           已導入: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  Speed
100 24361  100 24361    0     0   8580      0  0:00:02  0:00:02 --:--:-- 36359
Downloading https://github.com/rvm/rvm/archive/1.29.4.tar.gz
curl: (35) SSL connect error

Could 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.gz
Downloading https://bitbucket.org/mpapis/rvm/downloads/1.29.4.tar.gz.asc
gpg: 於 2018年07月02日 星期一 03時41分26秒 CST 創建的簽名,使用 RSA,鑰匙號 BF04FF17
gpg: 完好的簽名,來自於“Michal Papis (RVM signing) <[email protected]>”
gpg:               亦即“Michal Papis <[email protected]>”
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 FF17
GPG 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-<name> --url https://github.com/github/ruby.git --branch 2.2

# JRuby
jruby-1.6[.8]
jruby-1.7[.27]
jruby-9.1[.17.0]
jruby[-9.2.0.0]
jruby-head

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

# TruffleRuby
truffleruby[-1.0.0-rc2]

# 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-1[.4.0]
mruby[-head]

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

# Topaz
topaz

# MagLev
maglev-1.0.0
maglev-1.1[RC1]
maglev[-1.2Alpha4]
maglev-head

# 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
[root@MQ1-S archives]# 

安裝一個ruby版本
#rvm install 2.3.7

[root@MQ1-S archives]# rvm install 2.3.7
Searching 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     0
Warning: Transient problem: timeout Will retry in 2 seconds. 3 retries left.
Throwing away 2326528 bytes
100 13.7M  100 13.7M    0     0  2057k      0  0:00:06  0:00:06 --:--:-- 3181k
ruby-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 --version
ruby 2.3.7p456 (2018-03-28 revision 63024) [x86_64-linux]

三、安裝redis-dump

[root@MQ1-S ~]# gem install redis-dump
Fetching: redis-4.0.1.gem (100%)
Successfully installed redis-4.0.1
Fetching: uri-redis-0.4.2.gem (100%)
Successfully installed uri-redis-0.4.2
Fetching: drydock-0.6.9.gem (100%)
Successfully installed drydock-0.6.9
Fetching: redis-dump-0.4.0.gem (100%)
Successfully installed redis-dump-0.4.0
Parsing documentation for redis-4.0.1
Installing ri documentation for redis-4.0.1
Parsing documentation for uri-redis-0.4.2
Installing ri documentation for uri-redis-0.4.2
Parsing documentation for drydock-0.6.9
Installing ri documentation for drydock-0.6.9
Parsing documentation for redis-dump-0.4.0
Installing ri documentation for redis-dump-0.4.0
Done installing documentation for redis, uri-redis, drydock, redis-dump after 1 seconds
4 gems installed

到此處redis-dump安裝完成

CentOS6.10安裝redis-dump小插曲