zoukankan      html  css  js  c++  java
  • sysbench对自装MySQL数据库进行基准测试

    一、 安装sysbench

    wget https://packagecloud.io/install/repositories/akopytov/sysbench/script.rpm.sh
    chmod +x script.rpm.sh
    ./script.rpm.sh
    yum install -y sysbench

    二、准备测试表

    sysbench 
    //基于mysql的驱动去连接mysql数据库
    --db-driver=mysql 
    //连续访问300秒
    --time=300 
    //10个线程模拟并发访问
    --threads=10 
    //每隔1秒输出一下压测情况
    --report-interval=1 
    //本机
    --mysql-host=127.0.0.1 
    //端口号:3306
    --mysql-port=3306 
    //测试用户
    --mysql-user=root 
    //测试密码
    --mysql-password=******* 
    //测试数据库
    --mysql-db=test_db 
    //模拟新建20个表
    --tables=20 
    //100万条数据 执行oltp数据库的读写测试
    --table_size=1000000 oltp_read_write 
    //参照这个命令的设置去构造出来我们需要的数据库里的数据
    //自动创建20个测试表,每个表里创建100万条测试数据
    --db-ps-mode=disable prepare

    执行命令:

    sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_read_write --db-ps-mode=disable prepare

    执行命令之后:

    三、开始测试

    测试机配置

    虚拟机  8vCPUs | 32GB | CentOS7.7 64bit |  MariaDB 10.4.12

    1、测试综合TPS

    sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_read_write --db-ps-mode=disable run

    执行命令后:

    thds 压测线程数 | tps 每秒事务数 | qps 每秒请求数 | (r/w/o) 每秒的请求数中读请求个数/写请求个数/其他请求个数 | lat(ms,95%) 95% 的请求延迟都在多少以下 | err/s 错误数 | reconn/s 重连数

    测试结果:

    SQL statistics:
        queries performed:
            read:                            2468032                      #300s执行了246万读请求
            write:                           705152                       #300s执行了70万写请求
            other:                           352576                       #300s执行了30万其他请求
            total:                           3525760                      #300s执行了共352万请求
        transactions:                        176288 (587.61 per sec.)         #300s执行了共17万次事务(每秒587次事务)
        queries:                             3525760 (11752.14 per sec.)      #300s执行了查询共352万次请求(每秒1.1万次请求)
        ignored errors:                      0      (0.00 per sec.)           #300s忽略错误总数(每秒忽略错误次数)
        reconnects:                          0      (0.00 per sec.)           #300s重连总数(每秒重连次数)
    
    General statistics:
        total time:                          300.0077s                      #总耗时
        total number of events:              176288                       #总发生的事务数
    
    Latency (ms):
             min:                                    4.17                #最小延迟 4.17ms
             avg:                                   17.01                #平均延迟 17.01ms
             max:                                  418.77                #最大延迟 418.77ms
             95th percentile:                       44.98                #95%的请求延迟 44.98ms
             sum:                              2999093.13
    
    Threads fairness:
        events (avg/stddev):           17628.8000/226.93
        execution time (avg/stddev):   299.9093/0.00

    2、其他测试

    只读性能 oltp_read_only

    sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_read_only --db-ps-mode=disable run

    删除性能 oltp_delete

    sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_delete --db-ps-mode=disable run

    更新索引字段性能 oltp_update_index

    sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_update_index --db-ps-mode=disable run

    更新非索引字段性能 oltp_update_non_index

    sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_update_non_index --db-ps-mode=disable run

    插入性能 oltp_insert

    sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_insert --db-ps-mode=disable run

    写入性能 oltp_write_only

    sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_write_only --db-ps-mode=disable run

    测试完成进行清理 CleanUp

    sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_read_write --db-ps-mode=disable cleanup
  • 相关阅读:
    mysql修改数据表名
    HDU 5742 It's All In The Mind (贪心)
    HDU 5752 Sqrt Bo (数论)
    HDU 5753 Permutation Bo (推导 or 打表找规律)
    HDU 5762 Teacher Bo (暴力)
    HDU 5754 Life Winner Bo (博弈)
    CodeForces 455C Civilization (并查集+树的直径)
    CodeForces 455B A Lot of Games (博弈论)
    CodeForces 455A Boredom (DP)
    HDU 4861 Couple doubi (数论 or 打表找规律)
  • 原文地址:https://www.cnblogs.com/kgdxpr/p/12597073.html
Copyright © 2011-2022 走看看