亚洲视频二区_亚洲欧洲日本天天堂在线观看_日韩一区二区在线观看_中文字幕不卡一区

公告:魔扣目錄網(wǎng)為廣大站長提供免費(fèi)收錄網(wǎng)站服務(wù),提交前請(qǐng)做好本站友鏈:【 網(wǎng)站目錄:http://www.430618.com 】, 免友鏈快審服務(wù)(50元/站),

點(diǎn)擊這里在線咨詢客服
新站提交
  • 網(wǎng)站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會(huì)員:747

一、介紹

  • SysBench 是一款開源的、跨平臺(tái)的、模塊化的、多線程的性能測(cè)試工具, 可以執(zhí)行 CPU/內(nèi)存/線程/IO/數(shù)據(jù)庫 等方面的性能測(cè)試

二、安裝 sysbench

  • yum -y install sysbench
  • 安裝完sysbench后,/usr/share/sysbench下對(duì)數(shù)據(jù)庫壓力測(cè)試的lua文件
  • lua腳本說明
mysql如何進(jìn)行壓力測(cè)試?

 

1、 bulk_insert.lua 批量寫入操作
2、 oltp_common.lua oltp公用代碼
3、 oltp_delete.lua 寫入和刪除并行操作
4、 oltp_insert.lua 純寫入操作
5、 oltp_point_select.lua 只讀操作,條件為唯一索引列
6、 oltp_read_only.lua 只讀操作,包含聚合,去重等操作
7、 oltp_read_write.lua 讀寫混合操作,最常用的腳本
8、 oltp_update_index.lua 更新操作,通過主鍵進(jìn)行更新
9、 oltp_update_non_index.lua 更新操作,不通過索引列
10、 oltp_write_only.lua 純寫操作,常用腳本,包括insert update delete
11、 select_random_points.lua 隨機(jī)集合只讀操作,常用腳本,聚集索引列的selete in操作
12、 select_random_ranges.lua 隨機(jī)范圍只讀操作,常用腳本,聚集索引列的selete between操作
  • 參數(shù)說明
-–db-driver:用到的數(shù)據(jù)庫類型
-–MySQL-host:數(shù)據(jù)庫的IP
-–mysql-port:數(shù)據(jù)庫的端口
-–mysql-socket:socket的路徑
-–mysql-user:數(shù)據(jù)庫用戶名
-–mysql-password:用戶密碼
-–mysql-db:數(shù)據(jù)庫名字,默認(rèn)為sysbench,需要提前創(chuàng)建創(chuàng)好
-–tables:生成表的個(gè)數(shù)
-–table-size:每個(gè)表的行數(shù)
-–report-interval:每隔多久在屏幕打印一次信息
-–time:壓測(cè)時(shí)間
-–threads:啟動(dòng)多少個(gè)線程,即模擬多少個(gè)用戶
  • 幫助命令 sysbench /usr/share/sysbench/oltpreadwrite.lua help
oltp_read_write.lua options:
 --auto_inc[=on|off] Use AUTO_INCREMENT column as Primary Key (for MySQL), or its alternatives in other DBMS. When disabled, use client-generated IDs [on]
 --create_secondary[=on|off] Create a secondary index in addition to the PRIMARY KEY [on]
 --delete_inserts=N Number of DELETE/INSERT combinations per transaction [1]
 --distinct_ranges=N Number of SELECT DISTINCT queries per transaction [1]
 --index_updates=N Number of UPDATE index queries per transaction [1]
 --mysql_storage_engine=STRING Storage engine, if MySQL is used [innodb]
 --non_index_updates=N Number of UPDATE non-index queries per transaction [1]
 --order_ranges=N Number of SELECT ORDER BY queries per transaction [1]
 --pgsql_variant=STRING Use this PostgreSQL variant when running with the PostgreSQL driver. The only currently supported variant is 'redshift'. When enabled, create_secondary is automatically disabled, and delete_inserts is set to 0
 --point_selects=N Number of point SELECT queries per transaction [10]
 --range_selects[=on|off] Enable/disable all range SELECT queries [on]
 --range_size=N Range size for range SELECT queries [100]
 --secondary[=on|off] Use a secondary index in place of the PRIMARY KEY [off]
 --simple_ranges=N Number of simple range SELECT queries per transaction [1]
 --skip_trx[=on|off] Don't start explicit transactions and execute all queries in the AUTOCOMMIT mode [off]
 --sum_ranges=N Number of SELECT SUM() queries per transaction [1]
 --table_size=N Number of rows per table [10000]
 --tables=N Number of tables [1]

數(shù)據(jù)庫壓力測(cè)試通常三個(gè)階段,準(zhǔn)備數(shù)據(jù)、壓測(cè)數(shù)據(jù)、清理數(shù)據(jù)

  • 第一階段數(shù)據(jù)準(zhǔn)備
mysql -uroot -p123 -e "create database sbtest;" -- 創(chuàng)建測(cè)試數(shù)據(jù)庫
sysbench /usr/share/sysbench/oltp_read_write.lua --mysql-host=localhost --mysql-port=3306 --mysql-user=root --mysql-password='test' --mysql-socket=/data/mysql/mysql.sock --mysql-db=sbtest --db-driver=mysql --tables=10 --table-size=50000 --threads=4 prepare
mysql如何進(jìn)行壓力測(cè)試?

 

登錄數(shù)據(jù)庫檢查生成表和數(shù)據(jù)情況

mysql如何進(jìn)行壓力測(cè)試?

 

  • 第二階段數(shù)據(jù)運(yùn)行測(cè)試
情況1:查詢
sysbench /usr/share/sysbench/oltp_read_write.lua --mysql-host=localhost --mysql-port=3306 --mysql-user=root --mysql-password='test' --mysql-socket=/data/mysql/mysql.sock --mysql-db=sbtest --db-driver=mysql --tables=10 --table-size=50000 --report-interval=10 --threads=128 --time=600 ru
mysql如何進(jìn)行壓力測(cè)試?

 

備注:重要指標(biāo)

QPS(Query per second) 每秒查詢量:21021.78

TPS(Transaction per second)每秒事務(wù)量 1052.19

情況2: 在每個(gè)查詢的事物里面添加 INSERT/UPDATE/DELDETE 操作
sysbench /usr/share/sysbench/oltp_read_write.lua --mysql-host=localhost --mysql-port=3306 --mysql-user=root --mysql-password='test' --mysql-socket=/data/mysql/mysql.sock --mysql-db=sbtest --db-driver=mysql --tables=10 --table-size=50000 --delete_inserts=10 --index_updates=10 --non_index_updates=10 --report-interval=10 --threads=4 --time=60 run
mysql如何進(jìn)行壓力測(cè)試?

 

  • 第三階段刪除測(cè)試數(shù)據(jù)
sysbench /usr/share/sysbench/oltp_read_write.lua --mysql-host=localhost --mysql-port=3306 --mysql-user=root --mysql-password='test' --mysql-socket=/data/mysql/mysql.sock --mysql-db=sbtest --db-driver=mysql --tables=10 --table-size=50000 --delete_inserts=10 --index_updates=10 --non_index_updates=10 --report-interval=10 --threads=4 --time=60 cleanup
mysql如何進(jìn)行壓力測(cè)試?

 

  • 注一個(gè)錯(cuò)誤處理(修改自己安裝mysql對(duì)應(yīng)socket文件)
mysql如何進(jìn)行壓力測(cè)試?

 

分享到:
標(biāo)簽:壓力測(cè)試 mysql
用戶無頭像

網(wǎng)友整理

注冊(cè)時(shí)間:

網(wǎng)站:5 個(gè)   小程序:0 個(gè)  文章:12 篇

  • 51998

    網(wǎng)站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會(huì)員

趕快注冊(cè)賬號(hào),推廣您的網(wǎng)站吧!
最新入駐小程序

數(shù)獨(dú)大挑戰(zhàn)2018-06-03

數(shù)獨(dú)一種數(shù)學(xué)游戲,玩家需要根據(jù)9

答題星2018-06-03

您可以通過答題星輕松地創(chuàng)建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學(xué)四六

運(yùn)動(dòng)步數(shù)有氧達(dá)人2018-06-03

記錄運(yùn)動(dòng)步數(shù),積累氧氣值。還可偷

每日養(yǎng)生app2018-06-03

每日養(yǎng)生,天天健康

體育訓(xùn)練成績?cè)u(píng)定2018-06-03

通用課目體育訓(xùn)練成績?cè)u(píng)定