6
8

More than 3 years have passed since last update.

jmeter master/slave環境 構築~実施まで

Last updated at Posted at 2020-10-15

構成

  • 負荷テスト用webサーバ : 192.168.119.99
  • jmeter master/slave環境
    • masterサーバ : 192.168.119.100
    • slaveサーバ(複数台可能) : 192.168.119.101

マスターサーバに設定ファイルを置いて実行することで、ログなどmasterサーバへ集約
今回は、ローカル環境で構築しております。
firewallなどのセキュリティの設定は、各自適切に設定してください。

masterの設定

サーバの前準備

  • SELinux無効化
sed -i -e 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
setenforce 0
  • firewallの無効化
systemctl stop firewalld
systemctl disable firewalld
  • パッケージのインストール
yum -y update
yum -y install wget
yum -y install java-1.8.0-openjdk.x86_64 java-1.8.0-openjdk-devel.x86_64
  • javaの動作確認
java -version
==========
openjdk version "1.8.0_262"
OpenJDK Runtime Environment (build 1.8.0_262-b10)
OpenJDK 64-Bit Server VM (build 25.262-b10, mixed mode)
==========

masterサーバのセットアップ

jmeterインストール

  • jmeterのダウンロードURLを確認

Apache JMeter 本体をオフィシャルサイト のDownloadから取得

無題 - ペイント 2020-09-29 10.23.03.png

  • jmeterのインストール
cd /usr/local/
wget http://www.trieuvan.com/apache//jmeter/binaries/apache-jmeter-5.3.zip
  • 解凍
yum -y install unzip
unzip apache-jmeter-5.3.zip

jmeterの設定

  • slaveサーバの設定(slaveサーバのIPアドレスを記載)
vi /usr/local/apache-jmeter-5.3/bin/jmeter.properties
==========
remote_hosts=192.168.119.101
==========
  • クラスタ内をSSL通信させない設定
vi /usr/local/apache-jmeter-5.3/bin/jmeter.properties
==========
server.rmi.ssl.disable=true
==========
  • hostsの変更
vi /etc/hosts
==========
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
↓
192.168.119.100   localhost localhost.localdomain localhost4 localhost4.localdomain4
==========

起動

  • jmeterが動作することを確認
/usr/local/apache-jmeter-5.3/bin/jmeter -v
==========
OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
    _    ____   _    ____ _   _ _____       _ __  __ _____ _____ _____ ____
   / \  |  _ \ / \  / ___| | | | ____|     | |  \/  | ____|_   _| ____|  _ \
  / _ \ | |_) / _ \| |   | |_| |  _|    _  | | |\/| |  _|   | | |  _| | |_) |
 / ___ \|  __/ ___ \ |___|  _  | |___  | |_| | |  | | |___  | | | |___|  _ <
/_/   \_\_| /_/   \_\____|_| |_|_____|  \___/|_|  |_|_____| |_| |_____|_| \_\ 5.3

Copyright (c) 1999-2020 The Apache Software Foundation
==========
  • 起動
/usr/local/apache-jmeter-5.3/bin/jmeter-server &
  • プロセス確認
ps ax | grep jmeter
==========
16373 pts/1    S      0:00 /bin/sh /usr/local/apache-jmeter-5.3/bin/jmeter-server
16375 pts/1    S      0:00 /bin/sh /usr/local/apache-jmeter-5.3/bin/jmeter -Dserver_port=1099 -s -j jmeter-server.log
16398 pts/1    Sl     0:01 /usr/bin/java -server -XX:+HeapDumpOnOutOfMemoryError -Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20 -Djava.security.egd=file:/dev/urandom -Duser.language=en -Duser.region=EN -jar /usr/local/apache-jmeter-5.3/bin/ApacheJMeter.jar -Dserver_port=1099 -s -j jmeter-server.log
16420 pts/1    R+     0:00 grep --color=auto jmeter
==========
  • 自動でjmeter起動行う設定
vi /etc/rc.d/rc.local
==========
追加
/usr/local/apache-jmeter-5.3/bin/jmeter-server &
==========

chmod +x /etc/rc.d/rc.local

slaveの設定

サーバの前準備

  • SELinux無効化
sed -i -e 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
setenforce 0
  • firewallの無効化
systemctl stop firewalld
systemctl disable firewalld
  • パッケージのインストール
yum -y update
yum -y install wget
yum -y install java-1.8.0-openjdk.x86_64 java-1.8.0-openjdk-devel.x86_64
  • javaの動作確認
java -version
==========
openjdk version "1.8.0_262"
OpenJDK Runtime Environment (build 1.8.0_262-b10)
OpenJDK 64-Bit Server VM (build 25.262-b10, mixed mode)
==========

slaveサーバのセットアップ

jmeterインストール

  • jmeterのダウンロードURLを確認

Apache JMeter 本体をオフィシャルサイト のDownloadから取得

無題 - ペイント 2020-09-29 10.23.03.png

  • jmeterのインストール
cd /usr/local/
wget http://www.trieuvan.com/apache//jmeter/binaries/apache-jmeter-5.3.zip
  • 解凍
yum -y install unzip
unzip apache-jmeter-5.3.zip

jmeterの設定

  • ipアドレスの設定(自分自身、slaveサーバのIPアドレスを記載)
vi /usr/local/apache-jmeter-5.3/bin/jmeter-server
==========
追加
RMI_HOST_DEF=-Djava.rmi.server.hostname=192.168.119.101
==========
  • クラスタ内をSSL通信させない設定
vi /usr/local/apache-jmeter-5.3/bin/jmeter.properties
==========
server.rmi.ssl.disable=true
==========
  • hostsの変更
vi /etc/hosts
==========
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
↓
192.168.119.100   localhost localhost.localdomain localhost4 localhost4.localdomain4
==========

起動

  • jmeterが動作することを確認
/usr/local/apache-jmeter-5.3/bin/jmeter -v
==========
OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
    _    ____   _    ____ _   _ _____       _ __  __ _____ _____ _____ ____
   / \  |  _ \ / \  / ___| | | | ____|     | |  \/  | ____|_   _| ____|  _ \
  / _ \ | |_) / _ \| |   | |_| |  _|    _  | | |\/| |  _|   | | |  _| | |_) |
 / ___ \|  __/ ___ \ |___|  _  | |___  | |_| | |  | | |___  | | | |___|  _ <
/_/   \_\_| /_/   \_\____|_| |_|_____|  \___/|_|  |_|_____| |_| |_____|_| \_\ 5.3

Copyright (c) 1999-2020 The Apache Software Foundation
==========
  • 起動
/usr/local/apache-jmeter-5.3/bin/jmeter-server &
  • プロセス確認
ps ax | grep jmeter
==========
16373 pts/1    S      0:00 /bin/sh /usr/local/apache-jmeter-5.3/bin/jmeter-server
16375 pts/1    S      0:00 /bin/sh /usr/local/apache-jmeter-5.3/bin/jmeter -Dserver_port=1099 -s -j jmeter-server.log
16398 pts/1    Sl     0:01 /usr/bin/java -server -XX:+HeapDumpOnOutOfMemoryError -Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20 -Djava.security.egd=file:/dev/urandom -Duser.language=en -Duser.region=EN -jar /usr/local/apache-jmeter-5.3/bin/ApacheJMeter.jar -Dserver_port=1099 -s -j jmeter-server.log
16420 pts/1    R+     0:00 grep --color=auto jmeter
==========
  • 自動でjmeter起動行う設定
vi /etc/rc.d/rc.local
==========
追加
/usr/local/apache-jmeter-5.3/bin/jmeter-server &
==========

chmod +x /etc/rc.d/rc.local

webサーバの作成

前準備

  • 最新化
yum update
  • セキュリティ無視
systemctl stop firewalld
systemctl disable firewalld
  • selinuxをoff
vi /etc/selinux/config
==========
削除
SELINUX=enforcing
追加
SELINUX=disabled
==========
  • 反映
reboot

webサーバの設定

  • httpdのインストール
yum install httpd
  • 設定ファイル変更
# コメントアウトを外す
ServerName www.example.com:80
  • httpdの起動
systemctl start httpd
systemctl enable httpd

負荷テスト用ファイルの設定

  • ファイルを作成
vi /var/www/html/index.html
==========
hello world
==========
  • ブラウザから確認
http://IPアドレス/index.html

負荷テスト実施

  • 負荷テストについて

負荷テストについては、全てmaster側で操作を行う
今回は事前に負荷テスト用のjmxファイルを用意いたしました。
http://192.168.119.99/index.html を5回叩く設定をtest.jmxに書き込んでおります。
jmxファイルはGUIで作成するのをおすすめします。

  • テスト計画ファイルの作成の際に作ったテスト計画のファイルをjmeterサーバのmasterのみに設置
ll /usr/local/apache-jmeter-5.3/bin/templates/test.jmx 
  • 実施
slaveのjmeterを使って、test.jmxファイルに記述したことをCUIモードで実行する

cd /usr/local/apache-jmeter-5.3/bin
./jmeter -n -t templates/test.jmx -r
----------
-n : CUIモードで実行
-t : シナリオファイル(ここで言うtest.jmx)を指定
-r : slaveのjmeterを利用する
---以下ここでは使っていないがよく使うオプション---
-l : 結果ファイルを指定
-e : レポートを作成
----------
cd /usr/local/apache-jmeter-5.3/bin/
./jmeter -n -t templates/test.jmx -r
==========
OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
Creating summariser <summary>
Created the tree successfully using templates/test.jmx
Configuring remote engine: 192.168.119.101
Starting distributed test with remote engines: [192.168.119.101] @ Tue Sep 29 14:06:52 JST 2020 (1601356012593)
Remote engines have been started:[192.168.119.101]
Waiting for possible Shutdown/StopTestNow/HeapDump/ThreadDump message on port 4445
summary =      5 in 00:00:01 =    5.7/s Avg:     2 Min:     1 Max:     3 Err:     0 (0.00%)
Tidying up remote @ Tue Sep 29 14:06:54 JST 2020 (1601356014825)
... end of run
==========
  • webサーバ側のlog
tail -f /var/log/httpd/access_log 
==========
192.168.119.101 - - [29/Sep/2020:14:06:34 +0900] "GET /index.html HTTP/1.1" 200 12 "-" "Apache-HttpClient/4.5.12 (Java/1.8.0_262)"
192.168.119.101 - - [29/Sep/2020:14:06:34 +0900] "GET /index.html HTTP/1.1" 200 12 "-" "Apache-HttpClient/4.5.12 (Java/1.8.0_262)"
192.168.119.101 - - [29/Sep/2020:14:06:34 +0900] "GET /index.html HTTP/1.1" 200 12 "-" "Apache-HttpClient/4.5.12 (Java/1.8.0_262)"
192.168.119.101 - - [29/Sep/2020:14:06:54 +0900] "GET /index.html HTTP/1.1" 200 12 "-" "Apache-HttpClient/4.5.12 (Java/1.8.0_262)"
192.168.119.101 - - [29/Sep/2020:14:06:54 +0900] "GET /index.html HTTP/1.1" 200 12 "-" "Apache-HttpClient/4.5.12 (Java/1.8.0_262)"
192.168.119.101 - - [29/Sep/2020:14:06:54 +0900] "GET /index.html HTTP/1.1" 200 12 "-" "Apache-HttpClient/4.5.12 (Java/1.8.0_262)"
192.168.119.101 - - [29/Sep/2020:14:06:54 +0900] "GET /index.html HTTP/1.1" 200 12 "-" "Apache-HttpClient/4.5.12 (Java/1.8.0_262)"
192.168.119.101 - - [29/Sep/2020:14:06:54 +0900] "GET /index.html HTTP/1.1" 200 12 "-" "Apache-HttpClient/4.5.12 (Java/1.8.0_262)"
==========
slaveのjmeterから5回、index.htmlにアクセスがあった

参考

構築時に参考

詰まったときに参考

6
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
8