如何通过JMeter查看数据库连接? [英] How to see DB connections via JMeter?

查看:563
本文介绍了如何通过JMeter查看数据库连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JMeter的新手,我们可以通过Jmeter跟踪活动的数据库连接吗? Jmeter中是否有任何参数或东西可以使工作变得更容易.

M newbie to JMeter, Can we track the active DB connections via Jmeter? Is there any parameter or thing in Jmeter which can do the job easier.

现在,我只是通过终端监视数据库连接. Jmeter有可能

Right now I am just monitoring the DB connections via terminal. Is it possible with Jmeter

推荐答案

鉴于您的数据库是MySQL:

Given that your database is MySQL:

  1. 下载 MySQL Connector/J ,解压缩mysql-connector-java-x.x.xx-bin.jar,将其拖放到JMeter安装的/lib文件夹,重新启动JMeter
  2. 线程组添加到测试计划中.对其进行如下配置:

  1. Download MySQL Connector/J, extract mysql-connector-java-x.x.xx-bin.jar, drop it to /lib folder of your JMeter installation, restart JMeter
  2. Add Thread Group to the test plan. Configure it as follows:

  • 线程数:1
  • 升级:1
  • 循环数:勾选Forever
  • Number of threads: 1
  • Ramp-up: 1
  • Loop Count: tick Forever

添加 JDBC连接配置元素.对其进行如下配置:

Add JDBC Connection Configuration element. Configure it as follows:

  • 变量名称:任何有意义的名称,例如test
  • 数据库URL:jdbc:mysql://your_mysql_host:3306/information_schema
  • JDBC驱动程序类:com.mysql.jdbc.Driver
  • 也提供您的凭据
  • Variable Name: anything meaningful, i.e. test
  • Database URL: jdbc:mysql://your_mysql_host:3306/information_schema
  • JDBC Driver Class: com.mysql.jdbc.Driver
  • provide your credentials as well

添加 JDBC请求采样器.以另一种方式配置它:

Add JDBC Request Sampler. Configure it the next way:

  • 变量名称:test或您在JDBC连接配置元素中输入的名称
  • SQL查询:select * from PROCESSLIST;
  • Variable Name: test or what you have entered in the JDBC Connection Configuration element
  • SQL Query: select * from PROCESSLIST;

以上配置将每5秒钟查询一次MySQL服务器,结果将转到查看结果树"侦听器.

Above config will query MySQL server each 5 seconds and results will go to the View Results Tree listener.

如果使用其他RDBMS服务器,则方法应该相同,但是JDBC驱动程序二进制文件,驱动程序类名称,URL和SQL查询将有所不同.

If you use other RDBMS server the approach should be the same, however JDBC driver binary, driver class name, URL and SQL query will be different.

请参见构建数据库测试计划的真正秘诀JMeter 获取有关使用Apache JMeter进行数据库测试的更多信息.

See The Real Secret to Building a Database Test Plan With JMeter for extra information on database testing with Apache JMeter.

这篇关于如何通过JMeter查看数据库连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆