centos8安装redis6.0.5

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

  centos8安装redis6.0.5

2. 新建个目录,下载redis并解压缩:

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

    centos8安装redis6.0.5

 

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