sysbench安装及简单使用

简介:

本文主要描述了sysbench的安装,碰到的错误 及 简单的使用。


欢迎转载,请注明作者、出处。

作者:张正
blog:http://space.itpub.net/26355921 
QQ:176036317
如有疑问,欢迎联系。

sysbench安装:

tar -zxf  sysbench-0.4.12.tar.gz

cd sysbench-0.4.12

./configure --with-mysql-includes=/usr/local/mysql/include/mysql --with-mysql-libs=/usr/local/mysql/lib/mysql
export echo=echo

make

如果make报错,则执行:

./autogen.sh

然后make && make install即可

有很多时候仍然还有报错,那么就需要检查gcc和libtool包有没有装全,使用rpm -qa和yum list看看。

报错信息如:

---------------------------------------------------------------------------------------------------------------------------------------------------------

../libtool: line 838: X--tag=CC: command not found

 

../libtool: line 871: libtool: ignoring unknown tag : command not found

 

../libtool: line 838: X--mode=link: command not found

 

../libtool: line 1004: *** Warning: inferring the mode of operation is deprecated.: command not found

 

../libtool: line 1005: *** Future versions of Libtool will require --mode=MODE be specified.: command not found

 

../libtool: line 2231: X-g: command not found

 

../libtool: line 2231: X-O2: command not found

 

../libtool: line 2231: X-rdynamic: command not found

 

../libtool: line 1951: X-L/usr/lib/mysql: No such file or directory

 

../libtool: line 2400: Xsysbench: command not found

Fatal server error:

 

Server is already active for display 0

 

        If this server is no longer running, remove /tmp/.X0-lock

 

        and start again.

../libtool: line 2412: Xsysbench: command not found

 

../libtool: line 2547: X-lmysqlclient_r: command not found

 

../libtool: line 2547: X-lz: command not found

 

../libtool: line 2547: X-lcrypt: command not found

 

../libtool: line 2547: X-lnsl: command not found

 

../libtool: line 2547: X-lm: command not found

 

../libtool: line 2547: X-lmygcc: command not found

 

../libtool: line 2547: X-lrt: command not found

 

../libtool: line 2547: X-lm: command not found

 

../libtool: line 2629: X-L/root/tool/sysbench-0.4.12/sysbench: No such file or directory

 

../libtool: line 2547: X-lmysqlclient_r: command not found

 

../libtool: line 2547: X-lz: command not found

 

../libtool: line 2547: X-lcrypt: command not found

 

../libtool: line 2547: X-lnsl: command not found

 

../libtool: line 2547: X-lmygcc: command not found

 

../libtool: line 2547: X-lrt: command not found

 

../libtool: line 2547: X-lm: command not found

 

../libtool: line 2629: X-L/root/tool/sysbench-0.4.12/sysbench: No such file or directory

 

../libtool: line 2547: X-lmysqlclient_r: command not found

 

../libtool: line 2547: X-lz: command not found

 

../libtool: line 2547: X-lcrypt: command not found

 

../libtool: line 2547: X-lnsl: command not found

 

../libtool: line 2547: X-lmygcc: command not found

 

../libtool: line 2547: X-lrt: command not found

 

../libtool: line 2547: X-lm: command not found

 

../libtool: line 5162: Xgcc -pthread "" "" -o @OUTPUT@ sysbench.o sb_timer.o sb_options.o sb_logger.o db_driver.o ""  tests/fileio/libsbfileio.a tests/threads/libsbthreads.a tests/memory/libsbmemory.a tests/cpu/libsbcpu.a tests/oltp/libsboltp.a tests/mutex/libsbmutex.a drivers/mysql/libsbmysql.a -L/root/tool/sysbench-0.4.12/sysbench -lmysqlclient_r -lz -lcrypt -lnsl -lmygcc -lrt -lm: No such file or directory

 

../libtool: line 5163: Xgcc -pthread "" "" -o @OUTPUT@ sysbench.o sb_timer.o sb_options.o sb_logger.o db_driver.o ""  tests/fileio/libsbfileio.a tests/threads/libsbthreads.a tests/memory/libsbmemory.a tests/cpu/libsbcpu.a tests/oltp/libsboltp.a tests/mutex/libsbmutex.a drivers/mysql/libsbmysql.a -L/root/tool/sysbench-0.4.12/sysbench -lmysqlclient_r -lz -lcrypt -lnsl -lmygcc -lrt -lm: No such file or directory

---------------------------------------------------------------------------------------------------------------------------------------------------------

[root@hd-119-186 ~]# rpm -qa|grep gcc

compat-gcc-34-3.4.6-4.1

compat-gcc-34-g77-3.4.6-4.1

gcc-gnat-4.1.2-52.el5

gcc-c++-4.1.2-52.el5

gcc44-c++-4.4.6-3.el5.1

compat-libgcc-296-2.96-138

gcc-gfortran-4.1.2-52.el5

libgcc-4.1.2-52.el5

libgcc-4.1.2-52.el5

gcc-objc-4.1.2-52.el5

gcc-4.1.2-52.el5

gcc44-4.4.6-3.el5.1

gcc44-gfortran-4.4.6-3.el5.1

compat-gcc-34-c++-3.4.6-4.1

gcc-java-4.1.2-52.el5 

一定要保证/usr/lib或/usr/lib64下有相应的mysql/libmysqlclient.so文件或软链接

[root@root lib64]# pwd

/usr/lib64

[root@root lib64]# ll|grep mysql

lrwxrwxrwx.  1 root root       43 May 28 10:04 libmysqlclient_r.so -> /usr/lib64/mysql/libmysqlclient_r.so.16.0.0

lrwxrwxrwx.  1 root root       43 May 28 10:05 libmysqlclient_r.so.16 -> /usr/lib64/mysql/libmysqlclient_r.so.16.0.0

-rwxr-xr-x.  1 root root  1591560 May 28 10:05 libmysqlclient_r.so.16.0.0

lrwxrwxrwx.  1 root root       41 May 28 10:05 libmysqlclient.so -> /usr/lib64/mysql/libmysqlclient.so.16.0.0

lrwxrwxrwx.  1 root root       41 May 28 10:05 libmysqlclient.so.16 -> /usr/lib64/mysql/libmysqlclient.so.16.0.0

-rwxr-xr-x.  1 root root  1580928 May 28 10:06 libmysqlclient.so.16.0.0

lrwxrwxrwx.  1 root root       37 May 28 09:26 libmysqlclient.so.18 -> /usr/lib64/mysql/libmysqlclient.so.18

lrwxrwxrwx.  1 root root       20 May 28 09:37 libperconaserverclient.so.18 -> libmysqlclient.so.18

准备数据:

sysbench  --test=oltp --debug=off --mysql-table-engine=innodb  --oltp-table-size=20000000 --mysql-user=root --mysql-password=root --mysql-db=test --mysql-socket=/tmp/mysql.sock prepare

进行测试:

sysbench --num-threads=10 --test=oltp --mysql-user=root --mysql-password=root --mysql-table-engine=innodb  --init-rng=on --oltp-table-size=20000000 --max-time=$RT --max-requests=20000 --mysql-db=test --mysql-socket=/tmp/mysql.sock run > sysbench.log

线程数为10,测试类型为OLTP,表存储引擎为innodb的,表总行数200万行,(每行252bytes),访问请求为2万次,数据库为test,(准备数据时会创建sbtest表)

结果中的TPS结果:

transactions:                        20001  (908.75 per sec.)

查看帮助:

[root@hd-119-186 test]# sysbench --help

Usage:

  sysbench [general-options]... --test= [test-options]... command

General options:

  --num-threads=N            number of threads to use [1]

  --max-requests=N           limit for total number of requests [10000]

  --max-time=N               limit for total execution time in seconds [0]

  --forced-shutdown=STRING   amount of time to wait after --max-time before forcing shutdown [off]

  --thread-stack-size=SIZE   size of stack per thread [32K]

  --init-rng=[on|off]        initialize random number generator [off]

  --test=STRING              test to run

  --debug=[on|off]           print more debugging info [off]

  --validate=[on|off]        perform validation checks where possible [off]

  --help=[on|off]            print help and exit

  --version=[on|off]         print version and exit

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

  oltp - OLTP test

Commands: prepare run cleanup help version

See 'sysbench --test= help' for a list of options for each test.

[root@hd-119-186 test]# sysbench --test=oltp --help

Usage:

  sysbench [general-options]... --test= [test-options]... command

General options:

  --num-threads=N            number of threads to use [1]

  --max-requests=N           limit for total number of requests [10000]

  --max-time=N               limit for total execution time in seconds [0]

  --forced-shutdown=STRING   amount of time to wait after --max-time before forcing shutdown [off]

  --thread-stack-size=SIZE   size of stack per thread [32K]

  --init-rng=[on|off]        initialize random number generator [off]

  --test=STRING              test to run

  --debug=[on|off]           print more debugging info [off]

  --validate=[on|off]        perform validation checks where possible [off]

  --help=[on|off]            print help and exit

  --version=[on|off]         print version and exit

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

  oltp - OLTP test

Commands: prepare run cleanup help version

See 'sysbench --test= help' for a list of options for each test.

实际测试用法:
sysbench --num-threads=1792 --test=oltp --mysql-user=root --mysql-password=123456 --mysql-table-engine=innodb --oltp-test-mode=complex --oltp-table-size=20000000 --max-time=3600 --max-requests=0 --mysql-db=testdb --mysql-socket=/data/mysql6134/mysql.sock run > 1792_thread.log
线程数:1792
表行数:2000万
测试时间:3600秒
测试类型:OLTP混合测试
2014.11.19:
今天在做sysbench测试的时候,连接数开到1792时,报错了:
mysql_stmt_prepare failed! error(1461)Can't create more than max_prepared_stmt_count statements (current value: 16382)
查看相应参数的值:
mysql> show global variables like '%stmt%';
+----------------------------+----------------------+
| Variable_name              | Value                |
+----------------------------+----------------------+
| binlog_stmt_cache_size     | 32768                |
| max_binlog_stmt_cache_size | 18446744073709547520 |
| max_prepared_stmt_count    | 16382               |
+----------------------------+----------------------+
3 rows in set (0.00 sec)

将该值改大:
set global max_prepared_stmt_count=124000;
再次进行sysbench测试,开1792线程,没有问题。
mysql> show global status like '%stmt%';
+----------------------------+----------+
| Variable_name              | Value    |
+----------------------------+----------+
| Binlog_stmt_cache_disk_use | 0        |
| Binlog_stmt_cache_use      | 0        |
| Com_stmt_close             | 0        |
| Com_stmt_execute           | 14144611 |
| Com_stmt_fetch             | 0        |
| Com_stmt_prepare           | 55752    |
| Com_stmt_reprepare         | 0        |
| Com_stmt_reset             | 0        |
| Com_stmt_send_long_data    | 0        |
| Prepared_stmt_count        | 17920    |
+----------------------------+----------+
10 rows in set (0.00 sec)

修改后即可。
查阅其他资料:
Com_stmt_close             prepare语句关闭的次数
Com_stmt_execute           prepare语句执行的次数
Com_stmt_prepare           prepare语句创建的次数

本文转自ITPUB博客84223932的博客,原文链接:安装及简单使用sysbench,如需转载请自行联系原博主。

相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。   相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情: https://www.aliyun.com/product/rds/mysql 
相关文章
|
小程序
微信小程序四种弹窗方式实例
微信小程序四种弹窗方式实例
1634 0
微信小程序四种弹窗方式实例
|
前端开发 应用服务中间件 nginx
Nginx配置详解Docker部署Nginx使用Nginx部署vue前端项目
Nginx配置详解Docker部署Nginx使用Nginx部署vue前端项目
1905 0
|
存储 SQL 监控
ClickHouse 应用剖析:设计理念、机制与实践
ClickHouse 是一款高性能的列式数据库管理系统,主要用于实时的大数据分析场景。它由俄罗斯 Yandex 公司开源于 2016 年,在网页日志分析、物联网监控、广告计费等领域有广泛应用。ClickHouse 通过列式存储、向量化执行和分布式架构,实现对海量数据的快速查询分析。本文将介绍 ClickHouse 的设计理念,以及在实际使用中如何处理数据删除更新、冷热数据分离等问题,并提供常见配置的调优建议和异常问题的处理方法。
2875 14
ClickHouse 应用剖析:设计理念、机制与实践
|
存储 SQL 自然语言处理
ClickHouse查询执行与优化
本文详细介绍了SQL语法扩展、执行计划分析及优化策略,涵盖特殊函数与子句(如`WITH`、`ANY JOIN`)、聚合函数扩展(如`uniqCombined`、`quantileTDigest`)以及执行计划优化技巧。同时深入解析了ClickHouse的索引原理,包括主键索引和跳数索引的工作机制与优化方法。针对查询优化,文章提供了过滤条件下推、分布式查询优化和数据预聚合等策略,并探讨了资源管理与并发控制的核心参数(如`max_memory_usage`、`max_threads`)及队列优先级调度机制,助力高效使用ClickHouse。
1940 9
|
Oracle 关系型数据库 数据库
实时计算 Flink版操作报错合集之错误信息"ORA-65040: operation not allowed from within a pluggable database"如何解决
在使用实时计算Flink版过程中,可能会遇到各种错误,了解这些错误的原因及解决方法对于高效排错至关重要。针对具体问题,查看Flink的日志是关键,它们通常会提供更详细的错误信息和堆栈跟踪,有助于定位问题。此外,Flink社区文档和官方论坛也是寻求帮助的好去处。以下是一些常见的操作报错及其可能的原因与解决策略。
1144 2
|
SQL 分布式计算 关系型数据库
Clickhouse时间日期函数一文详解+代码展示
Clickhouse时间日期函数一文详解+代码展示
5109 0
Clickhouse时间日期函数一文详解+代码展示
|
传感器 测试技术 芯片
基于STM32的环境监测系统 (esp8266)(上)
基于STM32的环境监测系统 (esp8266)(上)
3047 1
|
安全 网络安全 数据安全/隐私保护
wsl---ssh远程连接、ip映射及服务自启详细配置
在初步体验了wsl后,我们都想通过一些类似xshell的工具来进行连接,因为cmd真的是不太友好。 在多次反复操作后发现,网上很多千篇一律的教程在有些地方,真的是误导像我这种小白,因此,本片文章经历过多次修改以保让我等小白不被带偏。
2107 0
|
Linux 测试技术
Linux系统【设备管理】sensors命令 – 检测服务器硬件信息
sensors命令用于检测服务器硬件信息,例如CPU电压与温度、主板、风扇转速等数据。
970 0
Linux系统【设备管理】sensors命令 – 检测服务器硬件信息

热门文章

最新文章