jmeter学习-命令行执行脚本

1、命令参数

在这里插入图片描述

2、实例
(1)直接执行
D:\software\apache-jmeter-3.3\bin>jmeter -n -t crm.jmx
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/software/apache-jmeter-3.3/lib/log4j-slf4j-impl-2.8.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/software/apache-jmeter-3.3/lib/ext/jmeter-plugins-dubbo-1.3.6-jar-with-dependencies.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/software/apache-jmeter-3.3/lib/ext/jmeter-test.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Creating summariser <summary>
Created the tree successfully using crm.jmx
Starting the test @ Tue Jan 14 15:14:48 CST 2020 (1578986088425)
Waiting for possible Shutdown/StopTestNow/Heapdump message on port 4445
summary =      4 in 00:00:01 =    7.1/s Avg:   112 Min:     2 Max:   363 Err:     0 (0.00%)
Tidying up ...    @ Tue Jan 14 15:14:49 CST 2020 (1578986089355)
... end of run
(2)指定报告路径
D:\software\apache-jmeter-3.3\bin>jmeter -n -t crm.jmx -l test.jtl
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/software/apache-jmeter-3.3/lib/log4j-slf4j-impl-2.8.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/software/apache-jmeter-3.3/lib/ext/jmeter-plugins-dubbo-1.3.6-jar-with-dependencies.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/software/apache-jmeter-3.3/lib/ext/jmeter-test.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Creating summariser <summary>
Created the tree successfully using crm.jmx
Starting the test @ Tue Jan 14 15:18:49 CST 2020 (1578986329264)
Waiting for possible Shutdown/StopTestNow/Heapdump message on port 4445
summary =      4 in 00:00:00 =    8.2/s Avg:    96 Min:     0 Max:   342 Err:     0 (0.00%)
Tidying up ...    @ Tue Jan 14 15:18:50 CST 2020 (1578986330127)

将test.jtl导入到jmeterGUI中可看到

在这里插入图片描述

(3) 生成报告
D:\software\apache-jmeter-3.3\bin>jmeter -n -t crm.jmx -l test.jtl -e -o web
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/software/apache-jmeter-3.3/lib/log4j-slf4j-impl-2.8.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/software/apache-jmeter-3.3/lib/ext/jmeter-plugins-dubbo-1.3.6-jar-with-dependencies.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/software/apache-jmeter-3.3/lib/ext/jmeter-test.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Creating summariser <summary>
Created the tree successfully using crm.jmx
Starting the test @ Tue Jan 14 15:23:21 CST 2020 (1578986601678)
Waiting for possible Shutdown/StopTestNow/Heapdump message on port 4445
summary =      4 in 00:00:00 =    8.2/s Avg:    95 Min:     1 Max:   340 Err:     0 (0.00%)
Tidying up ...    @ Tue Jan 14 15:23:22 CST 2020 (1578986602521)

注意:web为测试报告所导出的目录,该目录必须为空文件夹

在这里插入图片描述

测试报告如下:

在这里插入图片描述

3 分布式执行
D:\software\apache-jmeter-3.3\bin>jmeter -n -t crm.jmx -r
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/software/apache-jmeter-3.3/lib/log4j-slf4j-impl-2.8.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/software/apache-jmeter-3.3/lib/ext/jmeter-plugins-dubbo-1.3.6-jar-with-dependencies.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/software/apache-jmeter-3.3/lib/ext/jmeter-test.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Creating summariser <summary>
Created the tree successfully using crm.jmx
Configuring remote engine: 127.0.0.1
Using remote object: UnicastRef [liveRef: [endpoint:[192.168.3.199:63025](remote),objID:[4e831b4d:16f8d44d876:-7fff, -7041486427723727807]]]
Configuring remote engine: 192.168.3.161
Connection refused to host: 192.168.3.161; nested exception is:
        java.net.ConnectException: Connection refused: connect
Failed to configure 192.168.3.161

注意:3.161上面的jmeter服务没有启动,所以报错了

将171上面的jmeter启动

[root@DataNode0 bin]# jmeter-server 
Created remote object: UnicastServerRef [liveRef: [endpoint:[192.168.3.171:16746](local),objID:[-3183922:16fa2f8e18e:-7fff, -875491763938485046]]]

随后在主服务器上执行命令:

D:\software\apache-jmeter-3.3\bin>jmeter -n -t crm.jmx -R 192.168.3.171:1099
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/software/apache-jmeter-3.3/lib/log4j-slf4j-impl-2.8.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/software/apache-jmeter-3.3/lib/ext/jmeter-plugins-dubbo-1.3.6-jar-with-dependencies.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/software/apache-jmeter-3.3/lib/ext/jmeter-test.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Creating summariser <summary>
Created the tree successfully using crm.jmx
Configuring remote engine: 192.168.3.171:1099
Using remote object: UnicastRef [liveRef: [endpoint:[192.168.3.171:16746](remote),objID:[-3183922:16fa2f8e18e:-7fff, -875491763938485046]]]
Starting remote engines
Starting the test @ Tue Jan 14 15:33:46 CST 2020 (1578987226562)
Remote engines have been started
Waiting for possible Shutdown/StopTestNow/Heapdump message on port 4445
summary =      4 in 00:00:01 =    3.4/s Avg:   232 Min:     0 Max:   470 Err:     1 (25.00%)
Tidying up remote @ Tue Jan 14 15:33:56 CST 2020 (1578987236730)

此时从服务器上

**Jan 14, 2020 3:33:57 PM java.util.prefs.FileSystemPreferences$1 run
INFO: Created user preferences directory.
Starting the test on host 192.168.3.171:1099 @ Tue Jan 14 15:33:57 CST 2020 (1578987237972)
Finished the test on host 192.168.3.171:1099 @ Tue Jan 14 15:33:59 CST 2020 (1578987239645)
**

至此,远程执行成功。

可能出现的问题

从服务器没有启动,1099端口占用:
使用lsof -i:1099查看是否端口被占用,若存在则kill -9 “进程号”杀掉进程,然后使用jmeter-server重启一下即可
4、代理设置

使用命令执行时,有时候需要抓包查看脚本是否正确。这时候就需要使用代理了。代理工具可使用fiddler

(1)在fiddler中设置监听的端口号
在这里插入图片描述
(2)执行脚本

D:\software\apache-jmeter-3.3\bin>jmeter -n -t crm.jmx -H 127.0.0.1 -P 8888
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/software/apache-jmeter-3.3/lib/log4j-slf4j-impl-2.8.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/software/apache-jmeter-3.3/lib/ext/jmeter-plugins-dubbo-1.3.6-jar-with-dependencies.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/software/apache-jmeter-3.3/lib/ext/jmeter-test.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Creating summariser <summary>
Created the tree successfully using crm.jmx
Starting the test @ Tue Jan 14 15:43:29 CST 2020 (1578987809414)
Waiting for possible Shutdown/StopTestNow/Heapdump message on port 4445
summary +      1 in 00:00:00 =    2.3/s Avg:   333 Min:   333 Max:   333 Err:     0 (0.00%) Active: 1 Started: 1 Finished: 0
summary +      3 in 00:00:00 =   76.9/s Avg:     6 Min:     1 Max:    13 Err:     0 (0.00%) Active: 0 Started: 2 Finished: 2
summary =      4 in 00:00:00 =    8.4/s Avg:    88 Min:     1 Max:   333 Err:     0 (0.00%)
Tidying up ...    @ Tue Jan 14 15:43:30 CST 2020 (1578987810271)
... end of run

(3)fiddler抓包记录
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值