为了使用YCSB压测mongo,自己摸索了很久,碰到很多问题,可以说举步维艰,毕竟是开源的东西,网上没有可行的流程化方案参考。下面是自己使用YCSB压测mongo的完整过程,提供给大家参考。
一、YCSB压测需要的软件及其版本
操作系统:rhel-server-6.4-x86_64
MongoDB版本:mongodb-linux-x86_64-3.2.7.tar.gz
JDK版本:jdk-8u11-linux-x64.rpm
MAVEN版本:apache-maven-3.3.9-bin.zip
YCSB版本:YCSB-0.1.4.zip
二、压测环境部署
1、操作系统、MongoDB数据库已经安装成功,mongoDB的安装可以参考本人博文 MongoDB 3.2 for RHEL6.4 installation
2、部署JDK环境:
如果服务器上部署有JDK环境,最好将JDK版本升级到1.8,可能用到的JDK卸载命令:
[root@mongo ycsb]# rpm -qa|grep jdk
jdk-1.8.0_11-fcs.x86_64
[root@mongo ycsb]# rpm -e jdk-1.8.0_11-fcs.x86_64
使用root登录并执行:
rpm -ivh jdk-8u11-linux-x64.rpm
安装完成后查看JDK版本:
[root@mongo ycsb]# java -version
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)
配置root&mongo用户的环境变量
[root@mongo maven]# cat /root/.bash_profile |grep PATH
PATH=$PATH:$HOME/bin
export PATH
export PATH=/opt/mongo/mongosoft/bin: /home/mongo/Documents/maven/bin :/usr/java/jdk1.8.0_11/bin/:/opt/mongo/ycsb/bin:$PATH
[root@mongo maven]# cat /home/mongo/.bash_profile |grep PATH
PATH=$PATH:$HOME/bin
export PATH
export PATH=/opt/mongo/mongosoft/bin: /home/mongo/Documents/maven/bin :/usr/java/jdk1.8.0_11/bin/:/opt/mongo/ycsb/bin:$PATH
3、部署MAVEN环境:
由于,我的mongoDB安装用户是mongo,参与压测的用户有root、mongo,所以我将MAVEN部署到: /home/mongo/Documents/,只需将apache-maven-3.3.9-bin.zip上传到/home/mongo/Documents/
解压后进行mv apache-maven-3.3.9-bin maven
[root@mongo maven]# pwd
/home/mongo/Documents/maven
[root@mongo maven]#
[root@mongo maven]# mvn -version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T08:41:47-08:00)
Maven home: /home/mongo/Documents/maven
Java version: 1.8.0_11, vendor: Oracle Corporation
Java home: /usr/java/jdk1.8.0_11/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-358.el6.x86_64", arch: "amd64", family: "unix"
配置用户root、mongo的环境变量
[root@mongo maven]# cat /root/.bash_profile |grep PATH
PATH=$PATH:$HOME/bin
export PATH
export PATH=/opt/mongo/mongosoft/bin: /home/mongo/Documents/maven/bin:/usr/java/jdk1.8.0_11/bin/:/opt/mongo/ycsb/bin:$PATH
[root@mongo maven]# cat /home/mongo/.bash_profile |grep PATH
PATH=$PATH:$HOME/bin
export PATH
export PATH=/opt/mongo/mongosoft/bin: /home/mongo/Documents/maven/bin :/usr/java/jdk1.8.0_11/bin/:/opt/mongo/ycsb/bin:$PATH
4、部署YCSB环境
这里强调一下:网上提供的 YCSB-0.1.4,只有百来kb并且都声称不用编译,但是通过实践没有一个是管用的,这里给大家看下编译过的并且可用的YCSB到底多大(希望大家不要在寻找YCSB上绕弯路):
[mongo@mongo mongo]$ du -ksh ycsb
190M ycsb
我将YCSB部署到了mogoDB的安装目录 /opt/mongo/ycsb,部署很简单,将 YCSB-0.1.4.zip上传到/opt/mongo解压然后:mv YCSB-0.1.4 ycsb
配置用户环境变量:
[root@mongo maven]# cat /root/.bash_profile |grep PATH
PATH=$PATH:$HOME/bin
export PATH
export PATH=/opt/mongo/mongosoft/bin: /home/mongo/Documents/maven/bin :/usr/java/jdk1.8.0_11/bin/:/opt/mongo/ycsb/bin:$PATH
[root@mongo maven]# cat /home/mongo/.bash_profile |grep PATH
PATH=$PATH:$HOME/bin
export PATH
export PATH=/opt/mongo/mongosoft/bin: /home/mongo/Documents/maven/bin :/usr/java/jdk1.8.0_11/bin/:/opt/mongo/ycsb/bin:$PATH
重头戏是使用maven编译ycsb,这里有2种思路:一种是老老实实配置服务器连接互联网(编译过程中maven要联网下载很多JAR和pom文件,如果网速不好需要的时间非常长,很容易失败)编译、二是自己下载maven2的所有库文件放在/root/目录下的.m2中
配置虚拟机联网可以参考:http://jingyan.baidu.com/article/6c67b1d68facbb2786bb1e7b.html
这里给出.m2文件夹内的结构及其包含的所有文件,下载地址:http://pan.baidu.com/s/1boIsq5p
接下来是编译ycsb:
[root@mongo ycsb]# pwd
/opt/mongo/ycsb
[root@mongo ycsb]# mvn -nf clean pacakge
[root@mongo ycsb]# mvn -fn clean package
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] YCSB Root
[INFO] Core YCSB
[INFO] HBase DB Binding
[INFO] Cassandra DB Binding
[INFO] Gemfire DB Binding
[INFO] Infinispan DB Binding
[INFO] JDBC DB Binding
[INFO] Mapkeeper DB Binding
[INFO] Mongo DB Binding
[INFO] Redis DB Binding
[INFO] Voldemort DB Binding
[INFO] YCSB Release Distribution Builder
.......
[INFO] Building tar : /opt/mongo/ycsb/distribution/target/ycsb-0.1.4.tar.gz
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] YCSB Root .......................................... SUCCESS [ 1.357 s]
[INFO] Core YCSB .......................................... SUCCESS [ 8.237 s]
[INFO] HBase DB Binding ................................... SUCCESS [ 12.594 s]
[INFO] Cassandra DB Binding ............................... SUCCESS [ 4.423 s]
[INFO] Gemfire DB Binding ................................. SUCCESS [ 4.129 s]
[INFO] Infinispan DB Binding .............................. SUCCESS [ 15.690 s]
[INFO] JDBC DB Binding .................................... SUCCESS [ 3.486 s]
[INFO] Mapkeeper DB Binding ............................... FAILURE [ 0.012 s]
[INFO] Mongo DB Binding ................................... SUCCESS [ 2.199 s]
[INFO] Redis DB Binding ................................... SUCCESS [ 33.472 s]
[INFO] Voldemort DB Binding ............................... SUCCESS [ 9.754 s]
[INFO] YCSB Release Distribution Builder .................. SUCCESS [ 6.481 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:42 min
[INFO] Finished at: 2016-06-16T18:08:23-07:00
[INFO] Final Memory: 86M/209M
这里说明一下:mvn -fn clean package必须使用-fn才能跳过Mapkeeper DB Binding,另外,本次压测中 Mapkeeper DB Binding编译失败没有影响,也用不到;下载完成maven2库后的完整编译过程下载地址:http://pan.baidu.com/s/1eRTH31o
三、压测前的状态信息检查
1、配置环境:/etc/hosts
[root@mongo ycsb]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.144.130 mongo
[root@mongo ycsb]#
[root@mongo ycsb]# cat /root/.bash_profile
export MONGO_BASE=/opt/mongo
export MONGO_DATA=/opt/mongo/data
export MONGO_LOGS=/opt/mongo/logs
export JAVA_HOME=/usr/java/jdk1.8.0_11/
export YCSB_HOME=/root/Documents/ycsb
export PATH=/opt/mongo/mongosoft/bin:/home/mongo/Documents/maven/bin:/usr/java/jdk1.8.0_11/bin/:/opt/mongo/ycsb/bin:$PATH
2、压测文件配置信息
mongodb.url=mongodb://localhost:27017
mongodb.database=zhul
mongodb.writeConcern=normal
recordcount=10000000
operationcount=10000000
workload=com.yahoo.ycsb.workloads.CoreWorkload
readallfields=true
readproportion=0.5
updateproportion=0.5
scanproportion=0
insertproportion=0
requestdistribution=zipfian
3、数据库状态检查
[root@mongo ycsb]# ps -ef|grep mongo
root 35714 1983 0 17:51 ? 00:00:00 sshd: mongo [priv]
mongo 35721 35714 0 17:51 ? 00:00:00 sshd: mongo@pts/3
mongo 35722 35721 0 17:51 pts/3 00:00:00 -bash
root 41198 37802 0 21:30 pts/9 00:00:00 grep mongo
mongo 47215 1 1 Jun15 ? 00:35:51 mongod --dbpath=/opt/mongo/data --logpath=/opt/mongo/logs/mongodb.log --logappend
[root@mongo ycsb]#
[root@mongo ycsb]# netstat -pan|grep 27017
tcp 0 0 0.0.0.0:27017 0.0.0.0:* LISTEN 47215/mongod
unix 2 [ ACC ] STREAM LISTENING 185900 47215/mongod /tmp/mongodb-27017.sock
[root@mongo ycsb]#
[root@mongo ycsb]# ycsb shell basic
java -cp /opt/mongo/ycsb/voldemort/src/main/conf:/opt/mongo/ycsb/gemfire/src/main/conf:/opt/mongo/ycsb/jdbc/src/main/conf:/opt/mongo/ycsb/core/target/core-0.1.4.jar:/opt/mongo/ycsb/infinispan/src/main/conf:/opt/mongo/ycsb/nosqldb/src/main/conf:/opt/mongo/ycsb/hbase/src/main/conf com.yahoo.ycsb.CommandLine -db com.yahoo.ycsb.BasicDB
YCSB Command Line client
Type "help" for command line help
Start with "-help" for usage info
***************** properties *****************
"db"="com.yahoo.ycsb.BasicDB"
**********************************************
Connected.
> quit
[root@mongo ycsb]#
四、执行压测
1、加载压测任务
[root@mongo ycsb]# ./bin/ycsb load mongodb -P workloads/workloada
任务加载日志下载地址:http://pan.baidu.com/s/1skTvdEX
部分日志展示:
Loading workload...
Starting test.
new database url = localhost:27017/zhul
mongo connection created with localhost:27017/zhul
[OVERALL], RunTime(ms), 243.0
[OVERALL], Throughput(ops/sec), 0.0
[INSERT], Operations, 1
[INSERT], AverageLatency(us), 52974.0
[INSERT], MinLatency(us), 52974
[INSERT], MaxLatency(us), 52974
[INSERT], 95thPercentileLatency(ms), 52
[INSERT], 99thPercentileLatency(ms), 52
[INSERT], Return=1, 1
[INSERT], 0, 0
[INSERT], 1, 0
[INSERT], 2, 0
[INSERT], 3, 0
[INSERT], 4, 0
[INSERT], 5, 0
[INSERT], 6, 0
[INSERT], 7, 0
[INSERT], 8, 0
[INSERT], 9, 0
[INSERT], 10, 0
[INSERT], 11, 0
[INSERT], 12, 0
[INSERT], 13, 0
[INSERT], 14, 0
[INSERT], 15, 0
[INSERT], 16, 0
[INSERT], 17, 0
[INSERT], 18, 0
[INSERT], 19, 0
[INSERT], 20, 0
2、执行压测任务
[root@mongo ycsb]# ./bin/ycsb run mongodb -P workloads/workloada
执行任务日志下载地址:http://pan.baidu.com/s/1cjyHyQ
部分日志展示:
Loading workload...
Starting test.
new database url = localhost:27017/zhul
mongo connection created with localhost:27017/zhul
[OVERALL], RunTime(ms), 1043002.0
[OVERALL], Throughput(ops/sec), 9587.709323663808
[READ], Operations, 4999128
[READ], AverageLatency(us), 65.37705095768702
[READ], MinLatency(us), 30
[READ], MaxLatency(us), 79095
[READ], 95thPercentileLatency(ms), 0
[READ], 99thPercentileLatency(ms), 0
[READ], Return=0, 39699
[READ], Return=1, 4959429
[READ], 0, 4989900
[READ], 1, 6603
[READ], 2, 1196
[READ], 3, 918
[READ], 4, 149
[READ], 5, 58
[READ], 6, 17
[READ], 7, 9
[READ], 8, 5
[READ], 9, 3
[READ], 10, 2
[READ], 11, 1
[READ], 12, 4
[READ], 13, 5
[READ], 14, 76
[READ], 15, 127
[READ], 16, 25
[READ], 17, 11
[READ], 18, 3
[READ], 19, 3
五、压测中遇到的问题总结
1、服务器没有安装JDK、JDK的环境变量没有配置好、JDK版本过低
现象:
File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
2、ycsb没有经过编译
现象:
[mongo@mongo ycsb]$ ./bin/ycsb load mongodb -threads 100 -P workloads/workloada
java -cp /opt/mongo/ycsb/voldemort/src/main/conf:/opt/mongo/ycsb/gemfire/src/main/conf:/opt/mongo/ycsb/jdbc/src/main/conf:/opt/mongo/ycsb/infinispan/src/main/conf:/opt/mongo/ycsb/nosqldb/src/main/conf:/opt/mongo/ycsb/hbase/src/main/conf com.yahoo.ycsb.Client -db com.yahoo.ycsb.db.MongoDbClient -threads 100 -P workloads/workloada -load
Exception in thread "main" java.lang.NoClassDefFoundError: com/yahoo/ycsb/Client
Caused by: java.lang.ClassNotFoundException: com.yahoo.ycsb.Client
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: com.yahoo.ycsb.Client. Program will exit.
3、服务器没有联网的情况下进行ycsb的编译
现象:[root@mongo ycsb]# mvn clean package
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] YCSB Root
[INFO] Core YCSB
[INFO] HBase DB Binding
[INFO] Cassandra DB Binding
[INFO] Gemfire DB Binding
[INFO] Infinispan DB Binding
[INFO] JDBC DB Binding
[INFO] Mapkeeper DB Binding
[INFO] Mongo DB Binding
[INFO] Redis DB Binding
[INFO] Voldemort DB Binding
[INFO] YCSB Release Distribution Builder
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building YCSB Root 0.1.4
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ root ---
[INFO]
[INFO] --- maven-checkstyle-plugin:2.6:checkstyle (validate) @ root ---
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Core YCSB 0.1.4
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ core ---
[INFO] Deleting /opt/mongo/ycsb/core/target
[INFO]
[INFO] --- maven-checkstyle-plugin:2.6:checkstyle (validate) @ core ---
[INFO] Starting audit...
loading ……
4、ycsb的环境变量配置有问题(可以到/ycsb/bin进行验证)
现象:
[root@mongo ycsb]#
[root@mongo ycsb]# ycsb shell basic
java -cp /root/Documents/ycsb/voldemort/src/main/conf:/root/Documents/ycsb/gemfire/src/main/conf:/root/Documents/ycsb/jdbc/src/main/conf:/root/Documents/ycsb/infinispan/src/main/conf:/root/Documents/ycsb/dynamodb/conf:/root/Documents/ycsb/accumulo/src/main/conf:/root/Documents/ycsb/nosqldb/src/main/conf:/root/Documents/ycsb/hbase/src/main/conf com.yahoo.ycsb.CommandLine -db com.yahoo.ycsb.BasicDB
Error: Could not find or load main class com.yahoo.ycsb.CommandLine
5、关于ycsb编译过程中到 Mapkeeper DB Binding异常退出,我没找到好方法,但是可以使用mvn -fn clean package跳过
[INFO] Mapkeeper DB Binding ............................... FAILURE [ 0.012 s]
六、压测用到的软件下载地址
mongodb-linux-x86_64-3.2.7.tgz http://pan.baidu.com/s/1kUIHXiv
apache-maven-3.3.9-bin.zip http://pan.baidu.com/s/1c2hsKLU
jdk-8u11-linux-x64.rpm http://pan.baidu.com/s/1pL8aFHL
YCSB-0.1.4.zip http://pan.baidu.com/s/1jHSTwge
.m2(maven2的JAR库及pom文件库) http://pan.baidu.com/s/1cHoDQY
一、YCSB压测需要的软件及其版本
操作系统:rhel-server-6.4-x86_64
MongoDB版本:mongodb-linux-x86_64-3.2.7.tar.gz
JDK版本:jdk-8u11-linux-x64.rpm
MAVEN版本:apache-maven-3.3.9-bin.zip
YCSB版本:YCSB-0.1.4.zip
二、压测环境部署
1、操作系统、MongoDB数据库已经安装成功,mongoDB的安装可以参考本人博文 MongoDB 3.2 for RHEL6.4 installation
2、部署JDK环境:
如果服务器上部署有JDK环境,最好将JDK版本升级到1.8,可能用到的JDK卸载命令:
[root@mongo ycsb]# rpm -qa|grep jdk
jdk-1.8.0_11-fcs.x86_64
[root@mongo ycsb]# rpm -e jdk-1.8.0_11-fcs.x86_64
使用root登录并执行:
rpm -ivh jdk-8u11-linux-x64.rpm
安装完成后查看JDK版本:
[root@mongo ycsb]# java -version
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)
配置root&mongo用户的环境变量
[root@mongo maven]# cat /root/.bash_profile |grep PATH
PATH=$PATH:$HOME/bin
export PATH
export PATH=/opt/mongo/mongosoft/bin: /home/mongo/Documents/maven/bin :/usr/java/jdk1.8.0_11/bin/:/opt/mongo/ycsb/bin:$PATH
[root@mongo maven]# cat /home/mongo/.bash_profile |grep PATH
PATH=$PATH:$HOME/bin
export PATH
export PATH=/opt/mongo/mongosoft/bin: /home/mongo/Documents/maven/bin :/usr/java/jdk1.8.0_11/bin/:/opt/mongo/ycsb/bin:$PATH
3、部署MAVEN环境:
由于,我的mongoDB安装用户是mongo,参与压测的用户有root、mongo,所以我将MAVEN部署到: /home/mongo/Documents/,只需将apache-maven-3.3.9-bin.zip上传到/home/mongo/Documents/
解压后进行mv apache-maven-3.3.9-bin maven
[root@mongo maven]# pwd
/home/mongo/Documents/maven
[root@mongo maven]#
[root@mongo maven]# mvn -version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T08:41:47-08:00)
Maven home: /home/mongo/Documents/maven
Java version: 1.8.0_11, vendor: Oracle Corporation
Java home: /usr/java/jdk1.8.0_11/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-358.el6.x86_64", arch: "amd64", family: "unix"
配置用户root、mongo的环境变量
[root@mongo maven]# cat /root/.bash_profile |grep PATH
PATH=$PATH:$HOME/bin
export PATH
export PATH=/opt/mongo/mongosoft/bin: /home/mongo/Documents/maven/bin:/usr/java/jdk1.8.0_11/bin/:/opt/mongo/ycsb/bin:$PATH
[root@mongo maven]# cat /home/mongo/.bash_profile |grep PATH
PATH=$PATH:$HOME/bin
export PATH
export PATH=/opt/mongo/mongosoft/bin: /home/mongo/Documents/maven/bin :/usr/java/jdk1.8.0_11/bin/:/opt/mongo/ycsb/bin:$PATH
4、部署YCSB环境
这里强调一下:网上提供的 YCSB-0.1.4,只有百来kb并且都声称不用编译,但是通过实践没有一个是管用的,这里给大家看下编译过的并且可用的YCSB到底多大(希望大家不要在寻找YCSB上绕弯路):
[mongo@mongo mongo]$ du -ksh ycsb
190M ycsb
我将YCSB部署到了mogoDB的安装目录 /opt/mongo/ycsb,部署很简单,将 YCSB-0.1.4.zip上传到/opt/mongo解压然后:mv YCSB-0.1.4 ycsb
配置用户环境变量:
[root@mongo maven]# cat /root/.bash_profile |grep PATH
PATH=$PATH:$HOME/bin
export PATH
export PATH=/opt/mongo/mongosoft/bin: /home/mongo/Documents/maven/bin :/usr/java/jdk1.8.0_11/bin/:/opt/mongo/ycsb/bin:$PATH
[root@mongo maven]# cat /home/mongo/.bash_profile |grep PATH
PATH=$PATH:$HOME/bin
export PATH
export PATH=/opt/mongo/mongosoft/bin: /home/mongo/Documents/maven/bin :/usr/java/jdk1.8.0_11/bin/:/opt/mongo/ycsb/bin:$PATH
重头戏是使用maven编译ycsb,这里有2种思路:一种是老老实实配置服务器连接互联网(编译过程中maven要联网下载很多JAR和pom文件,如果网速不好需要的时间非常长,很容易失败)编译、二是自己下载maven2的所有库文件放在/root/目录下的.m2中
配置虚拟机联网可以参考:http://jingyan.baidu.com/article/6c67b1d68facbb2786bb1e7b.html
这里给出.m2文件夹内的结构及其包含的所有文件,下载地址:http://pan.baidu.com/s/1boIsq5p
接下来是编译ycsb:
[root@mongo ycsb]# pwd
/opt/mongo/ycsb
[root@mongo ycsb]# mvn -nf clean pacakge
[root@mongo ycsb]# mvn -fn clean package
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] YCSB Root
[INFO] Core YCSB
[INFO] HBase DB Binding
[INFO] Cassandra DB Binding
[INFO] Gemfire DB Binding
[INFO] Infinispan DB Binding
[INFO] JDBC DB Binding
[INFO] Mapkeeper DB Binding
[INFO] Mongo DB Binding
[INFO] Redis DB Binding
[INFO] Voldemort DB Binding
[INFO] YCSB Release Distribution Builder
.......
[INFO] Building tar : /opt/mongo/ycsb/distribution/target/ycsb-0.1.4.tar.gz
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] YCSB Root .......................................... SUCCESS [ 1.357 s]
[INFO] Core YCSB .......................................... SUCCESS [ 8.237 s]
[INFO] HBase DB Binding ................................... SUCCESS [ 12.594 s]
[INFO] Cassandra DB Binding ............................... SUCCESS [ 4.423 s]
[INFO] Gemfire DB Binding ................................. SUCCESS [ 4.129 s]
[INFO] Infinispan DB Binding .............................. SUCCESS [ 15.690 s]
[INFO] JDBC DB Binding .................................... SUCCESS [ 3.486 s]
[INFO] Mapkeeper DB Binding ............................... FAILURE [ 0.012 s]
[INFO] Mongo DB Binding ................................... SUCCESS [ 2.199 s]
[INFO] Redis DB Binding ................................... SUCCESS [ 33.472 s]
[INFO] Voldemort DB Binding ............................... SUCCESS [ 9.754 s]
[INFO] YCSB Release Distribution Builder .................. SUCCESS [ 6.481 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:42 min
[INFO] Finished at: 2016-06-16T18:08:23-07:00
[INFO] Final Memory: 86M/209M
这里说明一下:mvn -fn clean package必须使用-fn才能跳过Mapkeeper DB Binding,另外,本次压测中 Mapkeeper DB Binding编译失败没有影响,也用不到;下载完成maven2库后的完整编译过程下载地址:http://pan.baidu.com/s/1eRTH31o
三、压测前的状态信息检查
1、配置环境:/etc/hosts
[root@mongo ycsb]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.144.130 mongo
[root@mongo ycsb]#
[root@mongo ycsb]# cat /root/.bash_profile
export MONGO_BASE=/opt/mongo
export MONGO_DATA=/opt/mongo/data
export MONGO_LOGS=/opt/mongo/logs
export JAVA_HOME=/usr/java/jdk1.8.0_11/
export YCSB_HOME=/root/Documents/ycsb
export PATH=/opt/mongo/mongosoft/bin:/home/mongo/Documents/maven/bin:/usr/java/jdk1.8.0_11/bin/:/opt/mongo/ycsb/bin:$PATH
2、压测文件配置信息
mongodb.url=mongodb://localhost:27017
mongodb.database=zhul
mongodb.writeConcern=normal
recordcount=10000000
operationcount=10000000
workload=com.yahoo.ycsb.workloads.CoreWorkload
readallfields=true
readproportion=0.5
updateproportion=0.5
scanproportion=0
insertproportion=0
requestdistribution=zipfian
3、数据库状态检查
[root@mongo ycsb]# ps -ef|grep mongo
root 35714 1983 0 17:51 ? 00:00:00 sshd: mongo [priv]
mongo 35721 35714 0 17:51 ? 00:00:00 sshd: mongo@pts/3
mongo 35722 35721 0 17:51 pts/3 00:00:00 -bash
root 41198 37802 0 21:30 pts/9 00:00:00 grep mongo
mongo 47215 1 1 Jun15 ? 00:35:51 mongod --dbpath=/opt/mongo/data --logpath=/opt/mongo/logs/mongodb.log --logappend
[root@mongo ycsb]#
[root@mongo ycsb]# netstat -pan|grep 27017
tcp 0 0 0.0.0.0:27017 0.0.0.0:* LISTEN 47215/mongod
unix 2 [ ACC ] STREAM LISTENING 185900 47215/mongod /tmp/mongodb-27017.sock
[root@mongo ycsb]#
[root@mongo ycsb]# ycsb shell basic
java -cp /opt/mongo/ycsb/voldemort/src/main/conf:/opt/mongo/ycsb/gemfire/src/main/conf:/opt/mongo/ycsb/jdbc/src/main/conf:/opt/mongo/ycsb/core/target/core-0.1.4.jar:/opt/mongo/ycsb/infinispan/src/main/conf:/opt/mongo/ycsb/nosqldb/src/main/conf:/opt/mongo/ycsb/hbase/src/main/conf com.yahoo.ycsb.CommandLine -db com.yahoo.ycsb.BasicDB
YCSB Command Line client
Type "help" for command line help
Start with "-help" for usage info
***************** properties *****************
"db"="com.yahoo.ycsb.BasicDB"
**********************************************
Connected.
> quit
[root@mongo ycsb]#
四、执行压测
1、加载压测任务
[root@mongo ycsb]# ./bin/ycsb load mongodb -P workloads/workloada
任务加载日志下载地址:http://pan.baidu.com/s/1skTvdEX
部分日志展示:
Loading workload...
Starting test.
new database url = localhost:27017/zhul
mongo connection created with localhost:27017/zhul
[OVERALL], RunTime(ms), 243.0
[OVERALL], Throughput(ops/sec), 0.0
[INSERT], Operations, 1
[INSERT], AverageLatency(us), 52974.0
[INSERT], MinLatency(us), 52974
[INSERT], MaxLatency(us), 52974
[INSERT], 95thPercentileLatency(ms), 52
[INSERT], 99thPercentileLatency(ms), 52
[INSERT], Return=1, 1
[INSERT], 0, 0
[INSERT], 1, 0
[INSERT], 2, 0
[INSERT], 3, 0
[INSERT], 4, 0
[INSERT], 5, 0
[INSERT], 6, 0
[INSERT], 7, 0
[INSERT], 8, 0
[INSERT], 9, 0
[INSERT], 10, 0
[INSERT], 11, 0
[INSERT], 12, 0
[INSERT], 13, 0
[INSERT], 14, 0
[INSERT], 15, 0
[INSERT], 16, 0
[INSERT], 17, 0
[INSERT], 18, 0
[INSERT], 19, 0
[INSERT], 20, 0
2、执行压测任务
[root@mongo ycsb]# ./bin/ycsb run mongodb -P workloads/workloada
执行任务日志下载地址:http://pan.baidu.com/s/1cjyHyQ
部分日志展示:
Loading workload...
Starting test.
new database url = localhost:27017/zhul
mongo connection created with localhost:27017/zhul
[OVERALL], RunTime(ms), 1043002.0
[OVERALL], Throughput(ops/sec), 9587.709323663808
[READ], Operations, 4999128
[READ], AverageLatency(us), 65.37705095768702
[READ], MinLatency(us), 30
[READ], MaxLatency(us), 79095
[READ], 95thPercentileLatency(ms), 0
[READ], 99thPercentileLatency(ms), 0
[READ], Return=0, 39699
[READ], Return=1, 4959429
[READ], 0, 4989900
[READ], 1, 6603
[READ], 2, 1196
[READ], 3, 918
[READ], 4, 149
[READ], 5, 58
[READ], 6, 17
[READ], 7, 9
[READ], 8, 5
[READ], 9, 3
[READ], 10, 2
[READ], 11, 1
[READ], 12, 4
[READ], 13, 5
[READ], 14, 76
[READ], 15, 127
[READ], 16, 25
[READ], 17, 11
[READ], 18, 3
[READ], 19, 3
五、压测中遇到的问题总结
1、服务器没有安装JDK、JDK的环境变量没有配置好、JDK版本过低
现象:
File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
2、ycsb没有经过编译
现象:
[mongo@mongo ycsb]$ ./bin/ycsb load mongodb -threads 100 -P workloads/workloada
java -cp /opt/mongo/ycsb/voldemort/src/main/conf:/opt/mongo/ycsb/gemfire/src/main/conf:/opt/mongo/ycsb/jdbc/src/main/conf:/opt/mongo/ycsb/infinispan/src/main/conf:/opt/mongo/ycsb/nosqldb/src/main/conf:/opt/mongo/ycsb/hbase/src/main/conf com.yahoo.ycsb.Client -db com.yahoo.ycsb.db.MongoDbClient -threads 100 -P workloads/workloada -load
Exception in thread "main" java.lang.NoClassDefFoundError: com/yahoo/ycsb/Client
Caused by: java.lang.ClassNotFoundException: com.yahoo.ycsb.Client
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: com.yahoo.ycsb.Client. Program will exit.
3、服务器没有联网的情况下进行ycsb的编译
现象:[root@mongo ycsb]# mvn clean package
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] YCSB Root
[INFO] Core YCSB
[INFO] HBase DB Binding
[INFO] Cassandra DB Binding
[INFO] Gemfire DB Binding
[INFO] Infinispan DB Binding
[INFO] JDBC DB Binding
[INFO] Mapkeeper DB Binding
[INFO] Mongo DB Binding
[INFO] Redis DB Binding
[INFO] Voldemort DB Binding
[INFO] YCSB Release Distribution Builder
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building YCSB Root 0.1.4
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ root ---
[INFO]
[INFO] --- maven-checkstyle-plugin:2.6:checkstyle (validate) @ root ---
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Core YCSB 0.1.4
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ core ---
[INFO] Deleting /opt/mongo/ycsb/core/target
[INFO]
[INFO] --- maven-checkstyle-plugin:2.6:checkstyle (validate) @ core ---
[INFO] Starting audit...
loading ……
4、ycsb的环境变量配置有问题(可以到/ycsb/bin进行验证)
现象:
[root@mongo ycsb]#
[root@mongo ycsb]# ycsb shell basic
java -cp /root/Documents/ycsb/voldemort/src/main/conf:/root/Documents/ycsb/gemfire/src/main/conf:/root/Documents/ycsb/jdbc/src/main/conf:/root/Documents/ycsb/infinispan/src/main/conf:/root/Documents/ycsb/dynamodb/conf:/root/Documents/ycsb/accumulo/src/main/conf:/root/Documents/ycsb/nosqldb/src/main/conf:/root/Documents/ycsb/hbase/src/main/conf com.yahoo.ycsb.CommandLine -db com.yahoo.ycsb.BasicDB
Error: Could not find or load main class com.yahoo.ycsb.CommandLine
5、关于ycsb编译过程中到 Mapkeeper DB Binding异常退出,我没找到好方法,但是可以使用mvn -fn clean package跳过
[INFO] Mapkeeper DB Binding ............................... FAILURE [ 0.012 s]
六、压测用到的软件下载地址
mongodb-linux-x86_64-3.2.7.tgz http://pan.baidu.com/s/1kUIHXiv
apache-maven-3.3.9-bin.zip http://pan.baidu.com/s/1c2hsKLU
jdk-8u11-linux-x64.rpm http://pan.baidu.com/s/1pL8aFHL
YCSB-0.1.4.zip http://pan.baidu.com/s/1jHSTwge
.m2(maven2的JAR库及pom文件库) http://pan.baidu.com/s/1cHoDQY