CentOS 下 Redis 安裝

肯定測試環境和軟件版本php

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

獲取 redismysql

建立目錄存放源碼包nginx

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

wget http://redis.googlecode.com/files/redis-2.4.11.tar.gz

注:須要更多版本的 Redis,移步:http://code.google.com/p/redis/downloads/listweb

編譯安裝 redisredis

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 可執行文件sql

安裝成功後,自動複製 redis 可執行文件到環境變量中shell

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、一、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

相關文章
相關標籤/搜索