MySQL壓力測試工具

來源:互聯網
上載者:User

標籤:mysql壓力測試工具

工具名稱:mysqlha_sysbench.sh

工具用途:用於MySQL壓力測試  (2種功能:填充資料&&測試資料)

工具參數:

options:

-P 需要測試的連接埠
-D 需要測試的db名字
-H 需要測試的host
-S 填充&&測試 表的資料量,default 100w
-C 填充&&測試 表的數量, default 1
-T prepare and run ,prepare is 製造資料 run is 開始測試 ,default run
-O on and off, on 是讀寫混合模式 off是唯讀模式 ,default on
-B 並發數 default 1
-Y 測試時間 ,填充時不用填寫 default 1800#半小時 
-N test number 測試的數量 例如 128線程跑3次

 

工具樣本: 

Example: Usage make(填充資料) data:mysqlha_sysbench.sh -P 連接埠 -D db -H ip -T prepare 
Example: Usage test (測試資料)data:mysqlha_sysbench.sh -P 連接埠 -D db -H ip -B 並發數  -Y 測試時間 -N 次數


注意事項:

1)許可權問題    使用myadmin帳號,注意授權

2)本地必須安裝sysbench 路徑在/usr/local/xywy/sysbench/bin/ 

工具執行結果:

650) this.width=650;" class="confluence-embedded-image" src="http://wiki.op.xywy.com/download/attachments/14256024/image2016-9-2%2011%3A0%3A3.png?version=1&modificationDate=1472785499000&api=v2" alt="image2016-9-2%2011%3A0%3A3.png?version=1" />




#!/bin/bash

# Author: [email protected]

# Date: 2016-09-02



# helpfunc shows the help info

function helpfunc(){

        echo 

         echo "Please check your input!!!!"

         echo "options:"

         echo " -P      test port"

         echo " -D      databases name"

         echo " -H      test host"

         echo " -S      table size   ,default 100w"

         echo " -C      test table number ,  default 1"

         echo " -T      prepare and run ,prepare is 製造資料 run is 開始測試  ,default run"

         echo " -O      on and off, on 是讀寫混合模式 off是唯讀模式  ,default on"

         echo " -B      並發數 default 1"

         echo " -Y       Test time in seconds  default 1800#半小時 "

         echo " -N       test number "


         echo "  Example:  Usage make data:mysqlha_sysbench.sh -P  -D  -H  -T  "

         echo "  Example:  Usage test data:mysqlha_sysbench.sh -P  -D  -H  -B  -Y  "


}

############################################

. /etc/dbbin/sh_lib/config.sh "/etc/dbbin/conf/mysql.cfg"

user="myadmin";

password=`getConfig "mysql" $user`


bfs=1

option="on"

time=1800

number=1

if [ $# -lt 1 ] ;

    then

        helpfunc

         exit 1

else

                        P) port=$OPTARG;;

                        D) db=$OPTARG;;

                        H) host=$OPTARG;;

                        S) size=$OPTARG;;

                        C) count=$OPTARG;;

                        T) type=$OPTARG;;

                        O) option=$OPTARG;;

                        B) bfs=$OPTARG;;

                        Y) time=$OPTARG;;

                        N) number=$OPTARG;;

                         *) helpfunc; exit 1; ;;

                esac

        done


fi


date=`date "+%Y-%m-%d"`

function test_data(){

        if [ "$type" == "prepare" ];then

                /usr/local/xywy/sysbench/bin/sysbench --test=/usr/local/xywy/sysbench/db/oltp.lua --oltp-table-size="$size" --oltp-table-name=tt --mysql-db=$db --mysql-port=$port  --mysql-host=$host  --mysql-user=$user --mysql-password=$password  --oltp_tables_count=$count --oltp-test-mode=complex --rand-type=uniform --rand-init=on --report-interval=10 --percentile=99 prepare >> /data/logs/sysbench_oltp$date.log

                if [ $? -ne 0 ] ; then

                        echo "insert data failure!"

                        exit -1

                else

                        echo "insert $count data is sucess"

                fi

        elif [ "$type" == "run" ];then

                for i in $(seq 1 $number)

                do

                        /usr/local/xywy/sysbench/bin/sysbench --test=/usr/local/xywy/sysbench/db/oltp.lua --oltp-table-size=$size   --mysql-db=$db --mysql-port=$port  --mysql-host=$host  --mysql-user=$user --mysql-password=$password  --oltp_tables_count=$count --oltp-read-only=$option --oltp-test-mode=complex --rand-type=uniform --rand-init=on --num-threads=$bfs --max-time=$time --max-requests=0 --report-interval=10 --percentile=99 run >> /data/logs/sysbench_oltp$date.log

                        if [ $? -ne 0 ] ; then

                                echo " Test failure!"

                                exit -1

                        else

                                log=`cat /data/logs/sysbench_oltp$date.log|grep transactions: -B 10|grep $bfs -A10`

                                echo " Concurrent for $bfs of the results is $log "

                        fi

                done

        else

                helpfunc

        fi

}


test_data


本文出自 “10937712” 部落格,請務必保留此出處http://10947712.blog.51cto.com/10937712/1845560

MySQL壓力測試工具

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.