環境:centos6.5
安裝gcc、gcc-c++編譯的環境
1、下載下傳Redis
2、解壓
tar xf redis-2.8.3.tar.gz -C /usr/src/
cd /usr/src/redis-2.8.3/
3、安裝Redis之前測試一下make test(執行make test必須先安裝tcl語言包)
tar xf tcl8.6.1-src.tar.gz
cd tcl8.6.1/unix/
./configure && make && make install
這個時候在指令行就可以輸入tclsh進入tcl解釋器
tcl就可以使用了。
4、安裝
[root@moban src]# make PREFIX=/usr/local/redis install
[root@moban src]# cd /usr/local/redis/
[root@moban redis]# ls
bin
[root@moban redis]# cd bin/
[root@moban bin]# ls
redis-benchmark redis-check-aof redis-check-dump redis-cli redis-server
[root@moban bin]# cp /usr/src/redis-2.8.3/redis.conf /usr/local/redis
[root@localhost redis]# ls
bin redis.conf
到這裡redis已經安裝成功了
5、啟動Redis
方法一:進入 安裝路徑下的bin下
[root@localhost redis]# cd bin
[root@localhost bin]# ./redis-server redis.conf
[23753] 13 Nov 00:43:50.340 * Max number of open files set to 10032
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 2.8.3 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 23753
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
| `-._`-._ _.-'_.-' |
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
[23753] 13 Nov 00:43:50.342 # Server started, Redis version 2.8.3
[23753] 13 Nov 00:43:50.342 * DB loaded from disk: 0.000 seconds
[23753] 13 Nov 00:43:50.342 * The server is now ready to accept connections on port 6379
這樣其實已經啟動成功了,但是這屬于前端啟動,啟動redis之後,我們的控制台就不能進行任何操作了。隻能ctrl+c停止啟動。
方法二:背景啟動
編輯redis.conf檔案 daemonize no 改為yes儲存退出
再次啟動
檢視啟動成功沒有:
netstat -anptl |grep redis
[root@moban redis]# netstat -antp|grep redis
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 23767/./bin/redis-s
tcp 0 0 :::6379 :::* LISTEN 23767/./bin/redis-s
6、關閉redis
[root@localhost redis]# ./bin/redis-cli shutdown
7、簡單的使用
//連接配接用戶端
[root@moban redis]# ./bin/redis-cli
127.0.0.1:6379>
//檢查網絡是否通
127.0.0.1:6379> ping
PONG
//設定一個鍵值對
127.0.0.1:6379> set name cheny
OK
//擷取剛剛設定的鍵值對
127.0.0.1:6379> get name
"cheny"
//檢視所有的鍵
127.0.0.1:6379> keys *
1) "name"
//删除name這個鍵
127.0.0.1:6379> del name
(integer)
1127.0.0.1:6379> keys *
(empty list or set)
到這裡簡單的redis安裝就好了
本文轉自liujing0751CTO部落格,原文連結:http://blog.51cto.com/13281352/1981017 ,如需轉載請自行聯系原作者