Centos下安装Redis
CentOS安装Redis5.0
官网下载源码包,解压, 根据redeme中的提示按照步骤安装。注意,make是linux系统自带的c编译器,记得安装gcc:
yum install gcc
安装步骤:
# 编译,make命令会去当前路径寻找Makefile文件,执行编译过程
make
make install
# 指定位置安装
make install PREFIX=/opt/redis/
CentOS7安装Redis6.0
# 安装依赖
yum -y install gcc centos-release-scl cmake wget tcl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
# 解决gcc版本低的问题-临时
scl enable devtoolset-9 bash
# 解决gcc版本低的问题-永久
echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile
# 编译
make
# 安装, 默认安装到/usr/local/bin 目录下
make install
# 指定位置安装
make install PREFIX=/root/redis6
./utils/install_server.sh安装redis服务
在源码包下,有一个快速安装redis服务的脚本: ./utils/install_server.sh
,执行此脚本,会提示输入相应的参数去安装redis服务,或者指定相应的参数去直接安装redis服务:
sudo REDIS_PORT=6379 \
REDIS_CONFIG_FILE=/etc/redis/6379.conf \
REDIS_LOG_FILE=/var/log/redis_6379.log \
REDIS_DATA_DIR=/var/lib/redis/6379 \
REDIS_EXECUTABLE=`command -v redis-server` ./utils/install_server.sh
在redis6版本中,可能会出现如下错误:
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!
解决方案:修改脚本 vi ./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
最后更新于
这有帮助吗?