1. 下载redis压缩包并解压
wget https://download.redis.io/releases/redis-6.0.9.tar.gz
tar xf redis-6.0.9.tar.gz
2. 安装gcc
yum install gcc
3. 更新gcc版本(如果当前的gcc版本不是5.3以上,执行下面命令更新gcc版本)redis6.0以上需要更新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
4. 安装编译(若报错,执行make distclean 后再make)
make
make install
5. 添加到环境变量
export REDIS_HOME=/user/local/redis-6.0.9
export PATH=$PATH:$REDIS_HOME/src
source /etc/profile
6. 安装redis为服务
cd utils
./install_server.sh
7. 注释掉install_server.sh中的判断,然后继续8步骤
#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
8. 服务启动停止
service redis_6379 start/stop/status