본문 바로가기

리눅스

[리눅스] How to install JMeter on Linux

반응형

How to install JMeter on Linux

Installation platform

$ cat /etc/os-release
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"

Installing JAVA

$ amazon-linux-extras install java-openjdk11

$ java -version
openjdk version "11.0.7" 2020-04-14 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.7+10-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.7+10-LTS, mixed mode, sharing)

Installing JMeter

$ cd /usr/local/src/
$ export JMETER_VERSION=5.3
$ wget -q https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-$JMETER_VERSION.tgz
$ tar -xzf apache-jmeter-$JMETER_VERSION.tgz
$ mv apache-jmeter-$JMETER_VERSION /usr/local/jmeter

$ export JMETER_HOME=/usr/local/jmeter
$ export PATH=$JMETER_HOME/bin:$PATH

$ jmeter -v

728x90

www_testplan.jmx edit

- LoopController.loops : 10
- ThreadGroup.num_threads : 100
- ThreadGroup.ramp_time : 0
- HTTPSampler.domain : sangchul.kr
- HTTPSampler.port : 443
- HTTPSampler.protocol : https

Number of Threads(user) : 쓰레드 개수(가상 유저의 수)
Ramp-Up Period(in seconds) : 사용자 수가 모이는(만들어지는) 시간을 설정합니다. 유저 수가 100인데 Ramp-up Period가 10이라면 10초동안 100명의 사용자를 만들어내는 것을 뜻한다. 즉 0.1초에 1명의 사용자가 생성됩니다.
Loop Count : 반복하고자 하는 횟수, Infinite를 누르면 무제한 실행.
...
    <hashTree>
      <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
        <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
        <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
          <boolProp name="LoopController.continue_forever">false</boolProp>
          <stringProp name="LoopController.loops">10</stringProp>
        </elementProp>
        <stringProp name="ThreadGroup.num_threads">100</stringProp>
        <stringProp name="ThreadGroup.ramp_time">0</stringProp>
        <boolProp name="ThreadGroup.scheduler">false</boolProp>
        <stringProp name="ThreadGroup.duration"></stringProp>
        <stringProp name="ThreadGroup.delay"></stringProp>
        <boolProp name="ThreadGroup.same_user_on_next_iteration">true</boolProp>
      </ThreadGroup>
      <hashTree>
        <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Request" enabled="true">
          <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
            <collectionProp name="Arguments.arguments"/>
          </elementProp>
          <stringProp name="HTTPSampler.domain">sanghcul.kr</stringProp>
          <stringProp name="HTTPSampler.port">443</stringProp>
          <stringProp name="HTTPSampler.protocol">https</stringProp>
          <stringProp name="HTTPSampler.contentEncoding"></stringProp>
          <stringProp name="HTTPSampler.path"></stringProp>
          <stringProp name="HTTPSampler.method">GET</stringProp>
          <boolProp name="HTTPSampler.follow_redirects">true</boolProp>
          <boolProp name="HTTPSampler.auto_redirects">false</boolProp>
          <boolProp name="HTTPSampler.use_keepalive">true</boolProp>
          <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
          <stringProp name="HTTPSampler.embedded_url_re"></stringProp>
          <stringProp name="HTTPSampler.connect_timeout"></stringProp>
          <stringProp name="HTTPSampler.response_timeout"></stringProp>
        </HTTPSamplerProxy>
        <hashTree/>
      </hashTree>
...

Run jmeter

jmeter -n -f -t www_testplan.jmx -l www_log.jtl -e -o www-report

Print out the jmeter report

docker run -d -v /usr/local/jmeter/bin/www-report:/usr/share/nginx/html -p 80:80 --name nginx nginx

 

728x90
반응형