標籤:
Redis簡介:
Redis是一個開源的使用ANSI C語言編寫、支援網路、可基於記憶體亦可持久化的日誌型、Key-Value資料庫,並提供多種語言的API。從2010年3月15日起,Redis的開發工作由VMware主持。
redis是一個key-value儲存系統。和Memcached類似,它支援儲存的value類型相對更多,包括string(字串)、list(鏈表)、set(集合)、zset(sorted set --有序集合)和hash(雜湊類型)。這些資料類型都支援push/pop、add/remove及取交集並集和差集及更豐富的操作,而且這些操作都是原子性的。在此基礎上,redis支援各種不同方式的排序。與memcached一樣,為了保證效率,資料都是緩衝在記憶體中。區別的是redis會周期性的把更新的資料寫入磁碟或者把修改操作寫入追加的記錄檔案,並且在此基礎上實現了master-slave(主從)同步。
安裝環境:
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
執行make命令,最後幾行的輸出結果
Hint: To run ‘make test‘ is a good idea ;)
make[1]: Leaving directory `/opt/redis-2.8.13/src‘
執行安裝命令
make install
提示:
[plain] view plaincopy
- 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‘
根據提示,執行:cd src && make install
提示:
[plain] view plaincopy
- Hint: To run ‘make test‘ is a good idea ;)
-
- INSTALL install
- INSTALL install
- INSTALL install
- INSTALL install
- INSTALL instal
按照提示執行:make test
提示:
[plain] view plaincopy
- 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 命令安裝
後來經搜尋發現不需要安裝,直接到src目錄下執行 ./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
服務啟動成功,服務已經在6379連接埠上監聽串連請求。
你可以使用內建的用戶端串連Redis:http://www.redis.cn/download.html
[plain] view plaincopy
- $ src/redis-cli
- redis> set foo bar
- OK
- redis> get foo
- "bar"
注意事項:要遠端存取它,還需要開啟防火牆連接埠,要保持服務的運行可以直接關閉終端視窗,但不要使用Ctrl+C,這樣會使程式退出。轉自:http://blog.csdn.net/testcs_dn/article/details/39756477==================================================================在學習RHP SessionRedis時,發現根本沒有裝Redis。
立馬搜尋安裝教程,轉snowolf 的http://snowolf.iteye.com/blog/1630697
1、下載和解壓
wget http://redis.googlecode.com/files/redis-2.6.14.tar.gz
tar zxvf redis-2.6.14.tar.gz
2、在/opt/redis-2.6.14/目錄下,執行make時報錯:/bin/sh: cc: command not found
好吧,都沒有裝相關的編譯工具。
搜,sudo apt-get install build-essential
error 1):bash: apt-get: command not found
再搜,CentOS的軟體安裝工具不是apt-get 是yum,
正確的應該是sudo yum -y install gcc gcc-c++ libstdc++-devel
安裝成功。
error 2)在/opt/redis-2.6.14/目錄下,執行make時報錯
make[1]: Entering directory `/opt/redis-2.6.14/src‘
CC adlist.o
In file included from adlist.c:34:
zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
zmalloc.h:55:2: error: #error "Newer version of jemalloc required"
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory `/opt/redis-2.6.14/src‘
make: *** [all] Error 2
好吧,繼續~,發現:http://xueliang1yi.blog.163.com/blog/static/1145570162012102114635764/
好像遇到了類似的情況,文中提到了安裝gcc,把他的命令也敲了一邊,系統提示最新版本的已經裝好了,不需要再裝了。
之後執行 make MALLOC=libc 就行
error 3)執行完上面的命令後,系統提示 ‘Hint: To run ‘make test‘ is a good idea‘
make test 報錯: You need tcl 8.5 or newer in order to run the Redis test
3.1)在上面的也是有提到的,不過還是找了一個更詳細的安裝tcl的方法;
:http://downloads.sourceforge.net/tcl/tcl8.5.10-src.tar.gz
安裝命令:http://blog.csdn.net/makebuaa/article/details/6709140
tcl 安裝
[[email protected] 案頭]$ ls tcl8.5.9-src.tar.gz
tcl8.5.9-src.tar.gz
[[email protected] 案頭]$ su
密碼:
[[email protected] 案頭]# cp tcl8.5.9-src.tar.gz /usr/local/src/
[[email protected] 案頭]# cd /usr/local/src/
[[email protected] src]# tar -zxvf tcl8.5.9-src.tar.gz
[[email protected] src]# cd tcl8.5.9/
[[email protected] tcl8.5.9]# cd unix/
[[email protected] unix]# ./configure --prefix=/usr/local/tcl/ --enable-shared
[[email protected] unix]# make
[[email protected] unix]# make install
[[email protected] unix]# /usr/local/tcl/bin/tclsh8.5
% exit
[[email protected] unix]#
3.2)還是提示錯誤需要tcl8.5或更新的版本
發現 sudo yum install tcl 就可以搞定,只是版本是8.5.7的。
終於提示‘\o/ All tests passed without errors!‘
在/opt/redis-2.6.14/目錄下,執行make,OK;
4、修改設定檔目錄
mkdir /etc/redis
cp redis.conf /etc/redis
5、運行
redis-server /etc/redis/redis.conf
摘自http://www.cnblogs.com/chy710/archive/2012/05/28/redis.html
redis-server.exe是Redis服務程式,命令列運行後啟動服務端
[2624] 28 May 17:19:30 * Server started, Redis version 2.4.2
[2624] 28 May 17:19:30 # Open data file dump.rdb: No such file or directory
[2624] 28 May 17:19:30 * The server is now ready to accept connections on port 6379
redis-cli.exe是一個用戶端程式,命令列下運行,簡單的一個Set/Get
redis 127.0.0.1:6379> set mykey "this is a value"
OK
redis 127.0.0.1:6379> get mykey
"this is a value"
redis 127.0.0.1:6379>
6、寫入開機自啟動 echo "redis-server /etc/redis/redis.conf" >>/etc/rc.local
7、測試,參考 http://blog.csdn.net/21aspnet/article/details/6960757
啟動進程
#redis-server /etc/redis/redis.conf
查看進程有沒有成功啟動
#ps -ef | grep redis 測試輸入一個索引值#redis-cli set test "123456"擷取索引值#redis-cli get test
Note:
以下兩文中都有連結一些另外的Redis的資訊,有時間去看看...
http://blog.csdn.net/chenggong2dm/article/details/6100001
http://www.cnblogs.com/chy710/archive/2012/05/28/redis.html
轉自:http://www.cnblogs.com/la-isla-bonita/p/3582751.html
CentOS 安裝Redis