标签:nosql
操作系统 | CentOS 6.4 |
redis版本 | redis-3.0.7 |
redis主服务器 | 192.168.1.111 |
redis从服务器1 | 192.168.1.112 |
redis从服务器2 | 192.168.1.113 |
有三台服务器,一台COS1安装twemproxy,另外两台COS2,COS3安装redis。
见 http://youngcheung.blog.51cto.com/10809015/1773154
3.1下载twemproxy(nutcracker)的安装包
[root@cos1 ~]# cd /usr/src/ [root@cos1src]# wget http://twemproxy.googlecode.com/files/nutcracker-0.2.4.tar.gz
3.2解压安装
[root@cos1 ~]# tar xf nutcracker-0.2.4.tar.gz [root@cos1 ~]# cd nutcracker-0.2.4 [root@cos1 nutcracker-0.2.4]# ./configure --prefix=/opt/phpdba/nutcracker-0.2.4 [root@cos1 nutcracker-0.2.4]# make && make install [root@cos1 nutcracker-0.2.4]# cp -r conf scripts /opt/phpdba/nutcracker-0.2.4
3.3 配置环境变量
[root@cos1 ~]# cd /etc/profile.d/ [root@cos1 profile.d]# vim twemproxy.sh #!/bin/sh #set Rutcracker environment export RUTCRACKER_HOME=/opt/phpdba/nutcracker-0.2.4 export PATH=$RUTCRACKER_HOME/bin:$PATH source twemporxy.sh
3.4 修改配置文件
[root@cos1 ~]# vim /opt/phpdba/nutcracker-0.2.4/conf/nutcracker.yml alpha: listen: 127.0.0.1:22121 hash: fnv1a_64 distribution: ketama auto_eject_hosts: true redis: true server_retry_timeout: 2000 server_failure_limit: 1 servers: - 192.168.1.112:6379:1 server1 - 192.168.1.113:6379:1 server2
3.5检查语法
[root@cos1 ~]# nutcracker -c /opt/phpdba/nutcracker-0.2.4/conf/nutcracker.yml -t nutcracker: configuration file ‘/opt/phpdba/nutcracker-0.2.4/conf/nutcracker.yml‘ syntax is ok [root@cos1 ~]# nutcracker -d -c /opt/phpdba/nutcracker-0.2.4/conf/nutcracker.yml
这里使用redis自带的redis-benchmark进行简单的性能测试,测试结果如下:
1.测试:
a.通过twemproxy测试:
[root@puppet01 ~]# redis-benchmark -h 127.0.0.1 -q -t set,get,incr,lpush,lpop,sadd,spop,lpush,lrange -c 100 -p 22121 SET: 62972.29 requests per second GET: 87336.24 requests per second INCR: 85034.02 requests per second LPUSH: 81699.35 requests per second LPOP: 82987.55 requests per second SADD: 85034.02 requests per second SPOP: 87412.59 requests per second LPUSH (needed to benchmark LRANGE): 80840.74 requests per second LRANGE_100 (first 100 elements): 28384.90 requests per second LRANGE_300 (first 300 elements): 9022.01 requests per second LRANGE_500 (first 450 elements): 4810.00 requests per second LRANGE_600 (first 600 elements): 3363.04 requests per second
b.通过对后端redis查看:
[root@puppet02 ~]# redis-cli 127.0.0.1:6379> KEYS * 1) "counter:__rand_int__" 127.0.0.1:6379> [root@localhost ~]# redis-cli 127.0.0.1:6379> KEYS * 1) "mylist" 2) "key:__rand_int__"
发现我们的测试数据分片到了两个redis实例中。
2.查看键值分布
[root@puppet01 ~]# redis-cli info|grep db0 db0:keys=1,expires=0,avg_ttl=0 [root@puppet02 ~]# redis-cli info|grep db0 db0:keys=1,expires=0,avg_ttl=0 [root@puppet02 ~]# [root@localhost ~]# redis-cli info|grep db0 db0:keys=2,expires=0,avg_ttl=0
测试结果:以基本的命令通过twemproxy性能有所下降;通过twemproxy分布基本平均。测试数据以业务测试为准。
标签:nosql
原文地址:http://youngcheung.blog.51cto.com/10809015/1773156