Linux系统启动jmeter可视化界面
阅读原文时间:2023年08月09日阅读:1

目的:方便在Linux系统调试jmeter脚本。
操作:Linux启动jmeter可视化界面,不能使用root用户,需要创建新用户,切换到新用户启动jmeter。


1. 创建用户

  创建一个新的系统用户。

[yyuser@zwzf-cwy-lzy-7-new ~]$ sudo -i
[root@zwzf-cwy-lzy-7-new ~]# useradd jmeter
[root@zwzf-cwy-lzy-7-new ~]# passwd jmeter
Changing password for user jmeter.
New password:
BAD PASSWORD: The password contains the user name in some form
Retype new password:
passwd: all authentication tokens updated successfully.
[root@zwzf-cwy-lzy-7-new ~]#

2. 用户赋权

  给新建系统用户赋予jmeter环境变量所在路径访问权限。

[root@zwzf-cwy-lzy-7-new opt]# chown -R jmeter /opt/apache-jmeter-5.4.1

3. 登录新用户

  重新访问虚拟机,登录新建用户。

[yyuser@zwzf-cwy-lzy-7-new ~]$ su - jmeter
Password:
[jmeter@zwzf-cwy-lzy-7-new ~]$

4. 启动jmeter

  使用新用户,启动jmeter图形化界面。

[jmeter@zwzf-cwy-lzy-7-new ~]$ jmeter
Apr 06, 2023 3:47:35 PM java.util.prefs.FileSystemPreferences$1 run

INFO: Created user preferences directory.

Don't use GUI mode for load testing !, only for Test creation and Test debugging.
For load testing, use CLI Mode (was NON GUI):
jmeter -n -t [jmx file] -l [results file] -e -o [Path to web report folder]
& increase Java Heap to meet your test requirements:
Modify current env variable HEAP="-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m" in the jmeter batch file

Check : https://jmeter.apache.org/usermanual/best-practices.html

[2023-04-06 15:47:37] [WARNING] System property 'awt.useSystemAAFontSettings' is not set. Using 'LCD HRGB antialiasing text mode'
It's recommended to manually add the property to the JVM startup parameters on your platform for optimal text antialiasing. Refer to the [documentation](https://docs.oracle.com/javase/8/docs/technotes/guides/2d/flags.html#aaFonts)for more information on the possible values. [at com.github.weisj.darklaf.task.FontDefaultsInitTask]
Apr 06, 2023 3:47:37 PM com.kitfox.svg.Text buildText
WARNING: Could not create font Arial
Apr 06, 2023 3:47:37 PM com.kitfox.svg.Text buildText
WARNING: Could not create font Arial
Apr 06, 2023 3:47:37 PM com.kitfox.svg.Text buildText
WARNING: Could not create font Arial
Apr 06, 2023 3:47:37 PM com.kitfox.svg.Text buildText
WARNING: Could not create font Arial
Apr 06, 2023 3:47:38 PM com.kitfox.svg.Text buildText
WARNING: Could not create font Arial


使用root用户,会出现如下问题:

[root@zwzf-cwy-lzy-13 jmeter]# jmeter

Don't use GUI mode for load testing !, only for Test creation and Test debugging.
For load testing, use CLI Mode (was NON GUI):
jmeter -n -t [jmx file] -l [results file] -e -o [Path to web report folder]
& increase Java Heap to meet your test requirements:
Modify current env variable HEAP="-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m" in the jmeter batch file

Check : https://jmeter.apache.org/usermanual/best-practices.html

An error occurred: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.