Installing JMeter on Ubuntu: Step-by-Step Guide
This guide outlines the essential steps to install Apache JMeter on Ubuntu, including prerequisites (Java), downloading JMeter, configuring environment variables, and verifying the installation.
1. Prerequisite: Install Java
JMeter is a Java-based application and requires Java (OpenJDK or Oracle JDK) to run. For most users, OpenJDK is recommended due to its ease of installation and maintenance.
- Update package lists:
sudo apt update - Install OpenJDK 11 (or later):
sudo apt install openjdk-11-jdk - Verify Java installation:
Run the following command to confirm Java is installed correctly. The output should display the Java version:
Example output:java -versionopenjdk version "11.0.20" 2023-07-18 OpenJDK Runtime Environment (build 11.0.20+8-post-Ubuntu-1ubuntu122.04) OpenJDK 64-Bit Server VM (build 11.0.20+8-post-Ubuntu-1ubuntu122.04, mixed mode)
2. Download Apache JMeter
Download the latest stable version of JMeter from the official Apache website. Use wget to directly download the tarball to your Ubuntu system.
- Navigate to a working directory (e.g.,
~/Downloads):cd ~/Downloads - Download JMeter (replace
5.4.1with the latest version from the JMeter download page):wget https://downloads.apache.org/jmeter/binaries/apache-jmeter-5.4.1.tgz
3. Extract and Move JMeter
Extract the downloaded tarball and move the extracted folder to a permanent location (e.g., /opt/jmeter) for easy access.
- Extract the tarball:
tar -xvzf apache-jmeter-5.4.1.tgz - Move to
/opt/jmeter(requiressudofor system directories):sudo mv apache-jmeter-5.4.1 /opt/jmeter
4. Configure Environment Variables
To run JMeter from any terminal without specifying its full path, add its bin directory to the PATH environment variable.
- Edit the profile file (choose either
~/.profilefor current user or/etc/profilefor all users). Here, we use~/.profile:nano ~/.profile - Add the following lines at the end of the file (replace
/opt/jmeterwith your JMeter installation path if different):export JMETER_HOME=/opt/jmeter export PATH=$JMETER_HOME/bin:$PATH - Save and exit: Press
CTRL+Oto write changes,Enterto confirm, thenCTRL+Xto exitnano. - Apply changes: Reload the profile to make the new environment variables take effect:
source ~/.profile
5. Verify JMeter Installation
Check if JMeter is installed correctly by running the version command.
- Run the following command:
jmeter -v - Expected output: You should see JMeter’s version information (e.g.,
Apache JMeter 5.4.1) along with Java version details. This confirms the installation was successful.
6. (Optional) Run JMeter in Non-GUI Mode
For performance testing, it’s recommended to use JMeter in non-graphical mode (-n) to reduce resource consumption.
- Basic non-GUI command: Replace
/path/to/testplan.jmxwith the path to your JMeter test plan (JMX file) and/path/to/results.jtlwith the desired output file for results:jmeter -n -t /path/to/testplan.jmx -l /path/to/results.jtl - Generate HTML report: After running the test, use the following command to generate a detailed HTML report from the
.jtlfile:
Open thejmeter -g /path/to/results.jtl -o /path/to/reportindex.htmlfile in the/path/to/reportdirectory to view the report in your browser.
Troubleshooting Common Issues
- Java not found: If you encounter errors like
java: command not found, ensure Java is installed correctly and theJAVA_HOMEenvironment variable is set. - Permission denied: When extracting or moving JMeter files, use
sudoto avoid permission issues. - Missing dependencies: If you’re using plugins (e.g., WebSocket Sampler), ensure required JAR files are placed in the
lib/extdirectory of your JMeter installation.
By following these steps, you’ll have a fully functional JMeter installation on Ubuntu, ready for performance testing and load analysis.
以上就是关于“ubuntu jmeter安装步骤”的相关介绍,筋斗云是国内较早的云主机应用的服务商,拥有10余年行业经验,提供丰富的云服务器、租用服务器等相关产品服务。云服务器资源弹性伸缩,主机vCPU、内存性能强悍、超高I/O速度、故障秒级恢复;电子化备案,提交快速,专业团队7×24小时服务支持!
简单好用、高性价比云服务器租用链接:https://www.jindouyun.cn/product/cvm