方法一:yum安裝
yum install -y http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
yum --enablerepo=remi install redis -y
方法二:源碼安裝
redis官網https://redis.io/download
# 1.進入目錄
cd /usr/local/
# 2.下載
wget https://download.redis.io/releases/redis-6.2.4.tar.gz
# 3.解壓
tar xzf redis-6.2.4.tar.gz
# 4.進入解壓目錄
cd redis-6.2.4
# 5.編譯
make
# 6.安裝
make install
編譯文件會自動複製到/usr/local/bin目錄下
進入源碼編譯src目錄,修改redis.conf文件並複製到etc目錄
在 /etc/systemd/system新建service文件
vim /etc/systemd/system/redis.service
[Unit]
Description=Redis
After=network.target
[Service]
#Type=forking
ExecStart=/usr/local/bin/redis-server /etc/redis.conf
ExecReload=/usr/local/bin/redis-server -s reload
ExecStop=/usr/local/bin/redis-server -s stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
注意Type=forking不註釋掉 服務無法啓動
安裝systemd服務
# 使服務自動運行
systemctl daemon-reload
systemctl enable redis
# 啓動服務
systemctl restart redis
systemctl status redis