Redis 2.8.18 安装报错 error: jemalloc/jemalloc.h: No s

本文为大家讲解的是Redis 2.8.18 安装报错 error: jemalloc/jemalloc.h: No such file or directory解决方法,感兴趣的同学参考下。

错误描述

安装Redis 2.8.18时报错:

zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
zmalloc.h:55:2: error: #error "Newer version of jemalloc required"
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory `/data0/src/redis-2.6.2/src'
make: *** [all] Error 2

原因分析

在README 有这个一段话。

Allocator  
---------  
 
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


说关于分配器allocator, 如果有MALLOC  这个 环境变量, 会有用这个环境变量的 去建立Redis。

而且libc 并不是默认的 分配器, 默认的是 jemalloc, 因为 jemalloc 被证明 有更少的 fragmentation problems 比libc。

但是如果你又没有jemalloc 而只有 libc 当然 make 出错。 所以加这么一个参数。

解决办法

make MALLOC=libc


CentOS 6.5 下安装 Redis

wget http://download.redis.io/redis-stable.tar.gz

tar xvzf redis-stable.tar.gz

cd redis-stable

make

 

前面3步应该没有问题,主要的问题是执行make的时候,出现了异常。

异常一:

make[2]: cc: Command not found

异常原因:没有安装gcc

解决方案:yum install gcc-c++

 

异常二:

zmalloc.h:51:31: error: jemalloc/jemalloc.h: No such file or directory

异常原因:一些编译依赖或原来编译遗留出现的问题

解决方案:make distclean。清理一下,然后再make。

 

 

在make成功以后,需要make test。在make test出现异常。

异常一:

couldn't execute "tclsh8.5": no such file or directory

异常原因:没有安装tcl

解决方案:yum install -y tcl。

 

在make成功以后,会在src目录下多出一些可执行文件:redis-server,redis-cli等等。

方便期间用cp命令复制到usr目录下运行。

cp redis-server /usr/local/bin/

cp redis-cli /usr/local/bin/

然后新建目录,存放配置文件

mkdir /etc/redis

mkdir /var/redis

mkdir /var/redis/log

mkdir /var/redis/run

mkdir /var/redis/6379

 

在redis解压根目录中找到配置文件模板,复制到如下位置。

cp redis.conf /etc/redis/6379.conf

通过vim命令修改

daemonize yes

pidfile /var/redis/run/redis_6379.pid

logfile /var/redis/log/redis_6379.log

dir /var/redis/6379

最后运行redis:

$ redis-server /etc/redis/6379.conf


你可能感兴趣的:(Redis 2.8.18 安装报错 error: jemalloc/jemalloc.h: No s)