美文网首页
CentOS8安装Redis

CentOS8安装Redis

作者: xhlc02 | 来源:发表于2020-04-01 11:54 被阅读0次

    1.下载Redis5.0.7版本

    xhl是我个人在/home/xhl的目录,根据个人的参考

     [xhlc02@localhost xhl]# wget http://download.redis.io/releases/redis-5.0.7.tar.gz
    

    2.解压包

    [xhlc02@localhost xhl]# tar -xzvf redis-5.0.7.tar.gz 
    

    3.准备编译环境

    执行gcc -v检查是否安装了gcc环境,如果Linux系统没有安装gcc编译器,会提示“Command not found”。

    [xhlc02@localhost redis-5.0.7]# gcc -v
    

    安装 gcc环境

    [xhlc02@localhost redis-5.0.7]# yum install gcc
    

    安装tcl环境

    [xhlc02@localhost redis-5.0.7]# yum install tcl
    

    4.编译环境

    make 后加 MALLOC的参数的原因:避免提示找不到 jemalloc/jemalloc.h

    [xhlc02@localhost redis-5.0.7]# make MALLOC=libc
    

    5.测试编译是否通过

    [xhlc02@localhost redis-5.0.7]# make test
    

    如果看到以下内容,代表通过

    \o/ All tests passed without errors!
    

    6.安装redis

    [xhlc02@localhost redis-5.0.7]# cd  /usr/local
    [xhlc02@localhost local]# mkdir  soft/redis5
    [xhlc02@localhost local]# cd  soft/redis5
    [xhlc02@localhost redis5]# mkdir bin
    [xhlc02@localhost redis5]# mkdir conf
    [xhlc02@localhost redis5]# cd bin/
    [xhlc02@localhost bin]# cp /home/xhl/redis-5.0.7/src/redis-cli ./
    [xhlc02@localhost bin]# cp /home/xhl/redis-5.0.7/src/redis-server ./
    [xhlc02@localhost bin]# cd ../conf/
    [xhlc02@localhost conf]# cp /home/xhl/redis-5.0.7/redis.conf ./
    

    7.配置redis.conf

    [root@localhost conf]# vi redis.conf
    

    按G或者shift+g,跳转到末尾,将以下内容粘贴

    # daemonize no
    daemonize yes
    # maxmemory <bytes>
    maxmemory 128MB 
    

    8.运行redis

    [xhlc02@localhost conf]# /usr/local/soft/redis5/bin/redis-server /usr/local/soft/redis5/conf/redis.conf
    

    9.编写service,使redis可以用systemd方式启动和管理

    [xhlc02@localhost /]# vim /lib/systemd/system/redis.service
    

    粘贴内容

    [Unit]
    Description=Redis
    After=network.target
    [Service]
    Type=forking
    PIDFile=/var/run/redis_6379.pid
    ExecStart=/usr/local/soft/redis5/bin/redis-server/usr/local/soft/redis5/conf/redis.conf
    ExecReload=/bin/kill -s HUP $MAINPID
    ExecStop=/bin/kill -s QUIT $MAINPID
    PrivateTmp=true
    [Install]
    WantedBy=multi-user.target
    

    10.重载服务

    [xhlc02@localhost /]# systemctl daemon-reload
    

    11.管理redis

    启动
    systemctl start redis    
    查看状态
    systemctl status redis
    使开机启动
    systemctl enable redis

    相关文章

      网友评论

          本文标题:CentOS8安装Redis

          本文链接:https://www.haomeiwen.com/subject/gosouhtx.html