Chinaunix首页 | 论坛 | 博客
  • 博客访问: 96822
  • 博文数量: 20
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 202
  • 用 户 组: 普通用户
  • 注册时间: 2013-09-07 01:56
个人简介

数据库技术爱好者

文章分类

全部博文(20)

文章存档

2016年(11)

2015年(9)

我的朋友

分类: NOSQL

2015-10-31 14:03:49

  YCSB(Yahoo! Cloud Serving Benchmark)是雅虎开源的一款通用的、针对各类NoSQL产品的性能测试工具。截止目前为止本人使用YCSB对Mongodb、Redis进行相应的基准测试。本文将介绍测试mongodb完整过程。
1、测试环境准备,所用软件有:
    JDK1.7
    apache-maven-3.1.1
    mongodb-2.6.11
    准备过程:
    

点击(此处)折叠或打开

  1. ##配置JAVA环境
  2. [root@mas ~]# rpm -ivh jdk-7u79-linux-x64.rpm
  3. Preparing... ########################################### [100%]
  4. 1:jdk ########################################### [100%]
  5. Unpacking JAR files...
  6. rt.jar...
  7. jsse.jar...
  8. charsets.jar...
  9. tools.jar...
  10. localedata.jar...
  11. jfxrt.jar...

  12. vi  /etc/profileexport JAVA_HOME=/usr/java/jdk1.7.0_79   //添加如下三行、使配置生效、测试
  13. export JAVA_HOME=/usr/java/jdk1.7.0_79   
  14. export PATH=${JAVA_HOME}/bin:${PATH}
  15. export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
  16. [root@mas ~]# which java
  17. /usr/java/jdk1.7.0_79/bin/java
  18. [root@mas ~]# java -version
  19. java version "1.7.0_79"
  20. Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
  21. Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

  22. ##配置MAVEN
  23. cd  /usr/local/
  24. tar -zxvf  /root/apache-maven-3.1.1-bin.tar.gz 
  25. ln -s  /usr/local/apache-maven-3.1.1   /usr/local/maven
  26. vi  /etc/profile.d/maven.sh
  27. [root@mas local]# cat  /etc/profile.d/maven.sh   
  28. export M2_HOME=/usr/local/maven
  29. export PATH=${M2_HOME}/bin:${PATH}

  30. [root@mas local]# mvn -version
  31. Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 23:22:22+0800)
  32. Maven home: /usr/local/maven
  33. Java version: 1.7.0_79, vendor: Oracle Corporation
  34. Java home: /usr/java/jdk1.7.0_79/jre
  35. Default locale: en_US, platform encoding: UTF-8
  36. OS name: "linux", version: "2.6.18-308.el5", arch: "amd64", family: "unix"

  37. 解压已编译好的ycsb,ycsb可以去github下载
  38. cd /server/
  39. tar -zxvf  /root/ycsb-0.4.0.tar.gz 

  40. 解压下载的mongodb数据库软件,并启动mongodb实例
  41. [root@mas server]# tar -zxvf /root/mongodb-linux-x86_64-2.6.11.tgz 
  42. [root@mas server]# mv mongodb-linux-x86_64-2.6.11  mongodb-2.6.11
  43. [root@mas server]# ./bin/mongod --dbpath=/server/mongodb-2.6.11/data/ --logpath=/server/mongodb-2.6.11/error.log --logappend &
  44. [root@mas server]# netstat -ntlp|grep mongod
  45. tcp        0      0 0.0.0.0:27017               0.0.0.0:*                   LISTEN      3331/mongod 





2、测试mongodb 2.7.11版本

点击(此处)折叠或打开

  1. ##编辑测试模板
  2. [root@mas ~]# cd /server/ycsb-0.4.0/
  3. vi workloads/workloada  //可参考YCSB提供的模板自行定义,此次测试模板内容如下
  4. mongodb.url=mongodb://localhost:27017
  5. mongodb.database=ycsb
  6. mongodb.writeConcern=normal
  7. recordcount=1000000
  8. operationcount=1000000
  9. workload=com.yahoo.ycsb.workloads.CoreWorkload
  10. readallfields=true
  11. readproportion=0.6    //read操作比例
  12. updateproportion=0.3  //update比例
  13. scanproportion=0 
  14. insertproportion=0.1  //insert比例
  15. requestdistribution=zipfian

  16. ##
  17. ##load数据,建议升级Python到2.7版本,貌似argparse模块被添加Python2.7标准库了,先前版本是没有,得手动安装,否则在load数据这一步会报错,提示缺少该模块
  18. [root@mas ycsb-0.4.0]# ./bin/ycsb load mongodb  -s -P  workloads/workloada    //可以-threads参数开启多线程


  19. [root@mas ycsb-0.4.0]# ./bin/ycsb run mongodb  -s -threads 16 -P  workloads/workloada  
  20. ##经过大量时间测试后,最后输出测试结果:整个测试时间,增删改查平均、最小、最大延迟,也可以计算出其他技术指标,例如QPS,TPS
  21. [OVERALL], RunTime(ms), 2218373.0
  22. [OVERALL], Throughput(ops/sec), 450.78081999735844
  23. [CLEANUP], Operations, 16.0
  24. [CLEANUP], AverageLatency(us), 7701.9375
  25. [CLEANUP], MinLatency(us), 3.0
  26. [CLEANUP], MaxLatency(us), 123199.0
  27. [CLEANUP], 95thPercentileLatency(us), 18.0
  28. [CLEANUP], 99thPercentileLatency(us), 123199.0
  29. [INSERT], Operations, 100240.0
  30. [INSERT], AverageLatency(us), 37795.81236033519
  31. [INSERT], MinLatency(us), 313.0
  32. [INSERT], MaxLatency(us), 7954431.0
  33. [INSERT], 95thPercentileLatency(us), 213503.0
  34. [INSERT], 99thPercentileLatency(us), 418559.0
  35. [INSERT], Return=0, 100240
  36. [READ], Operations, 599577.0
  37. [READ], AverageLatency(us), 25763.266649654674
  38. [READ], MinLatency(us), 145.0
  39. [READ], MaxLatency(us), 7454719.0
  40. [READ], 95thPercentileLatency(us), 128383.0
  41. [READ], 99thPercentileLatency(us), 352255.0
  42. [READ], Return=0, 599577
  43. [UPDATE], Operations, 300183.0
  44. [UPDATE], AverageLatency(us), 53808.972996472156
  45. [UPDATE], MinLatency(us), 218.0
  46. [UPDATE], MaxLatency(us), 8138751.0
  47. [UPDATE], 95thPercentileLatency(us), 282111.0
  48. [UPDATE], 99thPercentileLatency(us), 528383.0
  49. [UPDATE], Return=0, 300183
  50.  

3、测试mongodb3.0.7版本,对上面测试mongodb.2.7.11的结果进行对比,验证其性能的提升,本人测试机器差劲,估计没戏

点击(此处)折叠或打开

  1. [root@mas server]# ./mongodb-3.0.7/bin/mongod --logappend --logpath=/server/mongodb-3.0.7/error.log --dbpath=/server/mongodb-3.0.7/data &
  2. [root@mas server]# ps -ef|grep mongo   
    root      6681  3733  7 12:42 pts/1    00:00:23 ./mongodb-3.0.7/bin/mongod --logappend --logpath=/server/mongodb-3.0.7/error.log --dbpath=/server/mongodb-3.0.7/data
    root      6715  3772  0 12:46 pts/3    00:00:00 python ./bin/ycsb load mongodb -s -threads 16 -P workloads/workloada
    root      6716  6715 83 12:46 pts/3    00:00:25 /usr/java/jdk1.7.0_79/bin/java -cp /server/ycsb-0.4.0/mongodb-binding/conf:/server/ycsb-0.4.0/conf:/server/ycsb-0.4.0/lib/jackson-core-asl-1.9.4.jar:/server/ycsb-0.4.0/lib/jackson-mapper-asl-1.9.4.jar:/server/ycsb-0.4.0/lib/HdrHistogram-2.1.4.jar:/server/ycsb-0.4.0/lib/core-0.4.0.jar:/server/ycsb-0.4.0/mongodb-binding/lib/logback-classic-1.1.2.jar:/server/ycsb-0.4.0/mongodb-binding/lib/mongodb-async-driver-2.0.1.jar:/server/ycsb-0.4.0/mongodb-binding/lib/mongodb-binding-0.4.0.jar:/server/ycsb-0.4.0/mongodb-binding/lib/mongo-java-driver-3.0.3.jar:/server/ycsb-0.4.0/mongodb-binding/lib/logback-core-1.1.2.jar:/server/ycsb-0.4.0/mongodb-binding/lib/slf4j-api-1.6.4.jar com.yahoo.ycsb.Client -db com.yahoo.ycsb.db.MongoDbClient -s -threads 16 -P workloads/workloada -load
    root      6768  3733  0 12:47 pts/1    00:00:00 grep mongo
  3. [root@mas ycsb-0.4.0]# ./bin/ycsb run  mongodb  -s -threads 16 -P  workloads/workloada 
  4. 测试结果如下:
  5. [OVERALL], RunTime(ms), 2487847.0
  6. [OVERALL], Throughput(ops/sec), 401.95397868116487
  7. [CLEANUP], Operations, 16.0
  8. [CLEANUP], AverageLatency(us), 43344.75
  9. [CLEANUP], MinLatency(us), 2.0
  10. [CLEANUP], MaxLatency(us), 626687.0
  11. [CLEANUP], 95thPercentileLatency(us), 67071.0
  12. [CLEANUP], 99thPercentileLatency(us), 626687.0
  13. [INSERT], Operations, 100249.0
  14. [INSERT], AverageLatency(us), 30794.44838352502
  15. [INSERT], MinLatency(us), 316.0
  16. [INSERT], MaxLatency(us), 2162687.0
  17. [INSERT], 95thPercentileLatency(us), 148479.0
  18. [INSERT], 99thPercentileLatency(us), 348927.0
  19. [INSERT], Return=0, 100249
  20. [READ], Operations, 599559.0
  21. [READ], AverageLatency(us), 35769.579687737154
  22. [READ], MinLatency(us), 161.0
  23. [READ], MaxLatency(us), 2160639.0
  24. [READ], 95thPercentileLatency(us), 196735.0
  25. [READ], 99thPercentileLatency(us), 421119.0
  26. [READ], Return=0, 599559
  27. [UPDATE], Operations, 300192.0
  28. [UPDATE], AverageLatency(us), 50238.05311600576
  29. [UPDATE], MinLatency(us), 227.0
  30. [UPDATE], MaxLatency(us), 2162687.0
  31. [UPDATE], 95thPercentileLatency(us), 270335.0
  32. [UPDATE], 99thPercentileLatency(us), 518655.0
  33. [UPDATE], Return=0, 300192
      

由于我测试用是N年前被淘汰机器的,CPU还是奔四的,从两次测试的结果来看没多大区别,哪天换台PC Server试试,这里主要记录下测试的整个过程。

参考自:
阅读(2871) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:我的一次mongodb升级

给主人留下些什么吧!~~