Sysbench 在 mysql OLTP 测试中出现错误

Sysbench 在 mysql OLTP 测试中出现错误

我在运行 MySQL 5.5.16 的 RHEL 5.6 服务器上运行 sysbench,使用以下设置:

sysbench --test=oltp --db-driver=mysql --mysql-user=sbench \
 --mysql-socket=/var/lib/mysql/mysql.sock --mysql-db=sbench \
 --mysql-table-engine=innodb --oltp-table-size=1000000 prepare

这将创建默认的 sbench 表,如下所示:

mysql> SHOW CREATE TABLE sbench.sbtest\G
*************************** 1. row ***************************
       Table: sbtest
Create Table: CREATE TABLE `sbtest` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `k` int(10) unsigned NOT NULL DEFAULT '0',
  `c` char(120) NOT NULL DEFAULT '',
  `pad` char(60) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`),
  KEY `k` (`k`)
) ENGINE=InnoDB AUTO_INCREMENT=1000001 DEFAULT CHARSET=latin1
1 row in set (0.04 sec)

对 1,000,000 行运行 16 线程 innodb 读/写测试:

sysbench --num-threads=16 --test=oltp --db-driver=mysql --mysql-user=sbench \
  --mysql-socket=/var/lib/mysql/mysql.sock --mysql-db=sbench \
  --mysql-table-engine=innodb --oltp-table-size=100000 \
  --oltp-reconnect-mode=query --batch --batch-delay=5 run

导致以下错误

[1319136662] sysbench 0.4.12:  multi-threaded system evaluation benchmark

[1319136663] Running the test with following options:
[1319136663] Number of threads: 16
[1319136663] 
[1319136663] Doing OLTP test.
[1319136663] Running mixed OLTP test
[1319136663] Using Special distribution (12 iterations,  1 pct of values are returned in 75 pct cases)
[1319136663] Using "BEGIN" for starting transactions
[1319136663] Using auto_inc on the id column
[1319136663] Maximum number of requests for OLTP test is limited to 10000
[1319136663] Threads started!
[1319136668] min: 0.2181  avg: 0.2484  max: 0.3025  percentile: 0.2715
[1319136673] min: 0.2181  avg: 0.2454  max: 0.3025  percentile: 0.2646
[1319136678] min: 0.2173  avg: 0.2441  max: 0.3115  percentile: 0.2646
[1319136683] min: 0.2173  avg: 0.2435  max: 0.3115  percentile: 0.2648
[1319136688] min: 0.2173  avg: 0.2440  max: 0.3115  percentile: 0.2663
ALERT: [1319136690] failed to execute mysql_stmt_execute(): Err1062 Duplicate entry '49616' for key 'PRIMARY'
FATAL: [1319136690] database error, exiting...
[1319136691] Done.

我对使用 sysbench 还很陌生,但这是一个错误,还是我配置错误导致它插入重复的主键?

答案1

没关系,我想我找到了。

我使用 --oltp-table-size=1000000 (1m) 设置测试,然后使用 --oltp-table-size=100000 (100k) 运行测试

使用正确的数字(1m)运行它,16个线程成功完成。

相关内容