注意:
1、之前写过一个是windows平台的,本文是Linux平台的;
2、另外需要注意的是,本文仅为示例过程,所以将客户端和服务器都用在同一台机器上。一般情况下不建议这么做,会影响性能结果的准确性。
noamanelson@noamanelson-Virtual-Machine:~$ uname -a
Linux noamanelson-Virtual-Machine 6.2.0-36-generic #37~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Oct 9 15:34:04 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
x86_64
,选对应的包即可:sudo mkdir /usr/local/java
sudo tar -zxvf jdk-21_linux-x64_bin.tar.gz
export JAVA_HOME=/usr/local/java/jdk-21.0.1
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
source /etc/profile
java -version
查看安装是否ok
即可。mkdir jmeter_test
chmod +755 apache-jmeter-5.6.2.tgz
tar -zxvf apache-jmeter-5.6.2.tgz
# /home/noamanelson/jmeter_test/apache-jmeter-5.6.2
jmeter_scirpt
:# /home/noamanelson/jmeter_test/jmeter_scirpt
mkdir jmeter_scirpt
jmeter_report
:# /home/noamanelson/jmeter_test/jmeter_report
mkdir jmeter_report
jmeter_log
:# /home/noamanelson/jmeter_test/jmeter_log
mkdir jmeter_log
jmeter_result
:# /home/noamanelson/jmeter_test/jmeter_result
mkdir jmeter_result
sudo vim /etc/profile
,最后添加如下内容:export JMETER_HOME=/home/noamanelson/jmeter_test/apache-jmeter-5.6.2
exportCLASSPATH=${JMETER_HOME}/lib/ext/ApacheJMeter_core.jar:${JMETER_HOME}/lib/jorphan.jar:${CLASSPATH}
export PATH=${JMETER_HOME}/bin:$PATH
source /etc/profile
jmeter -v
,如果出现以下内容,说明安装成功了:noamanelson@noamanelson-Virtual-Machine:~$ 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
Options—>Choose Language—>
选择语言(例如:Chinese(Simplified)
简体中文)设置成功。重启Jmeter
又会恢复英文;Jmeter
的bin
目录下,找到jmeter.properties
文档;language
,找到language=en
的行如下图,将en
改为zh_CN
,并且去掉前面的#号,保存退出;vim jmeter.properties
sudo cp ZenTaoPMS-18.8-zbox_amd64.tar.gz /opt/
/opt
目录下:sudo tar -zxvf ZenTaoPMS-18.8-zbox_amd64.tar.gz
Apache
和Mysql
,启动命令如下;/opt/zbox/zbox start
;/opt/zbox/zbox stop
;/opt/zbox/zbox restart
;/opt/zbox/zbox restart
加到操作系统的自启目录。http://禅道服务器ip:apache端口。
特别注意:这里需要开放几个端口:
1、sudo ufw status
查看开放的端口:
2、开放需要的端口:sudo ufw allow
端口
selinux
再刷新网页访问试一下;apache
使用端口;admin
,密码 123456
;/opt/zbox/zbox
会打印输出命令可用参数:Usage: ./zbox {start|stop|status} [--aport=8080] [--mport=3307]
–aport参数 可以修改Apache的端口
–mport参数 可以修改Mysql的端口
adminer
,但是为了安全,访问adminer
的时候需要身份验证,需要运行 sudo /opt/zbox/auth/adduser.sh
来添加用户,如下命令:# 进入脚本目录
cd /opt/zbox/auth
# 执行添加用户的脚本
bash adduser.sh
This tool is used to add user to access adminer
Account: admin # 输入用户名
Password: # 输入密码
Adding password for user admin
1、系 统:默认选择MySQL。
2、服务器:127.0.0.1:MySQL端口
(MySQL端口启用的是3306,那么就填写127.0.0.1:3306。
注意:ip只能写127.0.0.1)
3、用户名:root(禅道默认的数据库用户名是root) 密 码:123456(禅道默认的数据库密码是123456) 数据库:zentao。
# 请求地址:
http://172.26.132.77:80/zentao/api.php/v1/tokens
# 请求方式:
POST
# 请求参数:
{"account": "admin", "password": "123456"}
jmeter
客户端集成jmeter-plugins-manager
插件,在服务端部署插件serverAgent
来实时监控被压测服务器的性能;jmeter
的安装目录lib\ext
下:Jmeter
,点击选项-插件管理器:PerfMon(Servers Performance Monitoring)
选项,点击右下角的Apply Changes and Restart JMeter
按钮应用:linux
上,并解压:sudo unzip ServerAgent-2.2.3.zi
特别注意:
1、默认启动端口为4444;
2、也可以使用命令指定端口启动(例如将指定TCP为5678,UDP指定为6789):./startAgent.sh --tcp-port 5678--udp-port 6789--sysinfo
;
3、建议将此脚本写成shell脚本,授权chmod -R 777 XXX
之后下次直接启动脚本程序。
4、如果提示无法连接到4444端口,需要开放4444端口:sudo ufw allow 4444
jp@gc-PerfMon Metrics Collector
上进行指标选择;AddRow
,然后在host
的地方添加需要监控的服务器的主机域名或者IP,port
填写端口,Metric to collect
下拉选择监控的指标(CPU、Memory、Swap、Disks I/O、Network I/O
等):.jtl
结尾;# /home/noamanelson/jmeter_test/jmeter_scirpt # 脚本路径
# /home/noamanelson/jmeter_test/jmeter_report # 报告路径
# /home/noamanelson/jmeter_test/jmeter_log # 日志路径
# /home/noamanelson/jmeter_test/jmeter_result # 结果路径
jmeter -n -t 脚本路径 -l jtl数据文件路径 -e -o 测试报告存放路径
jmeter -n -t \
./jmeter_scirpt/test_login.jmx -l \
./jmeter_result/test_login.jtl -e -o \
./jmeter_report/
Creating summariser <summary>
Created the tree successfully using ./jmeter_scirpt/test_login.jmx
Starting standalone test @ 2023 Nov 30 16:15:44 CST (1701332144880)
Waiting for possible Shutdown/StopTestNow/HeapDump/ThreadDump message on port 4445
summary + 1133 in 00:00:15 = 76.4/s Avg: 247 Min: 62 Max: 3045 Err: 0 (0.00%) Active: 20 Started: 20 Finished: 0
summary + 2442 in 00:00:30 = 81.7/s Avg: 245 Min: 108 Max: 1383 Err: 0 (0.00%) Active: 20 Started: 20 Finished: 0
summary = 3575 in 00:00:45 = 80.0/s Avg: 245 Min: 62 Max: 3045 Err: 0 (0.00%)
summary + 2585 in 00:00:30 = 86.2/s Avg: 231 Min: 117 Max: 616 Err: 0 (0.00%) Active: 20 Started: 20 Finished: 0
summary = 6160 in 00:01:15 = 82.4/s Avg: 240 Min: 62 Max: 3045 Err: 0 (0.00%)
summary + 2509 in 00:00:30 = 83.6/s Avg: 238 Min: 97 Max: 1172 Err: 0 (0.00%) Active: 20 Started: 20 Finished: 0
summary = 8669 in 00:01:45 = 82.8/s Avg: 239 Min: 62 Max: 3045 Err: 0 (0.00%)
summary + 2644 in 00:00:30 = 88.0/s Avg: 227 Min: 92 Max: 826 Err: 0 (0.00%) Active: 20 Started: 20 Finished: 0
summary = 11313 in 00:02:15 = 84.0/s Avg: 236 Min: 62 Max: 3045 Err: 0 (0.00%)
summary + 2606 in 00:00:30 = 87.0/s Avg: 229 Min: 101 Max: 985 Err: 0 (0.00%) Active: 20 Started: 20 Finished: 0
summary = 13919 in 00:02:45 = 84.5/s Avg: 235 Min: 62 Max: 3045 Err: 0 (0.00%)
summary + 2656 in 00:00:30 = 88.5/s Avg: 226 Min: 110 Max: 1042 Err: 0 (0.00%) Active: 20 Started: 20 Finished: 0
summary = 16575 in 00:03:15 = 85.1/s Avg: 233 Min: 62 Max: 3045 Err: 0 (0.00%)
summary + 2656 in 00:00:30 = 88.5/s Avg: 225 Min: 113 Max: 1199 Err: 0 (0.00%) Active: 20 Started: 20 Finished: 0
summary = 19231 in 00:03:45 = 85.6/s Avg: 232 Min: 62 Max: 3045 Err: 0 (0.00%)
summary + 2724 in 00:00:30 = 90.8/s Avg: 220 Min: 108 Max: 1299 Err: 0 (0.00%) Active: 20 Started: 20 Finished: 0
summary = 21955 in 00:04:15 = 86.2/s Avg: 231 Min: 62 Max: 3045 Err: 0 (0.00%)
summary + 2676 in 00:00:30 = 89.2/s Avg: 223 Min: 88 Max: 1357 Err: 0 (0.00%) Active: 20 Started: 20 Finished: 0
summary = 24631 in 00:04:45 = 86.5/s Avg: 230 Min: 62 Max: 3045 Err: 0 (0.00%)
summary + 1407 in 00:00:16 = 90.6/s Avg: 221 Min: 127 Max: 1441 Err: 0 (0.00%) Active: 0 Started: 20 Finished: 20
summary = 26038 in 00:05:00 = 86.7/s Avg: 230 Min: 62 Max: 3045 Err: 0 (0.00%)
Tidying up ... @ 2023 Nov 30 16:20:45 CST (1701332445534)
... end of run
/home/noamanelson/jmeter_test/jmeter_report
mkdir jmeter_picture
:/home/noamanelson/jmeter_test/jmeter_picture
JMeterPluginsCMD.sh
,看下这个命令有没有问题:$ JMeterPluginsCMD.sh
Error: Unable to access jarfile /home/noamanelson/jmeter_test/apache-jmeter-5.6.2/bin/../lib/cmdrunner-2.2.jar
/home/noamanelson/jmeter_test/apache-jmeter-5.6.2/bin/../lib/cmdrunner-2.2.jar
中的文件是否存在:/home/noamanelson/jmeter_test/apache-jmeter-5.6.2/lib
cmdrunner-2.3.jar
而不是cmdrunner-2.2.jar
,则需要修改JMeterPluginsCMD.sh
文件;JMeterPluginsCMD.sh
文件在/home/noamanelson/jmeter_test/apache-jmeter-5.6.2/bin
目录下:cmdrunner-2.3.jar
:JMeterPluginsCMD.sh --generate-png 存放图片的路径 --input-jtl jtl数据文件路径 --plugin-type PerfMon --width 图片宽度 --height 图片高度
JMeterPluginsCMD.sh \
--generate-png ./jmeter_picture/test_login.png \
--input-jtl ./jmeter_result/test_login.jtl \
--plugin-type PerfMon --width 800 --height 600
csv
文件存放路径,比如/home/noamanelson/jmeter_test/jmeter_csv
:mkdir jmeter_csv
JMeterPluginsCMD.sh --tool Reporter --generate-csv 存放csv路径 --input-jtl 存放jtl数据文件路径 --plugin-type PerfMon
JMeterPluginsCMD.sh \
--tool Reporter \
--generate-csv ./jmeter_csv/test_login.csv \
--input-jtl ./jmeter_result/test_login.jtl \
--plugin-type PerfMon