系統技術非業餘研究 » sysbench oltp測試MySQL問題
阿新 • • 發佈:2018-12-23
昨天有同學在使用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.