CentOS 5.10 下安裝配置redis
本來想整點遊戲,但是工作一直在做hybrid。
忙是一個借口,昨天白天是睡過去的,在連續奮戰22個小時上線生產後,雖然又發現了新問題——越獄版蘋果4s下拉重新整理又有bug。但是也僅僅是發現了一台會出現這個問題,希望天亮能翻開這一頁,畢竟新需求眼瞅又得開始編碼了,預計12底上線的活動,這幾天我一直都在關注大家的白頭髮。
個人部落格整了許久,express3加mongodb打造的,雖然上線了,但是很多功能沒有完善,最近想統計訪問量決定用redis打造。
putty進入我的雲端服務器
到http://download.redis.io/releases/可以找到各種版本的redis
[plain]view plaincopyprint?
- #wgethttp://download.redis.io/releases/redis-2.6.14.tar.gz
解壓
[plain]view plaincopyprint?
- tarzxvfredis-2.6.14.tar.gz
進入解壓目錄 安裝
[plain]view plaincopyprint?
- cdredis-2.6.14
[plain]view plaincopyprint?
- make
[plain]view plaincopyprint?
- zmalloc.o:Infunction`zmalloc_used_memory':
- /usr/local/src/redis-2.6.14/src/zmalloc.c:223:undefinedreferenceto`__sync_add_and_fetch_4'
- collect2:ldreturned1exitstatus
- make[1]:***[redis-server]Error1
- make[1]:Leavingdirectory`/usr/local/src/redis-2.6.14/src'
- make:***[all]Error2
報錯了:
網上查了一下,因為的我的系統是32位的,所以得在make後加FLAGS="-march=i686"
[plain]view plaincopyprint?
- makeCFLAGS="-march=i686"
安裝沒有再上面的問題
[plain]view plaincopyprint?
- makeinstall<spanstyle="font-family:Monaco,'DejaVuSansMono','BitstreamVeraSansMono',Consolas,'CourierNew',monospace;line-height:18px;background-color:rgb(250,250,250);">安裝會把redis的命令被拷貝到/usr/local/bin下面</span>
提示
[plain]view plaincopyprint?
- cdsrc&&makeinstall
執行這步後提示To run 'make test' is a good idea ;) 對於這一步的test ————測試案例,非必選,可以跳過。
[plain]view plaincopyprint?
- maketest
居然提示You need tcl 8.5 or newer in order to run the Redis test
網上找tcl8.5安裝
[plain]view plaincopyprint?
- wgethttp://downloads.sourceforge.net/tcl/tcl8.5.10-src.tar.gz
- tarxzvftcl8.5.10-src.tar.gz
- <prename="code"class="plain">cdtcl8.5.10/unix/
[plain]view plaincopyprint?
- ./configure
- make
- makeinstall
安裝成功後,回到 目錄,繼續執行 make test,卡在
[plain]view plaincopyprint?
- [30/32done]:unit/sort(72seconds)
- [ok]:Clientoutputbuffersoftlimitisenforcediftimeisoverreached
- [31/32done]:unit/obuf-limits(40seconds)
ctrl+c強制停止,再試了幾次,卡得不耐煩後,終於出現
[plain]view plaincopyprint?
- \o/Alltestspassedwithouterrors!
- Cleanup:maytakesometime...OK
redis用例測試成功
在啟動redis前,回到上一級目錄,編輯redis.conf,修改配置
vim redis.conf
把daemonizeno改成daemonizeyes,這樣啟動redis時就會成會後台服務
把#bind 127.0.0.1改成bind 127.0.0.1
這樣遠程就不能訪問,安全性考慮,當然還可以配置連接埠,密碼等。
然後進入/usr/local/src/redis-2.6.14/src目錄 啟動
[plain]view plaincopyprint?
- [root@iZ28jgc6wlbZsrc]#./redis-server./../redis.conf
- [root@iZ28jgc6wlbZsrc]#grepredis
- [root@iZ28jgc6wlbZsrc]#redis-cli
- redis127.0.0.1:6379>sethelloworld
- OK
- redis127.0.0.1:6379>gethello
- "world"
- redis127.0.0.1:6379>
redis安裝 並且操作成功。