日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

MySql性能测试工具-sysbench

發布時間:2024/3/26 编程问答 44 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MySql性能测试工具-sysbench 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

轉自:MySql性能測試工具-sysbench — 沒那么簡單的博客

雖然mysql默認的有mysqlslap這個性能測試工具,但和sysbench比較來說,還遜色不少。

  • 下載安裝包 https://github.com/akopytov/sysbench
  • shell> wget https://github.com/akopytov/sysbench/archive/1.0.zip -O "sysbench-1.0.zip" shell> unzip sysbench-1.0.zip shell> cd sysbench-1.0
  • 安裝依賴庫
  • shell> yum install automake libtool -y
  • 開始安裝
  • shell> ./autogen.sh shell> ./configure #ERROR: cannot find MySQL libraries. If you want to compile with MySQL support 沒找到mysql庫 需要用參數指定下 --with-mysql-includes和--with-mysql-libs shell> ./configure --with-mysql-includes=/alidata/server/mysql5.7/include/ --with-mysql-libs=/alidata/server/mysql5.7/lib/ shell> make
  • 執行下命令:
  • shell> sysbench --help #sysbench: error while loading shared libraries: libmysqlclient.so.20: cannot open shared object file: No such file or directory #問題原因:sysbench無法找到mysql的庫文件,可能是環境變量LD_LIBRARY_PATH沒有設置,設置后即可解決該問題: shell> export LD_LIBRARY_PATH=/alidata/server/mysql5.7/lib/lib shell> sysbench --version sysbench 1.0
  • 創建測試數據庫sbtest
  • shell> mysqladmin create sbtest -uroot -p Enter password:
  • 測試準備: 20個并發連接,20張表 每個表填充10W條數據 最大請求時間120s
  • #-test=tests/db/oltp.lua 表示調用 tests/db/oltp.lua 腳本進行 oltp 模式測試 #--oltp_tables_count=10 表示會生成 10 個測試表 #--oltp-table-size=100000 表示每個測試表填充數據量為 100000 #--rand-init=on 表示每個測試表都是用隨機數據來填充的 #-num-threads=8 表示發起 8個并發連接 #--oltp-read-only=off 表示不要進行只讀測試,也就是會采用讀寫混合模式測試 #--report-interval=10 表示每10秒輸出一次測試進度報告 #--rand-type=uniform 表示隨機類型為固定模式,其他幾個可選隨機模式:uniform(固定),gaussian(高斯),special(特定的),pareto(帕累托) #--max-time=120 表示最大執行時長為 120秒 #--max-requests=0 表示總請求數為 0,因為上面已經定義了總執行時長,所以總請求數可以設定為 0;也可以只設定總請求數,不設定最大執行時長 #--percentile=99 表示設定采樣比例,默認是 95%,即丟棄1%的長請求,在剩余的99%里取最大值shell> sysbench --test=oltp --oltp_tables_count=10 --oltp-table-size=100000 --mysql-user=root --mysql-password=123456 --num-threads=20 --max-time=120 --max-requests=0 --oltp-test-mode=complex prepare sysbench 1.0: multi-threaded system evaluation benchmarkCreating table 'sbtest1'... Inserting 100000 records into 'sbtest1' Creating secondary indexes on 'sbtest1'... Creating table 'sbtest2'... Inserting 100000 records into 'sbtest2' Creating secondary indexes on 'sbtest2'... Creating table 'sbtest3'... Inserting 100000 records into 'sbtest3' Creating secondary indexes on 'sbtest3'... Creating table 'sbtest4'... Inserting 100000 records into 'sbtest4' Creating secondary indexes on 'sbtest4'... Creating table 'sbtest5'... Inserting 100000 records into 'sbtest5' Creating secondary indexes on 'sbtest5'... Creating table 'sbtest6'... Inserting 100000 records into 'sbtest6' Creating secondary indexes on 'sbtest6'... Creating table 'sbtest7'... Inserting 100000 records into 'sbtest7' Creating secondary indexes on 'sbtest7'... Creating table 'sbtest8'... Inserting 100000 records into 'sbtest8' Creating secondary indexes on 'sbtest8'... Creating table 'sbtest9'... Inserting 100000 records into 'sbtest9' Creating secondary indexes on 'sbtest9'... Creating table 'sbtest10'... Inserting 100000 records into 'sbtest10' Creating secondary indexes on 'sbtest10'...

    7.開始測試

    shell> sysbench --test=oltp --oltp_tables_count=10 --oltp-table-size=100000 --mysql-user=root --mysql-password=123456 --num-threads=20 --max-time=120 --max-requests=0 --oltp-test-mode=complex run >> /tmp/log/sysbench_oltpx_20161121.log#執行結束后查看測試報告 shell> less /tmp/log/sysbench_oltpx_20161121.log sysbench 1.0: multi-threaded system evaluation benchmark#報告內容如下: Running the test with following options: Number of threads: 20 Initializing random number generator from current timeInitializing worker threads...Threads started!OLTP test statistics:queries performed:read: 935592 --讀總數write: 267295 --寫總數other: 133650 --其他操作(CURD之外的操作,例如COMMIT)total: 1336537 --全部總數transactions: 66822 (556.77 per sec.) --總事務數(每秒事務數)read/write requests: 1202887 (10022.55 per sec.) --讀寫總數(每秒讀寫次數)other operations: 133650 (1113.58 per sec.) --其他操作總數(每秒其他操作次數)ignored errors: 6 (0.05 per sec.) --總忽略錯誤總數(每秒忽略錯誤次數)reconnects: 0 (0.00 per sec.) --重連總數(每秒重連次數)General statistics: --常規統計total time: 120.0180s --總耗時total number of events: 66822 --共發生多少事務數total time taken by event execution: 2399.7900s --所有事務耗時相加(不考慮并行因素)response time:min: 2.76ms --最小耗時avg: 35.91ms --平均耗時max: 1435.19ms --最長耗時approx. 95 percentile: 84.22ms --超過95%平均耗時Threads fairness: --并發統計events (avg/stddev): 3341.1000/37.54 --總處理事件數/標準偏差execution time (avg/stddev): 119.9895/0.02 --總執行時間/標準偏差

    總結

    以上是生活随笔為你收集整理的MySql性能测试工具-sysbench的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。