1. 程式人生 > 其它 >centos7安裝redis6.0

centos7安裝redis6.0

1.官網下載最新包,上傳到/usr/local/src目錄並解壓

2.安裝依賴

yum install -y gcc-c++ autoconf automake

3.升級gcc(redis6適配centos8,依賴的gcc版本較高)

  #安裝scl源

  yum install -y centos-release-scl scl-utils-build

  #安裝9版本的gcc,gcc-c++,gdb工具鏈

  yum install -y devtoolset-9-toolchain

  #臨時覆蓋系統原有的gcc引用

  scl enabledevtoolset-9 bash

  #檢視gcc當前版本

  gcc -v

4.編譯

  #進入解壓後的目錄

  make

5.自定義安裝目錄

  #建立目錄

  mkdir /usr/local/redis

  #安裝

  make PREFIX=/usr/local/redis install

6.後臺守護程序啟動

  #拷貝配置檔案

  cp /usr/local/src/redis-6.2.4/redis.conf /usr/local/redis/bin

  #修改daemonnize引數為yes

  #指定配置檔案啟動

  ./redis-server ./redis.conf

7.設定開機自啟動

  #建立redis.service檔案

  vim /etc/systemd/system/redis.service

    [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

  #重新整理

  systemctl daemon-reload

  

  #新增到開機自啟動

  systemctl enable redis.service

  #測試

  systemctl stop redis.service 停止

  systemctl start redis.service 啟動

  systemctl restart redis.service 重啟

  ps -ef | grep redis 檢視程序