Centos7安裝Redis4

  1. 下載,進目錄/home/file
    wget http://download.redis.io/releases/redis-4.0.0.tar.gz

所以我們在安裝Redis之前先執(zhí)行以下兩項命令

sudo yum install gcc-c++

  1. 然后執(zhí)行make編譯源碼:
    tar xzf redis-4.0.0.tar.gz
    cd redis-4.0.0
    make

  2. make命令執(zhí)行完成后,會在src目錄下生成6個可執(zhí)行文件,分別是redis-server、redis-cli、redis-benchmark、redis-check-aof、redis-check-dump、redis-sentinel

  • redis-server is the Redis Server itself.(Redis服務器本身)
  • redis-sentinel is the Redis Sentinel executable (monitoring and failover).(Redis集群的管理工具)
  • redis-cli is the command line interface utility to talk with Redis.(與Redis進行交互的命令行客戶端)
  • redis-benchmark is used to check Redis performances.(Redis性能測試工具)
  • redis-check-aof and redis-check-dump are useful in the rare event of corrupted data files.(AOF文件修復工具和RDB文件檢查工具)

可以使用如下命令,把redis-server和redis-cli拷貝到合適的位置(/usr/local/bin/):
sudo cp src/redis-server /usr/local/bin/
sudo cp src/redis-cli /usr/local/bin/
這樣我們就可以直接使用redis-server和redis-cli而不需要指定全路徑了。

4.為了能夠讓redis-server后臺運行,需要如下操作,進入目錄/home/file/redis-4.0.0/src,高版本的在/home/file/redis-x.x.x目錄,將配置文件拷貝到/etc
#cp redis.conf /etc
然后進入etc,找到redis.conf 并修改 daemonize no(第128行) 為 daemonize yes ,這樣就可以默認啟動就后臺運行。

  1. 開啟服務端啟動,自動后臺運行
    #redis-server /etc/redis.conf
    image.png

6.測試效果


image.png

7.關閉redis服務,使用如下命令可以關閉redis服務
#redis-cli shutdown

8.配置redis開機自動啟動
#vi /etc/rc.local
末尾添加如下內(nèi)容:redis-server /etc/redis.conf
保存退出

9.重啟測試


image.png
最后編輯于
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容