Installing JMeter on Ubuntu: A Step-by-Step Tutorial
Apache JMeter is a powerful Java-based tool for performance testing. This tutorial guides you through installing JMeter on Ubuntu, including prerequisites (Java), configuration, and basic usage.
1. Prerequisite: Install Java
JMeter requires Java (OpenJDK or Oracle JDK). OpenJDK is recommended for Ubuntu due to its ease of installation.
Run the following commands to install OpenJDK 11 (or later):
sudo apt update
sudo apt install openjdk-11-jdk
Verify the installation:
java -version
You should see output like openjdk version "11.x.x" confirming Java is installed.
2. Download and Extract JMeter
- Download the latest JMeter binary:
Visit the Apache JMeter download page and copy the link for the latest stable release (e.g.,apache-jmeter-5.6.3.tgz). Usewgetto download it:wget https://dlcdn.apache.org/jmeter/binaries/apache-jmeter-5.6.3.tgz - Extract the tarball:
tar -xzf apache-jmeter-5.6.3.tgz - Move to a permanent directory:
For system-wide access, move the extracted folder to/opt:sudo mv apache-jmeter-5.6.3 /opt/jmeter
3. Configure Environment Variables
To run JMeter from any terminal, add its bin directory to your PATH.
- Edit your shell profile (e.g.,
.bashrcor.zshrc):nano ~/.bashrc - Add the following lines at the end:
export JMETER_HOME=/opt/jmeter export PATH=$JMETER_HOME/bin:$PATH - Save the file (
Ctrl+O,Enter,Ctrl+X) and apply changes:source ~/.bashrc
4. Verify JMeter Installation
Run the following command to check if JMeter is correctly installed:
jmeter -v
You should see version information (e.g., Apache JMeter 5.6.3) and no errors.
5. Optional: Install Plugins (for Advanced Features)
If you need plugins (e.g., WebSocket support, custom samplers), install the JMeter Plugins Manager:
- Download the plugin JAR from the Plugins Manager page.
- Place it in the
lib/extdirectory of your JMeter installation:sudo cp jmeter-plugins-manager-1.7.jar /opt/jmeter/lib/ext/ - Restart JMeter, and the Plugins Manager will appear in the “Options” menu.
6. Basic Usage Examples
- GUI Mode (for test creation):
Launch the graphical interface:jmeter - Non-GUI Mode (for load testing):
Run a test plan (replacetest.jmxwith your file path) and save results toresults.jtl:jmeter -n -t /path/to/test.jmx -l /path/to/results.jtl - Generate HTML Report:
After running a test, generate a report from the.jtlfile:
Open thejmeter -g /path/to/results.jtl -o /path/to/reportindex.htmlfile in the report directory to view metrics.
Troubleshooting Common Issues
- Java Not Found: Ensure Java is installed and
java -versionworks. If using a non-default Java version, setJAVA_HOMEin your profile. - Permission Denied: Run
chmod +x /opt/jmeter/bin/jmeterto make the JMeter executable runnable. - Missing Dependencies (e.g., WebSocket plugins): Install required JARs in the
lib/extdirectory (see Step 5).
This tutorial covers the core steps to install and use JMeter on Ubuntu. For advanced configurations (distributed testing, custom properties), refer to the official JMeter documentation.
以上就是关于“jmeter在ubuntu上的安装教程”的相关介绍,筋斗云是国内较早的云主机应用的服务商,拥有10余年行业经验,提供丰富的云服务器、租用服务器等相关产品服务。云服务器资源弹性伸缩,主机vCPU、内存性能强悍、超高I/O速度、故障秒级恢复;电子化备案,提交快速,专业团队7×24小时服务支持!
简单好用、高性价比云服务器租用链接:https://www.jindouyun.cn/product/cvm