一、Redis入門

· 前言redis

https://i.loli.net/2017/09/11/59b6909fe4cfb.jpg

· Redis常見應用場景vim

1. 緩存(首頁商品內容、購物車信息)(最多使用)緩存

2.任務隊列(秒殺、搶購、12306等)服務器

3.聊天室在線好友列表測試

4.應用排行榜spa

5.數據過時處理.net

1、安裝code

1.下載server

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

2.解壓隊列

tar -zxvf redis-3.0.7.tar.gz

3.編譯與安裝

cd redis-3.0.7
make
make install PREFIX=/usr/local/redis-3.0.7

4.啓動服務器

cd /usr/local/redis-3.0.7
bin/redis-server
# 直接啓動爲前臺啓動,控制檯會被佔用
# 可使用Ctrl+C強制關閉服務

5.配置後啓動

· 將源碼中redis.conf 拷貝到/usr/local/redis目錄

· vi命令中「/daemonize」查找daemonize,小寫n查找下一個,大寫N查找上一個

· 並將「daemonize no」 行改成「daemonize yes」

cp /root/redis-3.0.7/redis.conf ./
vim redis.conf

· 後臺啓動

bin/redis-server redis.conf

· 查看狀態

[root@localhost redis-3.0.7]ps -ef | grep redis
root 10452 0.0 0.1 137444 7460 ? Ssl 11:27 0:00 bin/redis-server *:6379 
root 10456 0.0 0.0 103244 836 pts/0 S+ 11:28 0:00 grep redis

6.測試環境

bin/redis-cli
redis> set foo bar
OK
redis> get foo
"bar"

7.關閉服務器

# 推薦使用
bin/redis-cli shutdown
# 不推薦使用
kill -9 10452
...
...
相關文章
相關標籤/搜索