本篇文章为大家展示了如何安装使用sysbench,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

yum-yinstallmakeautomakelibtoolpkgconfiglibaio-develyum-yinstallmysql-developenssl-develunzipsysbench-master.zip./autogen.sh./configure--with-mysql-includes=/usr/local/mysql/include--with-mysql-libs=/usr/local/mysql/libmake&&makeinstall

需要设置环境变量

[root@dpcm01sysbench-master]#sysbenchsysbench:errorwhileloadingsharedlibraries:libmysqlclient.so.20:cannotopensharedobjectfile:Nosuchfileordirectory[root@dpcm01sysbench-master]#echo$LD_LIBRARY_PATH[root@dpcm01sysbench-master]#echo$LD_LIBRARY_PATH[root@dpcm01sysbench-master]#[root@dpcm01sysbench-master]#exportLD_LIBRARY_PATH=/usr/local/mysql/lib[root@dpcm01sysbench-master]#[root@dpcm01sysbench-master]#sysbenchsysbench1.1.0(usingbundledLuaJIT2.1.0-beta3)Readingthescriptfromthestandardinput:[root@dpcm01lua]#sysbencholtp_read_write.lua--mysql-socket=/data/mysql/mysql.sock--mysql-user=root--mysql-host=localhost\>--mysql-user=root--mysql-host=localhost--mysql-password=123456--tables=10--table_size=100000preparesysbench1.1.0(usingbundledLuaJIT2.1.0-beta3)FATAL:unabletoconnecttoMySQLserveronsocket'/data/mysql/mysql.sock',aborting...FATAL:error1049:Unknowndatabase'sbtest'FATAL:`sysbench.cmdline.call_command'functionfailed:./oltp_common.lua:88:connectioncreationfailed[root@dpcm01lua]#sysbencholtp_read_write.lua--mysql-socket=/data/mysql/mysql.sock--mysql-user=root--mysql-host=localhost--mysql-user=root--mysql-host=localhost--mysql-password=123456--tables=10--table_size=100000preparesysbench1.1.0(usingbundledLuaJIT2.1.0-beta3)Creatingtable'sbtest1'...Inserting100000recordsinto'sbtest1'Creatingasecondaryindexon'sbtest1'...Creatingtable'sbtest2'...Inserting100000recordsinto'sbtest2'Creatingasecondaryindexon'sbtest2'...Creatingtable'sbtest3'...Inserting100000recordsinto'sbtest3'Creatingasecondaryindexon'sbtest3'...Creatingtable'sbtest4'...Inserting100000recordsinto'sbtest4'Creatingasecondaryindexon'sbtest4'...Creatingtable'sbtest5'...Inserting100000recordsinto'sbtest5'Creatingasecondaryindexon'sbtest5'...Creatingtable'sbtest6'...Inserting100000recordsinto'sbtest6'Creatingasecondaryindexon'sbtest6'...Creatingtable'sbtest7'...Inserting100000recordsinto'sbtest7'Creatingasecondaryindexon'sbtest7'...Creatingtable'sbtest8'...Inserting100000recordsinto'sbtest8'Creatingasecondaryindexon'sbtest8'...Creatingtable'sbtest9'...Inserting100000recordsinto'sbtest9'Creatingasecondaryindexon'sbtest9'...Creatingtable'sbtest10'...Inserting100000recordsinto'sbtest10'Creatingasecondaryindexon'sbtest10'...[root@dpcm01lua]#sysbench--threads=4\>--time=20\>--report-interval=5\>--mysql-host=localhost\>--mysql-port=3306\>--mysql-user=root\>--mysql-password=123456--mysql-socket=/data/mysql/mysql.sock\>oltp_read_write.lua\>--tables=10\>--table_size=100000\>runsysbench1.1.0(usingbundledLuaJIT2.1.0-beta3)Runningthetestwithfollowingoptions:Numberofthreads:4Reportintermediateresultsevery5second(s)InitializingrandomnumbergeneratorfromcurrenttimeInitializingworkerthreads...Threadsstarted![5s]thds:4tps:286.08qps:5732.71(r/w/o:4013.85/1145.90/572.95)lat(ms,95%):23.95err/s:0.00reconn/s:0.00[10s]thds:4tps:337.00qps:6740.74(r/w/o:4719.55/1347.19/673.99)lat(ms,95%):23.10err/s:0.00reconn/s:0.00[15s]thds:4tps:342.04qps:6838.71(r/w/o:4786.90/1367.74/684.07)lat(ms,95%):23.10err/s:0.00reconn/s:0.00[20s]thds:4tps:344.79qps:6893.70(r/w/o:4824.79/1379.34/689.57)lat(ms,95%):24.38err/s:0.00reconn/s:0.00SQLstatistics:queriesperformed:read:91756write:26216other:13108total:131080transactions:6554(327.39persec.)queries:131080(6547.79persec.)ignorederrors:0(0.00persec.)reconnects:0(0.00persec.)Throughput:events/s(eps):327.3896timeelapsed:20.0190stotalnumberofevents:6554Latency(ms):min:4.88avg:12.21max:398.7295thpercentile:23.95sum:79998.74Threadsfairness:events(avg/stddev):1638.5000/9.10executiontime(avg/stddev):19.9997/0.00

上述内容就是如何安装使用sysbench,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注亿速云行业资讯频道。