通过案例带你轻松玩转JMeter连载(51)

简介: 通过案例带你轻松玩转JMeter连载(51)

性能测试监控



1压测端监控:JMeter集群+InfluxDB存储+Grafana


在压测端,如果发现发出去的进程失败的比例比较多,可以考虑以下两种情形:
1)被测软件的性能达到瓶颈,接受不了如此多的请求。
2)压测端压测工具(比如JMeter)所运行的机器由于发送过多的线程,压测机器资源(CPU、内存、网络或者是磁盘)不够用,需要增加JMeter来解决。


这就需要在执行性能测试的时候,有对应的监控工具来监控。第1节和第3节中介绍的工具均可以达到这个功能,但是JMeter集群+InfluxDB存储+Grafana是目前最友好的监控压测端的工具组合。


JMeter集群+InfluxDB存储+Grafana环境可以安装在Windows、Linux或MAC任意操作系统下,本节以Windows为例进行讲解。


1.1下载安装InfluxDB


  • InfluxDB是一个开源分布式时序、时间和指标的数据库,它是使用 Go语言编写的,无需外部依赖。其设计目标是实现分布式和水平伸缩扩展,是InfluxData的核心产品。
  • InfluxDB的应用:性能监控,应用程序指标,物联网传感器数据和实时分析等的后端存储。
  • InfluxDB 完整的上下游产业还包括:Chronograf、Telegraf、Kapacitor,其具体作用及关系如图1所示。

image.png

1 InfluxDB家族图


具体操作步骤如下。
1)到https://dl.influxdata.com/influxdb/releases/influxdb2-2.0.6-windows-amd64.zip下载influxdb2-2.0.6-windows-amd64.zip。
2)将下载下来的zip文件存储在本地一个非中文目录下(我下载在C:\influxdb-1.7.3-1下)。
3)进入C:\influxdb-1.7.3-1目录,用文本编辑器打开influxdb.conf。
4)按如下深色部分进行编辑


[meta]
  # Where the metadata/raft database is stored
  # dir = "/var/lib/influxdb/meta"
  dir = "C:\\influxdb\\meta"
  #我设为C:\\influxdb,数据库文件将产生在C:\\influxdb目录下。
  # Automatically create a default retention policy when creating a database.
  retention-autocreate = true
  # If log messages are printed for the meta service
  logging-enabled = true
[data]
  # The directory where the TSM storage engine stores TSM files.
  dir = "C:\\influxdb\\meta"
  # The directory where the TSM storage engine stores WAL files.
  wal-dir = "C:\\influxdb\\wal"
[retention]
  # Determines whether retention policy enforcement enabled.
  enabled = true
  # The interval of time when retention policy enforcement checks run.
  check-interval = "30m"
[shard-precreation]
  # Determines whether shard pre-creation service is enabled.
  enabled = true
  # The interval of time when the check to pre-create new shards runs.
  check-interval = "10m"
  # The default period ahead of the endtime of a shard group that its successor
  # group is created.
  advance-period = "30m"
[monitor]
  # Whether to record statistics internally.
  store-enabled = true
  # The destination database for recorded statistics
  store-database = "_internal"
  # The interval at which to record statistics
  store-interval = "10s"


5)用influxd -config influxdb.conf运行


C:\influxdb-1.7.3-1>influxd -config influxdb.conf
 8888888           .d888 888                   8888888b.  888888b.
   888            d88P"  888                   888  "Y88b 888  "88b
   888            888    888                   888    888 888  .88P
   888   88888b.  888888 888 888  888 888  888 888    888 8888888K.
   888   888 "88b 888    888 888  888  Y8bd8P' 888    888 888  "Y88b
   888   888  888 888    888 888  888   X88K   888    888 888    888
   888   888  888 888    888 Y88b 888 .d8""8b. 888  .d88P 888   d88P
 8888888 888  888 888    888  "Y88888 888  888 8888888P"  8888888P"
2021-06-04T09:46:34.406806Z     info    Starting retention policy enforcement service   
{"log_id": "0UXbWmRG000", "service": "retention", "check_interval": "30m"}
2021-06-04T09:46:34.408611Z     info    Listening for signals   {"log_id": 
"0UXbWmRG000"}
2021-06-04T09:46:34.408611Z     info    Sending usage statistics to 
usage.influxdata.com        {"log_id": "0UXbWmRG000"}


如果出现“Sending usage statistics to usage.influxdata.com”,表示InfluxDB启动成功。


1.2配置InfluxDB


  • 用InfluxDB Studio配置

InfluxDB Studio是InfluxDB的图形化配置界面。通过以下步骤配置InfluxDB。
1)连接获得InfluxDB Studio。
链接:https://pan.baidu.com/s/1CRJXtmj_W5bIEJjkP0mR5g
提取码:ok87。
2)解压后直接运行InfluxDBStudio.exe。
3)点击图2中的图标。


image.png

图2 在InfluxDBStudio开始建立数据库连接


4)在图3中,输入任意你喜欢的连接名,InfluxDB地址(默认为localhost)和端口号(默认为8086)以及用户名和密码。点击【Test】按键,显示测试成功,点击【Save】按键,显示连接成功后,保存关闭。


image.png

图3 建立InfluxDBStudio数据库连接


5)在左边出现图4的树状结构,_internal为默认数据库。

image.png

图 4 InfluxDB默认数据库


6)如图5 a)所示,右击菜单根部,点击菜单“Create Database”。
7)如图5 b)所示,输入“jmeter”。
8)如图5 c)所示,jmeter数据库建立成功后。


image.png

a)

image.png

b)


image.png

c)

图5 建立jmeter数据库


  • 用命令行配置

1)在命令行中,运行Influx.exe,进入InfluxDB命令行。

C:\InfluxDB-1.7.3-1>influx.exe
Connected to http://localhost:8086 version 1.7.3
InfluxDB shell version: 1.7.3
Enter an InfluxQL query
>


2)依次键入如下命令。

>CREATE USER admin WITH PASSWORD 'admin' WITH ALL PRIVILEGES
>auth admin admin 
>CREATE DATABASE jmeter 
>show databases use jmeter 
>show measurements


执行最后一个命令,命令行界面显示为空,当前还没有数据。

相关实践学习
通过性能测试PTS对云服务器ECS进行规格选择与性能压测
本文为您介绍如何利用性能测试PTS对云服务器ECS进行规格选择与性能压测。
目录
相关文章
|
存储 Linux
通过案例带你轻松玩转JMeter连载(60)
通过案例带你轻松玩转JMeter连载(60)
130 0
通过案例带你轻松玩转JMeter连载(60)
|
算法
通过案例带你轻松玩转JMeter连载(59)
通过案例带你轻松玩转JMeter连载(59)
177 0
通过案例带你轻松玩转JMeter连载(59)
|
XML JavaScript Java
通过案例带你轻松玩转JMeter连载(58)
通过案例带你轻松玩转JMeter连载(58)
102 0
通过案例带你轻松玩转JMeter连载(58)
通过案例带你轻松玩转JMeter连载(57)
通过案例带你轻松玩转JMeter连载(57)
93 0
通过案例带你轻松玩转JMeter连载(57)
|
存储 索引
通过案例带你轻松玩转JMeter连载(56)
通过案例带你轻松玩转JMeter连载(56)
87 0
通过案例带你轻松玩转JMeter连载(56)
|
存储 Prometheus 监控
通过案例带你轻松玩转JMeter连载(55)
通过案例带你轻松玩转JMeter连载(55)
114 0
通过案例带你轻松玩转JMeter连载(55)
|
存储 监控 数据可视化
通过案例带你轻松玩转JMeter连载(54)
通过案例带你轻松玩转JMeter连载(54)
118 0
通过案例带你轻松玩转JMeter连载(54)
|
存储 Prometheus 监控
通过案例带你轻松玩转JMeter连载(53)
通过案例带你轻松玩转JMeter连载(53)
113 0
通过案例带你轻松玩转JMeter连载(53)
|
JSON 监控 数据可视化
通过案例带你轻松玩转JMeter连载(52)
通过案例带你轻松玩转JMeter连载(52)
152 0
通过案例带你轻松玩转JMeter连载(52)
|
Java 测试技术 Apache
通过案例带你轻松玩转JMeter连载(50)
通过案例带你轻松玩转JMeter连载(50)
174 0
通过案例带你轻松玩转JMeter连载(50)