Linux服務器搭建系列—安裝Redis

1.下載

#如果wget沒有安裝,執行yum -y install wget命令在執行下列命令
cd /usr/local/src
wget http://download.redis.io/releases/redis-5.0.7.tar.gz

2.解壓

#解壓安裝包
tar -zxvf redis-5.0.7.tar.gz

3.編譯和安裝

cd redis-5.0.7
make #編譯時需確認系統中是否安裝了gcc
make install PREFIX=/usr/local/redis #安裝

4.配置

#在redis安裝目錄下添加etc文件夾,複製默認配置文件到此目錄
mkdir /usr/local/redis/etc/
cp redis.conf /usr/local/redis/etc/

# 修改配置文件中的參數
將daemonize no修改爲yes

5.設置開機啓動

# 1.添加redis.service服務文件
vim /usr/lib/systemd/system/redis.service

# 2.並在redis.service中添加以下內容
[Unit]
Description=Redis Server Manager
After=syslog.target network.target

[Service]
Type=forking
PIDFile=/var/run/redis_6379.pid
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf #這裏的路徑需要修改爲自己的
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/bin/kill -SIGINT $MAINPID

[Install]
WantedBy=multi-user.target

# 3.重載服務配置
systemctl daemon-reload

# 4.啓動redis.service
systemctl start redis
並使用systemctl status redis查看啓動狀態

# 5.設置開機啓動
systemctl enable redis

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章