tar -zxvf sysbench-1.1.0.tar.gz yum install automake libtool –y #安裝依賴包 cd sysbench-0.4.12.14 ./autogen.sh ./configure --with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib --with-mysql export LD_LIBRARY_PATH=/usr/local/mysql/include #這里換成機器中mysql路徑下的include make make install sysbench --version # 檢驗安裝是否成功 3.簡介 sysbench是跨平臺的基準測試工具,支持多線程,支持多種數據庫,主要包括以下幾種測試:
CPU性能 磁盤io性能 調度程序性能 內存分配及傳輸速度 POSIX線程性能 數據庫性能(基于OLTP的基本測試) 4.sysbench語法 sysbench [options] [testname] [command] command sysbench要執行的命令,包括prepare,run,cleanup。 testname 指定要進行的測試 options --mysql-host MySQL服務器主機名 --mysql-port MySQL服務器端口,默認為3306 --mysql-user MySQL用戶名 --mysql-password MySQL密碼 --oltp-test-mode 執行模式,默認為complex --oltp-tables-size 測試表的大小 --oltp-tables-count 測試表的數量 --threads 客戶端的并發連接 --time 測試執行的時間 5.測試實例 CPU測試 --cpu-max-prime=N upper limit for primes generator [10000] sysbench --cpu-max-prime=20000 --report-interval=10 fileio測試 *4個線程,隨機讀寫,每10s輸出一次結果 [root@slave1 sysbench-master]# sysbench fileio help sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3) fileio options: --file-num=N number of files to create [128] #需要創建的文件數,默認為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,mmap} [sync] # 文件操作模式{sync(同步),async(異步),fastmmap(快速map映射),slowmmap(慢map映射)}。默認是sync --file-async-backlog=N number of asynchronous operatons to queue per thread [128] --file-extra-flags=[LIST,...] list of additional flags to use to open files {sync,dsync,direct} [] #使用額外的標志來打開文件{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] #使用哪種方法進行同步{fsync, fdatasync}。默認是fsync --file-merged-requests=N merge at most this number of IO requests if possible (0 - don't merge) [0] #如果可以,合并最多的IO請求數(0–表示不合并)。默認是0 --file-rw-ratio=N reads/writes ratio for combined test [1.5] #測試時的讀寫比例。默認是1.5 [root@slave1 sysbench-master]# sysbench --threads=4 --file-test-mode=rndwr --report-interval=10 fileio prepare #準備階段 [root@slave1 sysbench-master]# sysbench --threads=4 --time=60 --report-interval=10 --file-test-mode=rndrw fileio run sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)
Running the test with following options: Number of threads: 4 Report intermediate results every 10 second(s) Initializing random number generator from current time
Extra file open flags: (none) 128 files, 16MiB each 2GiB total file size Block size 16KiB Number of IO requests: 0 Read/Write ratio for combined random IO test: 1.50 Periodic FSYNC enabled, calling fsync() each 100 requests. Calling fsync() at the end of test, Enabled. Using synchronous I/O mode Doing random r/w test Initializing worker threads...
Running the test with following options: Number of threads: 4 Report intermediate results every 10 second(s) Initializing random number generator from current time
Running memory speed test with the following options: block size: 1KiB total size: 102400MiB operation: write scope: global
Running the test with following options: Number of threads: 4 Report intermediate results every 10 second(s) Initializing random number generator from current time