ubuntu

ubuntu jmeter如何安装

小樊
43
2025-08-29 22:06:44
栏目: 智能运维

Installing Apache JMeter on Ubuntu: A Step-by-Step Guide

Apache JMeter is a powerful Java-based tool for performance and functional testing. This guide outlines the most reliable way to install JMeter on Ubuntu (22.04/24.04 LTS), including prerequisites, manual installation, and verification steps.

1. Prerequisite: Install Java (JDK 8 or Higher)

JMeter requires Java 8 (or newer) to run. Ubuntu’s default package manager (apt) offers OpenJDK, a free and open-source implementation of Java.

Steps:

  1. Update System Packages:
    Run sudo apt update && sudo apt upgrade -y to ensure your system has the latest package versions.
  2. Install OpenJDK 11 (recommended for compatibility):
    Execute sudo apt install openjdk-11-jdk -y.
  3. Verify Installation:
    Check the Java version with java -version. You should see output like:
    openjdk 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)  
    
    If Java is not found, ensure /etc/profile includes export PATH=$JAVA_HOME/bin:$PATH and run source /etc/profile.

2. Download Apache JMeter

Get the latest stable version from the official Apache JMeter website (HTTPS recommended for security).

Steps:

  1. Download via wget (replace 5.6.3 with the latest version from JMeter’s download page):
    wget https://dlcdn.apache.org//jmeter/binaries/apache-jmeter-5.6.3.tgz
    
  2. Verify the Download (optional but recommended):
    Check the file’s SHA-256 checksum against the value on the JMeter website to ensure integrity.

3. Extract and Move JMeter to a System Directory

Extract the downloaded tarball and move it to /opt (a standard location for third-party applications).

Steps:

  1. Extract the Tarball:
    tar -xzf apache-jmeter-5.6.3.tgz
    
  2. Move to /opt:
    Use sudo to move the extracted folder to /opt:
    sudo mv apache-jmeter-5.6.3 /opt/jmeter
    
    This ensures JMeter is accessible system-wide.

4. Configure Environment Variables

Add JMeter’s bin directory to your PATH so you can run jmeter from any terminal.

Steps:

  1. Edit ~/.bashrc (for your user) or /etc/profile (for all users):
    nano ~/.bashrc
    
  2. Add the Following Lines (replace /opt/jmeter with your JMeter path if different):
    export JMETER_HOME=/opt/jmeter  
    export PATH=$JMETER_HOME/bin:$PATH
    
  3. Apply Changes:
    Run source ~/.bashrc (or source /etc/profile for system-wide changes) to load the new variables.

5. Verify JMeter Installation

Check if JMeter is correctly installed and accessible.

Steps:

  1. Run JMeter in GUI Mode (optional):
    jmeter
    
    This opens the JMeter graphical interface. Close it after verifying (you’ll use non-GUI mode for performance tests).
  2. Check Version in Non-GUI Mode:
    jmeter -v
    
    You should see output like:
    Copyright (c) 1998-2023 The Apache Software Foundation  
    Version 5.6.3  
    
    If you encounter errors (e.g., jmeter: command not found), double-check your PATH configuration and run source ~/.bashrc again.

Optional: Install JMeter Plugins

For advanced features (e.g., WebSocket testing, JSON parsing), install plugins via the JMeter Plugins Manager:

  1. Open JMeter GUI, go to Options > Plugins Manager.
  2. Select Plugins: Choose required plugins (e.g., “WebSocket Samplers”) and click Apply Changes and Restart JMeter.
  3. Copy Plugins to lib/ext (if installing manually):
    For example, to add WebSocket support, download JMeterWebSocketSamplers.jar and place it in /opt/jmeter/lib/ext.

Troubleshooting Common Issues

By following these steps, you’ll have a fully functional JMeter installation on Ubuntu, ready for performance and functional testing.

0
看了该问题的人还看了