sysbench安装及简单使用

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
云数据库 RDS MySQL,高可用系列 2核4GB
简介:

本文主要描述了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 -qayum 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 
相关文章
|
小程序
微信小程序四种弹窗方式实例
微信小程序四种弹窗方式实例
1120 0
微信小程序四种弹窗方式实例
|
数据处理 Python
Pandas数据处理 | apply() 函数用法指南!
本文介绍一下关于 Pandas 中 apply() 函数的几个常见用法,apply() 函数的自由度较高,可以直接对 Series 或者 DataFrame 中元素进行逐元素遍历操作,方便且高效,具有类似于 Numpy 的特性。
|
数据可视化 Linux 开发工具
Linux文件内容查看和编辑指南:cat、less、grep等常用命令详解(二)
Linux文件内容查看和编辑指南:cat、less、grep等常用命令详解(二)
373 0
|
SQL 缓存 算法
香,聊聊TiDB的分布式事务模型
香,聊聊TiDB的分布式事务模型
723 0
香,聊聊TiDB的分布式事务模型
|
NoSQL MongoDB SQL
MongoShake最佳实践
mongoshake最佳实践,到底该怎么玩?
21768 0
|
缓存 Java API
Java工具篇之Guava-retry重试组件
Guava 是一组来自 Google 的核心 Java 库,其中包括新的集合类型(例如 multimap 和 multiset)、不可变集合、图形库以及用于并发、I/O、散列、缓存、原语、字符串等的实用程序!它广泛用于 Google 内部的大多数 Java 项目,也被许多其他公司广泛使用。 API 非常的简单,我们可以非常轻松的使用,来封装成我们业务中自己的组件。
1192 0
|
Oracle 关系型数据库 数据库
实时计算 Flink版操作报错合集之错误信息"ORA-65040: operation not allowed from within a pluggable database"如何解决
在使用实时计算Flink版过程中,可能会遇到各种错误,了解这些错误的原因及解决方法对于高效排错至关重要。针对具体问题,查看Flink的日志是关键,它们通常会提供更详细的错误信息和堆栈跟踪,有助于定位问题。此外,Flink社区文档和官方论坛也是寻求帮助的好去处。以下是一些常见的操作报错及其可能的原因与解决策略。
803 2
|
存储 移动开发 算法
Quorum NWR:通过仲裁实现数据一致性
Quorum NWR:通过仲裁实现数据一致性
251 11
|
消息中间件 Java 开发工具
消息队列 MQ使用问题之如何使用DefaultMQPushConsumer来消费消息
消息队列(MQ)是一种用于异步通信和解耦的应用程序间消息传递的服务,广泛应用于分布式系统中。针对不同的MQ产品,如阿里云的RocketMQ、RabbitMQ等,它们在实现上述场景时可能会有不同的特性和优势,比如RocketMQ强调高吞吐量、低延迟和高可用性,适合大规模分布式系统;而RabbitMQ则以其灵活的路由规则和丰富的协议支持受到青睐。下面是一些常见的消息队列MQ产品的使用场景合集,这些场景涵盖了多种行业和业务需求。
|
算法 搜索推荐 大数据
数据结构面试常见问题
V哥在工作中整理了22个常用数据结构实现与原理分析,在面试中可以帮你你充分准备
313 0