下載
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