首頁  >  文章  >  資料庫  >  Centos7怎麼安裝Redis5.0

Centos7怎麼安裝Redis5.0

WBOY
WBOY轉載
2023-06-01 19:08:491747瀏覽

一、安裝gcc依賴

由於redis 是用C 語言開發,安裝前必先確認是否安裝gcc 環境(gcc -v),如果沒有安裝,執行以下指令進行安裝

 [root@localhost local]# yum install -y gcc 

二、下載並解壓縮安裝套件

##[root@localhost local]# wget http://download.redis.io/releases/redis-5.0.3.tar.gz

[root@localhost local]# tar -zxvf redis-5.0.3.tar .gz

三、cd切換到redis解壓縮目錄下,執行編譯

[root@localhost local]# cd redis-5.0.3

[root@localhost redis-5.0.3]# make

#四、安裝並指定安裝目錄

[root@localhost redis- 5.0.3]# make install PREFIX=/usr/local/redis

#五、啟動服務

5.1前台啟動

#[root@localhost redis-5.0.3]# cd /usr/local/redis/bin/

[root@localhost bin]# ./redis-server

# 5.2後台啟動

從redis 的源碼目錄複製redis.conf 到redis 的安裝目錄

[root@localhost bin]# cp /usr/local/redis-5.0. 3/redis.conf /usr/local/redis/bin/

修改redis.conf 文件,把daemonize no 改為daemonize yes

[root@localhost bin ]# vi redis.conf

修改redis.conf檔

vim redis.conf

#註解掉它,以便讓外網存取

#bind 127.0.0.1

「後台進程方式啟動

daemonize yes

#requirepass foobared去掉註釋,foobared改為自己的密碼

後台啟動

[root@localhost bin]# ./redis-server redis.conf

Centos7怎麼安裝Redis5.0

六、設定開機啟動

新增開機啟動服務

[root@localhost bin]# vi /etc/systemd/system/redis.service##複製貼上以下內容:

Centos7怎麼安裝Redis5.0[Unit]

Description=redis-server

After=network.target

[Service]

Type=forking

ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf
PrivateTmp=true
##[Install]
WantedBy=multi- user.target


注意:ExecStart設定為自己的路徑 Centos7怎麼安裝Redis5.0

設定開機啟動

[root@localhost bin] # systemctl daemon-reload

[root@localhost bin]# systemctl start redis.service

[root@localhost bin]# systemctl enable redis.service

建立redis 指令軟連結

[root@localhost ~]# ln -s /usr/local/redis/bin/redis-cli /usr /bin/redis

測試redis

#服務作業指令Centos7怎麼安裝Redis5.0

systemctl start redis.service   #啟動redis服務

systemctl stop redis.service   #停止redis服務

systemctl restart redis.service   #重新啟動服務

systemctl status redis.service   #檢視服務目前狀態

systemctl enable redis.service   #設定開機自啟動

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

{{o.name}}

#{{m.name }}

以上是Centos7怎麼安裝Redis5.0的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:yisu.com。如有侵權,請聯絡admin@php.cn刪除