微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Linux7安装redis6

  1. 首先下载软件包并解压

    cd /opt
    wget https://download.redis.io/releases/redis-6.2.5.tar.gz
    tar -zxvf redis-6.2.5.tar.gz
    
  2. 开始安装

    cd redis-6.2.5
    make
    # 执行make命令的时候,有可能会报错,错误信息如下所示
    # server.c:2875:11: error: ‘struct redisServer’ has no member named ‘aof_last_write_errno’
    # 这是由于gcc版本过低导致,所以需要升级gcc版本,操作如下
    # 查看gcc版本是否在5.3以上,centos7.6认安装4.8.5
    gcc -v
    # 升级gcc到5.3及以上,如下:
    yum -y install centos-release-scl
    yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
    scl enable devtoolset-9 bash
    # 需要注意的是scl命令启用只是临时的,退出shell或重启就会恢复原系统gcc版本。如果要长期使用,执行以下命令
    echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile
    
    # 接下来继续安装
    make distclean
    make 
    make install PREFIX=/usr/local/redis6
    
  3. 将redis配置成系统服务

    # 首先配置redis的环境变量
    # vim /etc/profile
    # 添加如下内容   
    export REdis_HOME=/usr/local/redis6
    export PATH=$PATH:$REdis_HOME/bin
    # 保存文件退出后重新加载环境变量
    # source /etc/profile
    # 输出一下环境变量,确认redis的环境变量配置成功
    echo $PATH
    # 进入utils目录,执行脚本命令
    cd utils
    ./install_server.sh
    # 在执行install_server.sh命令的时候,可能会报错,报错内容如下
    # This systems seems to use systemd.
    # Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!
    # 注释掉install_server.sh中的如下内容
    
    #bail if this system is managed by systemd
    #_pid_1_exe="$(readlink -f /proc/1/exe)"
    #if [ "${_pid_1_exe##*/}" = systemd ]
    #then
    #     echo "This systems seems to use systemd."
    #    echo "Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!"
    #     exit 1
    #fi
    #unset _pid_1_exe
    
    # 继续执行install_server.sh
    ./install_server.sh
    
  4. 测试

    # 查看状态
    service redis_6379 status
    # 运行客户端
    redis-cli
    

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐