sysbench压测tdsql分布式实例 注意事项

2021-01-13 14:28:30 浏览数 (1)

如果你遇到报错:

FATAL: mysql_drv_query() returned error 609 (Proxy ERROR:get_auto_inc_id error) for query 'INSERT INTO sbtest

就可以看本文

这是因为获取自增ID失败 : https://cloud.tencent.com/document/product/557/16946

本环境为: sysbench 1.1.0

编译安装sysbench

代码语言:javascript复制
wget https://github.com/akopytov/sysbench/archive/master.zip
unzip sysbench-master.zip
cd sysbench-master
./autogen.sh
./configure
make && make install

修改src/lua/oltp_common.lua脚本 注释自增id 建表时添加shardkey=id 使其支持shardkey

也就是: 1. 注释掉lua脚本 58-61行

2. 建表语句199行处添加 shardkey=id

vi src/lua/oltp_common.lua

代码语言:lua复制
----省略
      range_selects =
      {"Enable/disable all range SELECT queries", true},
--   auto_inc =
--   {"Use AUTO_INCREMENT column as Primary Key (for MySQL), " ..
--       "or its alternatives in other DBMS. When disabled, use " ..
--       "client-generated IDs", true},
   create_table_options =
      {"Extra CREATE TABLE options", ""},
      
----省略

   query = string.format([[
CREATE TABLE sbtest%d(
  id %s,
  k INTEGER DEFAULT '0' NOT NULL,
  c CHAR(120) DEFAULT '' NOT NULL,
  pad CHAR(60) DEFAULT '' NOT NULL,
  %s (id)
) %s %s shardkey=id]],
      table_num, id_def, id_index_def, engine_def,
      sysbench.opt.create_table_options)
----省略

压测: 自己去搜.

0 人点赞