sysbench多线程性能测试工具,可以测试cpu/memory/IO/数据库等性能。 2个版本sysbench0.4和sysbench0.5介绍: 我们先了解对数据库OLTP测试: sysbench --help Usage: sysbench [general-options]... --test=<test-name> [test-options]... command --test:测试类型,有fileio/memory/threads/mutex. sysbench0.5与sysbench0.4区别:0.5支持多表测试,执行实时打印统计信息,自定义lua脚本; --test=<test-name> 2者测试模块如下: sysbench0.5: Compiled-in tests: fileio - File I/O test cpu - CPU performance test memory - Memory functions speed test threads - Threads subsystem performance test mutex - Mutex performance test sysbench0.5: Compiled-in tests: fileio - File I/O test cpu - CPU performance test memory - Memory functions speed test threads - Threads subsystem performance test mutex - Mutex performance test oltp - OLTP test #与0.5不同点 --general-options 每个模块对应的general-options可以借助: sysbench --test=oltp help 因0.4和0.5版本不同,但是基本参数是兼容的; --command 经历prepare run cleaup prepare:准备过程,oltp测试向表中load数据 run:正式测试过程 cleanup是清理过程,run后需要清理测试过程中遗留下来的信息。 sysbench测试实例: --prepare: sysbench --test=/home/zbs/sysbench-0.5/sysbench/tests/db/parallel_prepare.lua --oltp_tables_count=1 --oltp-table-size=$records --rand-init=on --num-threads=$thds --oltp-read-only=off --report-interval=10 --rand-type=special --rand-spec-pct=5 --mysql-table-engine=$type --max-time=8000 --mysql-host=$host --mysql-port=$port --mysql-user=test --mysql-password=test --mysql-db=test1 --max-requests=0 prepare --run: sysbench --test=/home/zbs/sysbench-0.5/sysbench/tests/db/parallel_prepare.lua --oltp_tables_count=1 --oltp-table-size=$records --rand-init=on --num-threads=$thds --oltp-read-only=off --report-interval=10 --rand-type=special --rand-spec-pct=5 --mysql-table-engine=$type --max-time=8000 --mysql-host=$host --mysql-port=$port --mysql-user=test --mysql-password=test --mysql-db=test1 --max-requests=0 run --cleanup: sysbench --test=/home/zbs/sysbench-0.5/sysbench/tests/db/parallel_prepare.lua --oltp_tables_count=1 --oltp-table-size=$records --rand-init=on --num-threads=$thds --oltp-read-only=off --report-interval=10 --rand-type=special --rand-spec-pct=5 --mysql-table-engine=$type --max-time=8000 --mysql-host=$host --mysql-port=$port --mysql-user=test --mysql-password=test --mysql-db=test1 --max-requests=0 cleanup 3者测试参数一致,不同的阶段使用的参数不同; 参数了解: --test:指定测试模式对应的lua文件,这个装好sysbench就有且这是0.5新增,0.4只需直接--test=oltp即可。 --oltp_table_count=1:指定测试过程中表的个数,0.5新增,0.4整个测试过程只有一个表。 --oltp-table-size=:指定表的大小,如果指定1000,那么它会往表里初始化1000条数据 --rand-init=on:是否随机初始化数据,如果不随机化那么初始好的数据每行内容除了主键不同外其他完全相同。 --num-threads=:测试过程中并发线程数,看测试要求来定并发压力。 --otlp-read-only=off:知否只读测试 --report-interval=10:每隔多久打印一次统计信息,单位秒,0.5新增 --rand-type=special:数据分布模式,special表示存在热点数据,uniform表示非热点数据模式,还有其他几个选项。 --rand-spec-pct=5:这个与上面那个选项相关 --mysql-table-engine=$type:表的存储引擎类型,innodb/myisam/tokudb/这些都可以。 --max-time=8000:这个命令跑多长时间,单位秒,与之相反的是指定请求数--max-requests --mysql-host=$host --mysql-port=$port --mysql-user=test --mysql-password=test --mysql-db=test1 这几个表示被测试的MySQL实例信息,因为需要连数据库 --max-requests:可以两者形式指定命令运行多长时间。 综上所述: sysbench优点: 1.测试类型可以选择 2.定制的参数选择丰富 缺点: 1.测试表结构太简单; CREATE TABLE `sbtest1` ( `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_1` (`k`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 有效仅有3个字段,不能正式模拟线上应用,可以利用它来做指导测试,作为标准, 测试产品稳定性,抗压性,mysql打补丁,更改参数,利用sysbench跑上几天或更久 转:http://blog./26855487/viewspace-775897/ |
|