1、进入官网下载Jmeter
国内镜像(下载的慢的话可以用国内镜像下载)
https://mirrors.cloud.tencent.com/apache/jmeter/binaries/
2、跳转到下载页面

3、根据不同系统下载相应版本的Jmeter压缩包,Linux系统下载tgz那个压缩包,Window系统下载zip压缩包(我这里用Window版来做示范)

4、下载完压缩包后解压压缩包


5、为Jmeter配置环境变量
注意!在运行Jmeter的时候需要用到JDK,在运行Jmeter之前需要先安装JDK1.8及以上的版本,没有安装的请先自行安装
(1)右击"此电脑",点击属性

(2)点击"高级系统设置"

(3)点击"环境变量"

(4)点击新建系统变量

(5)新建变量名为JMETER_HOME的系统变量,变量值为Jmeter的路径

(6)新建变量名为classpath的系统变量,变量值为%JMETER_HOME%\lib\ext\ApacheJMeter_core.jar;%JMETER_HOME%\lib\jorphan.jar;%JMETER_HOME%\lib/logkit-2.0.jar;

(7)点击确定保存变量然后退出


(8)完成系统变量的配置后即可点击bin目录下的jmeter.bat脚本来启动Jmeter

效果图:

6、使用Jmeter测试接口
(1)右击Test Plan,然后添加一个线程组

效果图:

(2)填写线程组的名称,设置线程数(线程数就是并发的用户数量)、执行时间、执行次数,图里我设置了20000的并发数

(3)按Ctrl+S保存线程组

(4)新建HTTP请求测试

效果图:

(5)填写请求测试的相关参数


(6)填写完毕后即可启动程序进行压力测试

(7)点击STOP可以停止程序运行,停止压力测试
