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

猜你喜欢

转载自zzgo20141028.iteye.com/blog/2366584