博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
sysbench压测过程
阅读量:5878 次
发布时间:2019-06-19

本文共 5960 字,大约阅读时间需要 19 分钟。

 1.sysbench安装(sysbench1.1.0)

 
 [root@master soft]# ls sysbench1.1.0.zip

sysbench1.1.0.zip

解压:

[root@master soft]# unzip sysbench1.1.0.zip

安装依赖:

yum -y install mysql-devel

yum -y  install make automake libtool pkgconfig libaio-devel vim-common

编译安装:

cd sysbench-master/

./autogen.sh

./configure --with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib

make

make install

cd /usr/local/share/sysbench

若编译安装出错的解决方法:

ls -l /usr/local/mysql/lib/libmysqlclient.so.18*

ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/

vi /etc/ld.so.conf

export LD_LIBRARY_PATH=/usr/local/mysql/lib

ldconfig 

2.sysbench压测说明

[root@master sysbench-master]# cd /usr/local/share/sysbench

[root@master sysbench]# ls

bulk_insert.lua  oltp_delete.lua  oltp_point_select.lua  oltp_read_write.lua    oltp_update_non_index.lua  select_random_points.lua  tests oltp_common.lua  oltp_insert.lua  oltp_read_only.lua     oltp_update_index.lua  oltp_write_only.lua        select_random_ranges.lua

使用其中的oltp_read_write.lua进行读写压力测试:

第1步:构建数据

sysbench oltp_read_write.lua --mysql-socket=/tmp/mysql3306.sock --mysql-host=192.168.88.8 --mysql-port=3306 --mysql-db=lbgtest --mysql-user=root --mysql-password=root --table_size=50000 --tables=10 --threads=20 --time=60 --report-interval=10 prepare

第2步:压测

sysbench oltp_read_write.lua --mysql-socket=/tmp/mysql3306.sock --mysql-host=192.168.88.8 --mysql-port=3306 --mysql-db=lbgtest --mysql-user=root --mysql-password=root --table_size=50000 --tables=10 --threads=20 --time=60 --report-interval=10 run

选项说明:

--mysql-db=lbgtest   --用来测试的库,需先创建好。

--table-size=100000 表示每个测试表数据量为 100000

--tables=10     测试的表的个数(会自动创建)。

--threads=20    20个并发链接进行测试。

time=60  表示测试总时长为 60

--report-interval=10 表示每10秒输出一次测试进度报告

注明:上面的oltp_read_write.lua可写成绝对路径,将prepare改为run即可进行测试。

3.压测示例

 建测试库:

mysql> create database lbgtest;

创建测试数据:

[root@master sysbench]# sysbench oltp_read_write.lua --mysql-socket=/tmp/mysql3306.sock --mysql-host=192.168.88.8 --mysql-port=3306 --mysql-db=lbgtest --mysql-user=root --mysql-password=root --table_size=50000 --tables=10 --threads=20 --time=60 --report-interval=10 prepare

sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)

Initializing worker threads...

Creating table 'sbtest7'...

Creating table 'sbtest10'...

Creating table 'sbtest8'...

Creating table 'sbtest3'...

Creating table 'sbtest1'...

Creating table 'sbtest2'...

Creating table 'sbtest6'...

Creating table 'sbtest5'...

Creating table 'sbtest4'...

Creating table 'sbtest9'...

Inserting 50000 records into 'sbtest3'

Inserting 50000 records into 'sbtest5'

Inserting 50000 records into 'sbtest1'

Inserting 50000 records into 'sbtest6'

Inserting 50000 records into 'sbtest9'

Inserting 50000 records into 'sbtest2'

Inserting 50000 records into 'sbtest4'

Inserting 50000 records into 'sbtest8'

Inserting 50000 records into 'sbtest10'

Inserting 50000 records into 'sbtest7'

Creating a secondary index on 'sbtest5'...

Creating a secondary index on 'sbtest6'...

Creating a secondary index on 'sbtest4'...

Creating a secondary index on 'sbtest7'...

Creating a secondary index on 'sbtest1'...

Creating a secondary index on 'sbtest9'...

Creating a secondary index on 'sbtest3'...

Creating a secondary index on 'sbtest2'...

Creating a secondary index on 'sbtest10'...

Creating a secondary index on 'sbtest8'...

完成后查看测试数据:

可以在测试库里看到数据:

mysql> use lbgtest;

mysql> show tables;

+-------------------+

| Tables_in_lbgtest |

+-------------------+

| sbtest1           |

| sbtest10          |

| sbtest2           |

| sbtest3           |

| sbtest4           |

| sbtest5           |

| sbtest6           |

| sbtest7           |

| sbtest8           |

| sbtest9           |

+-------------------+

mysql> select count(1) from sbtest1;

+----------+

| count(1) |

+----------+

|    50000 |

+----------+

1 row in set (0.02 sec)

测试:

[root@master sysbench]# sysbench oltp_read_write.lua --mysql-socket=/tmp/mysql3306.sock --mysql-host=192.168.88.8 --mysql-port=3306 --mysql-db=lbgtest --mysql-user=root --mysql-password=root --table_size=50000 --tables=10 --threads=20 --time=60 --report-interval=10 run

sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)

Running the test with following options:

Number of threads: 20

Report intermediate results every 10 second(s)

Initializing random number generator from current time

Initializing worker threads...

Threads started!

[ 10s ] thds: 20 tps: 112.24 qps: 2281.24 (r/w/o: 1598.45/456.37/226.42) lat (ms,95%): 303.33 err/s: 0.00 reconn/s: 0.00

[ 20s ] thds: 20 tps: 141.68 qps: 2829.12 (r/w/o: 1983.33/562.42/283.36) lat (ms,95%): 244.38 err/s: 0.00 reconn/s: 0.00

[ 30s ] thds: 20 tps: 160.33 qps: 3198.39 (r/w/o: 2239.41/638.32/320.66) lat (ms,95%): 219.36 err/s: 0.00 reconn/s: 0.00

[ 40s ] thds: 20 tps: 161.93 qps: 3248.02 (r/w/o: 2272.64/651.52/323.86) lat (ms,95%): 207.82 err/s: 0.00 reconn/s: 0.00

[ 50s ] thds: 20 tps: 153.09 qps: 3055.18 (r/w/o: 2140.95/608.16/306.08) lat (ms,95%): 227.40 err/s: 0.00 reconn/s: 0.00

[ 60s ] thds: 20 tps: 167.67 qps: 3354.30 (r/w/o: 2347.85/671.10/335.35) lat (ms,95%): 223.34 err/s: 0.00 reconn/s: 0.00

SQL statistics:

    queries performed:

        read:                            125762

        write:                           35932

        other:                           17966

        total:                           179660

    transactions:                        8983   (149.56 per sec.)

    queries:                             179660 (2991.27 per sec.)

    ignored errors:                      0      (0.00 per sec.)

    reconnects:                          0      (0.00 per sec.)

Throughput:

    events/s (eps):                      149.5636

    time elapsed:                        60.0614s

    total number of events:              8983

Latency (ms):

         min:                                 18.81

         avg:                                133.67

         max:                                922.85

         95th percentile:                    240.02

         sum:                            1200750.85

Threads fairness:

    events (avg/stddev):           449.1500/6.83

    execution time (avg/stddev):   60.0375/0.04 

4.测试结果说明

  queries performed:

        read:                125762   //读总数

        write:                35932    //写⼊总数

        other:               17966     //其他操作

        total:                179660   //总操作数

    transactions:       8983   (149.56 per sec.)   //TPS每秒事务数

    queries:           179660 (2991.27 per sec.)   //QPS 每秒的读写请求数

    ignored errors:      0      (0.00 per sec.)

    reconnects:        0      (0.00 per sec.)

Throughput:

    events/s (eps):                   149.5636

    time elapsed:                    60.0614s   //总时间

    total number of events:            8983     //总事务数

 

其中主要看:

    transactions:       8983   (149.56 per sec.)   //TPS每秒事务数

    queries:           179660 (2991.27 per sec.)   //QPS 每秒的读写请求数

 

转载于:https://www.cnblogs.com/lbg-database/p/10108606.html

你可能感兴趣的文章
关于outlook 保存的.msg文件打开一次之后不能再次打开的问题
查看>>
CentOS 6.6安装python3.4.3后yum不能使用的解决办法
查看>>
应用程序日志中总是说MS DTC无法正确处理DC 升级/降级事件,是什么意思
查看>>
毕业了,爱情怎么办?
查看>>
关于django一个请求的生命周期
查看>>
Supervisor-容器中启动多个程序
查看>>
CSS颜色代码大全
查看>>
mybatis数据处理的几种方式
查看>>
QStandardItem and QStandardItemModel Class Reference
查看>>
友情链接的作用
查看>>
我的友情链接
查看>>
使用Nginx搭建WEB服务器
查看>>
【oracle唯一主键SYS_GUID()】
查看>>
作业2
查看>>
raid技术-研究感受
查看>>
远程主机探测技术FAQ集 - 扫描篇
查看>>
C++中调用python函数
查看>>
Nomad添加acl认证
查看>>
“TI门外汉”网路知识笔记一 OSI参考模型
查看>>
你不需要jQuery(五)
查看>>