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. linux防火墙查看、开启、关闭

    查看   vi /etc/sysconfig/iptables 开启   service iptables stop 关闭   service iptables restart

  2. python接口自动化23-token参数关联登录(登录拉勾网)

    前言 登录网站的时候,经常会遇到传token参数,token关联并不难,难的是找出服务器第一次返回token的值所在的位置,取出来后就可以动态关联了 登录拉勾网 1.先找到登录首页https://pa ...

  3. MFC DLL对话框调用

    Regular Dll using shared MFC DLL extern "C" __declspec(dllexport) void Show() {   AFX_MANA ...

  4. 电子书mobi的格式详解

    https://wiki.mobileread.com/wiki/MOBI#Format Like PalmDOC, the Mobipocket file format is that of a s ...

  5. 深入理解Apache Flink核心技术

    深入理解Apache Flink核心技术 2016年02月18日 17:04:03 阅读数:1936 标签: Apache-Flink数据流程序员JVM   版权声明:本文为博主原创文章,未经博主允许 ...

  6. 为运行SQL Server的虚拟机切换装有DB Logs的最佳实践

    上一篇说到虚拟机启动不了, 原因是有一块VHDX的文件找不到了. 解决了这个问题之后, 又遇到了另一个问题, 那就是我的这台SQL Server的虚机启动之后, 我的几个重要database变成了su ...

  7. SQL Server 2008新特性——策略管理

    策略管理是SQL Server 2008中的一个新特性,用于管理数据库实例.数据库以及数据库对象的各种属性.策略管理在SSMS的对象资源管理器数据库实例下的“管理”节点下,如图: 从图中可以看到,策略 ...

  8. MS SQL 中判断 数据库, 存储过程,表,临时表,视图,函数,用户,用户创建对象 等是否存在 SQL脚本

    摘自: http://www.111cn.net/database/mssqlserver/39107.htm sql判断存储过程是否存在 判断数据库教程是否存在 Sql代码 if exists (s ...

  9. flex 无法将“<mx:>”解析为组件执行.解决方法

    转自:http://www.myexception.cn/flex/434924.html 问题描述: flex项目导入早期版本 无法将“<mx:******>”解析为组件执行. 如图: ...

  10. openstack horizon CSS 离线 改动

    Openstack horizon 的CSS主要保存在几个文件夹中,各自是horizon/static/dashboard/scss;horizon/openstack_dashboard/stati ...