Centos7安装Redis之VMware排错

故事背景

我在使用虚拟机安装Redis-6.2.6时发生以下报错:

# 省略之前....
MAKE hiredis
cd hiredis && make static
make[3]: Entering directory `/root/download/redis-6.2.6/deps/hiredis'
cc -std=c99 -pedantic -c -O3 -fPIC   -Wall -W -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb alloc.c
make[3]: cc: Command not found
make[3]: *** [alloc.o] Error 127
make[3]: Leaving directory `/root/download/redis-6.2.6/deps/hiredis'
make[2]: *** [hiredis] Error 2
make[2]: Leaving directory `/root/download/redis-6.2.6/deps'
make[1]: [persist-settings] Error 2 (ignored)
    CC adlist.o
/bin/sh: cc: command not found
make[1]: *** [adlist.o] Error 127
make[1]: Leaving directory `/root/download/redis-6.2.6/src'
make: *** [all] Error 2
报错信息

解决方案

Redis6.0之上需要gcc版本5.3以上,Centos7默认gcc版本为4.8.5,解决这个问题即可,如下:

# 升级gcc
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
# 修改配置
echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile
# 生效配置
source /etc/profile

重新安装Redis

wget https://download.redis.io/releases/redis-6.2.6.tar.gz
tar xzf redis-6.2.6.tar.gz
cd redis-6.2.6
make

至此,安装完成。


安装成功
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容