导读

  1. 各操作系统,GUI和非GUI模式启动JMeter

1、Windows GUI形式运行JMeter

(1)Windows下以GUI的形式运行JMeter很简单,直接双击jmeter.bat文件即可,这是我们前面一直在做的事情。
但是在双击jmeter.bat启动JMeter时,会弹出如下命令行提示符,如下图所示:

这些英文是什么意思呢?翻译如下:

不要使用GUI模式进行负载测试,只用于测试创建和测试调试。对于负载测试,请使用非GUI模式:
命令如下:
jmeter -n -t [jmx file] -l[results file] -e -o[Path to web report folder]

增加Java堆以满足您的测试要求:在jmeter batch文件中修改当前环境变量 HEAP=”-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m”

请参考:https://jmeter.apache.org/usermanual/best-practices.html

关于修改Java堆的原因及方法,我们后续介绍,本篇呢,我们先来看看如何以非GUI模式运行JMeter

2、Windows 非GUI形式运行JMeter

(1)使用“就meter -help”命名查看常用用法

E:\apache-jmeter-4.0\bin>jmeter -help_    ____   _    ____ _   _ _____       _ __  __ _____ _____ _____ ____/ \  |  _ \ / \  / ___| | | | ____|     | |  \/  | ____|_   _| ____|  _ \/ _ \ | |_) / _ \| |   | |_| |  _|    _  | | |\/| |  _|   | | |  _| | |_) |/ ___ \|  __/ ___ \ |___|  _  | |___  | |_| | |  | | |___  | | | |___|  _ <
/_/   \_\_| /_/   \_\____|_| |_|_____|  \___/|_|  |_|_____| |_| |_____|_| \_\ 4.0 r1823414Copyright (c) 1999-2018 The Apache Software Foundation
//上面是版权信息To list all command line options, open a command prompt and type:
//打开命令行窗口,输入下面的命令,可以查看所有命令选项
jmeter.bat(Windows)/jmeter.sh(Linux) -?--------------------------------------------------To run Apache JMeter in GUI mode, open a command prompt and type:
//如果想以GUI模式运行,使用下面的命令
jmeter.bat(Windows)/jmeter.sh(Linux) [-p property-file]--------------------------------------------------To run Apache JMeter in NON_GUI mode:
Open a command prompt (or Unix shell) and type:
//以非GUI模式运行,使用下面的命令
jmeter.bat(Windows)/jmeter.sh(Linux) -n -t test-file [-p property-file] [-l results-file] [-j log-file]--------------------------------------------------To run Apache JMeter in NON_GUI mode and generate a report at end :
Open a command prompt (or Unix shell) and type:
//如果在非GUI模式下运行JMeter,最后想生成一个报告的话,使用下面的命令
jmeter.bat(Windows)/jmeter.sh(Linux) -n -t test-file [-p property-file] [-l results-file] [-j log-file] -e -o [Path to output folder]--------------------------------------------------
To generate a Report from existing CSV file:
Open a command prompt (or Unix shell) and type:
//从一个存在的CSV文件生成报告
jmeter.bat(Windows)/jmeter.sh(Linux) -g [csv results file] -o [path to output folder (empty or not existing)]--------------------------------------------------To tell Apache JMeter to use a proxy server:
Open a command prompt and type:
//JMeter使用代理服务器
jmeter.bat(Windows)/jmeter.sh(Linux) -H [your.proxy.server] -P [your proxy server port]---------------------------------------------------To run Apache JMeter in server mode:
Open a command prompt and type:
//JMeter以server模式运行
jmeter-server.bat(Windows)/jmeter-server(Linux)---------------------------------------------------

(2)查看所有命令行参数

E:\apache-jmeter-4.0\bin>jmeter.bat -?_    ____   _    ____ _   _ _____       _ __  __ _____ _____ _____ ____/ \  |  _ \ / \  / ___| | | | ____|     | |  \/  | ____|_   _| ____|  _ \/ _ \ | |_) / _ \| |   | |_| |  _|    _  | | |\/| |  _|   | | |  _| | |_) |/ ___ \|  __/ ___ \ |___|  _  | |___  | |_| | |  | | |___  | | | |___|  _ <
/_/   \_\_| /_/   \_\____|_| |_|_____|  \___/|_|  |_|_____| |_| |_____|_| \_\ 4.0 r1823414Copyright (c) 1999-2018 The Apache Software Foundation--?print command line options and exit-h, --helpprint usage information and exit-v, --versionprint the version information and exit-p, --propfile <argument>the jmeter property file to use-q, --addprop <argument>additional JMeter property file(s)-t, --testfile <argument>the jmeter test(.jmx) file to run. "-t LAST" will load lastused file-l, --logfile <argument>the file to log samples to-i, --jmeterlogconf <argument>jmeter logging configuration file (log4j2.xml)-j, --jmeterlogfile <argument>jmeter run log file (jmeter.log)-n, --nonguirun JMeter in nongui mode-s, --serverrun the JMeter server-H, --proxyHost <argument>Set a proxy server for JMeter to use-P, --proxyPort <argument>Set proxy server port for JMeter to use-N, --nonProxyHosts <argument>Set nonproxy host list (e.g. *.apache.org|localhost)-u, --username <argument>Set username for proxy server that JMeter is to use-a, --password <argument>Set password for proxy server that JMeter is to use-J, --jmeterproperty <argument>=<value>Define additional JMeter properties-G, --globalproperty <argument>=<value>Define Global properties (sent to servers)e.g. -Gport=123or -Gglobal.properties-D, --systemproperty <argument>=<value>Define additional system properties-S, --systemPropertyFile <argument>additional system property file(s)-f, --forceDeleteResultFileforce delete existing results files before start the test-L, --loglevel <argument>=<value>[category=]level e.g. jorphan=INFO, jmeter.util=DEBUG or com.example.foo=WARN-r, --runremoteStart remote servers (as defined in remote_hosts)-R, --remotestart <argument>Start these remote servers (overrides remote_hosts)-d, --homedir <argument>the jmeter home directory to use-X, --remoteexitExit the remote servers at end of test (non-GUI)-g, --reportonly <argument>generate report dashboard only, from a test results file-e, --reportatendofloadtestsgenerate report dashboard after load test-o, --reportoutputfolder <argument>output folder for report dashboard

(3)JMeter环境变量
顺便解决个问题。如果你打开命令行窗口,直接运行上面的命令,应该会报找不到JMeter的错误,这是因为没有配置环境变量。因为我Windows下面一般双击jmeter.bat文件运行GUI模式,所以一直没配置JMeter的环境变量,要想用JMeter命令的话,可以先cd到jmeter的安装目录的bin目录下面,执行上面的命令就可以了。如果觉得麻烦,那就看看下面的步骤,配置下环境变量

  • 添加JMETER_HOME=E:\apache-jmeter-4.0
  • 添加PATH=%JMETER_HOME%\bin
  • 添加
    CLASSPATH=%JMETER_HOME%\lib\ext\ApacheJMeter_core.jar;%JMETER_HOME%\lib\jorphan.jar;

然后重启命令行窗口,即可直接执行jmeter命令。

(4)执行一个最简单的命令

C:\Users\admin>jmeter.bat -n -t E:\Script.jmx -l E:\res.jtl
Creating summariser <summary>
Created the tree successfully using E:\Script.jmx
Starting the test @ Tue Mar 20 16:52:12 CST 2018 (1521535932191)
Waiting for possible Shutdown/StopTestNow/Heapdump message on port 4445
summary =     20 in 00:00:14 =    1.4/s Avg:  3054 Min:    37 Max:  6736 Err:     0 (0.00%)
Tidying up ...    @ Tue Mar 20 16:52:27 CST 2018 (1521535947734)
... end of run

(5)将生成的结果文件用Jmeter图形化工具打开

步骤:

  • 添加一个线程组
  • 添加一个聚合报告
  • 点击Browser,浏览到上面生成的res.jtl,就可以得到上面的截图。

3、Mac GUI形式运行JMeter

打开terminal,进入到bin目录,直接输入命令 sh jmeter即可
或者双击jmeter.sh

4、Mac非GUI形式运行JMeter

命令一致

5、Linux 非GUI形式运行JMeter

(1)下载JMeter的tgz包

wget http://mirrors.tuna.tsinghua.edu.cn/apache//jmeter/binaries/apache-jmeter-4.0.tgz

(2)解压缩

[root@Beta-nginx bin]# gunzip apache-jmeter-4.0.tgz
[root@Beta-nginx bin]# tar -xvf apache-jmeter-4.0.tar

(3)运行

jmeter.sh -n -t /test-file/Script.jmx -l ./res-linux.jtl

6、分布式运行JMeter

在使用Jmeter进行性能测试时,如果要求并发比较大,单台电脑的配置(CPU、内存)可能无法支持,这就可以使用JMeter分布式测试。
(1)分布式测试原理

  • 选择一台机器作为调度机(master),其它机器作为执行机(slave)
  • 执行时,master会把脚本发送到每台slave上,slave拿到脚本后就开始执行,slave执行时不需要启动GUI
  • 执行完成后,slave会把结果回传给master,master会收集所有slave的信息并汇总

(2)执行机(slave)的配置,我们称之为server

  • 首先需要安装JMeter;
  • 配置环境变量
  • 修改jmeter.properties文件的几个选项(待补充)

(3)控制机(master)的配置,我们称之为client
从JMeter 4.0开始,需要生成rmi_keystore.jks文件,最简单的方法是,windows下双击bin目录下的create-rmi-keystore.bat文件,即可。然后将该文件上传到server端的bin目录下。

  • 修改jmeter.properties文件的几个选项(待补充)

(4)在server端,启动jmeter-server.bat(或者jmeter-server)
(5)在client端,启动jmeter
(6)通过client,连接启动server机

注:分布式部署遇到了一些问题,稍后整理完,更新本篇博客。

10-性能测试之JMeter运行方式相关推荐

  1. 性能测试之Jmeter元件

    性能测试之Jmeter元件 1.性能测试的本质 性能测试的定义 基于协议模拟用户发请求,对服务器形成一定的负载,来测试服务器的性能指标是否满足用户(产品&公司)的需求. 关注点 时间性能 空间 ...

  2. 性能测试之JMeter函数助手详解

    1.函数助手介绍 在性能测试过程中,为了模拟真实的用户,往往我们需要让提交的表单内容每次都发生变化,这个过程叫做参数化. JMeter中的配置元件与前置处理器都能帮助我们实现参数化,为了能够更好的帮助 ...

  3. 性能测试之JMeter测试结果写入Excel

    在使用JMeter进行测试的过程中,有时候需要将测试结果写入到Excel文件,本篇文章将详细说明具体步骤. 把测试结果写入Excel文件中操作思路分析: (1)准备需要的环境 引入操作Excel文件的 ...

  4. 多测师肖sir__性能测试之jmeter操作(2)

    一.jmeter 介绍 1·.jmeter jmeter 性能测试工具,是apache组织开发基于java的压力测试工具. 2.jmeter 的特点 (1)jmeter可以对http和ftp 服务器进 ...

  5. 性能测试之Jmeter参数化

    01.Jmeter参数化作用 参数化就是将某一些请求中的一些参数值替换为动态的请求,比如第一次请求的值是a,下一次迭代请求想变成b,这就是典型的参数化场景.     其目的在于模块真实的用户请求. 0 ...

  6. jmeter csv参数化_性能测试之Jmeter中如何设置参数化数据

    参数化配置 jmeter中进行参数化设置,右击测试计划或者线程组,add->config element->CSV Data Set Config参数1.png Allow quoted ...

  7. jmeter 线程执行顺序_性能测试之jmeter逻辑控制种类详解一

    逻辑控制器介绍 Jmeter逻辑控制可以对元件的执行逻辑进行控制,除Once only Controller仅一次控制器以外,其他控制器都可以可以嵌套其他种类的控制器,下面是jmeter5.3支持的控 ...

  8. 性能测试之JMeter配置元件【HTTP信息头管理器】

    JMeter提供了丰富的配置元件,常用的包括参数化配置元件.HTTP请求默认值.HTTP信息头管理器.计数器等,这些配置元件用于设置默认值和变量,提供给后面的sampler(取样器)使用. 提示:本文 ...

  9. 性能测试之JMeter主页面布局

    在介绍JMeter主页面布局的菜单栏和图标之前,我们可以把语言切换为简体中文,如下图所示: JMeter的主界面布局分为标题栏.菜单栏.工具栏.树形标签栏和内容栏,如下图所示: 接下来我们来逐一说明. ...

  10. 性能测试之JMeter取样器详解:sampler

    1.取样器介绍 取样器是用来模拟用户操作的,向服务器发送请求以及接收服务器的响应数据. 取样器是在线程组内部的元件,也就是说取样器只能在线程组中添加. 取样器(Sampler)是性能测试中向服务器发送 ...

最新文章

  1. Java基础知识强化之IO流笔记41:字符流缓冲流之复制文本文件案例02(使用 [ newLine() / readLine() ] )(重要)...
  2. 代理中调用alert()
  3. 用UltraISO制作Ubuntu20.04 U盘启动盘
  4. 【数据结构】除去线性表中的重复数字
  5. MySql 踩坑小记
  6. inheritance中文Java语言_3.3Java语言面向对象的封装(Encapsulation)、继承(Inheritance)、多态(polymorphic)...
  7. BZOJ 2733 线段树的合并 并查集
  8. 爬虫1_python2
  9. 物联网应用领域-物联网智能安全始于产品开发
  10. 深入理解JavaScript中的this关键字
  11. FLASH+XML:构建简单易更新网站
  12. jquery实现进度条
  13. jrebel IDEA热部署插件激活
  14. paypal支付交易数据
  15. 语音领域的波束形成Beamforming小结
  16. Day-3 文字排版
  17. 开发也可以如此简单!华为云发布两款开发工具
  18. Samara SAU ACM ICPC Quarterfinal Qualification Contest 2012
  19. 使用AlphaFold2进行蛋白质结构预测
  20. 【具体实现过程】百度地图POI区域的边界经纬度坐标数据采集

热门文章

  1. linux怎么挂载手机内部储存,Android获取内置、外置以及OTG等方式挂载的存储设备路径...
  2. Spectacle源码编译方法
  3. JAVA开发环境六个部分的安装——个人需求向(实习第一天)
  4. 网页中视频的下载方法
  5. KDNM5000-10A-2剩余电流保护器测试仪
  6. 均方误差越大越好_直观理解为什么分类问题用交叉熵损失而不用均方误差损失?...
  7. 七牛上传的视频,让截图变成一张独立存在的图片(持久化数据处理)
  8. 《复联4》上映首日票房过6亿,影评两极分化,这份数据分析报告必看!
  9. MyBatis梳理27题1-10
  10. 基于Hadoop的数据云盘的实现