Installation
Download, extract and compile Redis with:
$ wget http://download.redis.io/releases/redis-5.0.3.tar.gz
$ tar xzf redis-5.0.3.tar.gz
$ cd redis-5.0.3
$ make
执行make时会报以下错误,这是由于系统中缺少gcc,安装一下即可:yum install gcc
MAKE hiredis
cd hiredis && make static
make[3]: 进入目录“/root/redis-5.0.3/deps/hiredis”
make[3]: Warning: File `Makefile' has modification time 88415 s in the future
gcc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb net.c
make[3]: gcc:命令未找到
make[3]: *** [net.o] 错误 127
make[3]: 离开目录“/root/redis-5.0.3/deps/hiredis”
make[2]: *** [hiredis] 错误 2
make[2]: 离开目录“/root/redis-5.0.3/deps”
make[1]: [persist-settings] 错误 2 (忽略)
CC adlist.o
/bin/sh: cc: 未找到命令
make[1]: *** [adlist.o] 错误 127
make[1]: 离开目录“/root/redis-5.0.3/src”
make: *** [all] 错误 2
此时再次执行make命令还会报另一种如下的错误,这是因为libc不是默认的分配器, 默认的分配器是jemalloc(jemalloc被证明比libc有更少的fragmentation problems)但是如果你又没有jemalloc而只有libc,所以make会出错。解决办法:增加环境变量make MALLOC=libc
[root@localhost redis-5.0.3]# make
make: Warning: File `Makefile' has modification time 87860 s in the future
cd src && make all
make[1]: 进入目录“/root/redis-5.0.3/src”
make[1]: Warning: File `Makefile' has modification time 87860 s in the future
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]: 离开目录“/root/redis-5.0.3/src”
make: *** [all] 错误 2
The binaries that are now compiled are available in the src
directory. Run Redis with:
$ src/redis-server
You can interact with Redis using the built-in client:
$ src/redis-cli
redis> set foo bar
OK
redis> get foo
"bar"