一、首先列一下安裝步驟:
1.用winscp將安裝包redis-3.0.6.tar.gz掛載到系統root目錄下
2.解壓:tar zvxf redis-3.2.1.tar.gz
3.進入目錄: cd redis-3.2.1
4.編譯:make
5. 進入src目錄:cd src, 編譯:make install
二、遇到的問題:
1.沒有安裝gcc和gcc-c++,錯誤如下圖:
解決辦法:
yum install gcc yum install gcc-c++
有可能還要安裝tcl(如果make test出現You need tcl 8.5 or newer in order to run the Redis test的話)
yum install tcl
2.zmalloc.h:50:31: 致命錯誤:jemalloc/jemalloc.h:沒有那個檔案或目錄
問題原因:
在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 出錯。
所以加這麼一個參數。
解決方案:
[root@localhost src]# make MALLOC=libc