前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >DBA必备压测工具之--sysbench

DBA必备压测工具之--sysbench

作者头像
DBA札记
发布2021-07-29 10:16:56
5610
发布2021-07-29 10:16:56
举报
文章被收录于专栏:MySQL参数系列MySQL参数系列

1.github地址:https://github.com/akopytov/sysbench

2.在线安装

依赖安装:

代码语言:javascript
复制
yum -y install make automake libtool pkgconfig libaio-devel
 # For MySQL support, replace with mysql-devel on RHEL/CentOS 5
yum -y install mariadb-devel openssl-devel
 # For PostgreSQL support
yum -y install postgresql-devel

sysbench安装(centos系统)

代码语言:javascript
复制
curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/script.rpm.sh | sudo bash
sudo yum -y install sysbench

3.用法

代码语言:javascript
复制
 sysbench [options]... [testname] [command]

参数解释:

testname是一个内置测试(例如文件、内存、cpu等)的可选名称,或者一个捆绑的Lua脚本的名称(例如oltp_read_only),或者一个自定义Lua脚本的路径。如果在命令行上没有指定测试名(因此也没有命令,因为在这种情况下,它将被解析为testname),或者测试名是一个短横线(“-”),那么sysbench期望Lua脚本在其标准输入上执行。

command是一个可选参数,将由sysbench传递给内置的测试或脚本,由testname指定。命令定义了测试必须执行的动作。

可用命令的列表取决于特定的测试。有些测试还实现了它们自己的自定义命令。有4个选项:

prepare ---准备数据

run ---测试

cleanup ---清理数据

help ---帮助

常见可选项列表如下:

Option

Description

Default value

--threads

The total number of worker threads to create

1

--events

Limit for total number of requests. 0 (the default) means no limit

0

--time

Limit for total execution time in seconds. 0 means no limit

10

--warmup-time

Execute events for this many seconds with statistics disabled before the actual benchmark run with statistics enabled. This is useful when you want to exclude the initial period of a benchmark run from statistics. In many benchmarks, the initial period is not representative because CPU/database/page and other caches need some time to warm up

0

--rate

Average transactions rate. The number specifies how many events (transactions) per seconds should be executed by all threads on average. 0 (default) means unlimited rate, i.e. events are executed as fast as possible

0

--thread-init-timeout

Wait time in seconds for worker threads to initialize

30

--thread-stack-size

Size of stack for each thread

32K

--report-interval

Periodically report intermediate statistics with a specified interval in seconds. Note that statistics produced by this option is per-interval rather than cumulative. 0 disables intermediate reports

0

--debug

Print more debug info

off

--validate

Perform validation of test results where possible

off

--help

Print help on general syntax or on a specified test, and exit

off

--verbosity

Verbosity level (0 - only critical messages, 5 - debug)

4

--percentile

sysbench measures execution times for all processed requests to display statistical information like minimal, average and maximum execution time. For most benchmarks it is also useful to know a request execution time value matching some percentile (e.g. 95% percentile means we should drop 5% of the most long requests and choose the maximal value from the remaining ones). This option allows to specify a percentile rank of query execution times to count

95

--luajit-cmd

perform a LuaJIT control command. This option is equivalent to luajit -j. See LuaJIT documentation for more information

请注意,所有大小选项的数值(如该表中的——thread-stack-size)都可以通过添加相应的后缀来指定

(K表示kilobytes, M表示megabytes, G表示gigabytes, T表示terabytes)。

随机数的选项:

Sysbench提供了许多算法来生成根据给定概率分布分布的随机数。下表列出了可用于控制这些算法的选项。

Option

Description

Default value

--rand-type

random numbers distribution {uniform, gaussian, special, pareto, zipfian} to use by default. Benchmark scripts may choose to use either the default distribution, or specify it explictly, i.e. override the default.

special

--rand-seed

seed for random number generator. When 0, the current time is used as an RNG seed.

0

--rand-spec-iter

number of iterations for the special distribution

12

--rand-spec-pct

percentage of the entire range where 'special' values will fall in the special distribution

1

--rand-spec-res

percentage of 'special' values to use for the special distribution

75

--rand-pareto-h

shape parameter for the Pareto distribution

0.2

--rand-zipfian-exp

shape parameter (theta) for the Zipfian distribution

0.8

4. 实际测试案例

代码语言:javascript
复制
sysbench --mysql-host=localhost --mysql-port=3306 --mysql-user=root --mysql-password=password --mysql-db=dbtest oltp_insert prepare
代码语言:javascript
复制
sysbench --mysql-host=localhost --mysql-port=3306 --mysql-user=root 
--mysql-password=password --time=12000 --mysql-db=dbtest oltp_insert run > test1.txt &

ps:1.本文为sysbench 1.0.20版本,参数与老版本有区别;

2.其他操作系统的安装可参考文章开头地址。

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2021-07-21,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 DBA札记 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
云数据库 MySQL
腾讯云数据库 MySQL(TencentDB for MySQL)为用户提供安全可靠,性能卓越、易于维护的企业级云数据库服务。其具备6大企业级特性,包括企业级定制内核、企业级高可用、企业级高可靠、企业级安全、企业级扩展以及企业级智能运维。通过使用腾讯云数据库 MySQL,可实现分钟级别的数据库部署、弹性扩展以及全自动化的运维管理,不仅经济实惠,而且稳定可靠,易于运维。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档