Redis安裝配置


1. 安裝Redis

下載源碼並解壓編譯

wget http://download.redis.io/releases/redis-5.0.5.tar.gz
tar -xvf redis-5.0.5.tar.gz -C /usr/local
cd /usr/local/redis-5.0.5
make

  

src 目錄 中現在提供了已編譯的二進制文件 使用以下命令運行Redis

src/redis-server

可以使用內置客戶端與Redis進行交互

$ src/redis-cli
redis> set foo bar
OK
redis> get foo
"bar"

  

2. 將redis作為系統服務

2.1 /usr/local/redis-5.0.5/utils下已經有寫好的腳本,運行即可

該腳本還會設置redis開機自啟動

cd /usr/local/redis-5.0.5/utils
./install_server.sh

  選擇都選默認即可,需要注意的是executable path填寫的是redis-server

    Please select the redis executable path [] /usr/local/redis-5.0.5/src/redis-server

最后的配置如下:

Selected config:
Port : 6379
Config file : /etc/redis/6379.conf
Log file : /var/log/redis_6379.log
Data dir : /var/lib/redis/6379
Executable : /usr/local/redis-5.0.5/src
Cli Executable : /usr/local/redis-5.0.5/redis-cli

 

2.2 配置環境便變量

echo 'export PATH=$PATH:/usr/local/redis-5.0.5/src' >/etc/profile.d/redis.sh
source /etc/profile.d/redis.sh

 

2.3 啟動和關閉

系統服務方式啟動和關閉

service redis_6379 start
service redis_6379 stop
service redis_6379 restart

 直接命令行啟動和關閉

redis-cli -p 6379 shutdown
redis-server /etc/redis/6379.conf

  

3. 配置文件

  • /etc/redis/6379.conf

可以看見install_server.sh已經對默認的配置文件(/usr/local/redis-5.0.5/redis.conf)進行了修改。

daemonize yes

logfile /var/log/redis_6379.log

dir /var/lib/redis/6379

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM