佳木斯湛栽影视文化发展公司

主頁(yè) > 知識(shí)庫(kù) > Centos 7 如何安裝Redis(推薦)

Centos 7 如何安裝Redis(推薦)

熱門(mén)標(biāo)簽:Linux服務(wù)器 鐵路電話(huà)系統(tǒng) 呼叫中心市場(chǎng)需求 百度競(jìng)價(jià)排名 AI電銷(xiāo) 地方門(mén)戶(hù)網(wǎng)站 服務(wù)外包 網(wǎng)站排名優(yōu)化

話(huà)不多說(shuō),直接開(kāi)始。

一、安裝gcc依賴(lài)

redis 是用 C 語(yǔ)言開(kāi)發(fā),安裝之前必先確認(rèn)是否安裝 gcc 環(huán)境(gcc -v),如果沒(méi)有安裝,執(zhí)行以下命令進(jìn)行安裝。

$ yum install -y gcc 

二、下載并解壓安裝包

$ wget http://download.redis.io/releases/redis-5.0.7.tar.gz

$ tar -zxvf redis-5.0.7.tar.gz

三、cd切換到redis解壓目錄下,執(zhí)行編譯

$ cd redis-5.0.7  make

四、安裝并指定安裝目錄

$ make install PREFIX=/usr/local/redis

五、啟動(dòng)服務(wù)

5.1 前臺(tái)啟動(dòng)

$ cd /usr/local/redis/bin/

$ ./redis-server

5.2后臺(tái)啟動(dòng)

從 redis 的源碼目錄中復(fù)制 redis.conf 到 redis 的安裝目錄

$ cp /usr/local/redis-5.0.7/redis.conf /usr/local/redis/bin/

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

$ vim redis.conf

################################# GENERAL #####################################

# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize yes

后臺(tái)啟動(dòng)

$ ./redis-server redis.conf

六、設(shè)置開(kāi)機(jī)啟動(dòng)

添加開(kāi)機(jī)啟動(dòng)服務(wù)

$ vim /etc/systemd/system/redis.service

添加下面內(nèi)容

[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 配置成自己的路徑

設(shè)置開(kāi)機(jī)啟動(dòng)

$ systemctl daemon-reload

$ systemctl start redis.service

$ systemctl enable redis.service

創(chuàng)建 redis 命令軟鏈接

$ ln -s /usr/local/redis/bin/redis-cli /usr/bin/redis

# 測(cè)試
$ redis

127.0.0.1:6379> ping
PONG
127.0.0.1:6379>

最后,貼一下常用命令~

# 啟動(dòng)redis服務(wù)
systemctl start redis.service

# 停止redis服務(wù)
systemctl stop redis.service

# 重新啟動(dòng)服務(wù)
systemctl restart redis.service

# 查看服務(wù)當(dāng)前狀態(tài)
systemctl status redis.service

# 設(shè)置開(kāi)機(jī)自啟動(dòng)
systemctl enable redis.service

# 停止開(kāi)機(jī)自啟動(dòng)
systemctl disable redis.service

OK~完事~

到此這篇關(guān)于Centos 7 如何安裝Redis的文章就介紹到這了,更多相關(guān)Centos 7安裝Redis內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

您可能感興趣的文章:
  • CentOS7安裝配置 Redis的方法步驟
  • Centos7下Redis3.2.8最新版本安裝教程
  • CentOS 7下安裝 redis 3.0.6并配置集群的過(guò)程詳解
  • 詳解在Redis在Centos7上的安裝部署
  • 在CentOS 7環(huán)境下安裝Redis數(shù)據(jù)庫(kù)詳解

標(biāo)簽:蘭州 銅川 黃山 仙桃 崇左 衡水 湖南 湘潭

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Centos 7 如何安裝Redis(推薦)》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話(huà)咨詢(xún)

    • 400-1100-266
    昂仁县| 同德县| 成武县| 巨野县| 石渠县| 凭祥市| 公安县| 清水河县| 甘孜县| 孟州市| 彭水| 依安县| 吉隆县| 游戏| 塔河县| 怀集县| 碌曲县| 德州市| 蒙阴县| 新宁县| 玛多县| 航空| 镇沅| 佛坪县| 社会| 台东县| 旬阳县| 开封县| 根河市| 登封市| 宁晋县| 金塔县| 辉县市| 五大连池市| 普兰店市| 泽普县| 奉贤区| 唐河县| 松滋市| 漳平市| 武穴市|