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 -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博客 ” ,链接:http://blog.itpub.net/26355921/viewspace-1248101/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/26355921/viewspace-1248101/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值