redis之環境搭建

1.redis有什麼用想必不用我介紹了,我來介紹下從哪下

www.redis.io or www.redis.cn

下載最新的文件redis-3.2.8.tar.gz

如果你知道路徑也可以這樣

wget http://................redis-3.2.8.tar.gz

 

2.將這個文件上傳到Linux  /opt下

 

3.解壓redis-3.2.8.tar.gz

tar -zxvf redis-3.2.8.tar.gz

 

4.到redis-3.2.8進入後,make編譯,可是tmd報gcc命令沒有找到,寶寶苦啊



 以上說明我的電腦缺少gcc環境了

 

使用yum install gcc即可,可是使用此命令又來新的問題了,如下

 

解決辦法如下:
 Redhat之所以會出現這個錯誤是因爲沒有註冊RHN,我們只需要更新一下yum的源就可以了。

使用命令cd /etc/yum.repos.d/   進入yum的配置目錄。

在終端中輸入 wget http://docs.linuxtone.org/soft/lemp/CentOS-Base.repo 命令,下載CentOS- Base.repo文件。

然後將原有的rhel-debuginfo.repo備份一下,使用命令mv CentOS-Base.repo rhel-debuginfo.repo,將CentOS- Base.repo重命名成rhel-debuginfo.repo。

成功以後,使用yum install gcc安裝成功。

 

5.繼續編譯 make 還是報錯,寶寶真是要奔潰了,各種問題接踵而至

   (題外話:成語也不知道用的對不對,突然就感覺上來了)

錯誤如下:

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

zmalloc.h:55:2: error: #error "Newer version of jemalloc required"

make[1]: *** [adlist.o] Error 1

make[1]: Leaving directory `/data0/src/redis-3.2.8/src'

make: *** [all] Error 2

 

解決辦法

make MALLOC=libc

原因分析
在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 出錯。 所以加這麼一個參數。

 

6.繼續編譯 make 這下就成功了

 

7.安裝

make install

 

8.copy一份redis.conf文件到myredis目錄,爲的就是保留redis的出廠設置



 

9.修改配置讓redis後臺啓動

修改myredis目錄下redis.conf的文件,使用vim命令打開該文件

命令:vim redis.conf 

然後修改 daemonize no 改爲 daemonize yes

 

10.啓動並測試

 [root@localhost bin]# redis-server /myredis/redis.conf
127.0.0.1:6379> set a bbbbbbbbbb
OK
127.0.0.1:6379> get a
"bbbbbbbbbb"

 [root@localhost bin]路徑說明
 cd /usr/local/bin

 

 11.停止

shutdown

exit

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章