------------------------------------------------------------------- 

转载自:北京-宏哥 https://www.cnblogs.com/du-hong/p/13667219.html 

--------------------------------------------------------------------

Jmeter(三十九) - 从入门到精通进阶篇 - Jmeter配置文件的刨根问底 - 上篇(详解教程)

 

1.简介

为什么宏哥要对Jmeter的配置文件进行一下讲解了,因为有的童鞋或者小伙伴在测试中遇到一些需要修改配置文件的问题不是很清楚也不是很懂,就算修改了也是模模糊糊的。更有甚者觉得那是禁地神圣不可轻犯不敢触碰不敢修改,害怕修改错了Jmeter运行不了了。听宏哥的大胆修改大不了再重新安装一个新的Jmeter,或者你有做备份的好习惯,在修改前备份好以后大胆修改,修改错了直接使用备份文件恢复过来就可以。

2.配置文件

在%JMETER_HOME%\bin(or $JMETER_HOME/bin)目录下搜索框中输入:properties 会发现存在多个配置文件,如下图所示:

宏哥接下来将按照其的重要性的先后顺序进行一一讲解和说明,其中最重要的是jmeter.properties.是Jmeter核心配置项文件,下面对其常用的一些配置项的设置进行总结与说明.

2.官方建议

将需要修改的属性值,复制粘贴到同目录下的 user.properties ,这里就是简单的提一下,后边再介绍user.properties文件

好处:当Jmeter升级时,可以避免修改项需要重新应用

3.jmeter.properties文件

由于这个文件太大了,宏哥在这里就翻译了其中的一部分,有兴趣的可以全部翻一下看看到底都是干什么的。

3.1文件许可证说明

3.1.1第1段——许可证说明

(1)原文

################################################################################
# Apache JMeter Property file
################################################################################ ## Licensed to the Apache Software Foundation (ASF) under one or more
## contributor license agreements. See the NOTICE file distributed with
## this work for additional information regarding copyright ownership.
## The ASF licenses this file to You under the Apache License, Version 2.0
## (the "License"); you may not use this file except in compliance with
## the License. You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.

(2)译文

# 示例user.properties文件
#
## Apache软件基金会(ASF)下一个或多个许可
## 贡献者许可协议。请参阅
## 此作品用于获取关于版权所有权的附加信息。
## ASF根据Apache 2.0 版本许可证协议将此文件授权给您。
## (“许可证”);除非符合以下条件,否则不能使用此文件
## 许可证。您可以在
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## 除非适用法律要求或书面同意,软件
## 根据在“AS IS”BASIS上分发的许可证基础上发布的,
## 无任何明示或暗示的保证或条件。
## 有关管理权限的特定语

3.2文件修改说明

3.2.1第2段——用于说明jmeter.properties文件

(1)原文

################################################################################
#
# THIS FILE SHOULD NOT BE MODIFIED
#
# This avoids having to re-apply the modifications when upgrading JMeter
# Instead only user.properties should be modified:
# 1/ copy the property you want to modify to user.properties from jmeter.properties
# 2/ Change its value there
#
################################################################################ # JMeter properties are described in the file
# http://jmeter.apache.org/usermanual/properties_reference.html
# A local copy can be found in
# printable_docs/usermanual/properties_reference.html #Preferred GUI language. Comment out to use the JVM default locale's language.
#language=en # Additional locale(s) to add to the displayed list.
# The current default list is: en, fr, de, no, es, tr, ja, zh_CN, zh_TW, pl, pt_BR
# [see JMeterMenuBar#makeLanguageMenu()]
# The entries are a comma-separated list of language names
#locales.add=zu

(2)译文

################################################################################
#
# 这个文件不应该被修改
#
# JMeter这就避免了在升级JMeter时必须重新应用配置而再次修改
# user.properties文件的修改代替这里文件的修改:
# 1/ 从jmeter.properties文件中复制要修改的属性到user.properties文件中修改
# 2/ 在user.properties文件中修改复制属性的值
#
################################################################################ # 这个文件中描述了JMeter的配置
# 文件访问地址:http://jmeter.apache.org/usermanual/properties_reference.html
# 这个文件的副本在本地也可以找到
# 本地文件的位置:printable_docs/usermanual/properties_reference.html #首选GUI语言。注释掉以使用JVM默认语言环境的语言。
#language=en # 要添加到显示列表的其他区域设置。
# 当前默认的列表: en, fr, de, no, es, tr, ja, zh_CN, zh_TW, pl, pt_BR
# [请参见JMeterMenuBar\35; MakeLanguageenu()]
# 这些条目是以逗号分隔的语言名称列表
#locales.add=zu

3.3说明XML解析器

3.3.1第3段——用于说明XML解析器

(1)原文

#---------------------------------------------------------------------------
# XML Parser
#--------------------------------------------------------------------------- # Path to a Properties file containing Namespace mapping in the form
# prefix=Namespace
# Example:
# ns=http://biz.aol.com/schema/2006-12-18
#xpath.namespace.config= # XPath2 query cache for storing compiled XPath queries
#xpath2query.parser.cache.size=400

(2)译文

#---------------------------------------------------------------------------
# XML 解析器
#--------------------------------------------------------------------------- # 包含格式为prefix = Namespace的名称空间映射的属性文件的路径。例子:
# prefix=Namespace
# Example:
# ns=http://biz.aol.com/schema/2006-12-18
#xpath.namespace.config= # 查询缓存,用于存储编译的XPath查询,默认为400
#xpath2query.parser.cache.size=400

3.4说明SSL配置

3.4.1第4段——用于说明SSL配置

(1)原文

#---------------------------------------------------------------------------
# SSL configuration
#--------------------------------------------------------------------------- ## SSL System properties are now in system.properties # JMeter no longer converts javax.xxx property entries in this file into System properties.
# These must now be defined in the system.properties file or on the command-line.
# The system.properties file gives more flexibility. # By default, SSL session contexts are now created per-thread, rather than being shared.
# The original behaviour can be enabled by setting the JMeter property to true
#https.sessioncontext.shared=false # Be aware that https default protocol may vary depending on the version of JVM
# See https://blogs.oracle.com/java-platform-group/entry/diagnosing_tls_ssl_and_https
# See https://bz.apache.org/bugzilla/show_bug.cgi?id=58236
# Default HTTPS protocol level:
#https.default.protocol=TLS
# This may need to be changed here (or in user.properties) to:
#https.default.protocol=SSLv3 # List of protocols to enable. You may have to select only a subset if you find issues with target server.
# This is needed when server does not support Socket version negotiation, this can lead to:
# javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
# java.net.SocketException: Connection reset
# see https://bz.apache.org/bugzilla/show_bug.cgi?id=54759
#https.socket.protocols=SSLv2Hello SSLv3 TLSv1 # Control if we allow reuse of cached SSL context between iterations
# set the value to 'false' to reset the SSL context each iteration
# Deprecated since 5.0
#https.use.cached.ssl.context=true #
# Reset HTTP State when starting a new Thread Group iteration which means:
# true means next iteration is associated to a new user
# false means next iteration is associated to same user
# true involves:
# - Closing opened connection
# - resetting SSL State
#httpclient.reset_state_on_thread_group_iteration=true # Start and end index to be used with keystores with many entries
# The default is to use entry 0, i.e. the first
#https.keyStoreStartIndex=0
#https.keyStoreEndIndex=0

(2)译文

#---------------------------------------------------------------------------
# SSL 配置
#--------------------------------------------------------------------------- ## SSL系统属性现在位于system.properties中 # JMeter不再转换javax。jmeter.properties中的xxx属性条目 进入系统属性
# 现在必须在system.properties文件或命令行中定义它们。
# 在 system.properties文件提供了更多的灵活性。 # By default, SSL session contexts are now created per-thread, rather than being shared.默认情况下,SSL会话上下文现在是按线程创建的,而不是共享的。
# 可以通过将此属性设置为true来启用原来行为。默认为:false
#https.sessioncontext.shared=false # 请注意,https默认协议可能会根据JVM的版本而有所不同。
# See https://blogs.oracle.com/java-platform-group/entry/diagnosing_tls_ssl_and_https
# See https://bz.apache.org/bugzilla/show_bug.cgi?id=58236
# 默认HTTPS协议级别:
#https.default.protocol=TLS
# 这可能需要(或者在user.properties文件中) 更改为:
#https.default.protocol=SSLv3 # 要启用的协议列表。如果发现目标服务器有问题,则可能只需要选择一个子集。
# 如果服务器不支持Socket版本协商,则需要这样做,这可能导致以下错误:
# javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
# java.net.SocketException: Connection reset
# see https://bz.apache.org/bugzilla/show_bug.cgi?id=54759
#https.socket.protocols=SSLv2Hello SSLv3 TLSv1 # 控制是否允许在迭代之间重用缓存的SSL上下文。
# 将值设置为false可在每次迭代时重置SSL上下文。默认为:true
# Deprecated since 5.0
#https.use.cached.ssl.context=true #
# 开始新的线程组迭代时,重置HTTP状态。
# true表示下一次迭代与新用户相关联。
# false表示下一次迭代与同一用户相关联。
# true 涉及:
# - 关闭打开的连接
# - 重置SSL状态
#httpclient.reset_state_on_thread_group_iteration=true # 与具有许多条目的密钥库一起使用的起始索引和结束索引。
# 默认值是使用条目0,即第一个。
#https.keyStoreStartIndex=0
#https.keyStoreEndIndex=0

下边宏哥就挑一些常用和重要的和童鞋们或者小伙伴们分享一下。

4.GUI语言

4.1Windows系统

4.1.1方法一

——修改Options
依次点击Options-->Choose Language-->Chinese(Simplified)即可配置成中文简体,需注意的是该方法只对当次生效,下次打开Jmeter依然是英文。如需永久生效,请使用下面两种方法。

4.1.2方法二

——修改jmeter.properties文件

打开jmeter解压缩文件下的bin目录,找到jmeter.properties文件并用编辑器打开,
在#language=en下面插入一行language=zh_CN,修改后保存
重新启动Jmeter界面显示为中文简体

注意:

功能:设置JMeter GUI界面的显示语言
说明:若没有设置,则使用JVM(Java虚拟机)设置的locale语言.
4.1.3方法三

——修改jmeter.bat文件

使用编辑器打开JMeter启动文件jmeter.bat
将set JMETER_LANGUAGE=-Duser.language="en" -Duser.region="EN"修改成set JMETER_LANGUAGE=-Duser.language="zh" -Duser.region="CN",保存代码
重新启动Jmeter界面显示为中文简体

4.2Linux系统

在Linux中可以设置JVM的locale:

[root@localhost ~]# locale
LANG=zh_CN.UTF-8
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_ALL=
[root@localhost ~]# vi /etc/sysconfig/i18n
[root@localhost ~]# cat !$
cat /etc/sysconfig/i18n
LANG="zh_CN.UTF-8"
[root@localhost ~]#

注意:此配置项只能在jmeter.properties中设置才有效。

5.GUI图标放大比例设置

5.1JMeter GUI界面布局

当JMeter以GUI模式运行时,窗口主要由三部分构成:
1.功能区
上方菜单栏,下方工具栏。菜单栏展示了JMeter提供的功能菜单,而工具栏中的图标
是常见功能的快捷方式。
2.视图区
以树状结构呈现JMeter元素,其中“Test Plane”是树的根节点,每一个节点就是一个JMeter元素。
在此区域可以添加、删除节点或者通过拖曳调整节点的位置。
3.内容区
当在视图区选中一个JMeter元素节点时,内容区则会相应地显示该元素的内容。
这时可以对其内容进行查看、设置等操作。

5.2GUI图标放大比例设置

jmeter.hidpi.mode=true #开启视网膜模式
jmeter.hidpi.scale.factor=1.2 #将图标放大1.2倍

5.3功能区工具栏图标大小设置

#工具栏图标默认size: 22x22
#可用size: 22x22, 32x32, 48x48
jmeter.toolbar.icons.size=32x32

5.4视图区目录树图标大小设置

#目录树图标默认size: 19x19
#可用size: 19x19, 24x24, 32x32, 48x48
jmeter.tree.icons.size=24x24

5.5内容区编辑字体设置

#调整JMeter内容区的编辑字体
jsyntaxtextarea.font.family=consolas #默认Hack,太难看,使用经典的consolas
jsyntaxtextarea.font.size=18 #这两个配置项必须同时设置才有效

5.6响应数据编码设置

#响应数据编码默认为ISO-8859-1(即Latin-1)
sampleresult.default.encoding=UTF-8 #设置为UTF-8,避免出现乱码

6.添加JMeter元素快捷键设置

#配置添加JMeter元素时使用的快捷键,最多支持10个.
#在windows上可以使用 Ctrl+0 Ctrl+1 ... Ctrl+9
#在macOS上可以使用 Command+0 Command+1 ... Command+9
gui.quick_0=ThreadGroupGui #新增线程组
gui.quick_1=HttpTestSampleGui #新增HTTP取样器
gui.quick_2=RegexExtractorGui #新增正则表达式提取器
gui.quick_3=AssertionGui #新增响应断言
gui.quick_4=ConstantTimerGui #新增常量定时器
gui.quick_5=TestActionGui #新增测试活动
gui.quick_6=JSR223PostProcessor #新增JSR223 后置处理程序
gui.quick_7=JSR223PreProcessor #新增JSR223 预处理程序
gui.quick_8=DebugSampler #新增调试取样器
gui.quick_9=ViewResultsFullVisualizer #新增察看结果树

7.HTTP Request Post Content-Type设置

# Should JMeter add to POST request content-type header if missing:
# Content-Type: application/x-www-form-urlencoded
# Was true before version 5.0
post_add_content_type_if_missing=true
说明:此配置项在JMeter5.0以前默认值为true,以后版本默认为false,故在5.0以后的版本中
发送POST请求,将参数放在"body data"中,且没有设置
Content-Type时,默认为Content-Type值为"text/plain",而不是"application/x-www-form-urlencoded".

8.小结

1.宏哥在设置GUI语言的时候发现,宏哥的jmeter.properties文件中设置注释掉了,而且宏哥用的是win10默认的locale语言默认是中文但是宏哥启动jmeter后,发现GUI的语言还是英文。经过一系列研究发现是因为jmeter.bat文件中还有语言设置。

使用编辑器打开JMeter启动文件jmeter.bat
将set JMETER_LANGUAGE=-Duser.language="en" -Duser.region="EN"修改成set JMETER_LANGUAGE=-Duser.language="zh" -Duser.region="CN",保存代码
重新启动Jmeter界面显示为中文简体

2.jvm中的语言都是取得系统locale语言
(1)Windows系统

a.输入命令:java -X

b.输入命令:java -XshowSettings:locale

(2)Linux系统

a.输入命令:java -X

b.输入命令:java -XshowSettings:locale

好了今天就分享到这里吧,希望大家喜欢,同时也感谢您耐心的阅读本文!!!

最新文章

  1. Scalaz(0) - 写在前面
  2. hdu2807 矩阵乘法+floyd
  3. Linux netstat详解
  4. hadoop 常见问题
  5. [转]SQLITE3 C语言接口 API 函数简介
  6. 将多个网页制作成一个CHM文件
  7. android 28 SimpleAdapter
  8. C++ 用libcurl库进行http 网络通讯编程
  9. linux内核函数之 blk_plug
  10. mysql 发生系统错误 1067
  11. ASP.NET中登录时记住用户名和密码(附源码下载)--ASP.NET
  12. python 整理数据中的图片
  13. 根据select出来的数据进行update
  14. openstack 网络更改版
  15. 数位dp讲解及模板
  16. 关于MySQL 8.0的几个重点【转】
  17. Java 并发优化
  18. jquery智能弹出层,自己主动推断位置
  19. 注册vue组件的几种方式
  20. Hadoop中Partition深度解析

热门文章

  1. js类型以及存储方式
  2. Springboot2.0解决跨域问题
  3. 基于AD9361的双收双发射频FMC子卡
  4. 下载nvm并安装vue环境
  5. 【面试题】JS 中这些继承方式你知道吗?
  6. mysql 备份定时任务
  7. Mysql之迂回连接术
  8. 如何修改驱动使得NVIDIA Geforce GTX 970, 980, 980 TI and Titan X等显卡可以在Win XP/Win 2003 server x64下驱动?
  9. for循环axios套axios调用,同步调取
  10. mysql 优化表空间报错Creating index 'PRIMARY' required more than 'innodb_online_alter_log_max_size' bytes of modification log. Please try again