本文为你们讲解的是Redis 2.8.18 安装报错 error: jemalloc/jemalloc.h: No such file or directory解决方法,感兴趣的同窗参考下。html
安装Redis 2.8.18时报错:c++
zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
redis
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 有这个一段话。vim
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=jemallocui
说关于分配器allocator, 若是有MALLOC 这个 环境变量, 会有用这个环境变量的 去创建Redis。spa
并且libc 并非默认的 分配器, 默认的是 jemalloc, 由于 jemalloc 被证实 有更少的 fragmentation problems 比libc。code
可是若是你又没有jemalloc 而只有 libc 固然 make 出错。 因此加这么一个参数。server
make MALLOC=libchtm
wget http://download.redis.io/redis-stable.tar.gzblog
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