centos7编译安装redis遇坑

编译redis时:make cc Command not found

原因分析:没有安装gcc,执行:
yum install gcc

编译redis时:error: jemalloc/jemalloc.h: No such file or directory

原因分析:gcc在这里是作为c语言编译器编译redis的(当然现在已经发展成为多种语言的编译器),说到c语言一般都会想到那些.h的头文件,这些头文件里面包含了MALLOC这个环境变量并且MALLOC=jemalloc,然后我们再来看看redis的说明文件README.md,可以发现以下这段话:

Selecting a non-default memory allocator when building Redis is done by setting
the `MALLOC` environment variable. Redis is compiled and linked against libc
malloc by default, with the exception of jemalloc being the default on Linux
systems. This default was picked because jemalloc has proven to have fewer
fragmentation problems than libc malloc.

To force compiling against libc malloc, use:

% make MALLOC=libc

To compile against jemalloc on Mac OS X systems, use:

% make MALLOC=jemalloc

现在错误的原因和解决办法已经显现出来了,执行

make MALLOC=libc

问题解决

转载请注明博客出处:http://www.cnblogs.com/cjh-notes/

原文地址:https://www.cnblogs.com/cjh-notes/p/8735044.html