Centos7 安装 Redis 6.0

之前发布了一篇 Centos7 编译安装 Redis 4.0.6
https://www.jianshu.com/p/9b01c8915ab1
今天业务需求,测试 Redis 6.0版本安装使用,于是我就进行了接下来的安装过程:

\(\color{red}{下载 Redis 6.0版本}\)

华为镜像站Redis各版本列表:https://mirrors.huaweicloud.com/redis/
官方镜像站Redis各版本列表:http://download.redis.io/releases/
华为镜像站 Redis : https://mirrors.huaweicloud.com/redis/redis-6.0.5.tar.gz (加速)
Redis官方下载地址:http://download.redis.io/releases/redis-6.0.5.tar.gz (Stable版本)

\(\color{red}{编译安装 Redis6.0}\)

#!/bin/bash
set -u -e
# 安装依赖
yum -y install gcc centos-release-scl cmake wget tcl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
# 解决Centos默认gcc版本低的问题
  # 临时有效,退出 shell 或重启会恢复原 gcc 版本
  scl enable devtoolset-9 bash
  #长期有效(建议使用这方式)
  echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile && source /etc/profile && gcc -v
wget https://mirrors.huaweicloud.com/redis/redis-6.0.4.tar.gz && tar -xf redis-6.0.4.tar.gz && cd redis-6.0.4/
mkdir -p /usr/local/redis/conf && cp sentinel.conf redis.conf /usr/local/redis/conf/
# make -j 8 (多核编译)
make -j
make install PREFIX=/usr/local/redis
cd /usr/local/redis/bin && ls

\(\color{red}{Redis 6.0启动}\)

#!/bin/bash
# 后台启动
sed -i 's/^daemonize no/daemonize yes/' /usr/local/redis/conf/redis.conf
/usr/local/redis/bin/redis-server /usr/local/redis/conf/redis.conf

# 连接
/usr/local/redis/bin/redis-cli 
#127.0.0.1:6379> ping
#PONG

# 关闭
kill -9 `cat /var/run/redis_6379.pid`
posted @ 2021-10-10 22:21  运维之爪  阅读(62)  评论(0编辑  收藏  举报