-
解壓redis後,第一次make出現報錯:
[root@localhost redis-3.2.5]# make cd src && make all
make[1]: Entering directory `/data/redis/redis-3.2.5/src'
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-rdb redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html
(cd ../deps && make distclean)
make[2]: Entering directory `/data/redis/redis-3.2.5/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd geohash-int && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
make[2]: Leaving directory `/data/redis/redis-3.2.5/deps'
(rm -f .make-*)
echo STD=-std=c99 -pedantic -DREDIS_STATIC='' >> .make-settings
echo WARN=-Wall -W >> .make-settings
echo OPT=-O2 >> .make-settings
echo MALLOC=jemalloc >> .make-settings
echo CFLAGS= >> .make-settings
echo LDFLAGS= >> .make-settings
echo REDIS_CFLAGS= >> .make-settings
echo REDIS_LDFLAGS= >> .make-settings
echo PREV_FINAL_CFLAGS=-std=c99 -pedantic -DREDIS_STATIC='' -Wall -W -O2 -g -ggdb -I../deps/geohash-int -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -DUSE_JEMALLOC -I../deps/jemalloc/include >> .make-settings
echo PREV_FINAL_LDFLAGS= -g -ggdb -rdynamic >> .make-settings
(cd ../deps && make hiredis linenoise lua geohash-int jemalloc)
make[2]: Entering directory `/data/redis/redis-3.2.5/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd geohash-int && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
(echo "" > .make-cflags)
(echo "" > .make-ldflags)
MAKE hiredis
cd hiredis && make static
make[3]: Entering directory `/data/redis/redis-3.2.5/deps/hiredis'
gcc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb net.c
make[3]: gcc: Command not found
make[3]: *** [net.o] Error 127
make[3]: Leaving directory `/data/redis/redis-3.2.5/deps/hiredis'
make[2]: *** [hiredis] Error 2
make[2]: Leaving directory `/data/redis/redis-3.2.5/deps'
make[1]: [persist-settings] Error 2 (ignored)
CC adlist.o
/bin/sh: cc: command not found 這行報錯說明你沒有安裝gcc
make[1]: *** [adlist.o] Error 127
make[1]: Leaving directory `/data/redis/redis-3.2.5/src'
make: *** [all] Error 2html
-
安裝gcc後,繼續make出現以下報錯:
[root@localhost redis-3.2.5]# make
cd src && make all
make[1]: Entering directory `/data/redis/redis-3.2.5/src'
CC adlist.o
In file included from adlist.c:34:0:
zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory
#include <jemalloc/jemalloc.h>
^
compilation terminated.
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory `/data/redis/redis-3.2.5/src'
make: *** [all] Error 2redis
解決方法:
第一種:執行 make MALLOC=libc 命令 ,若是執行後報錯 或 還有其餘錯誤,建議刪除redis全部文件從新解壓編譯嘗試ui
緣由:因爲系統沒有jemalloc 而只有 libc ,可是默認回去找jemalloc,致使了 make 出錯。 因此加參:make MALLOC=libclua
第二種:make CFLAGS="-march=x86-64" spa
在README 有這個一段話。prototype
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=jemallocserver
在構建Redis時,經過設置來選擇非默認的內存分配器htm
MALLOC的環境變量。Redis被編譯並連接到libc內存
malloc是默認的,jemalloc是Linux上的默認值。之因此選擇這個默認值,是因爲事實證實jemalloc的內存更少,碎片化問題比libc malloc嚴重。string
如今因爲沒有jemalloc 而只有 libc ,可是默認回去找jemalloc,致使了 make 出錯。 因此加這麼一個參數。
要強制編譯libc malloc,請使用:
% MALLOC = libc
要在Mac OS X系統上編譯jemalloc,請使用:
% MALLOC = jemalloc