sysbench0.5 mysql_使用 sysbench 0.5 测试 MySQL 的性能

下面是insert.lua脚本的内容:

[root@pxc-control ~]# cat /usr/share/doc/sysbench/tests/db/insert.lua

pathtest = string.match(test, "(.*/)") or ""

dofile(pathtest .. "common.lua")

function thread_init(thread_id)

set_vars()

end

function event(thread_id)

local table_name

local i

local c_val

local k_val

local pad_val

table_name = "sbtest".. sb_rand_uniform(1, oltp_tables_count)

if (oltp_auto_inc) then

i = 0

else

i = sb_rand_uniq(1, oltp_table_size)

end

k_val = sb_rand(1, oltp_table_size)

c_val = sb_rand_str([[

###########-###########-###########-###########-###########-###########-###########-###########-###########-###########]])

pad_val = sb_rand_str([[

###########-###########-###########-###########-###########]])

rs = db_query("INSERT INTO " .. table_name ..  " (id, k, c, pad) VALUES " .. string.format("(%d, %d, '%s', '%s')",i, k_val, c_val, pad_val))

end

我比较喜欢sysbench 0.5的一个地方(超过lua 接口,肯定的!)是它现在带来一个配置项–report-interval option(我通常都是设置为 =1),以便在脚本运行时你可以定时看到输出信息。不要等到运行结束是再得到反馈!这里有个用sysbench 0.5的测试样例,通过本地hapoxy实例运行插入数据动作以及向在同一个PXC(Percona XtrDB Cluster)集群上的三个节点写数据动作,例如OpenStack Trove会做:

[root@pxc-control ~]# ./sys_haproxy.sh run

sysbench 0.5:  multi-threaded system evaluation benchmark

Running the test with following options:

Number of threads: 3

Report intermediate results every 1 second(s)

Random number generator seed is 0 and will be ignored

Threads started!

[  1s] threads: 3, tps: 0.00, reads/s: 0.00, writes/s: 1099.28, response time: 9.86ms (95%)

[  2s] threads: 3, tps: 0.00, reads/s: 0.00, writes/s: 973.02, response time: 10.77ms (95%)

[  3s] threads: 3, tps: 0.00, reads/s: 0.00, writes/s: 1181.01, response time: 6.23ms (95%)

[  4s] threads: 3, tps: 0.00, reads/s: 0.00, writes/s: 1103.00, response time: 6.77ms (95%)

我也想让你注意到来自Nilnandan Joshi博客的文章,Nilnandan Joshi是来自Percona支持团队,在这篇文章中他介绍了在Debian 7上编译构建sysbench 0.5的一种方法。在这里非常感谢Nil的贡献!

我希望这篇文章可以帮组那些想要升级到sysbench 0.5的同志,并且能质疑(探讨)-test=oltp去哪儿了。我很乐意看到你自己的关于sysbench用户案列,并且是否有其他人发布过他们自己的用于负载测试的lua脚本!

0b1331709591d260c1c78e86d0c51c18.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值