因为精力有限,所以先研究Mysql,等Mysql有些精通,再研究TiDB或其他开源数据库。
先从sysbench-0.4.12.14开始 - https://dev.mysql.com/downloads/benchmarks.html
create database sbtest;
grant all privileges on sbtest.* to test@‘localhost’ identified by ‘Welcome1+’;
采用–debug=on把“世界”变得更清澈
./sysbench --num-threads=1 --max-requests=2 --test=oltp --debug=on --mysql-table-engine=innodb --oltp-num-tables=1 --oltp-table-size=10 --mysql-user=test --mysql-password=Welcome1+ prepare
./sysbench --num-threads=1 --max-requests=2 --test=oltp --debug=on --mysql-table-engine=innodb --oltp-num-tables=1 --oltp-table-size=10 --mysql-user=test --mysql-password=Welcome1+ run
./sysbench --num-threads=1 --max-requests=2 --test=oltp --debug=on --mysql-table-engine=innodb --oltp-num-tables=1 --oltp-table-size=10 --mysql-user=test --mysql-password=Welcome1+ cleanup
表:
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=11 DEFAULT CHARSET=latin1;
压测SQL:
SELECT c from sbtest where id=?
SELECT c from sbtest where id in (?,?,?,?,?,?,?,?,?,?)
SELECT c from sbtest where id between ? and ?
SELECT SUM(K) from sbtest where id between ? and ?
SELECT c from sbtest where id between ? and ? order by c
SELECT DISTINCT c from sbtest where id between ? and ? order by c
UPDATE sbtest set k=k+1 where id=?
UPDATE sbtest set c=? where id=?
DELETE from sbtest where id=?
INSERT INTO sbtest values(?,0,’ ',‘aaaaaaaaaaffffffffffrrrrrrrrrreeeeeeeeeeyyyyyyyyyy’)
BEGIN
COMMIT
**Note:每次request会顺序执行以上SQL,而且UPDATE/DELETE/INSERT会使用同一个ID.
还有一个sysbench 1.1.0(基于LUA)- https://github.com/akopytov/sysbench
先简单学习LUA -
./third_party/luajit/bin/luajit-2.1.0-beta3
LuaJIT 2.1.0-beta3 – Copyright © 2005-2017 Mike Pall. http://luajit.org/
JIT: ON SSE2 SSE3 SSE4.1 fold cse dce fwd dse narrow loop abc sink fuse
print “Hello,world!”
Hello,world!
function create_a_counter()local count=0
return function()
count = count + 1
return count
end
end
ct = create_a_counter()
print(ct())
1
print(ct())
2
print(ct())
3
print(create_a_counter())
function: 0x408aa1f8
print(create_a_counter())
function: 0x408aa388
print(create_a_counter())
function: 0x408aa518
print((create_a_counter())())
1
print((create_a_counter())())
1
print((create_a_counter())())
在oltp_common.lua有参数说明:
sysbench.cmdline.options = {