JMeter安装使用
一、Java JDK安装
下载地址:https://repo.huaweicloud.com/java/jdk/
# 下载安装包
[root@ecs-a0e2 ~]# wget https://repo.huaweicloud.com/java/jdk/11.0.2+7/jdk-11.0.2_linux-x64_bin.tar.gz
# 解压
[root@ecs-a0e2 ~]# tar -zxvf jdk-11.0.2_linux-x64_bin.tar.gz
# 配置环境变量
[root@ecs-a0e2 ~]# vim /etc/profile
export JAVA_HOME=/root/jdk-11.0.2 # 这里的路径看你解压至哪里的路径
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
# 刷新环境变量
[root@ecs-a0e2 ~]# source /etc/profile
# 测试是否安装成功
[root@ecs-a0e2 ~]# java -version
java version "11.0.2" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.2+7-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+7-LTS, mixed mode)
二、JMeter安装
下载地址:http://jmeter.apache.org/download_jmeter.cgi
# 下载安装包
[root@ecs-a0e2 ~]# wget https://dlcdn.apache.org//jmeter/binaries/apache-jmeter-5.6.2.tgz
# 解压
[root@ecs-a0e2 ~]# tar -zxvf apache-jmeter-5.6.2.tgz
# 配置环境变量
[root@ecs-a0e2 ~]# vim /etc/profile
export JMETER_HOME=/root/apache-jmeter-5.6.2 # 这里的路径看你解压至哪里的路径
export CLASSPATH=$JMETER_HOME/lib/ext/ApacheJMeter_core.jar:$JMETER_HOME/lib/jorphan.jar:$JMETER_HOME/lib/logkit-2.0.jar:$CLASSPATH
export PATH=$JMETER_HOME/bin:$PATH:$HOME/bin
# 刷新环境变量
[root@ecs-a0e2 ~]# source /etc/profile
# 测试是否安装成功
[root@ecs-a0e2 ~]# jmeter -v
WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated and will be removed in a future release
WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated and will be removed in a future release
WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated and will be removed in a future release
WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated and will be removed in a future release
_ ____ _ ____ _ _ _____ _ __ __ _____ _____ _____ ____
/ \ | _ \ / \ / ___| | | | ____| | | \/ | ____|_ _| ____| _ \
/ _ \ | |_) / _ \| | | |_| | _| _ | | |\/| | _| | | | _| | |_) |
/ ___ \| __/ ___ \ |___| _ | |___ | |_| | | | | |___ | | | |___| _ <
/_/ \_\_| /_/ \_\____|_| |_|_____| \___/|_| |_|_____| |_| |_____|_| \_\ 5.6.2
Copyright (c) 1999-2023 The Apache Software Foundation
三、JMeter使用
# 使用本机运行Jmeter,执行的测试脚本为:/root/kongshuo.jmx,并把结果文件输出到当前目录下,文件名为kongshuo.jtl
jmeter -n -t /root/kongshuo.jmx -l kongshuo.jtl
四、实战演示
[root@ecs-a0e2 ~]# vim 汇总报告.jmx
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.6.2">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="测试计划" enabled="true">
<boolProp name="TestPlan.functional_mode">false</boolProp>
<boolProp name="TestPlan.tearDown_on_shutdown">false</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="用户定义的变量" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
</TestPlan>
<hashTree>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="线程组" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="循环控制器" enabled="true">
<stringProp name="LoopController.loops">10</stringProp>
<boolProp name="LoopController.continue_forever">false</boolProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">1500</stringProp>
<stringProp name="ThreadGroup.ramp_time">60</stringProp>
<boolProp name="ThreadGroup.delayedStart">false</boolProp>
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
<boolProp name="ThreadGroup.same_user_on_next_iteration">true</boolProp>
</ThreadGroup>
<hashTree>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP请求" enabled="true">
<boolProp name="HTTPSampler.postBodyRaw">false</boolProp>
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="用户定义的变量" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="HTTPSampler.domain">*********</stringProp>
<stringProp name="HTTPSampler.protocol">http</stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
<boolProp name="HTTPSampler.BROWSER_COMPATIBLE_MULTIPART">false</boolProp>
<boolProp name="HTTPSampler.image_parser">false</boolProp>
<boolProp name="HTTPSampler.concurrentDwn">false</boolProp>
<stringProp name="HTTPSampler.concurrentPool">6</stringProp>
<boolProp name="HTTPSampler.md5">false</boolProp>
<intProp name="HTTPSampler.ipSourceType">0</intProp>
</HTTPSamplerProxy>
<hashTree/>
</hashTree>
<ResultCollector guiclass="SummaryReport" testclass="ResultCollector" testname="汇总报告" enabled="true">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>true</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
<sentBytes>true</sentBytes>
<url>true</url>
<threadCounts>true</threadCounts>
<idleTime>true</idleTime>
<connectTime>true</connectTime>
</value>
</objProp>
<stringProp name="filename">/root/ceshi.jtl</stringProp>
</ResultCollector>
<hashTree/>
</hashTree>
</hashTree>
</jmeterTestPlan>
[root@ecs-a0e2 ~]# jmeter -n -t /root/apache-jmeter-5.6.2/汇总报告.jmx
WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated and will be removed in a future release
WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated and will be removed in a future release
WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated and will be removed in a future release
WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated and will be removed in a future release
Creating summariser <summary>
Created the tree successfully using /root/apache-jmeter-5.6.2/汇总报告.jmx
Starting standalone test @ 2023 Aug 30 11:54:26 CST (1693367666645)
Waiting for possible Shutdown/StopTestNow/HeapDump/ThreadDump message on port 4445
Warning: Nashorn engine is planned to be removed from a future JDK release
summary + 656 in 00:00:03 = 208.6/s Avg: 83 Min: 51 Max: 348 Err: 0 (0.00%) Active: 21 Started: 79 Finished: 58
summary + 7502 in 00:00:30 = 250.0/s Avg: 80 Min: 51 Max: 279 Err: 0 (0.00%) Active: 20 Started: 829 Finished: 809
summary = 8158 in 00:00:33 = 246.1/s Avg: 80 Min: 51 Max: 348 Err: 0 (0.00%)
summary + 6842 in 00:00:28 = 247.5/s Avg: 80 Min: 51 Max: 269 Err: 0 (0.00%) Active: 0 Started: 1500 Finished: 1500
summary = 15000 in 00:01:01 = 246.7/s Avg: 80 Min: 51 Max: 348 Err: 0 (0.00%)
Tidying up ... @ 2023 Aug 30 11:55:27 CST (1693367727653)
... end of run
[root@ecs-a0e2 ~]# vim ceshi.jmx
1693367688781,63,HTTP请求,200,OK,线程组 1-533,text,true,,59287,119,21,21,http://*******/,63,0,0
1693367688778,66,HTTP请求,200,OK,线程组 1-529,text,true,,59287,119,21,21,http://*******/,66,0,0
1693367688798,58,HTTP请求,200,OK,线程组 1-539,text,true,,59287,119,20,20,http://*******/,58,0,0
1693367688793,66,HTTP请求,200,OK,线程组 1-541,text,true,,59287,119,20,20,http://*******/,66,0,0
1693367688799,67,HTTP请求,200,OK,线程组 1-531,text,true,,59287,119,20,20,http://*******/,67,0,0
1693367688803,64,HTTP请求,200,OK,线程组 1-543,text,true,,59287,119,21,21,http://*******/,64,0,0
1693367688811,64,HTTP请求,200,OK,线程组 1-532,text,true,,59287,119,21,21,http://*******/,64,0,0
1693367688821,57,HTTP请求,200,OK,线程组 1-534,text,true,,59287,119,21,21,http://*******/,57,0,0
1693367688627,251,HTTP请求,200,OK,线程组 1-545,text,true,,59287,119,21,21,http://*******/,126,0,63
1693367688816,64,HTTP请求,200,OK,线程组 1-537,text,true,,59287,119,21,21,http://*******/,64,0,0
1693367688823,57,HTTP请求,200,OK,线程组 1-540,text,true,,59287,119,21,21,http://*******/,57,0,0
1693367688821,59,HTTP请求,200,OK,线程组 1-544,text,true,,59287,119,21,21,http://*******/,59,0,0
1693367688819,63,HTTP请求,200,OK,线程组 1-542,text,true,,59287,119,21,21,http://*******/,63,0,0
1693367688825,60,HTTP请求,200,OK,线程组 1-538,text,true,,59287,119,21,21,http://*******/,60,0,0
1693367688823,62,HTTP请求,200,OK,线程组 1-536,text,true,,59287,119,21,21,http://*******/,62,0,0
1693367688829,61,HTTP请求,200,OK,线程组 1-535,text,true,,59287,119,21,21,http://*******/,61,0,0
1693367688667,227,HTTP请求,200,OK,线程组 1-546,text,true,,59287,119,21,21,http://*******/,114,0,57
1693367688844,64,HTTP请求,200,OK,线程组 1-533,text,true,,59287,119,21,21,http://*******/,63,0,0
1693367688856,59,HTTP请求,200,OK,线程组 1-539,text,true,,59287,119,22,22,http://*******/,59,0,0
1693367688859,65,HTTP请求,200,OK,线程组 1-541,text,true,,59287,119,22,22,http://*******/,65,0,0
1693367688867,65,HTTP请求,200,OK,线程组 1-543,text,true,,59287,119,22,22,http://*******/,64,0,0
1693367688866,66,HTTP请求,200,OK,线程组 1-531,text,true,,59287,119,22,22,http://*******/,66,0,0
1693367688878,56,HTTP请求,200,OK,线程组 1-534,text,true,,59287,119,21,21,http://*******/,56,0,0
1693367688880,57,HTTP请求,200,OK,线程组 1-540,text,true,,59287,119,20,20,http://*******/,56,0,0
1693367688880,59,HTTP请求,200,OK,线程组 1-544,text,true,,59287,119,20,20,http://*******/,59,0,0
1693367688875,64,HTTP请求,200,OK,线程组 1-532,text,true,,59287,119,20,20,http://*******/,64,0,0
1693367688878,63,HTTP请求,200,OK,线程组 1-545,text,true,,59287,119,19,19,http://*******/,63,0,0
1693367688880,64,HTTP请求,200,OK,线程组 1-537,text,true,,59287,119,19,19,http://*******/,63,0,0
1693367688885,59,HTTP请求,200,OK,线程组 1-538,text,true,,59287,119,19,19,http://*******/,59,0,0
1693367688882,63,HTTP请求,200,OK,线程组 1-542,text,true,,59287,119,19,19,http://*******/,62,0,0
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2022-08-30 OpenStack Redhat Cinder对接NFS后端存储
2022-08-30 OpenStack Redhat glance对接swift