首先下载软件包并解压
cd /opt
wget https://download.redis.io/releases/redis-6.2.5.tar.gz
tar -zxvf redis-6.2.5.tar.gz
开始安装
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
将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
测试
# 查看状态
service redis_6379 status
# 运行客户端
redis-cli
原文:https://www.cnblogs.com/wqlken/p/15170343.html