CentOs7 Redis6.0.6安装
- 安装wget
yum install -y wget
- 下载redis
# 在home目录下创建目录
mkdir soft
# 下载redis
wget http://download.redis.io/releases/redis-6.0.6.tar.gz
# 解压
tar -xf redis-6.0.6.tar.gz
- 升级gcc4.8.5 到gcc9.3.0
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
scl enable devtoolset-9 bash
# 设置永久生效
echo source /opt/rh/devtoolset-9/enable >>/etc/profile
- 编译redis源代码
make
- 将redis安装成服务
make install PREFIX=/opt/lucas/redis6
# 编辑环境变量
vim /etc/profile
export REDIS_HOME=/opt/lucas/redis6
export PATH=$PATH:$REDIS_HOME/bin
# 将配置文件生效
source /etc/profile
# 打印查看环境变量
echo $PATH
- 生成脚本
cd utils
./install_server.sh
注:
执行
./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
然后重新运行
./install_server.sh
即可。
至此,redis安装成功,redis服务启动成功
- 启动客户,测试
redis-cli -p 6379