先去http://www.redis.io/ 這個網站下載源碼
tar -xvf redis-2.6.13.tar.gz
cd redis-2.6.13
可以先扯下 vi READMIN 這個文檔,很不錯的
make
make test
報了一個錯 You need tcl 8.5 or newer in order to run the Redis test
缺tcl ,我就不下載源碼包了
yum -y install tcl
再來 make clean
再來執行 make
make test 這下就不報錯了
make install 安裝到本地服務器上
cd utils
./install_server.sh 報服務器安裝到本地機上
報了個這個錯
./install_server.sh: line 178: update-rc.d: command not found
exists, process is already running or crashed
按着錯誤提示,我們對/etc/init.d/redis_6379進行修改,只有要“\n”刪除並且輸入回車,修改完畢后,保存
==================
還有解決方案是
vim install_server.sh ##第一個點###修改前-if[!`which chkconfig`];then###修改后+if[!`which chkconfig`];
##第二個點###修改前-if[!`which chkconfig`];then###修改后+if[!`which chkconfig`];then
也就是在
if[! `which chkconfig`];在!中間敲一個空格鍵
還有錯誤是:
Selected default - /var/lib/redis/6379
which: no redis-server in (/sbin:/bin:/usr/sbin:/usr/bin)
Please select the redis executable path [] vim ins ^H^H^H^H^H
Mmmmm... it seems like you don't have a redis executable. Did you run make install yet?
which redis找不能服
加入一個軟件鏈接
ln -s /usr/local/redis/bin/redis-* /usr/local/bin/
service redis_6379 start 啟動
ps -ef | grep redis
基本操作 redis-cli
redis 127.0.0.1:6379> info #查看server版本內存使用連接等信息
redis 127.0.0.1:6379> client list #獲取客戶連接列表
redis 127.0.0.1:6379> client kill 127.0.0.1:33441 #終止某個客戶端連接
redis 127.0.0.1:6379> dbsize #當前保存key的數量
redis 127.0.0.1:6379> save #立即保存數據到硬盤
redis 127.0.0.1:6379> bgsave #異步保存數據到硬盤
redis 127.0.0.1:6379> flushdb #當前庫中移除所有key
redis 127.0.0.1:6379> flushall #移除所有key從所有庫中
redis 127.0.0.1:6379> lastsave #獲取上次成功保存到硬盤的unix時間戳
redis 127.0.0.1:6379> monitor #實時監測服務器接收到的請求
redis 127.0.0.1:6379> slowlog len #查詢慢查詢日志條數
(integer) 3
redis 127.0.0.1:6379> slowlog get #返回所有的慢查詢日志,最大值取決於slowlog-max-len配置
redis 127.0.0.1:6379> slowlog get 2 #打印兩條慢查詢日志
redis 127.0.0.1:6379> slowlog reset #清空慢查詢日志信息
這樣基本上就安裝完成了