安裝並啟動redis
1. 首先執行解壓指令:tar -zxvf redis-3.0.7.tar.gz
2. cd指令切到解壓目錄中,然後執行指令: make
執行make的時候,會出現異常:
異常一:
make[2]: cc: Command not found
異常原因:沒有安裝gcc
解決方案:yum install gcc
異常二:
zmalloc.h:51:31: error: jemalloc/jemalloc.h: No such file or directory
異常原因:一些編譯依賴或原來編譯遺留出現的問題
解決方案:make distclean。清理一下,然後再make。
3.在make成功以後,執行指令:make test
在make test時出現異常:
異常一:
couldn't execute "tclsh8.5": no such file or directory
異常原因:沒有安裝tcl
解決方案:yum install -y tcl。
4. 安裝,執行指令:make install
5. 安裝完畢後,搭建測試配置,測試啟動:
第一種:前臺模式,預設配置啟動(預設埠6379)
直接執行指令:redis-server
第二種:守護程序(後臺)模式,指定配置檔案啟動
在redis解壓根目錄中找到配置檔案模板(redis.conf),複製到如下位置:
cp redis.conf /usr/local/redis/7000/7000.conf
通過vi命令修改
daemonize yes
pidfile /usr/local/redis/7000/7000.pid
logfile /usr/local/redis/7000/7000.log
dir /usr/local/redis/7000
最後執行redis: redis-server /usr/local/redis/7000/7000.conf
6. 啟動後:
執行指令:redis-cli 連線埠為6379 Host為127.0.0.1的redis伺服器
或者:redis-cli -p 7000 -h 192.168.31.10連線埠為7000 Host為192.168.31.10的redis伺服器
7.連線了redis伺服器後,可以通過 shutdown 關閉連線
8.redis配置檔案中的基本配置項:
port 7000 #埠
daemonize yes #守護程序模式啟動
cluster-enabled yes #是否支援叢集
cluster-config-file nodes-7000.conf #叢集配置檔名
pidfile /usr/local/redis/7000/redis.pid #程序id儲存位置
logfile /usr/local/redis/7000/redis.log #日誌檔案儲存位置
dir /usr/local/redis/7000 #工作目錄