環(huán)境
Redis Version:3.0.1及以上
OS:Centos 7
步驟
1. 下載到指定目錄并解壓
> cd /usr/src
> wget -c http://download.redis.io/redis-stable.tar.gz
> tar xvzf redis-stable.tar.gz
2. 構(gòu)建
> cd redis-stable
> make && make install
如果由于沒有安裝gcc導(dǎo)致make報錯绞惦,在安裝make之后重新構(gòu)建可能會報jemalloc/jemalloc.h相關(guān)錯誤昵慌,可參考
http://unix.stackexchange.com/questions/94479/jemalloc-and-other-errors-making-redis-on-centos-6-4進行修復(fù)
3. 運行安裝腳本
> utils/install_server.sh
腳本會有一系列引導(dǎo)
Please select the redis port for this instance: [6379]
回車選擇6379作為默認(rèn)端口
Please select the redis config file name [/etc/redis/6379.conf]
輸入/etc/redis/redis_6379.conf
母截,作為新的配置文件如暖,回車
Please select the redis log file name [/var/log/redis_6379.log]
回車赔退,繼續(xù)
Please select the data directory for this instance [/var/lib/redis/6379]
回車,繼續(xù)
Please select the redis executable path [/usr/local/bin/redis-server]
回車枣接,繼續(xù)颂暇,屏幕輸出配置如下,
Selected config:
Port : 6379
Config file : /etc/redis/redis_6379.conf
Log file : /var/log/redis_6379.log
Data dir : /var/lib/redis/6379
Executable : /usr/local/bin/redis-server
Cli Executable : /usr/local/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.
確認(rèn)無誤但惶,回車耳鸯,屏幕繼續(xù)輸出
Copied /tmp/6379.conf => /etc/init.d/redis_6379
Installing service...
Successfully added to chkconfig!
Successfully added to runlevels 345!
Starting Redis server...
Installation successful!
安裝成功
4. 驗證是否安裝成功
> /etc/init.d/redis_6379 status
輸出
Redis is running (27186)
查看server信息
> redis-cli -p 6379 info server
看是否有正確輸出
測試是否能寫入和讀取數(shù)據(jù)
> redis-cli
127.0.0.1:6379> set test 1
OK
127.0.0.1:6379> get test
"1"
ok,沒問題膀曾,至此县爬,安裝成功