广告
返回顶部
首页 > 资讯 > 数据库 >通过sysbench工具实现MySQL数据库的性能测试的方法
  • 208
分享到

通过sysbench工具实现MySQL数据库的性能测试的方法

2024-04-02 19:04:59 208人浏览 独家记忆
摘要

1.背景  sysbench是一款压力测试工具,可以测试系统的硬件性能,也可以用来对数据库进行基准测试。sysbench 支持的测试有CPU运算性能测试、内存分配及传输速度测试、磁盘io性能测试、

1.背景

 sysbench是一款压力测试工具,可以测试系统的硬件性能,也可以用来对数据库进行基准测试。sysbench 支持的测试有CPU运算性能测试、内存分配及传输速度测试、磁盘io性能测试、POSIX线程性能测试、互斥性测试测试、数据库性能测试(OLTP基准测试)。目前支持的数据库主要是Mysql数据库和PG数据库。

在新服务器上线时,建议对服务器的性能做一次测试,最好与既往的同类型的服务器的性能测试报表做一个横线比较,发现潜在问题。及新机器上线前,对服务器做一次体检。

对数据库而言,我们可以通过sysbench工具实现对数据库的基准测试。在现在的系统架构中,前端都比较容易弹性水平拓展,数据库相对较难,因此,基准测试对数据库具有很重要的作用。而对数据库的基准测试的作用,就是分析在当前的配置下(包括硬件配置、OS、数据库设置等),数据库的性能表现,从而找出mysql的性能阈值,并根据实际系统的要求调整配置。

2.sysbench的安装

1)安装命令

yum -y install sysbench

2)查看安装的版本

sysbench --version

通过sysbench工具实现MySQL数据库的性能测试的方法

3)查看已安装软件的信息(主要是通 rpm 命令)。

 查询sysbench的安装信息,主要是测试mysql时,需要使用sysbench自带的lua脚本进行测试。如果使用快速安装的方式,默认的脚本路径为:/usr/share/sysbench

 如果不在这个命令,我们我们执行以下命令查看,查找已安装在本机linux系统上面的所有的sysbench软件的程序:

rpm -qa sysbench

列出该软件所有的文件与目录所在完整文件名(list):

rpm -ql sysbench

通过sysbench工具实现MySQL数据库的性能测试的方法

3.sysbench 语法


sysbench --help
Usage:
 sysbench [options]... [testname] [command]
Commands implemented by most tests: prepare run cleanup help
General options:
 --threads=N           number of threads to use [1]
 --events=N           limit for total number of events [0]
 --time=N            limit for total execution time in seconds [10]
 --forced-shutdown=STRING    number of seconds to wait after the --time limit before forcing shutdown, or 'off' to disable [off]
 --thread-stack-size=SIZE    size of stack per thread [64K]
 --rate=N            average transactions rate. 0 for unlimited rate [0]
 --report-interval=N       periodically report intermediate statistics with a specified interval in seconds. 0 disables intermediate reports [0]
 --report-checkpoints=[LIST,...] dump full statistics and reset all counters at specified points in time. The argument is a list of comma-separated values representing the amount of time in seconds elapsed from start of test when report checkpoint(s) must be perfORMed. Report checkpoints are off by default. []
 --debug[=on|off]        print more debugging info [off]
 --validate[=on|off]       perform validation checks where possible [off]
 --help[=on|off]         print help and exit [off]
 --version[=on|off]       print version and exit [off]
 --config-file=FILENAME     File containing command line options
 --tx-rate=N           deprecated alias for --rate [0]
 --max-requests=N        deprecated alias for --events [0]
 --max-time=N          deprecated alias for --time [0]
 --num-threads=N         deprecated alias for --threads [1]
Pseudo-Random Numbers Generator options:
 --rand-type=STRING random numbers distribution {uniform,gaussian,special,pareto} [special]
 --rand-spec-iter=N number of iterations used for numbers generation [12]
 --rand-spec-pct=N percentage of values to be treated as 'special' (for special distribution) [1]
 --rand-spec-res=N percentage of 'special' values to use (for special distribution) [75]
 --rand-seed=N   seed for random number generator. When 0, the current time is used as a RNG seed. [0]
 --rand-pareto-h=N parameter h for pareto distribution [0.2]
Log options:
 --verbosity=N verbosity level {5 - debug, 0 - only critical messages} [3]
 --percentile=N    percentile to calculate in latency statistics (1-100). Use the special value of 0 to disable percentile calculations [95]
 --histogram[=on|off] print latency histogram in report [off]
General database options:
 --db-driver=STRING specifies database driver to use ('help' to get list of available drivers) [mysql]
 --db-ps-mode=STRING prepared statements usage mode {auto, disable} [auto]
 --db-debug[=on|off] print database-specific debug information [off]
Compiled-in database drivers:
 mysql - MySQL driver
 pgsql - postgresql driver
mysql options:
 --mysql-host=[LIST,...]     MySQL Server host [localhost]
 --mysql-port=[LIST,...]     MySQL server port [3306]
 --mysql-Socket=[LIST,...]    MySQL socket
 --mysql-user=STRING       MySQL user [sbtest]
 --mysql-passWord=STRING     MySQL password []
 --mysql-db=STRING        MySQL database name [sbtest]
 --mysql-ssl[=on|off]       use SSL connections, if available in the client library [off]
 --mysql-ssl-cipher=STRING    use specific cipher for SSL connections []
 --mysql-compression[=on|off]   use compression, if available in the client library [off]
 --mysql-debug[=on|off]      trace all client library calls [off]
 --mysql-ignore-errors=[LIST,...] list of errors to ignore, or "all" [1213,1020,1205]
 --mysql-dry-run[=on|off]     Dry run, pretend that all MySQL client api calls are successful without executing them [off]
pgsql options:
 --pgsql-host=STRING   PostgreSQL server host [localhost]
 --pgsql-port=N     PostgreSQL server port [5432]
 --pgsql-user=STRING   PostgreSQL user [sbtest]
 --pgsql-password=STRING PostgreSQL password []
 --pgsql-db=STRING    PostgreSQL database name [sbtest]
Compiled-in tests:
 fileio - File I/O test
 cpu - CPU performance test
 memory - Memory functions speed test
 threads - Threads subsystem performance test
 mutex - Mutex performance test
您可能感兴趣的文档:

--结束END--

本文标题: 通过sysbench工具实现MySQL数据库的性能测试的方法

本文链接: https://www.lsjlt.com/news/50766.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作