您的位置:首页 > 数据库 > Redis

CentOS 下 Redis 安装

2012-09-03 00:00 190 查看
确定测试环境和软件版本

Linux : centOS-6.2
Nginx : nginx-1.2.0
MySQL : mysql-5.5.3
PHP : php-5.3.8
Redis : Redis 2.4.11

获取 redis

创建目录存放源码包

mkdir -p /data0/software
cd /data0/software


wget http://redis.googlecode.com/files/redis-2.4.11.tar.gz[/code] 
注:需要更多版本的 Redis,移步:http://code.google.com/p/redis/downloads/list

编译安装 redis

tar zxvf redis-2.4.11.tar.gz
mv redis-2.4.11 /usr/local/webserver/redis
cd /usr/local/webserver/redis
make && make install


redis 可执行文件

安装成功后,自动复制 redis 可执行文件到环境变量中

redis-cli:客户端程序
redis-server:服务程序
redis-check-dump:本地数据库检查
redis-check-aof:更新日志检查
redis-benchmark:性能测试,用以模拟同时由N个客户端发送 M 个 SETs/GETs 查询 (类似于 Apache 的 ab 工具)

redis 启动

启动服务

redis-server redis.conf


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.
[解决办法]:键入 sysctl vm.overcommit_memory=1
该文件指定了内核针对内存分配的策略,其值可以是0、1、2。
0,表示内核将检查是否有足够的可用内存供应用进程使用;如果有足够的可用内存,内存申请允许;否则,内存申请失败,并把错误返回给应用进程。
1,表示内核允许分配所有的物理内存,而不管当前的内存状态如何。
2,表示内核允许分配超过所有物理内存和交换空间总和的内存

Warning: 32 bit instance detected but no memory limit set. Setting 3.5 GB maxmemory limit with 'noeviction' policy now.
[解决办法]:修改配置文件 redis.conf,将 maxmemory 设置为 maxmemory 1024000000 #分配256M内存

关闭服务

redis-cli shutdown


redis 基础配置

redis 各式文档

Redis 命令参考(中文):http://redis.readthedocs.org/en/latest/index.html
Redis 命令参考(英文):http://redis.io/commands
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Redis CentOS