1. 程式人生 > >linux下redis安裝遇到的問題記錄

linux下redis安裝遇到的問題記錄

1.redis在make時報錯

下載解壓redis-3.0.2後,執行make進行編譯,結果出現下面的錯誤:

make: cc: Command not found make: *** [adlist.o] Error 127

2.

這是由於新安裝的Linux系統沒有安裝gcc環境,需要安裝gcc,為了方便,這裡我選擇用yum進行安裝。

# yum  install  gcc

3.

驗證gcc是否安裝成功

# rpm -qa |grep gcc


4.

重新對redis進行編譯安裝

# make  && make install 

結果又報錯:

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

5.

原因分析

在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