• sysbench测试


    安装sysbench 
    tar xvf sysbench-0.4.12.tar.gz 
    cd sysbench-0.4.12 
    mkdir /usr/sysbench 
    ./configure --prefix=/usr/sysbench --with-mysql-includes=/mysql/include  --with-mysql-libs=/mysql/lib 
    cp /usr/bin/libtool /root/sysbench-0.4.12/libtool 
    make&&make install 
     
     
    #vim /etc/ld.so.conf 增加一行 
    /mysql/lib 
    #ldconfig 
     
     
    磁盘I/O性能测试 
     
     
    --file-num=N   创建测试文件的数量。默认是128 
    --file-block-size=N  测试时文件块的大小。默认是16384(16K) 
    --file-total-size=SIZE   测试文件的总大小。默认是2G 
    --file-test-mode=STRING  文件测试模式{seqwr(顺序写), seqrewr(顺序读写), seqrd(顺序读), rndrd(随机读), rndwr(随机写), rndrw(随机读写)} 
    --file-io-mode=STRING   文件操作模式{sync(同步),async(异步),fastmmap(快速map映射),slowmmap(慢map映射)}。默认是sync 
    --file-extra-flags=STRING   使用额外的标志来打开文件{sync,dsync,direct} 。默认为空 
    --file-fsync-freq=N   执行fsync()的频率。(0–不使用fsync())。默认是100 
    --file-fsync-all=[on|off] 每执行完一次写操作就执行一次fsync。默认是off 
    --file-fsync-end=[on|off] 在测试结束时才执行fsync。默认是on 
    --file-fsync-mode=STRING  使用哪种方法进行同步{fsync, fdatasync}。默认是fsync 
    --file-merged-requests=N   如果可以,合并最多的IO请求数(0–表示不合并)。默认是0 
    --file-rw-ratio=N     测试时的读写比例。默认是1.5 
     
     
    首先生成需要测试的文件-------在当前工作目录下创建测试文件,后续的运行(run)阶段将通过读写这些文件进行测试。生成测试用到的数据文件,生成的数据文件至少要比内存大 
    sysbench --test=fileio --num-threads=16 --file-num=2 --file-total-size=2G --file-test-mode=rndrw --file-rw-ratio=2 prepare 
    然后执行测试 
    sysbench --test=fileio --num-threads=16 --file-num=2 --file-total-size=2G --file-test-mode=rndrw --file-rw-ratio=2 run 
    最后清理测试文件 
    sysbench --test=fileio --num-threads=16 --file-num=2 --file-total-size=2G --file-test-mode=rndrw --file-rw-ratio=2 cleanup 
     
     
    数据库性能测试 
     
     
    oltp options: 
    --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 
    General database options: 
    --db-driver=STRING  指定数据库驱动程序(‘help’ to get list of available drivers) 
    --db-ps-mode=STRING编制报表使用模式{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     说明使用的数据库引擎是否是事务的 {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 [] 
     
     
    准备测试数据                                     
    首先创建测试的库 
    sysbench --test=oltp --mysql-host=localhost --mysql-user=root --db-driver=mysql --mysql-password=xxxx --mysql-db=test --oltp-table-name=test --mysql-table-engine=MyISAM --oltp-table-size=90000000 --myisam-max-rows=100000000 prepare
    然后执行测试  
    sysbench --test=oltp --mysql-host=localhost --db-driver=mysql --mysql-port=3306 --mysql-user=root --mysql-password=xxxx --mysql-db=test --oltp-table-name=test --mysql-table-engine=MyISAM --oltp-table-size=90000000 --max-requests=1000 --num-threads=100 --oltp-read-only run 
    最后清理测试数据  
    sysbench --test=oltp --mysql-host=localhost --mysql-user=root --db-driver=mysql --mysql-password=xxxx --mysql-db=test --oltp-table-name=test --mysql-table-engine=MyISAM --oltp-table-size=90000000 cleanup
    ==========mysql测试结果============= 
    [root@test1 ~]# sysbench --test=oltp --db-driver=mysql --mysql-host=localhost --mysql-user=root --mysql-socket=/var/lib/mysql/mysql.scok --mysql-db=test --mysql-password=xxxx  --mysql-table-engine=MyISAM --oltp-table-size=100 run   
    sysbench 0.4.12:  multi-threaded system evaluation benchmark 
     
     
    Running the test with following options: 
    Number of threads: 1 
     
     
    Doing OLTP test. 
    Running mixed OLTP test 
    Using Special distribution (12 iterations,  1 pct of values are returned in 75 pct cases) 
    Using "LOCK TABLES WRITE" for starting transactions 
    Using auto_inc on the id column 
    Maximum number of requests for OLTP test is limited to 10000 
    Threads started! 
    Done. 
     
     
    OLTP test statistics: 
        queries performed: 
            read:                            140000 
            write:                           50000 
            other:                           20000 
            total:                           210000 
        transactions:                        10000  (401.89 per sec.) 
        deadlocks:                           0      (0.00 per sec.) 
        read/write requests:                 190000 (7635.84 per sec.) 
        other operations:                    20000  (803.77 per sec.) 
    —-总共执行10000次请求事务操作,每秒平均401.89次,读写请求是190000次,每秒平均是7635.84,其他运行20000次 
    Test execution summary: 
        total time:                          24.8827s 
        total number of events:              10000 
        total time taken by event execution: 24.8381 
        per-request statistics: 
             min:                                  1.79ms 
             avg:                                  2.48ms 
             max:                                159.71ms 
             approx.  95 percentile:               3.56ms 
    —总共花费24秒,最终请求数为10000次,每次请求最小花费1.79ms,平均2.48ms,最大159ms, 
    Threads fairness: 
        events (avg/stddev):           10000.0000/0.00 
        execution time (avg/stddev):   24.8381/0.00 
     
     
    =======磁盘测试结果=========== 
    [root@test1 ~]# sysbench --test=fileio --num-threads=16 --file-total-size=300M --file-test-mode=rndrw run     
    sysbench 0.4.12:  multi-threaded system evaluation benchmark 
     
     
    Running the test with following options: 
    Number of threads: 16 
     
     
    Extra file open flags: 0 
    128 files, 2.3438Mb each   #####300M文件大小,128个文件,每个2.3438Mb 
    300Mb total file size 
    Block size 16Kb            ####block 16k 
    Number of random requests for random IO: 10000    ###随机IO请求数10000 
    Read/Write ratio for combined random IO test: 1.50 ###随机读写比例1.5:1 
    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  ###随机读写测试 
    Threads started! 
    Done. 
     
     
    Operations performed:  6006 Read, 3994 Write, 12800 Other = 22800 Total 
    Read 93.844Mb  Written 62.406Mb  Total transferred 156.25Mb  (11.44Mb/sec)  ###总的IO读写效率 
      732.13 Requests/sec executed 
    #######723.13/s是IOPC,每次IO读写一个block,每个block16k,723*16/1024=11M/s 
    Test execution summary: 
        total time:                          13.6588s 
        total number of events:              10000 
        total time taken by event execution: 165.7482 
        per-request statistics: 
             min:                                  0.00ms 
             avg:                                 16.57ms 
             max:                                869.99ms 
             approx.  95 percentile:             101.30ms 
     
     
    Threads fairness: 
        events (avg/stddev):           625.0000/38.27 
        execution time (avg/stddev):   10.3593/0.37 
     
     
     
     
    ./sysbench --mysql-db=sbtest --max-requests=0 --test=oltp --mysql-engine-trx=yes --mysql-table-engine=innodb --oltp-table-size=1000000 --db-ps-mode=disable  --mysql-user=root --mysql-host=192.168.101.25 --mysql-socket=/mysql/mysql.sock   --mysql-password --num-threads=16 --max-time=600 run 
    ./sysbench --mysql-db=sbtest --max-requests=0 --test=oltp --mysql-engine-trx=yes --mysql-table-engine=innodb --oltp-table-size=1000000 --db-ps-mode=disable  --mysql-user=root --mysql-host=192.168.101.25 --mysql-socket=/mysql/mysql.sock   --mysql-password --num-threads=16 --max-time=600 --oltp-read-only run 
     
  • 相关阅读:
    BISDN上收集到的SAP BI的极好文章的链接
    如何设置'REUSE_ALV_GRID_DISPLAY'的单个单元格的颜色
    如何设置REUSE_ALV_GRID_DISPLAY'的单个单元格的是否可以输入
    BWABAP to copy aggregates from one cube to another
    SDva01的屏幕增强
    js鼠标悬停效果
    MySQL更新UPDATA的使用
    使用mysql C语言API编写程序—MYSQL数据库查询操作
    MySQL的部分基础语句
    MySQLdelete某个元组||、&&操作
  • 原文地址:https://www.cnblogs.com/cptao/p/10913025.html
Copyright © 2020-2023  润新知