在CentOS 6.5下安裝Redis 2.8.13教程

2014-10-04 11:19:25來源:CSDN作者:微wx笑

Redis是一個開源的使用ANSI C語言編寫、支持網(wǎng)絡、可基于內(nèi)存亦可持久化的日志型、Key-Value數(shù)據(jù)庫,并提供多種語言的API。從2010年3月15日起,Redis的開發(fā)工作由VMware主持。

Redis簡介:

Redis是一個開源的使用ANSI C語言編寫、支持網(wǎng)絡、可基于內(nèi)存亦可持久化的日志型、Key-Value數(shù)據(jù)庫,并提供多種語言的API。從2010年3月15日起,Redis的開發(fā)工作由VMware主持。

redis是一個key-value存儲系統(tǒng)。和Memcached類似,它支持存儲的value類型相對更多,包括string(字符串)、list(鏈表)、set(集合)、zset(sorted set --有序集合)和hash(哈希類型)。這些數(shù)據(jù)類型都支持push/pop、add/remove及取交集并集和差集及更豐富的操作,而且這些操作都是原子性的。在此基礎上,redis支持各種不同方式的排序。與memcached一樣,為了保證效率,數(shù)據(jù)都是緩存在內(nèi)存中。區(qū)別的是redis會周期性的把更新的數(shù)據(jù)寫入磁盤或者把修改操作寫入追加的記錄文件,并且在此基礎上實現(xiàn)了master-slave(主從)同步。

安裝環(huán)境:

CentOS 6.5

Redis 2.8.13
 

下載安裝:

下載文件到 /opt/ 目錄下

wget http://download.redis.io/releases/redis-2.8.13.tar.gz

解壓文件

tar zxvf redis-2.8.13.tar.gz
 

切換目錄到 redis-2.8.13 目錄下

cd redis-2.8.13
 

執(zhí)行make命令,最后幾行的輸出結(jié)果

Hint: To run 'make test' is a good idea ;)
make[1]: Leaving directory `/opt/redis-2.8.13/src'
 

執(zhí)行安裝命令

make install
 

提示:

cd src && make install
make[1]: Entering directory `/opt/redis-2.8.13/src'

Hint: To run 'make test' is a good idea ;)

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
make[1]: Leaving directory `/opt/redis-2.8.13/src'
 

根據(jù)提示,執(zhí)行:cd src && make install

提示:
 

Hint: To run 'make test' is a good idea ;)

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL instal

按照提示執(zhí)行:make test

 

提示:

You need tcl 8.5 or newer in order to run the Redis test
make: *** [test] Error 1
 

解決方法參考:http://www.linuxfromscratch.org/blfs/view/cvs/general/tcl.html

 

也可以使用:yum install tcl 命令安裝

后來經(jīng)搜索發(fā)現(xiàn)不需要安裝,直接到src目錄下執(zhí)行 ./redis-server 就可以

\
可以使用類似 ./redis-server /path/to/redis.conf 命令指定配置文件;

Server started, Redis version 2.8.13
The server is now ready to accept connections on port 6379
 

服務啟動成功,服務已經(jīng)在6379端口上監(jiān)聽連接請求。

你可以使用內(nèi)置的客戶端連接Redis:http://www.redis.cn/download.html

$ src/redis-cli
redis> set foo bar
OK
redis> get foo
"bar"

注意事項:

要遠程訪問它,還需要開啟防火墻端口,
要保持服務的運行可以直接關閉終端窗口,但不要使用Ctrl+C,這樣會使程序退出。
關鍵詞:CentOSRedis