1.安装yscb
1.1 下载yscb
文件名: ycsb-0.17.0.tar.gz
git下载地址:
https://github.com/brianfrankcooper/YCSB/releases/tag/0.17.0
下载完后解压
tar -zxvf ycsb-0.17.0.tar.gz
1.2 其他环境准备工作
安装Java:
yum install java-devel -y
安装maven:
下载地址: https://downloads.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
安装:
wget https://downloads.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
tar xzf apache-maven-*-bin.tar.gz -C /usr/local
cd /usr/local
ln -s apache-maven-* maven
vi /etc/profile.d/maven.sh
在maven.sh中加入:
export M2_HOME=/usr/local/maven
export PATH=${M2_HOME}/bin:${PATH}
Reload bash 测试mvn是否工作正常
[root@hlet-fastdfs-tracker01 maven]# bash
[root@hlet-fastdfs-tracker01 maven]# mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/maven
Java version: 1.8.0_252, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-957.el7.x86_64", arch: "amd64", family: "unix"
2.压测
2.1 准备数据
ycsb提前已经在workload文件夹下准备好了几个压测场景分别对应workload[a:f]
workloada | 读写均衡型,50%读,50%写 |
---|---|
workloadb | 读多写少型,95%读,5%更新。 |
workloadc | 只读,100%读。 |
workloadd | 读最近写入记录型,95%读,5%插入。 |
workloade | 扫描小区间型,95%扫描,5%插入。 |
workloadf | 读写入记录均衡型,50%读,50%读、修改、写。 |
经过和开发人员沟通,workloadf最符合生产环境的实际场景,这里我们copy一份workloadf,编辑一下我们MongoDB相关测试的配置
mongodb.url=mongodb://mongouser:mongopassowrd@10.1.99.77:27017,10.1.99.78:27017/?authSource=admin
mongodb.batchsize=1000
mongodb.maxconnections=10000
table=workload_1e_2
recordcount=100000000
operationcount=100000000
workload=site.ycsb.workloads.CoreWorkload
readallfields=true
readproportion=0.5
updateproportion=0
scanproportion=0
insertproportion=0
readmodifywriteproportion=0.5
requestdistribution=zipfian
配置文件准备好了之后,我们通过load指令来生成数据:
./bin/ycsb load mongodb -P workloads/workloadf_mongo
默认会在MongoDB生成一个yscb的库,由于我们指定了collection名称,所以数据会插入到yscb.workload_1e_2这个collection里
注意,如果要测试分片集群的数据,最好提前创建好相应的集合并按_id分片:
mongos> use ycsb
switched to db ycsb
mongos> db.createCollection('workload_1e_2')
{
"ok" : 1,
"operationTime" : Timestamp(1595495035, 4),
"$clusterTime" : {
"clusterTime" : Timestamp(1595495035, 4),
"signature" : {
"hash" : BinData(0,"3X4B1s5oImsWrbkS8Klk9fOSYrk="),
"keyId" : NumberLong("6850640688736895007")
}
}
}
mongos> sh.shardCollection("ycsb.workload_1e_2" ,{ "_id" : 1 })
{
"collectionsharded" : "ycsb.workload_1e_2",
"collectionUUID" : UUID("661fd309-e737-44c4-8674-c54889cc070d"),
"ok" : 1,
"operationTime" : Timestamp(1595495123, 10),
"$clusterTime" : {
"clusterTime" : Timestamp(1595495123, 10),
"signature" : {
"hash" : BinData(0,"Wz1RBvhevN8SzYc7Fb5xsiYUuao="),
"keyId" : NumberLong("6850640688736895007")
}
}
}
数据准备命令输出:
[root@hlet-fastdfs-tracker01 ycsb-0.17.0]# ./bin/ycsb load mongodb -P workloads/workloadf_mongo
java -cp /root/ycsb-0.17.0/mongodb-binding/conf:/root/ycsb-0.17.0/conf:/root/ycsb-0.17.0/lib/core-0.17.0.jar:/root/ycsb-0.17.0/lib/htrace-core4-4.1.0-incubating.jar:/root/ycsb-0.17.0/lib/jackson-mapper-asl-1.9.4.jar:/root/ycsb-0.17.0/lib/jackson-core-asl-1.9.4.jar:/root/ycsb-0.17.0/lib/HdrHistogram-2.1.4.jar:/root/ycsb-0.17.0/mongodb-binding/lib/mongo-java-driver-3.8.0.jar:/root/ycsb-0.17.0/mongodb-binding/lib/logback-classic-1.1.2.jar:/root/ycsb-0.17.0/mongodb-binding/lib/slf4j-api-1.7.25.jar:/root/ycsb-0.17.0/mongodb-binding/lib/mongodb-async-driver-2.0.1.jar:/root/ycsb-0.17.0/mongodb-binding/lib/snappy-java-1.1.7.1.jar:/root/ycsb-0.17.0/mongodb-binding/lib/logback-core-1.1.2.jar:/root/ycsb-0.17.0/mongodb-binding/lib/mongodb-binding-0.17.0.jar site.ycsb.Client -db site.ycsb.db.MongoDbClient -P workloads/workloadf_mongo -load
Command line: -db site.ycsb.db.MongoDbClient -P workloads/workloadf_mongo -load
YCSB Client 0.17.0
Loading workload...
Starting test.
mongo client connection created with mongodb://mongouser:mongopassowrd@10.1.99.77:27017,10.1.99.78:27017/?authSource=admin&maxPoolSize=10000
DBWrapper: report latency for each error is false and specific error codes to track for latency are: []
DBWrapper: report latency for each error is false and specific error codes to track for latency are: []
[OVERALL], RunTime(ms), 1678202
[OVERALL], Throughput(ops/sec), 59587.58242452339
[TOTAL_GCS_PS_Scavenge], Count, 7024
[TOTAL_GC_TIME_PS_Scavenge], Time(ms), 16525
[TOTAL_GC_TIME_%_PS_Scavenge], Time(%), 0.984684799565249
[TOTAL_GCS_PS_MarkSweep], Count, 4
[TOTAL_GC_TIME_PS_MarkSweep], Time(ms), 187
[TOTAL_GC_TIME_%_PS_MarkSweep], Time(%), 0.011142877913385875
[TOTAL_GCs], Count, 7028
[TOTAL_GC_TIME], Time(ms), 16712
[TOTAL_GC_TIME_%], Time(%), 0.9958276774786348
[CLEANUP], Operations, 128
[CLEANUP], AverageLatency(us), 137.578125
[CLEANUP], MinLatency(us), 1
[CLEANUP], MaxLatency(us), 17375
[CLEANUP], 95thPercentileLatency(us), 3
[CLEANUP], 99thPercentileLatency(us), 27
[INSERT], Operations, 100000000
[INSERT], AverageLatency(us), 2141.56641891
[INSERT], MinLatency(us), 545
[INSERT], MaxLatency(us), 1204223
[INSERT], 95thPercentileLatency(us), 4771
[INSERT], 99thPercentileLatency(us), 8695
[INSERT], Return=OK, 100000000
2.2 实际压测
这次换成run命令来实际运行workloadf场景
./bin/ycsb run mongodb -P workloads/workloadf_mongo
输出:
[root@hlet-fastdfs-tracker01 ycsb-0.17.0]# ./bin/ycsb run mongodb -P workloads/workloadf_mongo
java -cp /root/ycsb-0.17.0/mongodb-binding/conf:/root/ycsb-0.17.0/conf:/root/ycsb-0.17.0/lib/core-0.17.0.jar:/root/ycsb-0.17.0/lib/htrace-core4-4.1.0-incubating.jar:/root/ycsb-0.17.0/lib/jackson-mapper-asl-1.9.4.jar:/root/ycsb-0.17.0/lib/jackson-core-asl-1.9.4.jar:/root/ycsb-0.17.0/lib/HdrHistogram-2.1.4.jar:/root/ycsb-0.17.0/mongodb-binding/lib/mongo-java-driver-3.8.0.jar:/root/ycsb-0.17.0/mongodb-binding/lib/logback-classic-1.1.2.jar:/root/ycsb-0.17.0/mongodb-binding/lib/slf4j-api-1.7.25.jar:/root/ycsb-0.17.0/mongodb-binding/lib/mongodb-async-driver-2.0.1.jar:/root/ycsb-0.17.0/mongodb-binding/lib/snappy-java-1.1.7.1.jar:/root/ycsb-0.17.0/mongodb-binding/lib/logback-core-1.1.2.jar:/root/ycsb-0.17.0/mongodb-binding/lib/mongodb-binding-0.17.0.jar site.ycsb.Client -db site.ycsb.db.MongoDbClient -P workloads/workloadf_mongo -t
Command line: -db site.ycsb.db.MongoDbClient -P workloads/workloadf_mongo -t
YCSB Client 0.17.0
Loading workload...
Starting test.
mongo client connection created with mongodb://mongouser:mongopassowrd@10.1.99.77:27017,10.1.99.78:27017/?authSource=admin&maxPoolSize=10000
DBWrapper: report latency for each error is false and specific error codes to track for latency are: []
DBWrapper: report latency for each error is false and specific error codes to track for latency are: []
[OVERALL], RunTime(ms), 1666002
[OVERALL], Throughput(ops/sec), 60023.93754629346
[TOTAL_GCS_PS_Scavenge], Count, 7050
[TOTAL_GC_TIME_PS_Scavenge], Time(ms), 15970
[TOTAL_GC_TIME_%_PS_Scavenge], Time(%), 0.9585822826143067
[TOTAL_GCS_PS_MarkSweep], Count, 17
[TOTAL_GC_TIME_PS_MarkSweep], Time(ms), 633
[TOTAL_GC_TIME_%_PS_MarkSweep], Time(%), 0.03799515246680376
[TOTAL_GCs], Count, 7067
[TOTAL_GC_TIME], Time(ms), 16603
[TOTAL_GC_TIME_%], Time(%), 0.9965774350811104
[READ], Operations, 100000000
[READ], AverageLatency(us), 1410.02291897
[READ], MinLatency(us), 508
[READ], MaxLatency(us), 2095103
[READ], 95thPercentileLatency(us), 2133
[READ], 99thPercentileLatency(us), 5599
[READ], Return=OK, 100000000
[READ-MODIFY-WRITE], Operations, 49997401
[READ-MODIFY-WRITE], AverageLatency(us), 2841.3056152658814
[READ-MODIFY-WRITE], MinLatency(us), 1108
[READ-MODIFY-WRITE], MaxLatency(us), 2144255
[READ-MODIFY-WRITE], 95thPercentileLatency(us), 4019
[READ-MODIFY-WRITE], 99thPercentileLatency(us), 7759
[CLEANUP], Operations, 128
[CLEANUP], AverageLatency(us), 134.71875
[CLEANUP], MinLatency(us), 1
[CLEANUP], MaxLatency(us), 16975
[CLEANUP], 95thPercentileLatency(us), 3
[CLEANUP], 99thPercentileLatency(us), 24
[UPDATE], Operations, 49997401
[UPDATE], AverageLatency(us), 1428.009917735524
[UPDATE], MinLatency(us), 516
[UPDATE], MaxLatency(us), 2055167
[UPDATE], 95thPercentileLatency(us), 2087
[UPDATE], 99thPercentileLatency(us), 3955
[UPDATE], Return=OK, 49997401
使用100%读的场景再测一次:
workloadc_mongo:
[root@hlet-fastdfs-tracker01 ycsb-0.17.0]# cat workloads/workloadc_mongo
mongodb.url=mongodb://mongouser:mongopassowrd@10.1.99.77:27017,10.1.99.78:27017/?authSource=admin
mongodb.batchsize=10000
mongodb.maxconnections=10000
threadcount=128
table=workload_1e_2
recordcount=100000000
operationcount=100000000
workload=site.ycsb.workloads.CoreWorkload
readallfields=true
readproportion=1
updateproportion=0
scanproportion=0
insertproportion=0
requestdistribution=zipfian
由于数据总量是一样的,这里就不重复生成数据了,直接run
[root@hlet-fastdfs-tracker01 ycsb-0.17.0]# ./bin/ycsb run mongodb -P workloads/workloadc_mongo
java -cp /root/ycsb-0.17.0/mongodb-binding/conf:/root/ycsb-0.17.0/conf:/root/ycsb-0.17.0/lib/core-0.17.0.jar:/root/ycsb-0.17.0/lib/htrace-core4-4.1.0-incubating.jar:/root/ycsb-0.17.0/lib/jackson-mapper-asl-1.9.4.jar:/root/ycsb-0.17.0/lib/jackson-core-asl-1.9.4.jar:/root/ycsb-0.17.0/lib/HdrHistogram-2.1.4.jar:/root/ycsb-0.17.0/mongodb-binding/lib/mongo-java-driver-3.8.0.jar:/root/ycsb-0.17.0/mongodb-binding/lib/logback-classic-1.1.2.jar:/root/ycsb-0.17.0/mongodb-binding/lib/slf4j-api-1.7.25.jar:/root/ycsb-0.17.0/mongodb-binding/lib/mongodb-async-driver-2.0.1.jar:/root/ycsb-0.17.0/mongodb-binding/lib/snappy-java-1.1.7.1.jar:/root/ycsb-0.17.0/mongodb-binding/lib/logback-core-1.1.2.jar:/root/ycsb-0.17.0/mongodb-binding/lib/mongodb-binding-0.17.0.jar site.ycsb.Client -db site.ycsb.db.MongoDbClient -P workloads/workloadc_mongo -t
Command line: -db site.ycsb.db.MongoDbClient -P workloads/workloadc_mongo -t
YCSB Client 0.17.0
Loading workload...
Starting test.
mongo client connection created with mongodb://mongouser:mongopassowrd@10.1.99.77:27017,10.1.99.78:27017/?authSource=admin&maxPoolSize=10000
DBWrapper: report latency for each error is false and specific error codes to track for latency are: []
DBWrapper: report latency for each error is false and specific error codes to track for latency are: []
[OVERALL], RunTime(ms), 1237596
[OVERALL], Throughput(ops/sec), 80801.81254625904
[TOTAL_GCS_PS_Scavenge], Count, 5132
[TOTAL_GC_TIME_PS_Scavenge], Time(ms), 11950
[TOTAL_GC_TIME_%_PS_Scavenge], Time(%), 0.9655816599277954
[TOTAL_GCS_PS_MarkSweep], Count, 14
[TOTAL_GC_TIME_PS_MarkSweep], Time(ms), 508
[TOTAL_GC_TIME_%_PS_MarkSweep], Time(%), 0.041047320773499596
[TOTAL_GCs], Count, 5146
[TOTAL_GC_TIME], Time(ms), 12458
[TOTAL_GC_TIME_%], Time(%), 1.0066289807012951
[READ], Operations, 100000000
[READ], AverageLatency(us), 1579.5437729
[READ], MinLatency(us), 527
[READ], MaxLatency(us), 2426879
[READ], 95thPercentileLatency(us), 2071
[READ], 99thPercentileLatency(us), 2815
[READ], Return=OK, 100000000
[CLEANUP], Operations, 128
[CLEANUP], AverageLatency(us), 134.296875
[CLEANUP], MinLatency(us), 1
[CLEANUP], MaxLatency(us), 16991
[CLEANUP], 95thPercentileLatency(us), 3
[CLEANUP], 99thPercentileLatency(us), 27
根据监控信息和结果粗略的算了一下,108G的数据,20多分钟跑完,已经是千兆网络的极限了...包括上面的读写混合测试,混合上传下载,网络也是到达了极限,所以暂时还没有测出这个集群的完整实力...