centos8安裝redis6.0.5


centos8安裝redis6.0.5

  1.   安裝redis需要gcc,所以,需要先安裝gcc  
yum install gcc

  

2. 新建個目錄,下載redis並解壓縮:

mkdir /usr/local/redis
cd /usr/local/redis
wget http://download.redis.io/releases/redis-6.0.5.tar.gz

    

 

3. 下載完成后解壓縮    

tar -zxvf redis-6.0.5.tar.gz

4.進入解壓后的文件夾,並執行make(可以看一下README.md)    

cd /usr/local/redis/cd redis-6.0.5/
make

5.執行完make以后,在redis的目錄下就有了一個src目錄,里面包含執行文件

6.遷出可執行程序:prefix是你想遷到的文件夾    

make install PREFIX=/opt/redis6

 這一步執行完以后,在/opt/redis6目錄下就會出現一個bin目錄,里面是redis的一些可執行程序,主要是與源碼分開

7.創建一個目錄    /etc/redis,放置redis的配置文件    

mkdir /etc/redis
cp /usr/local/redis/redis-6.0.5/redis.conf /etc/redis/6379.conf

# 修改一些配置:
logfile "/var/log/redis/6379.log"      # 配置日志文件存放的地方
dir   /var/lib/redis/6379          # 配置數據存放的路徑
daemonize yes                 # 以守護進程啟動

8. 創建為一個服務:

  在redis目錄下有個utils文件夾。里面有個service的示例

cp /usr/local/redis/redis-6.0.5/utils/systemd-redis_server.service /lib/systemd/system/redis_6379.service

  修改一下:

    

# example systemd service unit file for redis-server
#
# In order to use this as a template for providing a redis service in your
# environment, _at the very least_ make sure to adapt the redis configuration
# file you intend to use as needed (make sure to set "supervised systemd"), and
# to set sane TimeoutStartSec and TimeoutStopSec property values in the unit's
# "[Service]" section to fit your needs.
#
# Some properties, such as User= and Group=, are highly desirable for virtually
# all deployments of redis, but cannot be provided in a manner that fits all
# expectable environments. Some of these properties have been commented out in
# this example service unit file, but you are highly encouraged to set them to
# fit your needs.
#
# Please refer to systemd.unit(5), systemd.service(5), and systemd.exec(5) for
# more information.

[Unit]
Description=Redis_6379
After=network.target
#Documentation=https://redis.io/documentation
#Before=your_application.service another_example_application.service
#AssertPathExists=/var/lib/redis

[Service]
Type=forking
PIDFile=/var/run/redis_6379.pid
ExecStart=/opt/redis6/bin/redis-server /etc/redis/6379.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
## Alternatively, have redis-server load a configuration file:
#ExecStart=/usr/local/bin/redis-server /path/to/your/redis.conf
#LimitNOFILE=10032
#NoNewPrivileges=yes
#OOMScoreAdjust=-900
#PrivateTmp=yes
#TimeoutStartSec=infinity
#TimeoutStopSec=infinity
#UMask=0077
#User=redis
#Group=redis
#WorkingDirectory=/var/lib/redis

[Install]
WantedBy=multi-user.target

 9. 至此,就可以通過systemctl命令來開啟、關閉redis實例了

 

systemctl state redis_6379
systemctl status redis_6379
systemctl stop redis_6379

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM