1. 程式人生 > >【centos7】安裝redis

【centos7】安裝redis

1. 安裝wget工具

yum install wget

如果已經安裝了wget,可以直接跳過當前步驟.

2. 安裝epel(extra package for enterprise linux)

wget -r --no-parent -A 'epel-release-*.rpm' http://dl.fedoraproject.org/pub/epel/7/x86_64/e/

rpm -Uvh dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-*.rpm

上面命令執行後,你可以在/etc/yum.repos.d/目錄中發現新新增兩個的檔案:
1. epel.repo
2.epel-testing.repo

這裡寫圖片描述

3. 安裝redis

yum install redis

安裝後,redis的主要配置檔案放置在:
1. /etc/redis.conf
2. /etc/redis-sentinel.conf

4. 啟動redis

systemctl start redis.service

我們可以通過systemctl status redis.service命令瞭解當前redis的狀態.

也可以使用redis-cli ping來測試redis的連通性.

這裡寫圖片描述

5. redis的啟動,終止,重啟和狀態

systemctl start redis.service
systemctl stop redis.service
systemctl restart redis.service systemctl status redis.service

6. 設定redis的自啟動

systemctl enable redis.service #開機自啟動
systemctl disable redis.service #禁止開機自啟動