Jmerte分布式壓測(cè)及分布式壓測(cè)配置教程
1.本地基于jmeter創(chuàng)建壓測(cè)項(xiàng)目
(1)pom中依賴jmeter包:
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_java</artifactId>
<version>5.2.1</version>
</dependency>(2)pom中增加打包方式
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<fork>true</fork>
<verbose>true</verbose>
<encoding>UTF-8</encoding>
<compilerArguments>
<extdirs>${project.basedir}/lib</extdirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<!--配置本地jar包在項(xiàng)目中的存放路徑-->
<directory>${project.basedir}/lib</directory>
<!--配置打包時(shí)jar包的存放路徑-->
<targetPath>${project.basedir}/lib</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- 忽略測(cè)試 -->
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Rose>*</Rose>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.5</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>(3)編寫壓測(cè)腳本:
繼承AbstractJavaSamplerClient,并實(shí)現(xiàn)runTest方法。
public class StessTest extends AbstractJavaSamplerClient {
@Override
public void setupTest(JavaSamplerContext javaSamplerContext) {
}
@Override
@SneakyThrows
public SampleResult runTest(JavaSamplerContext javaSamplerContext) {
SampleResult sampleResult = new SampleResult();
try {
sampleResult.sampleStart();
String result= 請(qǐng)求接口;
sampleResult.setResponseData(result, "UTF-8");
sampleResult.setSuccessful(false);
TimeUnit.SECONDS.sleep(1L);
} catch (Exception e) {
e.printStackTrace();
sampleResult.setResponseData(e.getLocalizedMessage(), "UTF-8");
sampleResult.setResponseCode(e.getMessage());
sampleResult.setSuccessful(false);
} finally {
sampleResult.sampleEnd();
}
return sampleResult;
}
@Override
public void teardownTest(JavaSamplerContext javaSamplerContext) {
super.teardownTest(javaSamplerContext);
}
@Override
public Arguments getDefaultParameters() {
return null;
}2.將項(xiàng)目打包
將本地maven測(cè)試項(xiàng)目打成jar包:
mvn -U clean insall package
打包完后,有兩個(gè)地方的包:target\lib、target下面的包
首先本地調(diào)試壓測(cè)腳本是否生效
(1)創(chuàng)建一個(gè)線程組:

這里可以配置線程組名稱,線程數(shù),準(zhǔn)備時(shí)長、循環(huán)次數(shù),調(diào)度器等參數(shù)
(2)創(chuàng)建java請(qǐng)求


選好測(cè)試的方法,本地執(zhí)行一下,看可以跑通后,去遠(yuǎn)程機(jī)器壓測(cè)。
確定好Master和Slave機(jī)器,及被壓測(cè)服務(wù)所在的機(jī)器。且master機(jī)器 及slave機(jī)器上都配置相同版本的jmeter。
將項(xiàng)目依賴的jar包都放到slave機(jī)器 jmeter\lib\ext路徑下面。
3.Master配置
編輯$JMETER_HOME/bin/jmeter.properties文件
分別配置remote_hosts,和server.rmi.ssl.disable,端口號(hào)
server.rmi.ssl.disable=true server.rmi.localport=1099 server_port=1099 remote_hosts=ip1,ip2,ip3,ip4,ip5,ip6
4.Slave配置
(1)所有的slave機(jī)器上對(duì)應(yīng)修改 $JMETER_HOME/bin/jmeter.properties文件
server.rmi.ssl.disable=true
(2)所有的slave機(jī)器需要在$JMETER_HOME/lib/ext下放壓測(cè)腳本依賴的jar包
5.啟動(dòng)Slave
每臺(tái)slave機(jī)器上都啟動(dòng)jmeter
直接啟動(dòng)
$JMETER_HOME/bin/jmeter-server
或者指定機(jī)器的ip啟動(dòng)(建議指定ip啟動(dòng))
jmeter-server -Djava.rmi.server.hostname=xxx (機(jī)器的ip地址)
6.master啟動(dòng)壓測(cè)
onlinePressTest.jmx是用界面版jmeter生成的一個(gè)線程組,保存下來,放到master機(jī)器上
運(yùn)行壓測(cè)腳本:
jmeter -n -r -t onlinePressTest.jmx -l stressTest.jtl?-e -o webStressTest
7查看報(bào)告
stressTest.jtl 是壓測(cè)結(jié)果,可以導(dǎo)出到本地,使用jmeter打開,獲取報(bào)告

到此這篇關(guān)于Jmerte分布式壓測(cè),及分布式壓測(cè)配置的文章就介紹到這了,更多相關(guān)Jmerte分布式壓測(cè)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
SpringBoot工程打包與運(yùn)行的實(shí)現(xiàn)詳解
本文主要介紹了SpringBoot工程的打包與運(yùn)行的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2022-07-07
Java ZooKeeper分布式鎖實(shí)現(xiàn)圖解
ZooKeeper是一個(gè)分布式的,開放源碼的分布式應(yīng)用程序協(xié)調(diào)服務(wù),是Google的Chubby一個(gè)開源的實(shí)現(xiàn),是Hadoop和Hbase的重要組件。它是一個(gè)為分布式應(yīng)用提供一致性服務(wù)的軟件,提供的功能包括:配置維護(hù)、域名服務(wù)、分布式同步、組服務(wù)等2022-03-03
idea將maven項(xiàng)目改成Spring boot項(xiàng)目的方法步驟
這篇文章主要介紹了idea將maven項(xiàng)目改成Spring boot項(xiàng)目的方法步驟,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-09-09
詳解Springboot整合ActiveMQ(Queue和Topic兩種模式)
這篇文章主要介紹了詳解Springboot整合ActiveMQ(Queue和Topic兩種模式),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-04-04

