本文所使用的redis版本为redis-2.2.12。 Redis 是一个高性能的key-value数据库。 redis的出现,很大程度补偿了memcached这类keyvalue存储的不足,在部分场合可以对关系数据库起到很好的补充作用。它提供了Python,Ruby,Erlang,PHP客户端,使用很方便。
以下是安装测试步骤:
复制代码代码如下:
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# wget http://redis.googlecode.com/files/redis-2.2.12.tar.gz [root@localhost src]# tar zxf redis-2.2.12.tar.gz [root@localhost src]# cd redis-2.2.12 [root@localhost redis-2.2.12]# make PREFIX=/usr/local/redis install
2,配置redis:
复制代码代码如下:
[root@localhost redis-2.2.12]# mkdir -p /usr/local/redis/etc
[root@localhost redis-2.2.12]# mkdir -p /usr/local/redis/var [root@localhost redis-2.2.12]# cd /usr/local/redis/etc [root@localhost etc]# vi redis.conf daemonize yes pidfile /usr/local/redis/redis.pid port 10000 ###默认端口6379 bind 192.168.179.129 ###默认127.0.0.1 timeout 300 loglevel verbose logfile stdout databases 16 save 900 1 save 300 10 save 60 10000 rdbcompression yes dbfilename dump.rdb dir /usr/local/redis/var/ slave-serve-stale-data yes maxclients 12800 appendonly no appendfsync everysec no-appendfsync-on-rewrite no slowlog-log-slower-than 10000 slowlog-max-len 1024 vm-enabled no 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 activerehashing yes
3,启动关闭redis:
复制代码代码如下:
[root@localhost ~]# /usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
[root@localhost ~]# ps -ef|grep redis root 3891 1 0 18:11 ? 00:00:00 /usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf [root@localhost redis-2.2.12]# /usr/local/redis/bin/redis-cli -h 192.168.179.129 -p 10000 shutdown 如果配置使用默认的127.0.0.1和6379端口,可执行命令时可省略以上参数。
4,测试redis:
复制代码代码如下:
[root@localhost ~]# telnet 192.168.179.129 10000
Trying 192.168.179.129... Connected to localhost (192.168.179.129). Escape character is '^]'. ^] telnet> quit Connection closed.
5,/usr/local/redis/bin目录下执行文件功能说明:
实例:
复制代码代码如下:
[root@localhost ~]# /usr/local/redis/bin/redis-cli -h 192.168.179.129 -p 10000
redis 192.168.179.129:10000> set name sina OK redis 192.168.179.129:10000> get name "sina" redis 192.168.179.129:10000> quit
2)查看redis统计信息:
复制代码代码如下:
[root@localhost ~]# /usr/local/redis/bin/redis-cli -h 192.168.179.129 -p 10000 info
3)测试性能:
复制代码代码如下:
[root@localhost ~]# /usr/local/redis/bin/redis-benchmark -h 192.168.179.129 -p 10000 -n 10 -c 50
(责任编辑:IT) |