日期:2014-05-16  浏览次数:20513 次

redis安装配置及使用【转】
2011-03-27 20:41

http://code.google.com/p/redis/
http://redis.io/commands/slaveof
http://redis.io/documentation
http://baike.baidu.com/view/4595959.htm

在线演示:
http://try.redis-db.com/

参考链接:
http://redis.io/
http://github.com/jdp/redisent/tree/master
http://github.com/owlient/phpredis
http://rediska.geometria-lab.net/

python client : https://github.com/andymccurdy/redis-py/downloads

安装:

#yum install sinasrv2-redis

wget http://redis.googlecode.com/files/redis-2.2.2.tar.gz
tar -zxvf redis-2.2.2.tar.gz
cd redis-2.2.2
make
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

启动及停止:
nohup redis-server /etc/redis.conf &
redis-cli
/usr/local/sinasrv2/bin/redis-cli -p 7517 shutdown??

http://redis.io/topics/data-types-intro

配置:


daemonize yes
port 7613
pidfile /var/run/redis7613.pid
timeout 28800
loglevel verbose
logfile stdout
databases 16
save 900 1
save 300 10
save 60 10000
rdbcompression yes
dir /data1/redis7613
dbfilename r7613.rdb
appendonly no
appendfsync everysec
vm-enabled no
vm-swap-file /data1/redis7613/r7613.swap
vm-max-memory 0
vm-page-size 32
vm-pages 134217728
vm-max-threads 4
glueoutputbuf yes
hash-max-zipmap-entries 64
hash-max-zipmap-value 512
activerehashing yes

appendonly yes #持久化
82 # SLAVEOF host port
192.168.x.1 # slaveof 192.168.x.1 7113

命令参考:

Commands Clients Documentation Community Download Issues

All Keys Strings Hashes Lists Sets Sorted Sets Pub/Sub Transactions Connection Server
  • APPEND key value Append a value to a key
  • AUTH password Authenticate to the server
  • BGREWRITEAOF Asynchronously rewrite the append-only file
  • BGSAVE Asynchronously save the dataset to disk
  • BLPOP key [key ...] timeout Remove and get the first element in a list, or block until one is available
  • BRPOP key [key ...] timeout Remove and get the last element in a list, or block until one is available
  • BRPOPLPUSH source destination timeout Pop a value from a list, push it to another list and return it; or block until one is available
  • CONFIG GET parameter Get the value of a configuration parameter
  • CONFIG SET parameter value Set a configuration parameter to the given value
  • CONFIG RESETSTAT Reset the stats returned by INFO