CentOS 配置 redis

1、准备工作

下载软件:http://pan.baidu.com/share/link?shareid=319813&uk=1997289381

操作系统:CentOS 5.5

redis 版本:redis-2.6.9

2、编译安装

tar zxvf redis-2.6.9.tar.gz //解压

cd redis-2.6.9

make   //编译

如果出现如下错误:

zmalloc.o: In function `zmalloc_used_memory':
/data/redis-2.6.9/src/zmalloc.c:223: undefined reference to `__sync_add_and_fetch_4'
collect2: ld returned 1 exit status
make[1]: *** [redis-server] Error 1
make[1]: Leaving directory `/data/redis-2.6.9/src'
make: *** [all] Error 2

解决方法:

make CFLAGS="-march=i686"

当看见“Hint: To run 'make test' is a good idea ;)” 说明编译成功。

make install    //安装

说明:其实 make install 就是:

cp -p redis-server /usr/local/bin

cp -p redis-benchmark /usr/local/bin

cp -p redis-cli /usr/local/bin

cp -p redis-check-dump /usr/local/bin

cp -p redis-check-aof /usr/local/bin

这样,redis 就安装成功了。

接下来就是启动Redis了, 上面编译后生成的那些可执行文件拷贝到了/usr/local/bin目录下面, 他们的作用分别是:

redis-server:Redis服务器的daemon启动程序

redis-cli:Redis命令行操作工具。当然,你也可以用 telnet 根据其纯文本协议来操作

redis-benchmark:Redis性能测试工具,测试Redis在你的系统及你的配置下的读写性能

启动 Redis 进程只需要执行这个 /usr/local/bin/redis-server /path-to/redis.conf

启动的时候后面要跟上 redis 的配置文件, 这样Redis就顺利启动了.

3、启动 redis 会出现的问题

Warning: 32 bit instance detected but no memory limit set. Setting 3 GB maxmemory limit with 'noeviction' policy now.

解决方法:修改配置文件 redis.conf  将 maxmemory 设置为 maxmemory 1024000000 #分配256M内存

WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.

解决方法:警告:过量使用内存设置为0!在低内存环境下,后台保存可能失败。为了修正这个问题,请在/etc/sysctl.conf 添加一项 'vm.overcommit_memory = 1' ,然后重启(或者运行命令'sysctl vm.overcommit_memory=1' )使其生效。

当启动的时候没有任何信息,表明启动成功。也可以使用 "netstat -tnl" 查看6379端口是否启动。

posted @ 2013-10-21 23:24  likunran  阅读(218)  评论(0编辑  收藏  举报