小女巫 发表于 2015-1-14 20:45:28

CentOS教程之CentOS功能测试工具 C sysbench

如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的小伙伴们!sysbench是一款开源的多线程功能测试工具,能够实行CPU/内存/线程/IO/数据库等方面的功能测试。数据库今朝撑持MySQL/Oracle/PostgreSQL。本文只是复杂演示一下几种测试的用法,后续筹办使用sysbench来对MySQL举行一系列的测试。详细的一些参数设置,必要依据分歧的测试请求来举行调剂.
编译装置

#wget-chttp://sourceforge.net/projects/sysbench/files/sysbench/0.4.12/sysbench-0.4.12.tar.gz/download
#tarzxvfsysbench-0.4.12.tar.gz
#cdsysbench-0.4.12
#./configure&&make&&makeinstall
假如必要测试Oracle/PostgreSQL,则在configure时必要加上Cwith-oracle大概Cwith-pgsql参数
参数

#./sysbench
测试用例:
sysbench…Ctest=<test-name>…command
通用选项:
Cnum-threads=N创立测试线程的数量。默许为1.
Cmax-requests=N哀求的最年夜数量。默许为10000,0代表不限定。
Cmax-time=N最年夜实行工夫,单元是s。默许是0,不限定。
Cforced-shutdown=STRING凌驾max-time强迫中止。默许是off。]
Cthread-stack-size=SIZE每一个线程的仓库巨细。默许是32K。
Cinit-rng=在测试入手下手时是不是初始化随机数产生器。默许是off。
Ctest=STRING指定测试项目称号。
Cdebug=是不是显现更多的调试信息。默许是off。
Cvalidate=在大概情形下实行考证反省。默许是off。
测试项目:
fileioCFileI/Otest
cpuCCPUperformancetest
memoryCMemoryfunctionsspeedtest
threadsCThreadssubsystemperformancetest
mutexCMutexperformancetest(互斥功能测试)
oltpCOLTPtest
指令:prepare(测试前筹办事情)run(正式测试)cleanup(测试后删失落测试数据)helpversion
See‘sysbenchCtest=<name>help’foralistofoptionsforeachtest.检察每一个测试项目标更多选项列表。
#./sysbenchCtest=fileiohelp
Cfile-num=N创立测试文件的数目。默许是128
Cfile-block-size=N测试时文件块的巨细。默许是16384(16K)
Cfile-total-size=SIZE测试文件的总巨细。默许是2G
Cfile-test-mode=STRING文件测试形式{seqwr(按次写),seqrewr(按次读写),seqrd(按次读),rndrd(随机读),rndwr(随机写),rndrw(随机读写)}
Cfile-io-mode=STRING文件操纵形式{sync(同步),async(异步),fastmmap(疾速map映照),slowmmap(慢map映照)}。默许是sync
Cfile-extra-flags=STRING利用分外的标记来翻开文件{sync,dsync,direct}。默许为空
Cfile-fsync-freq=N实行fsync()的频次。(0C不利用fsync())。默许是100
Cfile-fsync-all=每实行完一次写操纵就实行一次fsync。默许是off
Cfile-fsync-end=在测试停止时才实行fsync。默许是on
Cfile-fsync-mode=STRING利用哪一种***举行同步{fsync,fdatasync}。默许是fsync
Cfile-merged-requests=N假如能够,兼并最多的IO哀求数(0C暗示分歧并)。默许是0
Cfile-rw-ratio=N测试时的读写比例。默许是1.5
#./sysbenchCtest=cpuhelp
Ccpu-max-prime=N最年夜质数产生器数目。默许是10000
#./sysbenchCtest=memoryhelp
Cmemory-block-size=SIZE测试时内存块巨细。默许是1K
Cmemory-total-size=SIZE传输数据的总巨细。默许是100G
Cmemory-scope=STRING内存会见局限{global,local}。默许是global
Cmemory-hugetlb=从HugeTLB池内存分派。默许是off
Cmemory-oper=STRING内存操纵范例。{read,write,none}默许是write
Cmemory-access-mode=STRING存储器存取体例{seq,rnd}默许是seq
#./sysbenchCtest=threadshelp
Cthread-yields=N每一个哀求发生几个线程。默许是1000
Cthread-locks=N每一个线程的锁的数目。默许是8
#./sysbenchCtest=mutexhelp
Cmutex-num=N数组互斥的总巨细。默许是4096
Cmutex-locks=N每一个线程互斥锁的数目。默许是50000
Cmutex-loops=N外部互斥锁的空轮回数目。默许是10000
#./sysbenchCtest=oltphelp
oltpoptions:
Coltp-test-mode=STRING实行形式{***,complex(advancedtransactional),nontrx(non-transactional),sp}。默许是complex
Coltp-reconnect-mode=STRING从头毗连形式{session(不利用从头毗连。每一个线程断开只在测试停止),transaction(在每次事件停止后从头毗连),query(在每一个SQL语句实行完从头毗连),random(关于每一个事件随机选择以上从头毗连形式)}。默许是session
Coltp-sp-name=STRING存储历程的称号。默许为空
Coltp-read-only=只读形式。Update,delete,insert语句不成实行。默许是off
Coltp-skip-trx=省略begin/commit语句。默许是off
Coltp-range-size=N查询局限。默许是100
Coltp-point-selects=Nnumberofpointselects
Coltp-***-ranges=Nnumberof***ranges
Coltp-sum-ranges=Nnumberofsumranges
Coltp-order-ranges=Nnumberoforderedranges
Coltp-distinct-ranges=Nnumberofdistinctranges
Coltp-index-updates=Nnumberofindexupdate
Coltp-non-index-updates=Nnumberofnon-indexupdates
Coltp-nontrx-mode=STRING查询范例关于非事件实行形式{select,update_key,update_nokey,insert,delete}
Coltp-auto-inc=AUTO_INCREMENT是不是开启。默许是on
Coltp-connect-delay=N在几微秒后毗连数据库。默许是10000
Coltp-user-delay-min=N每一个哀求最短守候工夫。单元是ms。默许是0
Coltp-user-delay-max=N每一个哀求最长守候工夫。单元是ms。默许是0
Coltp-table-name=STRING测试时利用到的表名。默许是sbtest
Coltp-table-size=N测试表的纪录数。默许是10000
Coltp-dist-type=STRING散布的随机数{uniform(匀称散布),Gaussian(高斯散布),special(空间散布)}。默许是special
Coltp-dist-iter=N发生数的迭代次数。默许是12
Coltp-dist-pct=N值的百分比被视为’special’(forspecialdistribution)。默许是1
Coltp-dist-res=N‘special’的百分比值。默许是75
Generaldatabaseoptions:
Cdb-driver=STRING指定命据库驱动步伐(‘help’togetlistofavailabledrivers)
Cdb-ps-mode=STRING体例报表利用形式{auto,disable}
Compiled-indatabasedrivers:
mysqlCMySQLdriver
mysqloptions:
Cmysql-host=MySQLserverhost
Cmysql-port=NMySQLserverport
Cmysql-socket=STRINGMySQLsocket
Cmysql-user=STRINGMySQLuser
Cmysql-password=STRINGMySQLpassword[]
Cmysql-db=STRINGMySQLdatabasename
Cmysql-table-engine=STRINGstorageenginetouseforthetesttable{myisam,innodb,bdb,heap,ndbcluster,federated}
Cmysql-engine-trx=STRINGwhetherstorageengineusedistransactionalornot{yes,no,auto}
Cmysql-ssl=useSSLconnections,ifavailableintheclientlibrary
Cmyisam-max-rows=Nmax-rowsparameterforMyISAMtables
Cmysql-create-options=STRINGadditionaloptionspassedtoCREATETABLE[]
测试

1、CPU测试
#./sysbenchCtest=cpuCcpu-max-prime=20000run
sysbench0.4.12:multi-threadedsystemevaluationbenchmark
Numberofthreads:1
DoingCPUperformancebenchmark
Threadsstarted!
Done.
MaximumprimenumbercheckedinCPUtest:20000
Testexecutionsummary:
totaltime:31.9364s
totalnumberofevents:10000
totaltimetakenbyeventexecution:31.9334
per-requeststatistics:
min:3.18ms
avg:3.19ms
max:3.60ms
approx.95percentile:3.20ms
Threadsfairness:
events(avg/stddev):10000.0000/0.00
executiontime(avg/stddev):31.9334/0.00
2、线程数测试
thread-locks小于线程数除以2,lock越少,处置工夫越长。
#./sysbenchCtest=threadsCnum-threads=512Cthread-yields=100Cthread-locks=2run
sysbench0.4.12:multi-threadedsystemevaluationbenchmark
Runningthetestwithfollowingoptions:Numberofthreads:512
Doingthreadsubsystemperformancetest
Threadyieldspertest:100Locksused:2
Threadsstarted!
WARNING:Operationtime(0.000000)islessthanminimalcountedvalue,countingas1.000000
WARNING:PercentilestatisticswillbeinaccurateDone.
Testexecutionsummary:
totaltime:4.1759s
totalnumberofevents:10000
totaltimetakenbyeventexecution:2038.5959
per-requeststatistics:
min:0.00ms
avg:203.86ms
max:2735.47ms
approx.95percentile:829.60ms
Threadsfairness:
events(avg/stddev):19.5312/8.26
executiontime(avg/stddev):3.9816/0.04
3、磁盘IO功能测试
起首天生必要的测试文件,文件总巨细3G,16个并发线程,随机读写形式。实行完后会在以后目次下天生一堆小文件。
#./sysbenchCtest=fileioCnum-threads=16Cfile-total-size=3GCfile-test-mode=rndrwprepare
sysbench0.4.12:multi-threadedsystemevaluationbenchmark
128files,24576Kbeach,3072Mbtotal
Creatingfilesforthetest…
入手下手测试:
#./sysbenchCtest=fileioCnum-threads=16Cfile-total-size=3GCfile-test-mode=rndrwrun
sysbench0.4.12:multi-threadedsystemevaluationbenchmark
Runningthetestwithfollowingoptions:Numberofthreads:16
Extrafileopenflags:0
128files,24Mbeach
3Gbtotalfilesize
Blocksize16Kb
NumberofrandomrequestsforrandomIO:10000
Read/WriteratioforcombinedrandomIOtest:1.50
PeriodicFSYNCenabled,callingfsync()each100requests
.Callingfsync()attheendoftest,Enabled.
UsingsynchronousI/OmodeDoingrandomr/wtest
Threadsstarted!
WARNING:Operationtime(0.000000)islessthanminimalcountedvalue,countingas1.000000
WARNING:PercentilestatisticswillbeinaccurateDone.
Operationsperformed:6004Read,3996Write,12800Other=22800TotalRead93.812MbWritten62.438MbTotaltransferred156.25Mb(6.472Mb/sec)414.21Requests/secexecuted
Testexecutionsummary:
totaltime:24.1426s
totalnumberofevents:10000
totaltimetakenbyeventexecution:164.4243
per-requeststatistics:
min:0.00ms
avg:16.44ms
max:821.08msapprox.95percentile:102.40ms
Threadsfairness:
events(avg/stddev):625.0000/63.99e
xecutiontime(avg/stddev):10.2765/0.62
清算现场
#./sysbenchCtest=fileioCnum-threads=16Cfile-total-size=3GCfile-test-mode=rndrwcleanup
sysbench0.4.12:multi-threadedsystemevaluationbenchmark
Removingtestfiles…
4、内存测试
上面的参数指定了本次测试全部历程是在内存中传输1G的数据量,每一个block巨细为8K。
./sysbenchCtest=memoryCnum-threads=64Cmemory-block-size=8192Cmemory-total-size=1Grun
sysbench0.4.12:multi-threadedsystemevaluationbenchmark
Runningthetestwithfollowingoptions:
Numberofthreads:64
Doingmemoryoperationsspeedtest
Memoryblocksize:8K
Memorytransfersize:1024M
Memoryoperationstype:writeMemoryscopetype:globalThreadsstarted!(lastmessagerepeated1times)
WARNING:Operationtime(0.000000)islessthanminimalcountedvalue,countingas1.000000
WARNING:Percentilestatisticswillbeinaccurate(lastmessagerepeated1times)Done.
Operationsperformed:131072(416391.08ops/sec)
1024.00MBtransferred(3253.06MB/sec)
Testexecutionsummary:
totaltime:0.3148s
totalnumberofevents:131072
totaltimetakenbyeventexecution:17.5553
per-requeststatistics:
min:0.00ms
avg:0.13ms
max:289.55ms
approx.95percentile:0.00ms
Threadsfairness:
events(avg/stddev):2048.0000/4854.85
executiontime(avg/stddev):0.2743/0.04
5、Mutex测试
测试mutex
#./sysbenchCtest=mutexCnum-threads=1500Cmax-requests=2000Cmutex-num=10240Cmutex-locks=100000
Cmutex-loops=15000run
sysbench0.4.12:multi-threadedsystemevaluationbenchmark
Runningthetestwithfollowingoptions:
Numberofthreads:1500
Doingmutexperformancetest
Threadsstarted!
Done.
Testexecutionsummary:
totaltime:74.0710s
totalnumberofevents:1500
totaltimetakenbyeventexecution:5410.6925
per-requeststatistics:
min:485.77ms
avg:3607.13ms
max:13770.44ms
approx.95percentile:12489.67ms
Threadsfairness:
events(avg/stddev):1.0000/0.00
executiontime(avg/stddev):3.6071/3.97
6、MySQL数据库测试

起首必要创立默许的sbtest数据库,大概利用Cmysql-db指定一个已存在的数据库
天生测试数据,引擎为myisam,表巨细为1000000笔记录
#./sysbench--test=oltp--mysql-table-engine=myisam--oltp-table-size=1000000--mysql-user=root--mysql-socket=/opt/mysql/run/mysql.sockpreparesysbench0.4.12:multi-threadedsystemevaluationbenchmarkNoDBdriversspecified,usingmysqlCreatingtablesbtest...Creating1000000recordsintablesbtest...root@sbtest11:42:18>descsbtest.sbtest;+-------+------------------+------+-----+---------+----------------+|Field|Type|Null|Key|Default|Extra|+-------+------------------+------+-----+---------+----------------+|id|int(10)unsigned|NO|PRI|NULL|auto_increment||k|int(10)unsigned|NO|MUL|0|||c|char(120)|NO|||||pad|char(60)|NO||||+-------+------------------+------+-----+---------+----------------+实行测试
#./sysbench--test=oltp--mysql-table-engine=myisam--oltp-table-size=1000000--mysql-user=root--mysql-socket=/opt/mysql/run/mysql.sockrunsysbench0.4.12:multi-threadedsystemevaluationbenchmarkNoDBdriversspecified,usingmysqlRunningthetestwithfollowingoptions:Numberofthreads:1DoingOLTPtest.RunningmixedOLTPtestUsingSpecialdistribution(12iterations,1pctofvaluesarereturnedin75pctcases)Using"LOCKTABLESWRITE"forstartingtransactionsUsingauto_incontheidcolumnMaximumnumberofrequestsforOLTPtestislimitedto10000Threadsstarted!Done.OLTPteststatistics:queriesperformed:read:140000write:50000other:20000total:210000transactions:10000(336.64persec.)deadlocks:0(0.00persec.)read/writerequests:190000(6396.11persec.)otheroperations:20000(673.27persec.)Testexecutionsummary:totaltime:29.7056stotalnumberofevents:10000totaltimetakenbyeventexecution:29.6301per-requeststatistics:min:2.27msavg:2.96msmax:43.88msapprox.95percentile:3.36msThreadsfairness:events(avg/stddev):10000.0000/0.00executiontime(avg/stddev):29.6301/0.00清算现场
#./sysbench--test=oltp--mysql-table-engine=myisam--oltp-table-size=1000000--mysql-user=root--mysql-socket=/opt/mysql/run/mysql.sockcleanupsysbench0.4.12:multi-threadedsystemevaluationbenchmarkNoDBdriversspecified,usingmysqlDroppingtablesbtest...Done.

如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的小伙伴们!

爱飞 发表于 2015-1-16 22:18:57

CentOS教程之CentOS功能测试工具 C sysbench

这种补充有助于他人在邮件列表/新闻组/论坛中搜索对你有过帮助的完整解决方案,这可能对他们也很有用。

再见西城 发表于 2015-1-24 15:05:55

掌握在Linux系统中安装软件,在安装Linux工具盘后大致日常所需的软件都会有,一般网络提供下载的软件都会有安装说明。

小魔女 发表于 2015-2-1 23:38:35

硬盘安装及光盘安装,清楚了解安装Linux应注意的有关问题,如安装Linux应在最后一个分区内,至少分二个分区。

简单生活 发表于 2015-2-7 18:21:14

随着Linux应用的扩展,出现了不少Linux社区。有一些非常优秀的社区往往是Linux高手的舞台,如果在探讨高级技巧的论坛张贴非常初级的问题经常会没有结果。

小女巫 发表于 2015-2-23 01:57:22

可以说自己收获很大,基本上完成了老师布置的任务,对于拔高的题目没有去做,因为我了解我的水平,没有时间和精力去做。?

分手快乐 发表于 2015-3-7 09:01:58

如果你想深入学习Linux,看不懂因为文档实在是太难了。写的最好的、最全面的文档都是英语写的,最先发布的技术信息也都是用英语写的。

变相怪杰 发表于 2015-3-14 22:18:14

掌握硬件配置,如显卡,声卡,网卡等,硬件只要不是太老或太新一般都能被支持,作为一名Linux系统管理员建议多阅读有关硬件配置文章,对各种不支持或支持不太好的硬件有深刻的了解。

若天明 发表于 2015-3-21 17:49:08

我们自学,就这个循环的过程中,我们学习了基本操作,用vi,shell,模拟内存的分配过程等一些OS管理。
页: [1]
查看完整版本: CentOS教程之CentOS功能测试东西 C sysbench