简述:  redis是一个key-value存储系统。和Memcached类似,它支持存储的value类型相对更多,包括string(字符 串)、list(链表)、set(集合)和zset(有序集合)。这些数据类型都支持push/pop、add/remove及取交集并集和差集及更丰富 的操作,而且这些操作都是原子性的。在此基础上,redis支持各种不同方式的排序。与memcached一样,为了保证效率,数据都是缓存在内存中。区 别的是redis会周期性的把更新的数据写入磁盘或者把修改操作写入追加的记录文件,并且在此基础上实现了master-slave(主从)同步。

环境:CentOS 5.5  x64

下载安装:

cd /root/tools
wget http://redis.googlecode.com/files/redis-2.4.2.tar.gz
tar zxvf redis-2.4.2.tar.gz
cd redis-2.4.2
make && make install
cp redis.conf  /etc/
cd
vi /etc/redis.conf
daemonize yes
pidfile /var/run/redis.pid
port 6379

#bind 127.0.0.1
timeout 600
loglevel notice
logfile /elain/logs/redis/redis.log

databases 16

save 900 1
save 300 10
save 60 10000

rdbcompression yes
dbfilename dump.rdb

dir /elain/data/redis/

# maxclients 128

appendonly yes
appendfilename appendonly.aof

# appendfsync always
appendfsync everysec
# appendfsync no

requirepass elain

no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb

slowlog-log-slower-than 10000

slowlog-max-len 1024

really-use-vm yes
vm-enabled yes
vm-swap-file /tmp/redis.swap
vm-max-memory 0
vm-page-size 32
vm-pages 134217728
vm-max-threads 4

hash-max-zipmap-entries 512
hash-max-zipmap-value 64

list-max-ziplist-entries 512
list-max-ziplist-value 64

set-max-intset-entries 512

zset-max-ziplist-entries 128
zset-max-ziplist-value 64

activerehashing yes

# include /path/to/local.conf
# include /path/to/other.conf

启动:

redis-server /etc/redis.conf

开机加自启动:

echo "redis-server /etc/redis.conf" >>/etc/rc.local

继续阅读