首页 > 其他分享 >sysbench压测工具操作文档

sysbench压测工具操作文档

时间:2023-03-24 13:46:22浏览次数:57  
标签:off 压测 XXX -- 文档 mysql sysbench

目录

sysbench压测工具操作文档

sysbench是一个基于 LuaJIT 的可编写脚本的多线程基准测试工具。它最常用于数据库基准测试,但也可用于创建不涉及数据库服务器的任意复杂工作负载

一、安装sysbench

1.1、借助包管理器安装

  • Debian/Ubuntu
curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/script.deb.sh | sudo bash
apt -y install sysbench
  • RHEL/CentOS
curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/script.rpm.sh | sudo bash
yum -y install sysbench
  • Fedora
curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/script.rpm.sh | sudo bash	
dnf -y install sysbench
  • Arch Linux
pacman -Suy sysbench

1.2、源码编译安装

以CentOS系统为例

yum install gcc gcc-c++ autoconf automake make libtool mysql-devel git mysql
git clone https://github.com/akopytov/sysbench.git
##从Git中下载Sysbench
cd sysbench
##打开sysbench目录
git checkout 1.0.18
##切换到sysbench 1.0.18版本
./autogen.sh
##运行autogen.sh
./configure --prefix=/usr --mandir=/usr/share/man
make
##编译
make install

使用说明

帮助文档

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];创建测试线程的数目。默认为1
  --events=N                      limit for total number of events [0];请求的最大数目,0代表不限制
  --time=N                        limit for total execution time in seconds [10];最大执行时间,单位是s。默认是10s
  --forced-shutdown=STRING        number of seconds to wait after the --time limit before forcing shutdown, or 'off' to disable [off];过max-time强制中断。默认是off
  --thread-stack-size=SIZE        size of stack per thread [64K];每个线程的堆栈大小。默认是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];是否显示更多的调试信息。默认是off
  --validate[=on|off]             perform validation checks where possible [off];在可能情况下执行验证检查。默认是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];默认情况下使用的随机数分布 {uniform, gaussian, special, pareto, zipfian}
  --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];随机数生成器的种子。为 0 时,当前时间用作 RNG 种子
  --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

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]

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

See 'sysbench <testname> help' for a list of options for each test.

一般用法

sysbench 的一般命令行语法是

sysbench [options]... [testname] [command] 
  • options:部分包括测试需要的各种选项,有全局的也有每个测试模式自由的选项
  • testname:指定测试类型,基本类型有fileio,cpu,memory,threads,mutex,oltp(或者指定lua脚本)
  • command:控制命令
  • prepare:为需要它们的测试执行准备操作,例如在磁盘上为测试创建必要的文件fileio,或为数据库基准填充测试数据库
  • run:运行用testname参数指定的实际测试
  • cleanup:清除准备阶段生成的测试数据
  • help:显示使用testname参数指定的测试的使用信息

mysql压测示例

#准备数据
sysbench --db-driver=mysql --mysql-host=XXX --mysql-port=XXX --mysql-user=XXX --mysql-password=XXX --mysql-db=sbtest --table_size=25000 --tables=100 --events=0 --time=300  --threads=XXX oltp_read_write prepare

#运行workload
sysbench --db-driver=mysql --mysql-host=XXX --mysql-port=XXX --mysql-user=XXX --mysql-password=XXX --mysql-db=sbtest --table_size=25000 --tables=100 --events=0 --time=300   --threads=XXX --percentile=95 --report-interval=1 oltp_read_write run

#清理数据
sysbench --db-driver=mysql --mysql-host=XXX --mysql-port=XXX --mysql-user=XXX --mysql-password=XXX --mysql-db=sbtest --table_size=25000 --tables=100 --events=0 --time=300   --threads=XXX --percentile=95  oltp_read_write cleanup

CPU压测示例

sysbench cpu --cpu-max-prime=XXX --threads=XXX run

内存压测示例

sysbench --test=memory --memory-block-size=8K --memory-total-size=1G --num-threads=XXX run

磁盘IO压测示例

#准备数据
sysbench --test=fileio --file-total-size=2G prepare

#运行
sysbench --test=fileio --file-total-size=2G run

#清理数据
sysbench --test=fileio --file-total-size=2G cleanup

标签:off,压测,XXX,--,文档,mysql,sysbench
From: https://www.cnblogs.com/c-moon/p/17251285.html

相关文章

  • JavaScript DOM总结(文档事件)
    阅读目录DOM文档事件窗口事件表单事件键盘事件鼠标事件DOM文档事件事件概述HTML事件可以触发浏览器中的行为,比方说当用户点击某个HTML元素时启动一段JavaScript。窗口事......
  • 暴力测试--CC压测服务器端口
    #coding=utf-8importctypeslibgcc_s=ctypes.CDLL('libgcc_s.so.1')importsocketimportthreading#定义IP地址和端口范围ip_address="192.168.1.45"start_p......
  • 文档流
    文档流文档流是文档中可显示对象在排列时所占用的位置/空间例如:块元素自上而下摆放,内联元素,从左到右摆放标准流里面的限制非常多,导致很多页面效果无法实现高矮不......
  • sysbench
    https://github.com/akopytov/sysbench->安装见readme,很简单。 sysbench是一个非常经典的综合性能测试工具,它支持CPU,IO,内存,尤其是数据库的性能测试。#如下表示安装......
  • 蓝鲸开发文档
    基础环境:1、蓝鲸平台,hosts文件配置2、python3.6x mysql5.x git  3、创建代码仓库,此文用的gitee,创建应用,并下载解压开发框架 初始化开发框架先修改本地ho......
  • docker搭建yapi接口文档系统、Idea中上传接口、在线调用
    一、前言在我们后端开发中,必不可少的是接口的交接,有很多种方式,常见的就是swagger,不过这个侵入性太强了。还有就是接口文档的框架,比如今天小编带大家一起搭建的yapi,在公司还......
  • gor实现线上HTTP流量复制压测引流
    一、使用背景gor是一款go语言实现的简单的http流量复制工具,它的主要目的是使你的生产环境HTTP真实流量在测试环境和预发布环境重现。只需要在代理例如nginx入口服务器上......
  • IDEA+Apifox生成接口文档以及接口测试
    问题写好代码,想要接口文档以及接口测试准备步骤1.ApifoxHelper插件下载:idea中下载插件file->settings->Plugins->Marktplace中搜索ApifoxHelper2.去官网下载注......
  • 全网最详细中英文ChatGPT-GPT-4示例文档-从0到1快速入门翻译编程语言应用——官网推荐
    目录Introduce简介setting设置Prompt提示Sampleresponse回复样本APIrequest接口请求python接口请求示例node.js接口请求示例curl命令示例json格式示例其它资料下载......
  • 全网最详细中英文ChatGPT-GPT-4示例文档-从0到1快速入门python代码解释应用——官网推
    目录Introduce简介setting设置Prompt提示Sampleresponse回复样本APIrequest接口请求python接口请求示例node.js接口请求示例curl命令示例json格式示例其它资料下载......