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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

sysbench --with-mysql-libs_sysbench

發布時間:2024/3/26 数据库 57 豆豆
生活随笔 收集整理的這篇文章主要介紹了 sysbench --with-mysql-libs_sysbench 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

sysbench是一款壓力測試工具,可以測試系統的硬件性能,也可以用來對數據庫進行基準測試

wget https://github.com/akopytov/sysbench/archive/1.0.zip -O "sysbench-1.0.zip"? 下載之后的名字是1.0.zip。解壓之后為sysbench-1.0

百度云網盤:https://pan.baidu.com/s/1mjoa25y? ?密碼:i4pm

cd?sysbench-1.0

執行autogen.sh用它來生成configure這個文件

./autogen.sh

執行configure && make && make install 來完成sysbench的安裝

./configure && make && make install 這個命令是用于mysql默認的安裝路徑

./configure --prefix=/usr/local/sysbench/ --with-mysql --with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib 這個是用于指定mysql安裝的路徑(我的mysql是默認路徑,所以我用第一種)

當然了,用上面的參數編譯的話,就要確保你的 MySQL lib目錄下有對應的 so 文件,如果沒有,可以自己下載 devel 或者 share 包來安裝。

另外,如果想要讓 sysbench 支持 pgsql/oracle 的話,就需要在編譯的時候加上參數

--with-pgsql

或者

--with-oracle

這2個參數默認是關閉的,只有 MySQL 是默認支持的

執行之后出現這個錯誤

這是缺少MySQL頭文件和庫文件

centos6用:

yum?install?MySQL-shared

yum?install?MySQL-devel

centos7用:

yum install -y Percona-XtraDB-Cluster-shared-56.x86_64

yum install? -y Percona-XtraDB-Cluster-devel-56

重新?./configure && make && make install

測試:sysbench cpu --cpu-max-prime=10000 run

出現這個就是成功

sysbench支持以下幾種測試模式:

1、CPU運算性能

2、磁盤IO性能

3、調度程序性能

4、內存分配及傳輸速度

5、POSIX線程性能

6、數據庫性能(OLTP基準測試)

目前sysbench主要支持 mysql,drizzle,pgsql,oracle 等幾種數據庫。

三、OLTP測試前準備

初始化測試庫環境(總共10個測試表,每個表 100000 條記錄,填充隨機生成的數據):

cd /tmp/sysbench-0.4.12-1.1/sysbench

mysqladmin create sbtest

./sysbench --mysql-host=1.2.3.4 --mysql-port=3317 --mysql-user=tpcc --mysql-password=tpcc \

--test=tests/db/oltp.lua --oltp_tables_count=10 --oltp-table-size=100000 --rand-init=on prepare

關于這幾個參數的解釋:

--test=tests/db/oltp.lua 表示調用 tests/db/oltp.lua 腳本進行 oltp 模式測試

--oltp_tables_count=10 表示會生成 10 個測試表

--oltp-table-size=100000 表示每個測試表填充數據量為 100000

--rand-init=on 表示每個測試表都是用隨機數據來填充的

如果在本機,也可以使用 –mysql-socket 指定 socket 文件來連接。加載測試數據時長視數據量而定,若過程比較久需要稍加耐心等待。

真實測試場景中,數據表建議不低于10個,單表數據量不低于500萬行,當然了,要視服務器硬件配置而定。如果是配備了SSD或者PCIE SSD這種高IOPS設備的話,則建議單表數據量最少不低于1億行。

四、進行OLTP測試

在上面初始化數據參數的基礎上,再增加一些參數,即可開始進行測試了:

./sysbench --mysql-host=1.2.3.4. --mysql-port=3306 --mysql-user=tpcc \

--mysql-password=tpcc --test=tests/db/oltp.lua --oltp_tables_count=10 \

--oltp-table-size=10000000 --num-threads=8 --oltp-read-only=off \

--report-interval=10 --rand-type=uniform --max-time=3600 \

--max-requests=0 --percentile=99 run >> ./log/sysbench_oltpX_8_20140921.log

幾個選項稍微解釋下

--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%里取最大值

即:模擬 對10個表并發OLTP測試,每個表1000萬行記錄,持續壓測時間為 1小時。

真實測試場景中,建議持續壓測時長不小于30分鐘,否則測試數據可能不具參考意義

五、測試結果解讀:

sysbench 0.5: multi-threaded system evaluation benchmark

Running the test with following options:

Number of threads: 8

Report intermediate results every 10 second(s)

Random number generator seed is 0 and will be ignored

Threads started!

-- 每10秒鐘報告一次測試結果,tps、每秒讀、每秒寫、99%以上的響應時長統計

[ 10s] threads: 8, tps: 1111.51, reads/s: 15568.42, writes/s: 4446.13, response time: 9.95ms (99%)

[ 20s] threads: 8, tps: 1121.90, reads/s: 15709.62, writes/s: 4487.80, response time: 9.78ms (99%)

[ 30s] threads: 8, tps: 1120.00, reads/s: 15679.10, writes/s: 4480.20, response time: 9.84ms (99%)

[ 40s] threads: 8, tps: 1114.20, reads/s: 15599.39, writes/s: 4456.30, response time: 9.90ms (99%)

[ 50s] threads: 8, tps: 1114.00, reads/s: 15593.60, writes/s: 4456.70, response time: 9.84ms (99%)

[ 60s] threads: 8, tps: 1119.30, reads/s: 15671.60, writes/s: 4476.50, response time: 9.99ms (99%)

OLTP test statistics:

queries performed:

read: 938224 -- 讀總數

write: 268064 -- 寫總數

other: 134032 -- 其他操作總數(SELECT、INSERT、UPDATE、DELETE之外的操作,例如COMMIT等)

total: 1340320 -- 全部總數

transactions: 67016 (1116.83 per sec.) -- 總事務數(每秒事務數)

deadlocks: 0 (0.00 per sec.) -- 發生死鎖總數

read/write requests: 1206288 (20103.01 per sec.) -- 讀寫總數(每秒讀寫次數)

other operations: 134032 (2233.67 per sec.) -- 其他操作總數(每秒其他操作次數)

General statistics: -- 一些統計結果

total time: 60.0053s -- 總耗時

total number of events: 67016 -- 共發生多少事務數

total time taken by event execution: 479.8171s -- 所有事務耗時相加(不考慮并行因素)

response time: -- 響應時長統計

min: 4.27ms -- 最小耗時

avg: 7.16ms -- 平均耗時

max: 13.80ms -- 最長耗時

approx. 99 percentile: 9.88ms -- 超過99%平均耗時

Threads fairness:

events (avg/stddev): 8377.0000/44.33

execution time (avg/stddev): 59.9771/0.00

其他信息可以參考這個連接:

http://www.linuxidc.com/Linux/2017-04/142856.htm

實時操作:

/usr/local/bin/sysbench oltp_common --mysql-host=10.1.18.74 --mysql-port=3306? --table-size=1000000 --db-driver=mysql --mysql-db=test --mysql-user=root--mysql-password=root prepare 此命令用來生成表

oltp_common #生成庫的腳本

--mysql-db=test#指定庫

prepare #運行的命令

--oltp_tables_count=10 用來指定生成多少張表

/usr/local/bin/sysbench ?oltp_read_only --mysql-host=10.1.18.74 --mysql-port=3306? --table-size=1000 --db-driver=mysql --mysql-db=test --mysql-user=root --mysql-password=root --time=10 --max-requests=0 --threads=8 run 這是運行

oltp_read_only #指定只讀腳本

--mysql-db=test #指定運行的庫

--threads=8 #指定并發連接數

run #運行指令

/usr/local/bin/sysbench oltp_write_only --mysql-host=10.1.18.74 --mysql-port=3306 --table-size=1000 --db-driver=mysql --mysql-db=test --mysql-user=hairong.cao --mysql-password=hairong.cao --time=10 --max-requests=0 --threads=8 run

oltp_write_only #指定只寫腳本

生成表:

/usr/local/bin/sysbench tests/include/oltp_legacy/oltp.lua --mysql-host=10.1.18.74 --mysql-port=3306? --oltp_tables_count=8 --table-size=10000000 --db-driver=mysql --mysql-db=test --mysql-user=hairong.cao --mysql-password=hairong.cao prepare

混合場景壓測:

/usr/local/bin/sysbench? tests/include/oltp_legacy/oltp.lua? --mysql-host=10.1.18.74 --mysql-port=3306? --table-size=10000000 --db-driver=mysql --mysql-db=test --mysql-user=root --mysql-password=root --oltp_tables_count=8 --max-requests=0 --threads=32 --oltp-read-olny=off --report-interval=10 --percentile=99 --max-time=3600 run >> ./logs/baidu.log

cpu測試:

/usr/local/bin/sysbench --test=cpu --num-threads=40 --max-requests=10000 --cpu-max-prime=20000 run

IO測試:

生成測試文件;?/usr/local/bin/sysbench --test=fileio --file-num=10 --file-total-size=5G prepare? 表示生成10個5G的文件

運行測試:?/usr/local/bin/sysbench --test=fileio --file-total-size=5G --file-test-mode=rndrw? --max-requests=5000 --num-threads=16? --file-num=10 --file-extra-flags=direct --file-fsync-freq=0 --file-block-size=16384 run

參數說明:?--max-requests=5000 表示5000請求量

--num-threads=16? 16個線程

File operations:

reads/s: 1791.40? ?表示每秒讀的次數

writes/s: 1188.31? 表示每秒寫的次數

fsyncs/s: 5.96? ?表示每秒從內存向磁盤同步的次數

Throughput:

read, MiB/s: 27.99? ?這里表示讀的帶寬

written, MiB/s: 18.57? 這里表示寫的帶寬

MySQL讀寫速度慢從外部分析原因:

待續

總結

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

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