sysbench的安裝與使用 引數配置(with MySQL)
在使用sysbench 之前 先要避免一個坑。。(搞了一上午才跳過去):
sysbench的版本有好多,每個版本對應的命令是不同的,語法也是有相當一部分的差異,所以一定要按照你安裝的版本,去sysbench --help 仔細看相關的命令,不然就會一直報各種語法錯誤。。
例如:在sysbench 0.4版本中 --help可以看到Compiled-in tests 下 有oltp基準測試的選項,而且可以用sysbench --test=oltp help 檢視具體引數配置。而在1.0及以上的版本中是沒有這個選項的。。
一.安裝三步驟:
1.configure
./configure --prefix=/u01/sysbench/ --with-mysql-includes=/usr/include/mysql/
其中標紅的地方為mysql的2個路徑,我在這個地方偷懶用的直接是yum install的方式安裝的,所以路徑為預設的這個。如果是自定義的,比如/u01/mysql之類的,那麼路徑就改成相應的就可以了。
2.make
這一步會根據上一步生成的makefile來進行make,但之前的configure裡面,生成makefile的時候,是用的32位的包,所以需要ln一下,使用64位的包:
ln -s /usr/lib64/mysql/* /usr/lib/mysql/,再執行autogen.sh,再執行make
3.make install
二.使用
首先,看看sysbench支援哪些功能引數:
[[email protected] bin]# sysbench --hlp Unknown option: --hlp. Usage: sysbench [general-options]... --test=<test-name> [test-options]... command General options: --num-threads=N number of threads to use [1] --max-requests=N limit for total number of requests [10000] --max-time=N limit for total execution time in seconds [0] --forced-shutdown=STRING amount of time to wait after --max-time before forcing shutdown [off] --thread-stack-size=SIZE size of stack per thread [32K] --init-rng=[on|off] initialize random number generator [off] --test=STRING test to run --debug=[on|off] print more debugging info [off] --validate=[on|off] perform validation checks where possible [off] --help=[on|off] print help and exit --version=[on|off] print version and exit 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 Commands: prepare run cleanup help version See ‘sysbench --test=<name> help‘ for a list of options for each test.
從幫助可以看出,sysbench的測試主要包括以下幾個方面:
(1)磁碟io效能
(2)cpu效能
(3)記憶體分配及傳輸速度
(4)執行緒效能
(5)mutex效能
(6)OLTP基準測試
2.1 測試fileio命令幫助:
[[email protected] bin]# sysbench --test=fileio help sysbench 0.4.12: multi-threaded system evaluation benchmark fileio options: --file-num=N number of files to create [128] --file-block-size=N block size to use in all IO operations [16384] --file-total-size=SIZE total size of files to create [2G] --file-test-mode=STRING test mode {seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw} --file-io-mode=STRING file operations mode {sync,async,fastmmap,slowmmap} [sync] --file-async-backlog=N number of asynchronous operatons to queue per thread [128] --file-extra-flags=STRING additional flags to use on opening files {sync,dsync,direct} [] --file-fsync-freq=N do fsync() after this number of requests (0 - don‘t use fsync()) [100] --file-fsync-all=[on|off] do fsync() after each write operation [off] --file-fsync-end=[on|off] do fsync() at the end of test [on] --file-fsync-mode=STRING which method to use for synchronization {fsync, fdatasync} [fsync] --file-merged-requests=N merge at most this number of IO requests if possible (0 - don‘t merge) [0] --file-rw-ratio=N reads/writes ratio for combined test [1.5]
引數詳解:
--file-num=N 代表生成測試檔案的數量,預設為128。
--file-block-size=N 測試時所使用檔案塊的大小,如果想磁碟針對innodb儲存引擎進行測試,可以將其設定為16384,即innodb儲存引擎頁的大小。預設為16384。
--file-total-size=SIZE 建立測試檔案的總大小,預設為2G大小。
--file-test-mode=STRING 檔案測試模式,包含:seqwr(順序寫), seqrewr(順序讀寫), seqrd(順序讀), rndrd(隨機讀), rndwr(隨機寫), rndrw(隨機讀寫)。
--file-io-mode=STRING 檔案操作的模式,sync(同步),async(非同步),fastmmap(快速mmap),slowmmap(慢速mmap),預設為sync同步模式。
--file-async-backlog=N 對應每個執行緒佇列的非同步運算元,預設為128。
--file-extra-flags=STRING 開啟檔案時的選項,這是與API相關的引數。
--file-fsync-freq=N 執行fsync()函式的頻率。fsync主要是同步磁碟檔案,因為可能有系統和磁碟緩衝的關係。 0代表不使用fsync函式。預設值為100。
--file-fsync-all=[on|off] 每執行完一次寫操作,就執行一次fsync。預設為off。
--file-fsync-end=[on|off] 在測試結束時執行fsync函式。預設為on。
--file-fsync-mode=STRING檔案同步函式的選擇,同樣是和API相關的引數,由於多個作業系統對於fdatasync支援不同,因此不建議使用fdatasync。預設為fsync。
--file-merged-requests=N 大多情況下,合併可能的IO的請求數,預設為0。
--file-rw-ratio=N 測試時的讀寫比例,預設時為1.5,即可3:2。
示例:
生成16個總共2G的檔案,進行讀寫io測試
準備工作:
[[email protected] bin]# sysbench --test=fileio --file-num=16 --file-total-size=2G prepare sysbench 0.4.12: multi-threaded system evaluation benchmark 16 files, 131072Kb each, 2048Mb total Creating files for the test...
[[email protected] bin]# ls -lrth
total 2.1G
-rwxr-xr-x 1 root root 293K Oct 15 16:20 sysbench
-rw------- 1 root root 128M Oct 15 17:38 test_file.0
-rw------- 1 root root 128M Oct 15 17:38 test_file.1
-rw------- 1 root root 128M Oct 15 17:38 test_file.2
-rw------- 1 root root 128M Oct 15 17:39 test_file.3
-rw------- 1 root root 128M Oct 15 17:39 test_file.4
-rw------- 1 root root 128M Oct 15 17:39 test_file.5
-rw------- 1 root root 128M Oct 15 17:39 test_file.6
-rw------- 1 root root 128M Oct 15 17:39 test_file.7
-rw------- 1 root root 128M Oct 15 17:39 test_file.8
-rw------- 1 root root 128M Oct 15 17:39 test_file.9
-rw------- 1 root root 128M Oct 15 17:39 test_file.10
-rw------- 1 root root 128M Oct 15 17:40 test_file.11
-rw------- 1 root root 128M Oct 15 17:40 test_file.12
-rw------- 1 root root 128M Oct 15 17:40 test_file.13
-rw------- 1 root root 128M Oct 15 17:40 test_file.14
-rw------- 1 root root 128M Oct 15 17:40 test_file.15
開始測試:
[[email protected] bin]# sysbench --test=fileio --file-total-size=2G --file-test-mode=rndrd --max-time=180 --max-requests=100000000 --num-threads=16 --init-rng=on --file-num=16 --file-extra-flags=direct --file-fsync-freq=0 --file-block-size=16384 run sysbench 0.4.12: multi-threaded system evaluation benchmark Running the test with following options: Number of threads: 16 Initializing random number generator from timer. Extra file open flags: 16384 16 files, 128Mb each 2Gb total file size Block size 16Kb Number of random requests for random IO: 100000000 Read/Write ratio for combined random IO test: 1.50 Calling fsync() at the end of test, Enabled. Using synchronous I/O mode Doing random read test Threads started! Time limit exceeded, exiting... (last message repeated 15 times) Done. Operations performed: 314382 Read, 0 Write, 0 Other = 314382 Total Read 4.7971Gb Written 0b Total transferred 4.7971Gb (27.288Mb/sec) 1746.43 Requests/sec executed Test execution summary: total time: 180.0138s total number of events: 314382 total time taken by event execution: 2879.5979 per-request statistics: min: 0.26ms avg: 9.16ms max: 131.24ms approx. 95 percentile: 25.96ms Threads fairness: events (avg/stddev): 19648.8750/138.91 execution time (avg/stddev): 179.9749/0.00 [[email protected] bin]# sysbench --test=fileio --file-total-size=2G --file-test-mode=rndrd --max-time=180 --max-requests=100000000 --num-threads=16 --init-rng=on --file-num=16 --file-extra-flags=direct --file-fsync-freq=0 --file-block-size=16384 run sysbench 0.4.12: multi-threaded system evaluation benchmark Running the test with following options: Number of threads: 16 Initializing random number generator from timer. Extra file open flags: 16384 16 files, 128Mb each 2Gb total file size Block size 16Kb Number of random requests for random IO: 100000000 Read/Write ratio for combined random IO test: 1.50 Calling fsync() at the end of test, Enabled. Using synchronous I/O mode Doing random read test Threads started! Time limit exceeded, exiting... (last message repeated 15 times) Done. Operations performed: 313704 Read, 0 Write, 0 Other = 313704 Total Read 4.7867Gb Written 0b Total transferred 4.7867Gb (27.229Mb/sec) 1742.62 Requests/sec executed Test execution summary: total time: 180.0182s total number of events: 313704 total time taken by event execution: 2879.6401 per-request statistics: min: 0.25ms avg: 9.18ms max: 121.35ms approx. 95 percentile: 26.06ms Threads fairness: events (avg/stddev): 19606.5000/85.96 execution time (avg/stddev): 179.9775/0.00
測試結果主要看標黃色的那一段。為了穩定,測了2次,看起來差不多。
測試完成後,需要把測試檔案給刪掉。
[[email protected] bin]# sysbench --test=fileio --file-num=16 --file-total-size=2G cleanup sysbench 0.4.12: multi-threaded system evaluation benchmark Removing test files... [[email protected] bin]# ls -lrth total 300K -rwxr-xr-x 1 root root 293K Oct 15 16:20 sysbench
2.2 測試cpu命令幫助:
[[email protected] bin]# sysbench --test=cpu help sysbench 0.4.12: multi-threaded system evaluation benchmark cpu options: --cpu-max-prime=N upper limit for primes generator [10000]
引數詳解:
--cpu-max-prime=N 用來選項指定最大的素數,具體引數可以根據CPU的效能來設定,預設為10000
2.3 測試memory命令幫助:
[[email protected] bin]# sysbench --test=memory help sysbench 0.4.12: multi-threaded system evaluation benchmark memory options: --memory-block-size=SIZE size of memory block for test [1K] --memory-total-size=SIZE total size of data to transfer [100G] --memory-scope=STRING memory access scope {global,local} [global] --memory-hugetlb=[on|off] allocate memory from HugeTLB pool [off] --memory-oper=STRING type of memory operations {read, write, none} [write] --memory-access-mode=STRING memory access mode {seq,rnd} [seq]
引數詳解:
--memory-block-size=SIZE 測試記憶體塊的大小,預設為1K
--memory-total-size=SIZE 資料傳輸的總大小,預設為100G
--memory-scope=STRING 記憶體訪問的範圍,包括全域性和本地範圍,預設為global
--memory-hugetlb=[on|off] 是否從HugeTLB池分配記憶體的開關,預設為off
--memory-oper=STRING 記憶體操作的型別,包括read, write, none,預設為write
--memory-access-mode=STRING 記憶體訪問模式,包括seq,rnd兩種模式,預設為seq
2.4 測試threads命令幫助:
[[email protected] bin]# sysbench --test=threads help sysbench 0.4.12: multi-threaded system evaluation benchmark threads options: --thread-yields=N number of yields to do per request [1000] --thread-locks=N number of locks per thread [8]
引數詳解:
--thread-yields=N 指定每個請求的壓力,預設為1000
--thread-locks=N 指定每個執行緒的鎖數量,預設為8
2.5 測試mutex命令幫助:
[[email protected] bin]# sysbench --test=mutex help sysbench 0.4.12: multi-threaded system evaluation benchmark mutex options: --mutex-num=N total size of mutex array [4096] --mutex-locks=N number of mutex locks to do per thread [50000] --mutex-loops=N number of empty loops to do inside mutex lock [10000]
引數詳解:
--mutex-num=N 陣列互斥的總大小。預設是4096
--mutex-locks=N 每個執行緒互斥鎖的數量。預設是50000
--mutex-loops=N 內部互斥鎖的空迴圈數量。預設是10000
2.6 測試oltp命令幫助:
[[email protected] bin]# sysbench --test=oltp help sysbench 0.4.12: multi-threaded system evaluation benchmark oltp options: --oltp-test-mode=STRING test type to use {simple,complex,nontrx,sp} [complex] --oltp-reconnect-mode=STRING reconnect mode {session,transaction,query,random} [session] --oltp-sp-name=STRING name of store procedure to call in SP test mode [] --oltp-read-only=[on|off] generate only ‘read‘ queries (do not modify database) [off] --oltp-skip-trx=[on|off] skip BEGIN/COMMIT statements [off] --oltp-range-size=N range size for range queries [100] --oltp-point-selects=N number of point selects [10] --oltp-simple-ranges=N number of simple ranges [1] --oltp-sum-ranges=N number of sum ranges [1] --oltp-order-ranges=N number of ordered ranges [1] --oltp-distinct-ranges=N number of distinct ranges [1] --oltp-index-updates=N number of index update [1] --oltp-non-index-updates=N number of non-index updates [1] --oltp-nontrx-mode=STRING mode for non-transactional test {select, update_key, update_nokey, insert, delete} [select] --oltp-auto-inc=[on|off] whether AUTO_INCREMENT (or equivalent) should be used on id column [on] --oltp-connect-delay=N time in microseconds to sleep after connection to database [10000] --oltp-user-delay-min=N minimum time in microseconds to sleep after each request [0] --oltp-user-delay-max=N maximum time in microseconds to sleep after each request [0] --oltp-table-name=STRING name of test table [sbtest] --oltp-table-size=N number of records in test table [10000] --oltp-dist-type=STRING random numbers distribution {uniform,gaussian,special} [special] --oltp-dist-iter=N number of iterations used for numbers generation [12] --oltp-dist-pct=N percentage of values to be treated as ‘special‘ (for special distribution) [1] --oltp-dist-res=N percentage of ‘special‘ values to use (for special distribution) [75] General database options: --db-driver=STRING specifies database driver to use (‘help‘ to get list of available drivers) --db-ps-mode=STRING prepared statements usage mode {auto, disable} [auto] Compiled-in database drivers: mysql - MySQL driver mysql options: --mysql-host=[LIST,...] MySQL server host [localhost] --mysql-port=N MySQL server port [3306] --mysql-socket=STRING MySQL socket --mysql-user=STRING MySQL user [sbtest] --mysql-password=STRING MySQL password [] --mysql-db=STRING MySQL database name [sbtest] --mysql-table-engine=STRING storage engine to use for the test table {myisam,innodb,bdb,heap,ndbcluster,federated} [innodb] --mysql-engine-trx=STRING whether storage engine used is transactional or not {yes,no,auto} [auto] --mysql-ssl=[on|off] use SSL connections, if available in the client library [off] --myisam-max-rows=N max-rows parameter for MyISAM tables [1000000] --mysql-create-options=STRING additional options passed to CREATE TABLE []
引數詳解:
--oltp-test-mode=STRING 執行模式{simple,complex(advanced transactional),nontrx(non-transactional),sp}。預設是complex
--oltp-reconnect-mode=STRING 重新連線模式{session(不使用重新連線。每個執行緒斷開只在測試結束),transaction(在每次事務結束後重新連線),query(在每個SQL語句執行完重新連線),random(對於每個事務隨機選擇以上重新連線模式)}。預設是session
--oltp-sp-name=STRING 儲存過程的名稱。預設為空
--oltp-read-only=[on|off] 只讀模式。Update,delete,insert語句不可執行。預設是off
--oltp-skip-trx=[on|off] 省略begin/commit語句。預設是off
--oltp-range-size=N 查詢範圍。預設是100
--oltp-point-selects=N number of point selects [10]
--oltp-simple-ranges=N number of simple ranges [1]
--oltp-sum-ranges=N number of sum ranges [1]
--oltp-order-ranges=N number of ordered ranges [1]
--oltp-distinct-ranges=N number of distinct ranges [1]
--oltp-index-updates=N number of index update [1]
--oltp-non-index-updates=N number of non-index updates [1]
--oltp-nontrx-mode=STRING 查詢型別對於非事務執行模式{select, update_key, update_nokey, insert, delete} [select]
--oltp-auto-inc=[on|off] AUTO_INCREMENT是否開啟。預設是on
--oltp-connect-delay=N 在多少微秒後連線資料庫。預設是10000
--oltp-user-delay-min=N 每個請求最短等待時間。單位是ms。預設是0
--oltp-user-delay-max=N 每個請求最長等待時間。單位是ms。預設是0
--oltp-table-name=STRING 測試時使用到的表名。預設是sbtest
--oltp-table-size=N 測試表的記錄數。預設是10000
--oltp-dist-type=STRING 分佈的隨機數{uniform(均勻分佈),Gaussian(高斯分佈),special(空間分佈)}。預設是special
--oltp-dist-iter=N 產生數的迭代次數。預設是12
--oltp-dist-pct=N 值的百分比被視為‘special‘ (for special distribution)。預設是1
--oltp-dist-res=N ‘special’的百分比值。預設是75
相關推薦
sysbench的安裝與使用 引數配置(with MySQL)
在使用sysbench 之前 先要避免一個坑。。(搞了一上午才跳過去):sysbench的版本有好多,每個版本對應的命令是不同的,語法也是有相當一部分的差異,所以一定要按照你安裝的版本,去sysbench --help 仔細看相關的命令,不然就會一直報各種語法錯誤。。例如:在
Linux下Elasticsearch-2.4.0的安裝與簡單配置(單節點)
下載地址: 傳到伺服器 ftp工具或者 rz指令,解壓檔案: tar -zxvf elasticsearch-2.4.0.tar.gz 建立使用者及授權 sudo useradd elsearch chown -R elsearch:elsearch /us
Maven安裝與環境配置(Windows)
m2_home fig ria tle 自己 m2eclipse user 我們 選擇 1、下載安裝包 在Maven官網下載最新版的安裝包:http://maven.apache.org/download.cgi 2、解壓安裝包 3、配置Maven環境變量 配置M2_HOM
webpack安裝與基本配置(一)
webpack安裝與基本配置(一) 1.假設你已經有了一個需要打包的專案,那麼我們開始以下操作 2.在src目錄下新建一個webpack的配置檔案叫做webpack.config.js 說明: 這個檔名可以修改,但是跟
Python安裝與環境配置(windows)
安裝 首先去官網下載安裝包https://www.python.org/downloads/windows/ 然後點選選擇安裝包 然後跳轉到這裡下載這個 然後一直下一步安裝即可 環境配置 這裡我的安裝路徑是 所以有兩種方法 1.在命令提示框中(c
react-native 安裝與環境配置(踩坑版,基於android studio)
一.安裝java環境 先去官網下載最近java 8版本,並進行安裝,注意:java 8之前的版本是不支援react native的,必須使用java 8,下載連結接:java jdk,下載完成之後進行環境變數配置,可以參考此連結進行配置,網頁:java8 環境變數配置,至
Linux系統Oracle 12cR2 RAC集群安裝與維護管理(12.2)專題
oracle教程 oracle培訓 oracle數據庫教程 oracle工程師培訓 oracle數據庫培訓 風哥Linux系統Oracle 12cR2 RAC集群安裝與維護管理(12.2)專題包括內容:Oracle數據庫12cR2(項目實戰之一):在Windows上安裝Oracle12.2
Cisco VLAN與trunk配置(簡配)
vlan trunk pc Switch>enSwitch>enableSwitch#configure terminalSwitch(config)#vlan 10Switch(config-vlan)#name lolSwitch(config-vlan)#vlan 20Switc
1. PostgreSQL-安裝和基本配置(學習筆記)
安裝和配置 日常使用 buffer java、 note 安裝完成 for ora har 1 PostgreSQL簡介1.1 概述??PostgreSQL數據庫是目前功能最強大的開源數據庫,支持豐富的數據類型(如JSON和JSONB類型,數組類型)和自定義類型。而且它提供
Android Studio 的下載安裝以及環境配置(最詳細)
Android Studio下載,可以去Android studio 中文社群下載最新版本以及SDK:http://www.android-studio.org/ 下載完成後,按著步驟安裝Android Studio就行 到這一步,第一次安裝選擇不匯入設定就行 啟動
完全分散式Hadoop叢集的安裝搭建和配置(4節點)
Hadoop版本:hadoop-2.5.1-x64.tar.gz 學習參考了給力星http://www.powerxing.com/install-hadoop-cluster/的兩個節點的hadoo
Node.js安裝及環境配置(windows版)
這裡簡要記載下Node.js安裝流程,畢竟配置環境機會很少,以備後續使用,過程很簡單,但坑還是一如既往有的。 第一步,進入官網下載nodeJS 進入官網“http://nodejs.cn/download/”根據本人電腦,按需下載: 一路【next】,需要
PhotoShop2018和PhotoShop2019安裝與破解教程(含資源)
大家有興趣的可以加下我剛建立的一個PS學習交流的群825493164(PS攝影學習交流),裡面答疑大家的問題。共同學習交流。 下面提及ps2018的地方也包括ps2019(如果在AdobeCreativeCloud軟體裡面下載的話,現在官方預設推送ps2019的了)
Ionic angularjs App安裝與使用總結(未完)
第一部分 安裝時總結 一、win系統下nodejs安裝及環境配置 第一步:下載nodejs,官網:http://nodejs.org/download/ 第二步:安裝nodejs 下載完成之後,雙擊"node-v0.10.28-x86.msi",開始安裝nodejs
MySQL安裝與配置(Windows 10)
基礎環境 Windows 10,MySQL 5.6 準備工作 下載地址: http://downloads.mysql.com/archives/community/ 開始安裝 切換至bin目錄下,執行以下命令即可完成安裝: mysqld.exe install
mysql安裝與初始配置
mysql select mysqld crete datebase Mysql數據庫的第一個版本就是發行在Linux系統上查看mysql安裝包:]# rpm -qa | grep mysqlmysql-libs-5.1.73-8.el6_8.x86_64mysql-5.1.73-8.el
mysql安裝配置 (單個mysql安裝)
AD data datadir 設置 安裝配置 nbsp c盤 啟動 mda mysql安裝於 c盤因為有註冊文件 和註冊表 1.為了防止mysql數據表變大和sql日誌增加 改變C:\ProgramData\MySQL\MySQL Server 5.7\my.ini
Linux(DeepInOS) 下 mysql 的安裝與基本配置
tro github 控制臺 str targe 5-0 技術 TP 開機 參看代碼 GitHub: DeepIn(GNU/Linux) MySQL 一、安裝 二、控制臺登陸 三、基本編碼配置 四、服務操作 五、運行狀態基本查看 六、
mysql安裝與卸載(阿裏雲)
ins info arch 開機 新的 community root用戶 art comm 1、安裝rpm包rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm 2、安裝mysq
MySql 5.6.21安裝及配置(超詳細)
cal 開始 流程 重復 配置 路徑 進行 驗證 高級 一、安裝 ----->點擊接受協議 ----->下一步 這裏選擇我只需要安裝服務器,因此選擇 Server only -------->下一步 -------->點擊execu