准备
CentOS
:7
Redis
:4.0.11
安装
下载redis安装包并上传
解压
[root@localhost redis]# tar -zxvf redis-4.0.11.tar.gz
执行编译
[root@localhost redis]# make
可能存在异常问题
/bin/sh: cc
: 未找到命令
[root@localhost redis-4.0.11]# make
cd src && make all
make[1]: 进入目录“/opt/apps/redis/redis-4.0.11/src”
CC adlist.o
/bin/sh: cc: 未找到命令
make[1]: *** [adlist.o] 错误 127
make[1]: 离开目录“/opt/apps/redis/redis-4.0.11/src”
make: *** [all] 错误 2
redis依赖于gcc进行编译,可使用yum安装,如yum不可用,可以参考CentOS安装配置yum进行配置
[root@localhost redis]# yum install gcc
- 致命错误:
jemalloc/jemalloc.h
:没有那个文件或目录
[root@localhost redis-4.0.11]# make
cd src && make all
make[1]: 进入目录“/opt/apps/redis/redis-4.0.11/src”
CC adlist.o
In file included from adlist.c:34:0:
zmalloc.h:50:31: 致命错误:jemalloc/jemalloc.h:没有那个文件或目录
#include <jemalloc/jemalloc.h>
^
编译中断。
make[1]: *** [adlist.o] 错误 1
make[1]: 离开目录“/opt/apps/redis/redis-4.0.11/src”
make: *** [all] 错误 2
查看 redis
说明文件 README.md
,存在关于 Allocator
的说明信息
Allocator
Selecting a non-default memory allocator when building Redis is done by setting
theMALLOC
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
,因此可以通过指定解决。
make MALLOC=libc
编译测试
[root@localhost redis-4.0.11]# make test
cd src && make test
make[1]: 进入目录“/opt/apps/redis/redis-4.0.11/src”
CC Makefile.dep
make[1]: 离开目录“/opt/apps/redis/redis-4.0.11/src”
make[1]: 进入目录“/opt/apps/redis/redis-4.0.11/src”
You need tcl 8.5 or newer in order to run the Redis test
make[1]: *** [test] 错误 1
make[1]: 离开目录“/opt/apps/redis/redis-4.0.11/src”
make: *** [test] 错误 2
redis
编译测试依赖于 tcl
,可以 yum
安装
[root@localhost redis-4.0.11]# yum install tcl
编译并安装
[root@localhost redis-4.0.11]# make install
其它
- 访问来源限制
默认为bind 127.0.0.1,限制本机访问,可设置不限制访问来源IP(注释效果一样)或指定访问IP
bind 0.0.0.0