JMeter的下载以及安装使用
下载
https://jmeter.apache.org/download_jmeter.cgi
安装
无须安装,解压之后即可使用。
解压到C:\Program Files\apache-jmeter-5.1目录下(无法直接解压,先在D盘解压,然后复制到C盘里面)。
运行之后,一闪而过,没有出现UI。
需要注意的是:启动bat文件最好用管理员权限,否则我的使用路径是系统盘,会出现log文件不能写的问题
问题排查
注释掉jmeter.bat文件中的第一行,rem @echo off,然后运行如下命令,可以看到错误:
C:\Program Files\apache-jmeter-5.1\bin [master +0 ~1 -0 !]> .\jmeter.bat >>launch.log
java.lang.Throwable: Could not access C:\Program Files\apache-jmeter-5.1\lib
at org.apache.jmeter.NewDriver.<clinit>(NewDriver.java:105)
java.lang.Throwable: Could not access C:\Program Files\apache-jmeter-5.1\lib\ext
at org.apache.jmeter.NewDriver.<clinit>(NewDriver.java:105)
java.lang.Throwable: Could not access C:\Program Files\apache-jmeter-5.1\lib\junit
at org.apache.jmeter.NewDriver.<clinit>(NewDriver.java:105)
java.lang.ClassNotFoundException: org.apache.jmeter.JMeter
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.apache.jmeter.NewDriver.main(NewDriver.java:250)
JMeter home directory was detected as: C:\Program Files\apache-jmeter-5.1
解决:发现是lib文件夹没有复制成功导致的,之前复制文件夹的时候,提示lib被占用。所以没有复制成功。
PluginsManager
https://jmeter-plugins.org/wiki/PluginsManager/
安装
https://jmeter-plugins.org/install/Install/
The easiest way to get the plugins is to install Plugins Manager. Then you'll be able to install any other plugins just by clicking a checkbox.
proxy
Plugins Manager respects JMeter's proxy settings. However, to avoid editing the properties files, we recommend to launch JMeter with additional parameters to pass it the proxy settings:
JVM_ARGS="-Dhttps.proxyHost=myproxy.com -Dhttps.proxyPort=8080" jmeter\bin\jmeter.bat
If you need proxy username/password, specify them with two additional properties http.proxyUser and http.proxyPasslike this:
JVM_ARGS="-Dhttps.proxyHost=myproxy.com -Dhttps.proxyPort=8080 -Dhttp.proxyUser=john -Dhttp.proxyPass=***" jmeter\bin\jmeter.bat
在system.properties文件中配置代理
So if you don't wish to set both http and https proxies, you can define the relevant properties in system.properties instead of using the command-line parameters.
https://stackoverflow.com/questions/52084212/how-to-manage-proxy-in-jmeter
You can configure JMeter to use proxy in 2 ways:
-
jmeter -H your_proxy_host -P your_proxy_port
-
Using system.properties (the file lives under "bin" folder of your JMeter installation, add the next lines to it:
http.proxyHost=your_proxy_host http.proxyPort=your_proxy_port https.proxyHost=your_proxy_host https.proxyPort=your_proxy_port
JMeter restart will be required to pick the properties up.
需要注意的是,http.proxyHost=http:// 这里需要加http://
unable to find valid certification path to requested target
https://www.cnblogs.com/chucklu/p/10445580.html
在jmeter.properties配置
# CookieManager behaviour - should Cookies be stored as variables?
# Default is false
CookieManager.save.cookies=true
407错误,代理需要授权
给代理配置上账户,这里的账号和密码。密码如果有特殊字符,需要先进行一次urlencode【密码中的@会被转换成%40】
http://账号:密码@域名(ip):端口号
总结
- 使用的proxy必须加上http://的前缀
- 使用的proxy必须配置账户和密码
建议在bin\ system.properties文件末尾添加如下两行
http.proxyHost=http://域账号:密码(url encode之后的) @proxy:port
http.proxyPort=8080
- 导出https://jmeter-plugins.org/网站的证书
参考https://blog.csdn.net/c5113620/article/details/80384660
- 将证书导入Java的证书验证系统(Java的证书验证系统是独立于操作系统和浏览器的,而是使用JRE中证书库,所有必须把代理工具的证书加入到JRE的证书库中。)
https://blog.csdn.net/write_down/article/details/79114573
https://www.blazemeter.com/blog/how-to-configure-jmeter-logging