sysbench是一个压力测试工具、可以用它来测试cpu、mem、disk、thread、mysql、postgr、oracle;然而作为一个mysql dba 我当然是用它来压测mysql啦!

一、从哪里可以下载到sysbench

  sysbench的源码可以在github上面下载的到,sysbench的主页

https://github.com/akopytov/sysbench

二、sysbench的一些安装依赖

yum -y install  make automake libtool pkgconfig libaio-devel vim-common

  在我的机器上已经安装上了mysql相关的所有包,如果你机器上还没有安装过这些,那你还要安装上mysql的开发包,由于系统自带mariadb

  这个mysql分支,所以在安装mysql-devel时应该是安装mariadb-devel

三、安装sysbench

  1  进入到sysbench源码目录

/home/jianglexing/Desktop/sysbench-master

  2  执行autogen.sh用它来生成configure这个文件

./autogen.sh

  3  执行configure && make && make install 来完成sysbench的安装

./configure --prefix=/usr/local/sysbench/ --with-mysql --with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib
make
make install

  我这里之所以要这样写是因为我的mysql安装在/usr/local/;而不是默认的rpm的安装位置

四、测试是否安装成功

[root@workstudio bin]# /usr/local/sysbench/bin/sysbench --version
sysbench 1.1.

  到目前为止sysbench的安装就算是完成了!

五、sysbench的帮助内容如下

 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]
--warmup-time=N execute events for this many seconds with statistics disabled before the actual benchmark run with statistics enabled [0]
--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]
--thread-init-timeout=N wait time in seconds for worker threads to initialize [30]
--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
--luajit-cmd=STRING perform LuaJIT control command. This option is equivalent to 'luajit -j'. See LuaJIT documentation for more information
--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)
--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对数据库进行压力测试的过程

  1  prepare 阶段 这个阶段是用来做准备的、比较说建立好测试用的表、并向表中填充数据。

  2  run       阶段 这个阶段是才是去跑压力测试的SQL

  3  cleanup 阶段 这个阶段是去清除数据的、也就是prepare阶段初始化好的表要都drop掉

七、sysbench 中的测试类型大致可以分成内置的,lua脚本自定义的测试:

  1、内置:

    fileio 、cpu 、memory 、threads 、 mutex

  2、lua脚本自定义型:

    sysbench 自身内涵了一些测试脚本放在了安装目录下的:

[jianglexing@cstudio sysbench]$ ll share/sysbench
总用量
-rwxr-xr-x. root root 10月 : bulk_insert.lua
-rw-r--r--. root root 10月 : oltp_common.lua
-rwxr-xr-x. root root 10月 : oltp_delete.lua
-rwxr-xr-x. root root 10月 : oltp_insert.lua
-rwxr-xr-x. root root 10月 : oltp_point_select.lua
-rwxr-xr-x. root root 10月 : oltp_read_only.lua
-rwxr-xr-x. root root 10月 : oltp_read_write.lua
-rwxr-xr-x. root root 10月 : oltp_update_index.lua
-rwxr-xr-x. root root 10月 : oltp_update_non_index.lua
-rwxr-xr-x. root root 10月 : oltp_write_only.lua
-rwxr-xr-x. root root 10月 : select_random_points.lua
-rwxr-xr-x. root root 10月 : select_random_ranges.lua
drwxr-xr-x. root root 10月 : tests

八、通过sysbench自带的lua脚本对mysql进行测试:

  1、第一步 prepare

sysbench --mysql-host=localhost --mysql-port= --mysql-user=sbtest \
--mysql-password= --mysql-db=tempdb oltp_insert prepare

  2、第二步 run

sysbench --mysql-host=localhost --mysql-port= --mysql-user=sbtest     --mysql-password= --mysql-db=tempdb oltp_insert run
sysbench 1.1. (using bundled LuaJIT 2.1.-beta3) Running the test with following options:
Number of threads:
Initializing random number generator from current time Initializing worker threads... Threads started! SQL statistics:
queries performed:
read:
write:
other:
total:
transactions: (2254.37 per sec.)
queries: (2254.37 per sec.)
ignored errors: (0.00 per sec.)
reconnects: (0.00 per sec.) Throughput:
events/s (eps): 2254.3691
time elapsed: .0006s
total number of events: Latency (ms):
min: 0.31
avg: 0.44
max: 10.47
95th percentile: 0.67
sum: 9918.59 Threads fairness:
events (avg/stddev): 22545.0000/0.00
execution time (avg/stddev): 9.9186/0.00

  3、第三步 cleanup

sysbench --mysql-host=localhost --mysql-port= --mysql-user=sbtest     --mysql-password= --mysql-db=tempdb oltp_insert cleanup
sysbench 1.1. (using bundled LuaJIT 2.1.-beta3) Dropping table 'sbtest1'...

----

sysbench的安装详解的更多相关文章

  1. Linux ssh登录和软件安装详解

    阿哲Style   Linux第一天 ssh登录和软件安装详解 Linux学习第一天 操作环境: Ubuntu 16.04 Win10系统,使用putty_V0.63 本身学习Linux就是想在服务器 ...

  2. 【转】Linux下Android ADB驱动安装详解

    原文网址:http://blog.csdn.net/zhenwenxian/article/details/5901350 Linux下Android ADB驱动安装详解 概述 最近由于内置的合作商比 ...

  3. scribefire 多博客管理利器 安装详解

    scribefire 多博客管理利器 安装详解 一.ScribeFire介绍 ScribeFire 是 Firefox (火狐浏览器)上著名的博客写作工具,目前已跨平台支持多浏览器(Firefox,C ...

  4. CentOS 6.5的安装详解

    CentOS 6.5的安装详解 主流: 目前的Linux操作系统主要应用于生产环境, 主流企业级Linux系统仍旧是RedHat或者CentOS 免费: RedHat 和CentOS差别不大,Cent ...

  5. Linux下tomcat的安装详解

    Linux下tomcat的安装详解 来源: ChinaUnix博客 日期: 2007.01.21 22:59 (共有0条评论) 我要评论 一,安装前的准备:1,Linux版本:我的是企业版.(至于红帽 ...

  6. Phoenix和SQuirrel安装详解

    Phoenix安装详解 描述 现有hbase的查询工具有很多如:Hive,Tez,Impala,Shark/Spark,Phoenix等.今天的主角是Phoenix. phoenix,中文译为“凤凰” ...

  7. zabbix agent安装详解

    安装 Installing repository configuration package Zabbix 2.2 for RHEL5, Oracle Linux 5, CentOS 5: rpm - ...

  8. zabbix server安装详解

    简介 zabbix(音同 zæbix)是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案. zabbix能监视各种网络参数,保证服务器系统的安全运营:并提供灵活的通知机制以 ...

  9. Oracle Database 12c Release 2安装详解

    第1章 Oracle Database 12c Release 2安装详解 1.1 下载方法 oracle官网https://www.oracle.com 1)打开官方网站,找到下载连接 2)选择更多 ...

随机推荐

  1. 使用vue脚手架工具搭建vue-webpack项目

    对于Vue.js来说,如果你想要快速开始,那么只需要在你的html中引入一个<script>标签,加上CDN的地址即可.但是,这并不算是一个完整的vue实际应用.在实际应用中,我们必须要一 ...

  2. ArcGIS for Android图层记录数,图层选择记录,图层字段数

    Log.d("图层记录数:", "" + pFeatureLayer.getFeatureTable().getNumberOfFeatures()); Log ...

  3. WebLogic中WLS 组件漏洞(CVE-2017-10271)专项检测工具

    来源: 时间:2017-12-23 00:00:00 作者: 浏览:1929 次 近期安恒信息在应急响应过程中发现有恶意攻击者利用WebLogic漏洞对企业服务器发起大范围远程攻击,攻击成功后植入挖矿 ...

  4. jQuery EasyUI API 中文文档 - Panel面板

    <html> <head> <title>布局管理器--控制面板</title> <script src="jquery-easyui/ ...

  5. 如何写科技论文How to write a technical paper

    This is the evolving set of recommendations I share with my graduate students for technical writing. ...

  6. Git 学习(二)版本库创建

    Git 版本库创建 什么是版本库(repository)? 可理解为文件仓库.由Git管理每个文件的新增.修改及删除,但这个仓库可以追溯历史.可还原至任意历史节点. 版本库创建 创建一个版本库非常简单 ...

  7. #include &lt;NOIP2009 Junior&gt; 细胞分裂 ——using namespace wxl;

    题目描述 Hanks 博士是 BT (Bio-Tech,生物技术) 领域的知名专家.现在,他正在为一个细胞实 验做准备工作:培养细胞样本. Hanks 博士手里现在有 N 种细胞,编号从 1~N,一个 ...

  8. Spark应用程序运行的日志存在哪里(转)

    原文链接:Spark应用程序运行的日志存在哪里 在很多情况下,我们需要查看driver和executors在运行Spark应用程序时候产生的日志,这些日志对于我们调试和查找问题是很重要的. Spark ...

  9. Plugin with id 'com.github.dcendents.android-maven' not found

    导入开源项目的时候老是报这个错 Error:(2, 0) Plugin with id 'com.github.dcendents.android-maven' not found 挺郁闷的,不知道是 ...

  10. Mac版小黑屋提示无法确认开发者身份的解决办法

    Mac版小黑屋提示无法确认开发者身份的解决办法 学习了:https://jingyan.baidu.com/article/37bce2be703fa21003f3a259.html 需要按住cont ...