Redis是一個開源的使用ANSI C語言編寫、支持網絡、可基於內存亦可持久化的日誌型、Key-Value數據庫,並提供多種語言的API。從2010年3月15日起,Redis的開發工做由VMware主持。
html
redis是一個key-value存儲系統。和Memcached相似,它支持存儲的value類型相對更多,包括string(字符串)、list(鏈表)、set(集合)、zset(sorted set --有序集合)和hash(哈希類型)。這些數據類型都 支持push/pop、add/remove及取交集並集和差集及更豐富的操做,並且這些操做都是原子性的。在此基礎上,redis支持各類不一樣方式的排 序。與memcached同樣,爲了保證效率,數據都是緩存在內存中。區別的是redis會週期性的把更新的數據寫入磁盤或者把修改操做寫入追加的記錄文 件,而且在此基礎上實現了master-slave(主從)同步。
linux
CentOS 6.5c++
Redis 2.8.13redis
下載文件到 /opt/ 目錄下數據庫
wget http://download.redis.io/releases/redis-2.8.13.tar.gz緩存
解壓文件bash
tar zxvf redis-2.8.13.tar.gz網絡
切換目錄到 redis-2.8.13 目錄下ide
cd redis-2.8.13memcached
執行make命令,最後幾行的輸出結果
Hint: To run 'make test' is a good idea ;)
make[1]: Leaving directory `/opt/redis-2.8.13/src'
執行安裝命令
make install
提示:
根據提示,執行:cd src && make install
提示:
按照提示執行:make test
提示:
解決方法參考: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
立馬搜索安裝教程,轉snowolf 的http://snowolf.iteye.com/blog/1630697
一、下載和解壓
wget http://redis.googlecode.com/files/redis-2.6.14.tar.gz
tar zxvf redis-2.6.14.tar.gz
二、在/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 安裝
[user@localhost 桌面]$ ls tcl8.5.9-src.tar.gz
tcl8.5.9-src.tar.gz
[user@localhost 桌面]$ su
密碼:
[root@localhost 桌面]# cp tcl8.5.9-src.tar.gz /usr/local/src/
[root@localhost 桌面]# cd /usr/local/src/
[root@localhost src]# tar -zxvf tcl8.5.9-src.tar.gz
[root@localhost src]# cd tcl8.5.9/
[root@localhost tcl8.5.9]# cd unix/
[root@localhost unix]# ./configure --prefix=/usr/local/tcl/ --enable-shared
[root@localhost unix]# make
[root@localhost unix]# make install
[root@localhost unix]# /usr/local/tcl/bin/tclsh8.5
% exit
[root@localhost 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;
四、修改配置文件目錄
mkdir /etc/redis
cp redis.conf /etc/redis
五、運行
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>
六、寫入開機自啓動 echo "redis-server /etc/redis/redis.conf" >>/etc/rc.local
七、測試,參考 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