首页 > 代码库 > JMeter学习-038-JMeter Linux 环境配置
JMeter学习-038-JMeter Linux 环境配置
1.1.下载
Download URL:http://mirrors.tuna.tsinghua.edu.cn/apache//jmeter/binaries/apache-jmeter-3.0.tgz
Plugins URL:https://github.com/undera/jmeter-plugins
执行命令如下所示:
1 $ wget http://mirrors.tuna.tsinghua.edu.cn/apache//jmeter/binaries/apache-jmeter-3.0.tgz 2 --2016-11-03 23:35:12-- http://mirrors.tuna.tsinghua.edu.cn/apache//jmeter/binaries/apache-jmeter-3.0.tgz 3 Resolving mirrors.tuna.tsinghua.edu.cn... 166.111.206.63, 2402:f000:1:416:166:111:206:63 4 Connecting to mirrors.tuna.tsinghua.edu.cn|166.111.206.63|:80... connected. 5 HTTP request sent, awaiting response... 200 OK 6 Length: 45178166 (43M) [application/octet-stream] 7 Saving to: “apache-jmeter-3.0.tgz” 8 9 100%[================================================================================================>] 45,178,166 6.81M/s in 6.2s 10 11 2016-11-03 23:35:19 (6.92 MB/s) - “apache-jmeter-3.0.tgz” saved [45178166/45178166]
拷贝、解压、重命名、查看jmeter脚本是否有可执行权限。若无,则添加可执行权限。
1 $ cp apache-jmeter-3.0.tgz /data/qa-smjr/jmeter/ 2 $ tar zxvf apache-jmeter-3.0.tgz 3 $ mv apache-jmeter-3.0 apache-jmeter-3.0.2 4 $ ll apache-jmeter-3.0.2/bin/jmeter
PS:jmeter的最终解压目录不建议放在Linux用户目录下。因用户目录是私有的,Linux中不允许非管理员访问其他用户的目录。若jmeter放在用户目录下,则即使为用户(例如FengpingFan)配置了相应的JMeter环境变量,用户FengpingFan也无法通过执行jmeter。
1.2.环境变量配置
为指定用户配置环境变量,是通过用户目录下的用户配置文件{.bash_profile}实现的,此文件为隐藏文件,可通过 ll -al 查看。将JMeter的环境变量配置文件中,即可实现指定用户的环境配置。添加内容如下所示:
1 # User specific environment and startup programs 2 3 export JMETER_HOME=/data/qa-smjr/jmeter/apache-jmeter-3.0.2 4 export CLASSPATH=$JMETER_HOME/lib/ext/ApacheJMeter_core.jar:$JMETER_HOME/lib/jorphan.jar:$JMETER_HOME/lib/logkit-2.0.jar:$CLASSPATH 5 export PATH=$JMETER_HOME/bin:$PATH:$HOME/bin
为所有用户配置环境变量,是通过修改系统变量配置实现的,添加的内容同指定用户的一致,只需要在配置时注意原有环境变量的引用即可。
系统环境配置文件全路径为:/etc/profile
修改配置文件后,执行如下命令使配置生效:
1 # 指定用户: 2 source ~/.bash_profile 3 4 # 系统变量: 5 source /etc/profile
1.3.验证
查看JMeter的版本信息。命令如下:
$ jmeter --version
执行结果如下图所示:
1 $ jmeter -v 2 3 Writing log file to: /data/qa-smjr/jmeter.log 4 log_file=jmeter.log java.io.FileNotFoundException: jmeter.log (Permission denied) 5 [log_file-> System.out] 6 2016/11/04 00:48:42 INFO - jmeter.util.JMeterUtils: Setting Locale to en_US 7 2016/11/04 00:48:42 INFO - jmeter.JMeter: Loading user properties from: /data/qa-smjr/jmeter/apache-jmeter-3.0.2/bin/user.properties 8 2016/11/04 00:48:42 INFO - jmeter.JMeter: Loading system properties from: /data/qa-smjr/jmeter/apache-jmeter-3.0.2/bin/system.properties 9 2016/11/04 00:48:42 INFO - jmeter.JMeter: Copyright (c) 1998-2016 The Apache Software Foundation 10 2016/11/04 00:48:42 INFO - jmeter.JMeter: Version 3.0 r1743807 11 2016/11/04 00:48:42 INFO - jmeter.JMeter: java.version=1.8.0_73 12 2016/11/04 00:48:42 INFO - jmeter.JMeter: java.vm.name=Java HotSpot(TM) 64-Bit Server VM 13 2016/11/04 00:48:42 INFO - jmeter.JMeter: os.name=Linux 14 2016/11/04 00:48:42 INFO - jmeter.JMeter: os.arch=amd64 15 2016/11/04 00:48:42 INFO - jmeter.JMeter: os.version=2.6.32-431.11.15.el6.ucloud.x86_64 16 2016/11/04 00:48:42 INFO - jmeter.JMeter: file.encoding=UTF-8 17 2016/11/04 00:48:42 INFO - jmeter.JMeter: Max memory =514850816 18 2016/11/04 00:48:42 INFO - jmeter.JMeter: Available Processors =2 19 2016/11/04 00:48:42 INFO - jmeter.JMeter: Default Locale=English (United States) 20 2016/11/04 00:48:42 INFO - jmeter.JMeter: JMeter Locale=English (United States) 21 2016/11/04 00:48:42 INFO - jmeter.JMeter: JMeterHome=/data/qa-smjr/jmeter/apache-jmeter-3.0.2 22 2016/11/04 00:48:42 INFO - jmeter.JMeter: user.dir =/data/qa-smjr 23 2016/11/04 00:48:42 INFO - jmeter.JMeter: PWD =/data/qa-smjr 24 2016/11/04 00:48:42 INFO - jmeter.JMeter: IP: 127.0.0.1 Name: localhost FullName: localhost
若可正确查看JMeter的版本,则说明JMeter配置成功。同时,从上述执行过程可看出如下信息。
1、加载的配置文件
2、JDK版本信息
3、OS信息
4、JMeter主目录路径
5、当前用户目录
同时,也可通过命令查看JMeter基础帮助文档,命令及查看结果如下所示:
jmeter -h
至此,此文顺利完结,希望此文能够给初学 JMeter 的您一份参考。
最后,非常感谢亲的驻足,希望此文能对亲有所帮助。热烈欢迎亲一起探讨,共同进步。非常感谢! ^_^
JMeter学习-038-JMeter Linux 环境配置