JMeter Remote Test|Distributed testing

環(huán)境

CentOS 7.2
JMeter 3.2

Topologie

image.png
  • (Client|Master): the system running Jmeter which controls the slave remote (and doesn't send any request)
  • (Server|Slave|Remote) Node: the system running JMeter in server mod (jmeter-server), which takes commands from the client and send the test plan requests to the target system(s)
  • Target: the server to stress test

Configure Client Node

JMeter uses Java RMI [Remote Method Invocation] to interact with objects in a distributed network.
JMeter master and slave communicate as shown in the below picture.

image.png
  • remote_hosts: in client JMeter machine,add value of JMeter servers IP address. Multiple servers can be added comma-delimited. A more convenient way to specify remote host is from command line. Use -R command line to specify which remote host to use

  • client.rmi.localport: Specify client.rmi.localport in jmeter.properties file (for example - client.rmi.localport=25000). This is the port on which the local JMeter instance will listen for the Remote Method Invocation (i.e. RMI connections) from the slave nodes. Results would be sent to client from slave nodes on this port

Configure Server Nodes

Server nodes should be running same version of JMeter and java as client

Test datafiles are not sent across by client, hence they should be available in appropriate directory in each server. You can keep test data file in /bin folder in each JMeter server. It gets you rid of specifying full qualified path of test data file on each server instance.

To use different values for properties use corresponding values for user.properties and system.properties on each server

  • server.rmi.localport: By default, RMI uses a dynamic port for the JMeter server engine. This may cause issues with firewalls, so with versions of JMeter after 2.3.2 you can define the JMeter property server.rmi.localport to control this port number. To use a specific port for the JMeter server engine, define server.rmi.localport property before starting the server

JMeter/RMI requires:
a connection from the client to the server. Default port 1099.
and a reverse connection in order to return results from the server to the client. This will use a high-numbered port controlled by jmeter property “client.rmi.localport”

Prerequisites

All the nodes (client and servers):

  • are running the same version of JMeter.
  • are running the same version of Java. For JMeter 2.9, Java 6 runtime or higher
  • have extra test data files available in the appropriate directory
    are on the same subnet
  • can communicate (the firewalls must be turned off of set up to allow the connections)
  • must be started with the same property (file and command line option)

JMeter安裝

下載解壓即可。

wget https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-3.2.tgz
tar -xzf apache-jmeter-3.2.tgz

JMeter命令

-h 幫助 -> 打印出有用的信息并退出
-n 非 GUI 模式 -> 在非 GUI 模式下運(yùn)行 JMeter
-t 測(cè)試文件 -> 要運(yùn)行的 JMeter 測(cè)試腳本文件
-l 日志文件 -> 記錄結(jié)果的文件
-r 遠(yuǎn)程執(zhí)行 -> 啟動(dòng)遠(yuǎn)程服務(wù)
-H 代理主機(jī) -> 設(shè)置 JMeter 使用的代理主機(jī)
-P 代理端口 -> 設(shè)置 JMeter 使用的代理主機(jī)的端口號(hào)

$ jmeter -n -t test1.jmx -l logfile1.jtl -H 192.168.1.1 -P 8080

方案1

client,server均采用手動(dòng)部署方式,方便調(diào)試查錯(cuò)。

啟動(dòng)server:

[root@VM_1_111_centos bin]# ./jmeter-server -Djava.rmi.server.hostname=10.0.1.111
Created remote object: UnicastServerRef [liveRef: [endpoint:[10.0.1.111:36522](local),objID:[-77441bd0:15bf138f424:-7fff, -7104802513269301355]]]

啟動(dòng)client:

[root@VM_1_246_centos bin]# ./jmeter -n -t baidu-test.jmx -R10.0.1.111:31099 -Djava.rmi.server.hostname=10.0.1.246
Creating summariser <summary>
Created the tree successfully using baidu-test.jmx
Configuring remote engine: 10.0.1.111:31099
Starting remote engines
Starting the test @ Wed May 10 15:19:58 CST 2017 (1494400798945)
Remote engines have been started
Waiting for possible Shutdown/StopTestNow/Heapdump message on port 4445
summary +      1 in 00:00:01 =    1.9/s Avg:   374 Min:   374 Max:   374 Err:     0 (0.00%) Active: 1 Started: 1 Finished: 0
summary =      1 in 00:00:01 =    1.9/s Avg:   374 Min:   374 Max:   374 Err:     0 (0.00%)
Tidying up remote @ Wed May 10 15:20:00 CST 2017 (1494400800718)
... end of run

可以看到server上的調(diào)用信息:

Starting the test on host 10.0.1.111:31099 @ Wed May 10 15:19:59 CST 2017 (1494400799839)
Finished the test on host 10.0.1.111:31099 @ Wed May 10 15:20:00 CST 2017 (1494400800740)

方案2

壓測(cè)需要部署大量server節(jié)點(diǎn),采用docker部署。

生成JMeter base鏡像需要的Dockerfile如下:

# Use Ubuntu
FROM ubuntu
MAINTAINER adeng <xxxxxx@qq.com>

# Install wger & JRE
RUN apt-get clean && \
    apt-get update && \
    apt-get -qy install \
            wget \
            default-jre-headless \
            telnet \
            iputils-ping \
            unzip

# Install jmeter
RUN   mkdir /jmeter \
    && cd /jmeter/ \
    && wget https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-3.2.tgz \
    && tar -xzf apache-jmeter-3.2.tgz \
    && rm apache-jmeter-3.2.tgz \
    && mkdir /jmeter-plugins \
    && cd /jmeter-plugins/ \
    && wget https://jmeter-plugins.org/downloads/file/JMeterPlugins-ExtrasLibs-1.4.0.zip \
    && unzip -o JMeterPlugins-ExtrasLibs-1.4.0.zip -d /jmeter/apache-jmeter-3.2/

# Set Jmeter Home
ENV JMETER_HOME /jmeter/apache-jmeter-3.2/

# Add Jmeter to the Path
ENV PATH $JMETER_HOME/bin:$PATH

生成JMeter slave鏡像需要的Dockerfile如下:

FROM malfurionpd/jmeter-base
MAINTAINER adeng <xxxxxx@qq.com>

# Ports to be exposed from the container for JMeter Slaves/Server
EXPOSE 31099 32500

# Application to run on starting the container
ENTRYPOINT $JMETER_HOME/bin/jmeter-server \
                        -Dserver.rmi.localport=32500 \
                        -Dserver_port=31099

可以參考這里在Dockerhub上生成鏡像,或者本地生成:

docker build -t malfurionpd/jmeter-slave .

部署三個(gè)容器,主機(jī)端口直接映射容器expose的端口,client直接遠(yuǎn)程調(diào)用:

[root@VM_1_246_centos bin]# ./jmeter -n -t baidu-test.jmx -R10.0.2.104:31099,10.0.3.248:31099,10.0.3.180:31099 -Djava.rmi.server.hostname=10.0.1.246
Creating summariser <summary>
Created the tree successfully using baidu-test.jmx
Configuring remote engine: 10.0.2.104:31099
Configuring remote engine: 10.0.3.248:31099
Configuring remote engine: 10.0.3.180:31099
Starting remote engines
Starting the test @ Wed May 10 17:09:50 CST 2017 (1494407390007)
Remote engines have been started
Waiting for possible Shutdown/StopTestNow/Heapdump message on port 4445
summary =      2 in 00:00:01 =    3.7/s Avg:   174 Min:   112 Max:   236 Err:     0 (0.00%)
Tidying up remote @ Wed May 10 17:09:51 CST 2017 (1494407391402)
summary +      1 in 00:00:01 =    0.8/s Avg:   721 Min:   721 Max:   721 Err:     0 (0.00%) Active: 0 Started: 2 Finished: 3
summary =      3 in 00:00:02 =    1.7/s Avg:   356 Min:   112 Max:   721 Err:     0 (0.00%)
Tidying up remote @ Wed May 10 17:09:52 CST 2017 (1494407392649)
... end of run
... end of run

方案3

參考這里,使用Rancher部署測(cè)試集群。

坑1

直接執(zhí)行jmeter-server報(bào)錯(cuò):

[root@localhost bin]# ./jmeter-server

Created remote object: UnicastServerRef [liveRef: [endpoint:[127.0.0.1:39150](local),objID:[-3126fe29:14300b1102e:-7fff, -4078314045196249121]]]
Server failed to start: java.rmi.RemoteException: Cannot start. localhost is a loopback address.
An error occurred: Cannot start. localhost is a loopback address.

解決方法如下:
In latest version, you can run your script with:指定本地IP

./jmeter-server -Djava.rmi.server.hostname=xxx.xxx.xxx.xxx

坑2

使用全容器部署時(shí),不指定Host IP情況下 RMI總是出問(wèn)題:

root@VM_7_2_centos:/jmeter/apache-jmeter-3.2/bin# ./jmeter -n -t baidu-test.jmx -Djava.rmi.server.hostname=10.0.7.2 -Dclient.rmi.localport=60000 -R10.0.7.14,10.0.7.7
Creating summariser <summary>
Created the tree successfully using baidu-test.jmx
Configuring remote engine: 10.0.7.14
Configuring remote engine: 10.0.7.7
Starting remote engines
Starting the test @ Tue Jun 13 12:59:01 UTC 2017 (1497358741786)
Error in rconfigure() method java.rmi.ConnectIOException: Exception creating connection to: 10.42.37.96; nested exception is:
    java.net.NoRouteToHostException: No route to host (Host unreachable)
Error in rconfigure() method java.rmi.ConnectIOException: Exception creating connection to: 10.42.255.116; nested exception is:
    java.net.NoRouteToHostException: No route to host (Host unreachable)
Remote engines have been started
Waiting for possible Shutdown/StopTestNow/Heapdump message on port 4445

解決方法和上邊一樣,必須想辦法指定 ./jmeter-server -Djava.rmi.server.hostname=xxx.xxx.xxx.xxx

參考文章1
參考文章2
參考文章3
參考文章4
參考文章5
參考Docker三部曲之1
參考Docker三部曲之2
參考Docker三部曲之3

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 230,106評(píng)論 6 542
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 99,441評(píng)論 3 429
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人,你說(shuō)我怎么就攤上這事?!?“怎么了?”我有些...
    開(kāi)封第一講書人閱讀 178,211評(píng)論 0 383
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)。 經(jīng)常有香客問(wèn)我,道長(zhǎng),這世上最難降的妖魔是什么? 我笑而不...
    開(kāi)封第一講書人閱讀 63,736評(píng)論 1 317
  • 正文 為了忘掉前任,我火速辦了婚禮,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 72,475評(píng)論 6 412
  • 文/花漫 我一把揭開(kāi)白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上,一...
    開(kāi)封第一講書人閱讀 55,834評(píng)論 1 328
  • 那天,我揣著相機(jī)與錄音,去河邊找鬼。 笑死,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 43,829評(píng)論 3 446
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了?” 一聲冷哼從身側(cè)響起,我...
    開(kāi)封第一講書人閱讀 43,009評(píng)論 0 290
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 49,559評(píng)論 1 335
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 41,306評(píng)論 3 358
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 43,516評(píng)論 1 374
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 39,038評(píng)論 5 363
  • 正文 年R本政府宣布,位于F島的核電站,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 44,728評(píng)論 3 348
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開(kāi)封第一講書人閱讀 35,132評(píng)論 0 28
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開(kāi)封第一講書人閱讀 36,443評(píng)論 1 295
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 52,249評(píng)論 3 399
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 48,484評(píng)論 2 379

推薦閱讀更多精彩內(nèi)容

  • Spring Cloud為開(kāi)發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見(jiàn)模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 134,826評(píng)論 18 139
  • =========================================================...
    lavor閱讀 3,504評(píng)論 0 5
  • Redis 配置文件示例 注意:想要讀取配置文件,Redis的第一個(gè)參數(shù)必須是文件的路徑 ./redis-serv...
    起個(gè)名忒難閱讀 1,220評(píng)論 0 1
  • 雪白的墻上開(kāi)始落下塊狀的墻灰 時(shí)間的蛇蜿蜒盤繞 屋頂上爬滿青苔的磚瓦開(kāi)始松動(dòng) 時(shí)間的風(fēng)悠久吹動(dòng) 窗欞上縱橫交錯(cuò)的木...
    廖丹妮閱讀 242評(píng)論 0 0
  • :【我的簡(jiǎn)介很簡(jiǎn)潔:播音主持在讀生。從專業(yè)上來(lái)說(shuō),跟口吃這兩個(gè)字八竿子打不著。但此口吃非彼口吃,我愛(ài)吃,一口一口將...
    林HY閱讀 377評(píng)論 3 3