Jmeter distributed concurrent deployment
If you install jmeter on a single terminal and perform concurrency, the CPU and memory of the machine may not be able to support the amount of concurrency. In this case, distributed concurrency is used as a solution.
1. Distributed concurrency principle
Use one of the machines as the master (scheduling machine) and the other machines as the slave (execution machine). When executing the script, execution is started on the master, and the master will send the script to each slave. The slave starts executing after getting the script. When executing, the slave does not need to start the GUI, only jmeter-server needs to be started.
2. Prerequisites that need to be met
- The master and all slaves are on the same LAN
- It is best to enable GUI mode on the master to facilitate script startup and debugging.
- Turn off the firewall on master and slave
- Install the same version of JDK and Jmeter on master and slave
3. Deployment steps from scratch
Step 1: Install jmeter on the local machine and debug the script
Download the jmeter installation package from the official website, unzip it, execute different jmeter startup files according to the local operating system, and debug the script inside, confirm that the script can run through and save it as a jmx file. Then re-package the local jmeter into a compressed package.
In this step, we obtained two files locally: jmx script file and jmeter tool compressed package .
Why not download the jmeter tool directly on the master and slave and debug it?
First of all, there is a difference between the jmeter tool compressed package obtained locally and the jmeter downloaded from the official website. It contains jmeter plug-ins, which can support the running of jmx scripts. After debugging the script, package it again, and then upload it to master and jmeter. It can be used directly as long as it is decompressed on the two machines. This ensures that the jmeter version and plug-in on the two machines are completely consistent and that the jmx script can be executed.
Step 2: Get a test machine
Rent two test servers in the Alibaba Cloud console, one as the master and one as the slave. In order to meet the conditions that the master and slave are in the same LAN and communicate with each other using private IP, when renting a server, be sure to select the same region as the server and join the same security group. My machine configuration is as follows:
LAN IP | CPU and memory configuration | Role |
---|---|---|
172.18.11.143 | 2vCPU,2G | slave |
172.18.11.142 | 1vCPU,2G | master |
First, confirm interoperability by pinging the other party's LAN IP address, as shown below:
The two machines can ping, and condition 1 is met.
Step 3: Turn off the firewall
Turn off the firewall on both machines by executing the following commands:systemctl stop firewalld
Check the firewall status of the two machines by executing the following command:systemctl status firewalld
Step 4: Deploy JDK
Install
Install some basic instructions on both machines, such as uploading yum -y install lrzsz
, zip yum -y install unzip
decompression and other commands.
Download the JDK package from the oracle official website. I downloaded the rpm package.
Upload the rpm package to the two test machines through the rz command. Only one of them is used as an example here.
Execute rpm -ivh jdk-8u311-linux-x64.rpm
. After the execution is completed, jdk will be installed in /usr/java
the directory. Go to the directory to find jdk, print out the path and copy the path. My jdk path is /usr/java/jdk1.8.0_311-amd64
.
Configure environment variables
Execute vi /etc/profile
the command, edit the file, and add the following content at the bottom of the file:
export JAVA_HOME=/usr/java/jdk1.8.0_311-amd64
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
Note: Replace the variable value of JAVA_HOME with your own jdk path. After saving the file, source /etc/profile
make the changes effective. So far jdk has been deployed.
Verify deployment is successful
In any directory, execute java -version
the command and the jdk version number can be printed successfully.
[root@iZbp13gmqo0y3pi60e0sz8Z jdk1.8.0_311-amd64]# java