1.下载jmeter
所有版本:https://archive.apache.org/dist/jmeter/binaries/
wget下载指定版本(由于下载太慢,我是从本地下载好,再上传到linux上)
[root@localhost ~]# wget https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-5.2.tgz
2.下载ant
所有版本:https://downloads.apache.org/ant/binaries/
下载后上传到linux
3.解压
[root@localhost ~]# tar -xvf apache-jmeter-5.2.1.tgz
[root@localhost ~]# tar -xzvf apache-ant-1.9.16-bin.tar.gz
4.设置环境变量
命令: vi /etc/profile
添加到文件里保存并退出
#ANT_HOME
ANT_HOME=/root/apache-ant-1.9.16
export PATH=
P
A
T
H
:
PATH:
PATH:ANT_HOME/bin
export PATH=
P
A
T
H
:
PATH:
PATH:ANT_HOME/lib
5.保存退出后输入命令使环境变量立即生效 source /etc/profile
[root@localhost apache-ant-1.9.16]# source /etc/profile
输入命令验证版本:ant -version
[root@localhost apache-ant-1.9.16]# ant -version
Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-1.el7.x86_64/lib/tools.jar
Apache Ant(TM) version 1.9.16 compiled on July 10 2021
6.jmeter配置
将jmeter目录bin\jmeter.properties的488行-526行改为如下:
注意:是jmeter.properties文件,在488-526行中,凡是有jmeter开头的且有#号都需要去掉
改完后再把这个文件重新上传并用vi查看是否完成配置
7.ant配置
将apache-jmeter-5.3\extras目录下的:ant-jmeter-1.1.1.jar 复制到apache-ant-1.9.15\lib\
[root@localhost extras]# cp ant-jmeter-1.1.1.jar ../../apache-ant-1.9.16/lib/
8.创建文件目录(也可本地创建好了在上传)
9.修改build.xml文件(可以在本地修改好了在上传)
10.在build.xml文件目录下运行ant
查看报告
11.配置发送邮件
下载commons-email.jar activation-1.1.1.jar mail.jar放到ant下的lib目录下
下载地址:https://commons.apache.org/proper/commons-email/download_email.cgi
http://www.java2s.com/Code/Jar/a/Downloadactivation111jar.htm
https://github.com/javaee/javamail/releases
修改build.xml文件
详细参照:https://www.cnblogs.com/jpr-ok/p/10780162.html
修改后上传到linux,执行ant
收到邮件
遇到的坑:Could not load definitions from resource net/sf/antcontrib/antcontrib.properties
原因:缺少ant-contrib.jar包,自行下载一个放到ant的lib目录下
下载地址:https://sourceforge.net/projects/ant-contrib/files/ant-contrib/ant-contrib-0.6/
You must set jmeterhome to your JMeter install directory(必须将jmeterhome设置为JMeter安装目录)
原因:jmeter路径配置错误