CentOS安裝Redis-dump遇到的坑

關(guān)于redis-dump 安裝遇到的問題以及解決方案


安裝平臺: centos7
[root@VM_16_15_centos ~]# redis-dump
-bash: redis-dump: command not found

沒有安裝這個管理工具【不想看過程的可以看末尾精華版】

因為這個工具是基于Ruby實現(xiàn)的,首先要安裝Ruby

一:安裝Ruby

參考:Ruby官方

示例:centos (模擬輸入和部分輸出, 可以在 install前面添加 -y 把后面的手動選擇y自動化)

[root@VM_16_15_centos ~]# yum install ruby  
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
二:嘗試安裝 redis-dump
[root@VM_16_15_centos ~]# gem install redis-dump
Fetching: yajl-ruby-1.4.1.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing redis-dump:
    ERROR: Failed to build gem native extension.

    /usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /usr/share/include/ruby.h

這里還是報錯

我就不說什么原因了歇父,直接開始解決宫静。先安裝這個

[root@VM_16_15_centos ~]# yum -y install ruby ruby-devel
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
Package ruby-2.0.0.648-35.el7_6.x86_64 already installed and latest version
Package ruby-devel-2.0.0.648-35.el7_6.x86_64 already installed and latest version

然后安裝這個

[root@VM_16_15_centos ~]# yum -y install rubygems
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
Package rubygems-2.0.14.1-35.el7_6.noarch already installed and latest version
...暫時先別動份招,替換下國內(nèi)源,加個速度,然后再復(fù)制它的提示指令繼續(xù)操作...

替換的指令為

[root@VM_16_15_centos ~]# gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
// 查詢狀態(tài)指令
[root@VM_16_15_centos ~]# gem sources -l
*** CURRENT SOURCES ***

https://gems.ruby-china.com/
然后繼續(xù)嘗試安裝
[root@VM_16_15_centos ~]# gem install redis-dump
Fetching: yajl-ruby-1.4.0.gem (100%)
Building native extensions.  This could take a while...
Successfully installed yajl-ruby-1.4.0
Fetching: redis-4.0.1.gem (100%)
ERROR:  Error installing redis-dump:
    redis requires Ruby version >= 2.2.2.
[root@VM_16_15_centos ~]# yum install curl
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
Package curl-7.29.0-51.el7_6.3.x86_64 already installed and latest version

然后通過上一步安裝好的 curl安裝下面的這個, 部分提示如下

[root@VM_16_15_centos ~]# curl -L get.rvm.io | bash -s stable
····部分提示如下····
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 to https://rvm.io/rvm/security

復(fù)制它的指令先改,再繼續(xù)

[root@VM_16_15_centos ~]# curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
[root@VM_16_15_centos ~]# curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -

然后重試浩蓉,這一步會等比較久

[root@VM_16_15_centos ~]# curl -L get.rvm.io | bash -s stable
這里之后需要使 rvm指令生效
[root@VM_16_15_centos local]# cd /etc/profile.d
[root@VM_16_15_centos local]# ls
這里會看到有個 `rvm.sh` 的文件,然后
[root@VM_16_15_centos profile.d]# source rvm.sh

然后使用一下rvm -v檢測 rvm 是否可用

可用的話查看 rvm 里面的支持的東西

[root@VM_16_15_centos ~]# rvm list known
因為安裝 那個需要 Ruby 等級大于2.2.2.

我直接安裝了 2.3

[root@VM_16_15_centos ~]# rvm install 2.3

安裝好了之后就可以安裝 redis-dump了

[root@VM_16_15_centos ~]# gem install redis-dump
然后檢測成功了嗎
[root@VM_16_15_centos ~]# redis-dump
[root@VM_16_15_centos ~]# redis-load
Usage: cat dumpfile_db15.json | redis-load -d 15

看來是成功了,讀取一下我存在內(nèi)存中的 redis內(nèi)容看看情況

[root@VM_16_15_centos ~]# redis-dump -u localhost:6379
{"db":0,"key":"hello","ttl":-1,"type":"string","value":"nihao","size":5}
{"db":0,"key":"funny","ttl":-1,"type":"string","value":"kaixin","size":6}
{"db":0,"key":"school","ttl":-1,"type":"string","value":"xuexiao","size":7}

大功告成

精華版

[root@VM_16_15_centos ~]# yum install ruby 
[root@VM_16_15_centos ~]# yum -y install ruby ruby-devel
[root@VM_16_15_centos ~]# yum -y install rubygems
[root@VM_16_15_centos ~]# gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
[root@VM_16_15_centos ~]# yum install curl
[root@VM_16_15_centos ~]# curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
[root@VM_16_15_centos ~]# curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -
[root@VM_16_15_centos ~]# curl -L get.rvm.io | bash -s stable
[root@VM_16_15_centos local]# cd /etc/profile.d
[root@VM_16_15_centos profile.d]# source rvm.sh
[root@VM_16_15_centos ~]# rvm install 2.3
[root@VM_16_15_centos ~]# gem install redis-dump

redis-dump和redis-load簡單的幾個操作派继,具體的去百度就好了

以下小括號內(nèi)的內(nèi)容是有密碼的時候需要做的事情
redis-dump -u (:password@)localhost:6379    # 導(dǎo)出0-15號數(shù)據(jù)庫數(shù)據(jù) 
------------------------------------------------------------------------------------
// 全局參數(shù)相關(guān):redis-dump [參數(shù)] COMMAND [參數(shù)及操作]
-u 代表Redis鏈接字符串  (上面那一條就用的這個)
-d 代表數(shù)據(jù)庫代號
-s 代表導(dǎo)出之后的休眠時間
-c 代表分塊大小,默認(rèn)10000
-f 代表導(dǎo)出時的過濾器
-O 代表禁用運(yùn)行時優(yōu)化
-V 顯示版本
-D 表示開啟調(diào)試 
--------------------------------------------------------------------------------------
redis-dump -u localhost:6379 > ./redis_data.jl                         # 導(dǎo)出json
redis-sump -u (:password@)localhost:6379 -d 1 > ./redis_data.jl        # 只導(dǎo)出1號數(shù)據(jù)庫內(nèi)容
redis-sump -u (:password@)localhost:6379 -f ads1:* > ./redis_data.jl   # 導(dǎo)出以adsl開頭的數(shù)據(jù), 加入-f參數(shù)來過濾
< redis_data.json redis-load -u (:password@)localhost:6379             # 將json文件導(dǎo)入redis數(shù)據(jù)庫
cat redis_data.json | redis-load -u (:password@)localhost:6379         # 同樣效果
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末捻艳,一起剝皮案震驚了整個濱河市驾窟,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌认轨,老刑警劉巖绅络,帶你破解...
    沈念sama閱讀 216,496評論 6 501
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異,居然都是意外死亡恩急,警方通過查閱死者的電腦和手機(jī)杉畜,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,407評論 3 392
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來衷恭,“玉大人此叠,你說我怎么就攤上這事∷嬷椋” “怎么了灭袁?”我有些...
    開封第一講書人閱讀 162,632評論 0 353
  • 文/不壞的土叔 我叫張陵,是天一觀的道長窗看。 經(jīng)常有香客問我茸歧,道長,這世上最難降的妖魔是什么烤芦? 我笑而不...
    開封第一講書人閱讀 58,180評論 1 292
  • 正文 為了忘掉前任举娩,我火速辦了婚禮,結(jié)果婚禮上构罗,老公的妹妹穿的比我還像新娘铜涉。我一直安慰自己,他們只是感情好遂唧,可當(dāng)我...
    茶點故事閱讀 67,198評論 6 388
  • 文/花漫 我一把揭開白布芙代。 她就那樣靜靜地躺著,像睡著了一般盖彭。 火紅的嫁衣襯著肌膚如雪纹烹。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,165評論 1 299
  • 那天召边,我揣著相機(jī)與錄音铺呵,去河邊找鬼。 笑死隧熙,一個胖子當(dāng)著我的面吹牛片挂,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播贞盯,決...
    沈念sama閱讀 40,052評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼音念,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了躏敢?” 一聲冷哼從身側(cè)響起闷愤,我...
    開封第一講書人閱讀 38,910評論 0 274
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎件余,沒想到半個月后讥脐,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體遭居,經(jīng)...
    沈念sama閱讀 45,324評論 1 310
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,542評論 2 332
  • 正文 我和宋清朗相戀三年攘烛,在試婚紗的時候發(fā)現(xiàn)自己被綠了魏滚。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 39,711評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡坟漱,死狀恐怖鼠次,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情芋齿,我是刑警寧澤腥寇,帶...
    沈念sama閱讀 35,424評論 5 343
  • 正文 年R本政府宣布,位于F島的核電站觅捆,受9級特大地震影響赦役,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜栅炒,卻給世界環(huán)境...
    茶點故事閱讀 41,017評論 3 326
  • 文/蒙蒙 一掂摔、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧赢赊,春花似錦乙漓、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,668評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至玩讳,卻和暖如春涩蜘,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背熏纯。 一陣腳步聲響...
    開封第一講書人閱讀 32,823評論 1 269
  • 我被黑心中介騙來泰國打工同诫, 沒想到剛下飛機(jī)就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人樟澜。 一個月前我還...
    沈念sama閱讀 47,722評論 2 368
  • 正文 我出身青樓误窖,卻偏偏與公主長得像,于是被迫代替她去往敵國和親往扔。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 44,611評論 2 353

推薦閱讀更多精彩內(nèi)容