Jmeter (53) - From beginner to advanced master - A lazy person teaches you how to install Jmeter in Linux system (detailed tutorial)

1 Introduction

Recently due to the epidemic, I have been busy working from home and have a lot of things to do, so there has been no update for about three weeks. I would like to say sorry to everyone! ! It is really easy to go from frugality to luxury, but hard to go from luxury to frugality! It’s better to take some rest time to continue outputting and updating. I hope to continue to follow Brother Hong to learn more useful information. It stands to reason that the jmeter series is almost finished, but since some friends or children left messages saying they don’t know how to install Jmeter on Linux, Hongge will continue to add articles about the jmeter series here. Most of us use Windows operating systems, so installing JMeter on Windows systems has become commonplace, and the installation is relatively simple. However, in order to ensure the security, flexibility and compactness of servers, especially the ransomware viruses in the past few years, most of them are now Most servers are Linux systems, so we need to install JMeter on the Linux system. Therefore, Brother Hong will explain and share today how to install Jmeter under Linux. Because Jmeter is developed in Java and needs to rely on the JDK environment, we need to install the JDK in advance. The installation packages installed by Hongge are all downloaded online, instead of downloading the installation package from the Windows system, then uploading it to the Linux system, and finally decompressing and installing it. Therefore, Hongge’s method is suitable for lazy people, and of course the diligent ones. It would be more suitable for people.

2. Check whether JDK is installed

First we need to install JDK on the Linux system, because Jmeter is developed in JAVA language. Sometimes the virtual machine of the Linux system has the JDK installed by default, but it is version 1.4 or other versions. However, since the Jmeter version we use matches the JDK version, we can use it, so we uninstall the previous JDK first (you can not uninstall it) , then reinstall the JDK and configure environment variables.

2.1 Check the JDK version in Linux system

The first method: Enter  java -version , java , javac in sequence , no error will appear and the jdk version number and java/javac related command parameter description interface will be displayed.

If you want to learn automated testing, I recommend a set of videos to you. This video can be said to be the number one automated testing tutorial on the entire network played by Bilibili. The number of people online at the same time has reached 1,000, and there are also notes that can be collected and distributed by various channels. Master technical communication: 798478386    

[Updated] A complete collection of the most detailed practical tutorials on Python interface automation testing taught by Bilibili (the latest practical version)_bilibili_bilibili [Updated] A complete collection of the most detailed practical tutorials on Python interface automated testing taught by Bilibili (practical version) The latest version) has a total of 200 videos, including: 1. Why interface automation should be done for interface automation, 2. Overall view of request for interface automation, 3. Interface practice for interface automation, etc. For more exciting videos from UP master, please follow the UP account . icon-default.png?t=N7T8https://www.bilibili.com/video/BV17p4y1B77x/?spm_id_from=333.337


[admin@oftpclient202 ~]$ java -version
java version "1.8.0_333"
Java(TM) SE Runtime Environment (build 1.8.0_281-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.281-b09, mixed mode)
[admin@oftpclient202 ~]$ java
Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)
where options include:
    -d32          use a 32-bit data model if available
    -d64          use a 64-bit data model if available
    -server       to select the "server" VM
                  The default VM is server.

    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
                  A : separated list of directories, JAR archives,
                  and ZIP archives to search for class files.
    -D<name>=<value>
                  set a system property
    -verbose:[class|gc|jni]
                  enable verbose output
    -version      print product version and exit
    -version:<value>
                  Warning: this feature is deprecated and will be removed
                  in a future release.
                  require the specified version to run
    -showversion  print product version and continue
    -jre-restrict-search | -no-jre-restrict-search
                  Warning: this feature is deprecated and will be removed
                  in a future release.
                  include/exclude user private JREs in the version search
    -? -help      print this help message
    -X            print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
                  enable assertions with specified granularity
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
                  disable assertions with specified granularity
    -esa | -enablesystemassertions
                  enable system assertions
    -dsa | -disablesystemassertions
                  disable system assertions
    -agentlib:<libname>[=<options>]
                  load native agent library <libname>, e.g. -agentlib:hprof
                  see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:<pathname>[=<options>]
                  load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
                  load Java programming language agent, see java.lang.instrument
    -splash:<imagepath>
                  show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.
[admin@oftpclient202 ~]$ javac
Usage: javac <options><source files>
where possible options include:
  -g                         Generate all debugging info
  -g:none                    Generate no debugging info
  -g:{lines,vars,source}     Generate only some debugging info
  -nowarn                    Generate no warnings
  -verbose                   Output messages about what the compiler is doing
  -deprecation               Output source locations where deprecated APIs are used
  -classpath <path>          Specify where to find user class files and annotation processors
  -cp <path>                 Specify where to find user class files and annotation processors
  -sourcepath <path>         Specify where to find input source files
  -bootclasspath <path>      Override location of bootstrap class files
  -extdirs <dirs>            Override location of installed extensions
  -endorseddirs <dirs>       Override location of endorsed standards path
  -proc:{none,only}          Control whether annotation processing and/or compilation is done.
  -processor <class1>[,<class2>,<class3>...] Names of the annotation processors to run; bypasses default discovery process
  -processorpath <path>      Specify where to find annotation processors
  -parameters                Generate metadata for reflection on method parameters
  -d <directory>             Specify where to place generated class files
  -s <directory>             Specify where to place generated source files
  -h <directory>             Specify where to place generated native header files
  -implicit:{none,class}     Specify whether or not to generate class files for implicitly referenced files
  -encoding <encoding>       Specify character encoding used by source files
  -source <release>          Provide source compatibility with specified release
  -target <release>          Generate class files for specific VM version
  -profile <profile>         Check that API used is available in the specified profile
  -version                   Version information
  -help                      Print a synopsis of standard options
  -Akey[=value]              Options to pass to annotation processors
  -X                         Print a synopsis of nonstandard options
  -J<flag>                   Pass <flag> directly to the runtime system
  -Werror                    Terminate compilation if warnings occur
  @<filename>                Read options and filenames from file

[admin@oftpclient202 ~]$

Second method: Enter the command: rpm -qa | grep java. The JDK checked here may be 1.4, which is installed by default in the system. Some may build a JAVA environment and the query results in 1.7, or it cannot be found, it does not matter.

[admin@bbajit202 ~]$ rpm -qa|grep java
java-1.8.0-openjdk-headless-1.8.0.262.b10-0.el8_2.x86_64
javapackages-filesystem-5.3.0-1.module_el8.0.0+11+5b8c10bd.noarch
tzdata-java-2020a-1.el8.noarch
java-1.8.0-openjdk-1.8.0.262.b10-0.el8_2.x86_64
[admin@bbajit301 ~]$

As you can see from the above, the JDK has been installed. If you don’t have JDK installed, you can refer to another article by Brother Hong to install it. You can also download the installation package directly on the Linux system, unzip and install: Portal (Troublesome things you must know about installing JDK 1.8 under Linux ).

2.2 Uninstall JDK

Enter the command: rpm -e --nodeps +   Start uninstalling the name of the jdk installation package found by the above command . After the uninstallation is completed, check whether it is gone.

[admin@oftpclient202 ~]$ rpm -qa|grep java
[admin@oftpclient202 ~]$

3. Environment

1. View the Linux environment input commands

1. Check the Linux environment and enter the command: lsb_release -a

[admin@oftpclient202 ~]$ lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 7.9.2009 (Core)
Release:        7.9.2009

2. Check the JDK environment command: java -version\

[admin@oftpclient202 ~]$ java -version
java version "1.8.0_333"
Java(TM) SE Runtime Environment (build 1.8.0_281-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.281-b09, mixed mode)
[admin@oftpclient201 ~]$

4. Download the Jmeter installation package

4.1Installation package address

1. Jmeter is an open source tool. We can download it directly from the official website. The version installed this time is  5.4(宏哥一般都是安装最新的,除非有特殊要求).

The latest version download address: https://jmeter.apache.org/download_jmeter.cgi The historical version download address: https://archive.apache.org/dist/jmeter/binaries/

 

The download suffix is  .tgz ​​or  .zip . We can  wget download the Jmeter installation package through commands in Linux, or download and then transfer it to Linux.

The installation package version I downloaded here is: apache-jmeter-5.4.tgz  .

4.2Linux download and installation package

Download the Jmeter installation package for Windows. Brother Hong will go into details here. You can download it by clicking directly. Brother Hong will talk about how to download the Jmeter installation package for Linux.

1.wget downloads the Jmeter installation package

Method: wget+installation package download link (right-click on the installation package and click to copy the link address), as shown in the figure below:

2. Run the command on the Linux system: wget+installation package download link, as shown below:

 

4.3 Check the installation package size

Based on the experience of installing JDK last time, Brother Hong first checked whether the download was successful. Don't copy and decompress it like the last time he installed JDK, only to find that the downloaded installation package was incomplete (the download was unsuccessful) and check the size of the installation package. ,As shown below:

 

From the picture above, we can see that the size of the installation package is similar to the size of the installation package displayed on the download page, indicating that the installation package is downloaded successfully. Then the next step is to unzip the installation package in the directory to be installed.

5. Unzip the installation package

Create a folder to store the Jmeter installation package, and then extract it to this directory.


创建文件夹:mkdir -p /usr/SoftWare/Jmeter
进入文件夹:cd /usr/SoftWare/Jmeter
将下载好的压缩文件剪贴到创建好的文件夹下:mv apache-jmeter-5.4.tgz /usr/SoftWare/Jmeter
解压:tar -zxvf /usr/SoftWare/Jmeter/apache-jmeter-5.4.tgz

As you can see, this time it was extracted  /usr/SoftWare/Jmeter/apache-jmeter-5.4to the directory.

6. Configure the environment

After decompression is completed, we need to configure the environment variables and  vi modify the configuration file through commands  /etc/profile to set the environment variables.

vi /etc/profile

 1. Enter the command line above in the Linux system terminal to enter the normal mode of vi. Please note that vi must be followed by the file name, regardless of whether the file exists or not! As shown below:

2. Enter  G the last line of the file, enter  i the edit mode, add the following content, then press to  Esc exit the edit mode, enter again to  :wq save and exit.

#Jmeter环境变量配置
export JMETER_HOME=/usr/SoftWare/Jmeter/apache-jmeter-5.4
export PATH=${JMETER_HOME}/bin:$PATH

 The addition is completed, as shown in the figure below:

3. Check whether the editing and saving is successful, vi /etc/profile , enter the general mode of vi again, enter G to the last line of the file, you can see the content added by Hong Ge just configured the JMeter environment variable, as shown in the following figure:

 

4. Check whether JMeter’s environment variables are configured successfully. Enter the command: jmeter -version, as shown in the figure below:

 

As you can see from the picture above, the configuration has not been successful. This is because the environment variables have not yet taken effect.

5. After setting, if you want the environment variables to take effect immediately, you need to source /etc/profilereload the configuration file by entering the command: . Finally,  jmeter --version verify that the installation is successful by checking the installed Jmeter version.

OK, the interface shown above appears. Congratulations. Here you are done. Jmeter has been installed and you can start using it!

7. Summary

1. When Linux downloads the installation package through the wget command, it feels a bit slow and takes a long time (maybe caused by Hong's network speed). Anxious children and friends can download it using Windows and then upload it to the Linux system.

2. Careful children or friends may have discovered that when verifying the environment variable input command, pay attention to the two dashes (**- ) in front of the version. Lazy man's trick: enter: jmeter -v**.

3. Why vim is not used here but vi? Brother Hong tells you, Brother Hong used it but unfortunately the Linux system did not install vim, so Brother Hong was lazy. Just use the vi that comes with the system. Take a look at the Linux system prompts after Brother Hong uses Vim, as shown below:

picture

So why can Vi but not Vim? That's because Vim is not installed on this Linux system. If I say this in vain, some serious friends or children may not believe it. Then Brother Hong will let you take a look. Generally, the commands executed in our Linux system are in the bin directory. Let me take a look at all the files starting with the letter V in the bin directory. You can see vi, but not vim, as shown in the following figure:

Secondly, another reason is that Hong Ge’s user identity for logging into the Linux system is now not root but admin. Generally speaking, installing this kind of command requires logging in as the root user. Friends who don’t believe it, you can take a look at it, as shown in the picture below:

 

As can be seen from the above picture, you need to log in as the root user to install vim. Then switch the user to root here, enter the command: su -  , and then continue to install vim, as shown in the following figure: 

After switching to root, install vim and enter the command: yum install vim  , as shown in the following figure:

 

 Enter Y in the middle (in order to avoid entering Y in the middle, you can enter the command: yum install -y vim ), and finally vim is installed successfully. Brother Hong then takes the children or friends to the bin directory to check whether there is vim, as shown in the figure below:

Then we can use vim. This time, edit and enter: vim /etc/porfile, and no error will be reported, as shown in the following figure:

 

Guess you like

Origin blog.csdn.net/Faith_Lzt/article/details/133386194