1. Background
XX project has not yet opened the Internet due to its deployment on the private cloud. The project team decided to build a pressure test environment in the Intranet environment to expose the performance bottleneck of the project interface in advance.
2. Machine allocation
Intranet environment machines, linked to springboard machines through fortress machines, operate by linking 20 intranet machines through springboard machines,
A total of 20 centos machines are allocated and two clusters are deployed. Each cluster has 10 machines, one control machine and 10 presses (the control machine is also used as a press)
3. Press jmeter deployment
3.1 jdk installation
1. Due to the Intranet environment, you can't download through yum source. You need to upload the file to the springboard machine through xshell\xftp, and then upload it to the corresponding machine through the springboard machine

2. Unzip the jdk to the specified directory, where the / usr/bin/java / directory is used

3./etc/profile add environment variable

Execute the environment variable source /etc/profile
4. Verify that the jdk is installed successfully
java -version

3.2jmeter installation
- Establish the installation path under linux: / root/jmeter
- Upload the jmeter installation package to the / root/jmeter path and unzip it
- Create script Directory: / root/jmeter/scripts, address of script upload
- Create report Directory: / root/jmeter/report, and the report generation and storage directory

5./etc/profile add environment variable

Execute the environment variable source /etc/profile
6. Verify jmeter installation
jmeter -v

The above steps are the same for both Master and slave
3.3 modify press configuration parameters
- Modify the slave configuration parameters of the press, and modify JMeter in the / root/jmeter/apache-jmeter-5.4.1/bin directory Properties file
- Modify server_port port
Default 1009
Any port can be modified, but it cannot be occupied

3. Modify server rmi. Port port
And server_ Just keep consistent

4. Set server rmi. ssl. disable
The default is false, which means authentication is required
Set to true to reduce unnecessary trouble

5. Modify remote_hosts
remote_hosts = IP address of control machine: port number

6. The system configures the local IP host name in the HOSTS file, such as 10.0.0.23 zhoucentos. Otherwise, an error will be reported when starting jmeter server!
First, let's look at the native ip and hostname


Then configure through vi /etc/hosts, configure ip and hostname and save them. Each machine is equipped with

7. Check whether the firewall is closed
Check firewall status command: systemctl status firewalld service

8. Environmental optimization
See Chapter 4 for details
4. Environmental optimization
1) Configure the memory used by jmeter and modify it according to the actual server and test requirements
vi /root/jmeter/apache-jmeter-5.4.1/bin/jmeter
Line 166 modification
: "${HEAP:="-Xms8g -Xmx8g -XX:MaxMetaspaceSize=2048m"}"
Restart in bin directory;
nohup jmeter-server -Djava.rmi.server.hostname=172.27.16.33 &
verification:
ps -ef | grep jmeter

2) Optimize linux memory parameters and modify limits Conf file and add:
#vi /etc/security/limits.conf * soft nofile 102400 * hard nofile 102400 * soft nproc 65535 * hard nproc 65535
Re open the SSH terminal and execute the following command to check whether it is effective
ulimit -n

3) Modify / etc / sysctl Conf file and add:
vi /etc/sysctl.conf net.ipv4.tcp_syncookies = 0 fs.file-max = 12553500 fs.nr_open = 12453500 kernel.shmall= 1048576 kernel.shmmax = 1887436 kernel.msgmax = 65536 kernel.sysrq = 0 kernel.pid_max= 65536 net.core.netdev_max_backlog = 2000000 net.core.rmem_default = 699040 net.core.rmem_max = 50331648 net.core.wmem_default = 131072 net.core.wmem_max = 33554432 net.core.somaxconn = 65535 net.ipv4.ip_nonlocal_bind = 1 net.ipv4.tcp_max_orphans = 3276800 net.ipv4.tcp_mem = 1048576 1572864 2097152 net.ipv4.tcp_rmem = 4096 4194304 8388608 net.ipv4.tcp_wmem = 4096 4194304 8388608 net.ipv4.tcp_slow_start_after_idle = 0 net.ipv4.tcp_synack_retries = 1 net.ipv4.tcp_window_scaling = 1 vm.swappiness = 0 #TCP connection recovery net.ipv4.tcp_max_tw_buckets = 6000000 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_fin_timeout = 30 net.ipv4.route.max_size = 5242880 net.ipv4.ip_forward = 1 #0 indicates that the check time is wrong without opening. It is recommended to set 0 net.ipv4.tcp_timestamps = 0 #Enable support for TCP timestamp. If this item is set to 0, the following settings will not work #TCP connection manager net.ipv4.tcp_max_syn_backlog = 655360 net.ipv4.tcp_syn_retries = 6 net.ipv4.tcp_retries1 = 3 net.ipv4.tcp_retries2 = 6 #TCP keepalive net.ipv4.ip_local_port_range = 1025 65534 net.ipv4.tcp_keepalive_time = 30 net.ipv4.tcp_keepalive_intvl = 30 net.ipv4.tcp_keepalive_probes = 3 Enter the following command for the kernel parameters to take effect: sysctl -p
5. Control machine deployment
The jmeter deployment of the control machine is the same as that of the press (refer to 3.1 and 3.2)
Modify the configuration parameters of the controller, and jmeter.com under / root/jmeter/apache-jmeter-5.4.1/bin Properties file
If the controller is also tested, add it, and then modify the server_port , server.rmi.port,server.rmi.ssl.disable (same procedure as the press)
remote_hosts = press IP address: port number, press IP address: port number
Multiple sets can be separated by English commas, and the control machine can also be used as a press

Configure mode and remove the previous#

6. Execute distributed pressure test script
Execute jmeter background start command on all presses:
nohup jmeter-server -Djava.rmi.server.hostname = divider IP&

Execute all press test scripts from any directory
jmeter -r -n -t /root/jmeter/scripts/**.jmx
Perform the pressure measurement of the specified press (172.27.16.20 here is the press ip)
sh jmeter -n -t /root/jmeter/scripts/XX.jmx -R 172.27.16.20

7. Stop the pressure measurement procedure
cd enters the bin directory of JMeter
Input/ shutdown. The SH command stops the script
Note: if you want to terminate the pressure measurement in the distributed pressure measurement process, do not press ctrl + c on Linux to forcibly terminate the program. In this way, you will know that after the main program hangs, the slave machine does not accept and execute, and will continue to run. When you run the script from the host again, the slave will still run in the program of the previous script.
If you want to terminate the program, you can execute the command line/ shutdown.sh, notify the master to terminate the program, and then the master notifies the save to stop running.
8.Meter+Grafana+Influxdb
Here, in order to facilitate us to monitor the QPS, number of threads and 95 points in the pressure measurement process, we can use the grafana control panel to display the data. We deploy grafana on the control machine;
The deployment of grafana is not discussed in detail here. Interested students can view this article of Tencent cloud;
JMeter+Grafana+Influxdb build a visual performance test and monitoring platform https://cloud.tencent.com/developer/article/1809013
