Home > 工具介绍, 杂七杂八 > sysbench oltp测试MySQL问题

sysbench oltp测试MySQL问题

July 1st, 2011

原创文章,转载请注明: 转载自系统技术非业余研究

本文链接地址: sysbench oltp测试MySQL问题

昨天有同学在使用sysbench时候遇到了点小麻烦:

$ sysbench --test=oltp --oltp-table-size=100000000 --oltp-read-only=off --init-rng=on --num-threads=16 --max-requests=0 --oltp-dist-type=uniform --max-time=1800 --mysql-user=root   --db-driver=mysql --mysql-table-engine=innodb --oltp-test-mode=simple prepare
sysbench 0.4.12:  multi-threaded system evaluation benchmark

FATAL: unable to connect to MySQL server, aborting...
FATAL: error 1049: Unknown database 'sbtest'
FATAL: failed to connect to database server!
...

错误提示说:mysql连接不上, sbtest库没找到。

首先确认mysql是正常的…

$ mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 91
Server version: 5.1.48-debug-log Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use sbtest;
ERROR 1049 (42000): Unknown database 'sbtest'

但是库 sbtest确实不存在。

通过查看sysbench-0.4.12/sysbench/drivers/mysql/drv_mysql.c:400行

  DEBUG("mysql_real_connect(%p, \"%s\", \"%s\", \"%s\", \"%s\", %u, \"%s\", %s)",
        con,
        host,
        args.user,
        args.password,
        args.db,
        args.port,
        args.socket,
        (MYSQL_VERSION_ID >= 50000) ? "CLIENT_MULTI_STATEMENTS" : "0"
        );
  if (!mysql_real_connect(con,
                         host,
                         args.user,
                         args.password,
                         args.db,
                         args.port,
                         args.socket,
#if MYSQL_VERSION_ID >= 50000
                          CLIENT_MULTI_STATEMENTS)
#else
                          0)
#endif

我们可以看到sysbench在连接的时候需要先连接到sbtest库,但是库不存在,所以出现问题。

解决问题的方法很简单:
在mysql的shell下运行:

create database sbtest;

搞定。

小结:开源软件总是有点小问题,自己动手丰衣足食!

玩得开心!

Post Footer automatically generated by wp-posturl plugin for wordpress.

Categories: 工具介绍, 杂七杂八 Tags: ,
  1. xiaokui
    July 1st, 2011 at 10:18 | #1

    学到了…

    PS:发现一处笔误:
    use database sbtest;

    应该是

    use sbtest;

    🙂

    Yu Feng Reply:

    谢谢更正!

  2. December 1st, 2011 at 20:35 | #2

    –mysql-db可以指定database,默认sbtest

Comments are closed.