redis搭建實戰記錄
-- from http://redis.io/
redis 是一個基于內存的高性能key-value數據庫,數據都保存在內存中定期刷新到磁盤,以極高的讀寫效率而備受關注。他的特點是支持各種數據結構,stirng,hashes, list,set,和sorted sets
client端對于不同數據結構是使用不同的命令
這里說一下redis的安裝
虛擬機環境: centos
1 wget make 安裝
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make
注: 這里記錄一下我安裝過程中出現的問題:
make: Warning: File `Makefile' has modification time 5.4e+06 s in the future
cd src && make all
make[1]: Entering directory `/redis/redis-2.4.7/src'
make[1]: Warning: File `Makefile' has modification time 5.4e+06 s in the future
MAKE hiredis
make[2]: Entering directory `/redis/redis-2.4.7/deps/hiredis'
make[2]: Warning: File `Makefile' has modification time 5.4e+06 s in the future
cc -c -std=c99 -pedantic -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb net.c
make[2]: cc: Command not found
make[2]: *** [net.o] Error 127
make[2]: Leaving directory `/redis/redis-2.4.7/deps/hiredis'
make[1]: *** [dependencies] Error 2
make[1]: Leaving directory `/redis/redis-2.4.7/src'
make: *** [all] Error 2
第一個問題
make: Warning: File `Makefile' has modification time 5.4e+06 s in the future
系統時間調整錯了,調過來就好了
第二個問題:
make[2]: Entering directory `/redis/redis-2.4.7/deps/hiredis'
cc -c -std=c99 -pedantic -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb net.c
make[2]: cc: Command not found
沒安裝gcc,
yum install gcc-c++
第三個問題:
make的時候顯示
make[1]: Entering directory `/redis/redis-2.4.7/src'
which: no tclsh8.5 in (/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
You need 'tclsh8.5' in order to run the Redis test
沒安裝tcl
按照官網http://www.linuxfromscratch.org/blfs/view/cvs/general/tcl.html 上的安裝
安裝完成之后,make成功!
安裝成功之后會在src文件夾內有redis-server和redis-cli兩個命令
建議將其放到bin下
sudo cp redis-server /usr/local/bin/
sudo cp redis-cli /usr/local/bin/
好了,現在redis就安裝成功了
2 測試redis安裝情況
我只在一臺虛擬機上安裝了redis,所以這臺虛擬機既是服務器,又是客戶端
測試:
1 使用secureRt打開一個會話,redis-server,讓其作為服務器運行
[19282] 19 Feb 23:52:57 - 1 clients connected (0 slaves), 726248 bytes in use
[19282] 19 Feb 23:53:02 - DB 0: 1 keys (0 volatile) in 4 slots HT.
[19282] 19 Feb 23:53:02 - 1 clients connected (0 slaves), 726248 bytes in use
[19282] 19 Feb 23:53:07 - DB 0: 1 keys (0 volatile) in 4 slots HT.
[19282] 19 Feb 23:53:07 - 1 clients connected (0 slaves), 726248 bytes in use
2 打開另一個會話:
ast login: Tue Feb 19 22:49:49 2013 from 192.168.1.103
set key和get key都正確
redis搭建測試通過
參考文章:
http://redis.io/topics/quickstart
http://hi.baidu.com/thinkinginlamp/blog/item/3358c93d174e35ce9f3d62bf.html
作者:yjf512(軒脈刃)
出處:http://www.cnblogs.com/yjf512/