MySQL/Mariadb基准测试工具-tpcc-mysql使用2

tpcc-mysql 是percona基于TPCC标准的mysql实现,专用于mysql基准测试。在上一篇说到tpcc-mysql 的安装和编译,本篇开始说它的使用。

根据叶大神的分析,官方基准测试仅适应于主键已生成的项目,对于由数据库自动生成主键的测试他有一篇博客和工具专门进行了描述。传送门:http://imysql.com/2014/10/11/percona-tpcc-mysql-branch-release.shtml

3.初始化

1)ReadMe 和帮助

README.md
[root@localhost tpcc-mysql-master]# cat README.md 
1. Build binaries
   * `cd src ; make`
   ( you should have mysql_config available in $PATH)

2. Load data
   * create database
     `mysqladmin create tpcc1000`
   * create tables
     `mysql tpcc1000 < create_table.sql`
   * create indexes and FK ( this step can be done after loading data)
     `mysql tpcc1000 < add_fkey_idx.sql`
   * populate data
     - simple step
       `tpcc_load -h127.0.0.1 -d tpcc1000 -u root -p "" -w 1000`
                 |hostname:port| |dbname| |user| |password| |WAREHOUSES|
       ref. tpcc_load --help for all options
     - load data in parallel 
       check load.sh script

3. Start benchmark
   * `./tpcc_start -h127.0.0.1 -P3306 -dtpcc1000 -uroot -w1000 -c32 -r10 -l10800`
   * |hostname| |port| |dbname| |user| |WAREHOUSES| |CONNECTIONS| |WARMUP TIME| |BENCHMARK TIME|
   * ref. tpcc_start --help for all options 

Output
===================================

With the defined interval (-i option), the tool will produce the following output:
``
  10, trx: 12920, 95%: 9.483, 99%: 18.738, max_rt: 213.169, 12919|98.778, 1292|101.096, 1293|443.955, 1293|670.842
  20, trx: 12666, 95%: 7.074, 99%: 15.578, max_rt: 53.733, 12668|50.420, 1267|35.846, 1266|58.292, 1267|37.421
  30, trx: 13269, 95%: 6.806, 99%: 13.126, max_rt: 41.425, 13267|27.968, 1327|32.242, 1327|40.529, 1327|29.580
  40, trx: 12721, 95%: 7.265, 99%: 15.223, max_rt: 60.368, 12721|42.837, 1271|34.567, 1272|64.284, 1272|22.947
  50, trx: 12573, 95%: 7.185, 99%: 14.624, max_rt: 48.607, 12573|45.345, 1258|41.104, 1258|54.022, 1257|26.626
``

Where: 
* 10 - the seconds from the start of the benchmark
* trx: 12920 - New Order transactions executed during the gived interval (in this case, for the previous 10 sec). Basically this is the throughput per interval. The more the better
* 95%: 9.483: - The 95% Response time of New Order transactions per given interval. In this case it is 9.483 sec
* 99%: 18.738: - The 99% Response time of New Order transactions per given interval. In this case it is 18.738 sec
* max_rt: 213.169: - The Max Response time of New Order transactions per given interval. In this case it is 213.169 sec
* the rest: `12919|98.778, 1292|101.096, 1293|443.955, 1293|670.842` is throughput and max response time for the other kind of transactions and can be ignored
  • 10 - 从基准开始的秒数
  • trx:12920 - 在订购间隔期间执行的新订单交易(在本例中为10秒)。 基本上这是每个间隔的吞吐量。 越多越好
  • 95%:9.483: - 每次给定间隔的新订单交易的95%响应时间。 在这种情况下是9.483秒
  • 99%:18.738: - 每次给定间隔的新订单交易的99%响应时间。 在这种情况下是18.738秒
  • max_rt:213.169: - 每次给定间隔的新订单交易的最大响应时间。 在这种情况下是213.169秒
    *其余:12919 | 98.778,1292 | 101.096,1293 | 443.955,1293 | 670.842是另一种交易的吞吐量和最大响应时间,可以忽略
tpcc_load帮助
[root@localhost tpcc-mysql-master]# ./tpcc_load --help
*************************************
*** TPCC-mysql Data Loader        ***
*************************************
./tpcc_load: invalid option -- '-'
Usage: tpcc_load -h server_host -P port -d database_name -u mysql_user -p mysql_password -w warehouses -l part -m min_wh -n max_wh
* [part]: 1=ITEMS 2=WAREHOUSE 3=CUSTOMER 4=ORDERS

参数说明:
-h server_host: 服务器名
-P port : 端口号,默认为3306
-d database_name: 数据库名
-u mysql_user : 用户名
-p mysql_password : 密码
-w warehouses: 仓库的数量
–下面三个参数等你在执行一次数据初始化以后就有了理解了,初始化确实太慢了,需要有加快执行的方法,大神们也已经替我们想到了,如果想创建的仓库确实比较对,可以并行初始化数据也可选择部分初始化。
-l part: 选择初始化的部分1=ITEMS 2=WAREHOUSE 3=CUSTOMER 4=ORDERS
-m min_wh: 选择初始化开始库
-n max_wh: 选择初始化结束库

在这里对part不理解的我们再回顾一下tpcc的模型,它的流程是首先需要订单–产生支付–仓库发货–物流–确认收货,等类似于电商的过程,然后来模拟高并发来完成一个典型电商的业务。

tpcc-mysql的业务逻辑及其相关的几个表作用如下:
·New-Order:新订单,主要对应 new_orders 表
·Payment:支付,主要对应 orders、history 表
·Order-Status:订单状态,主要对应 orders、order_line 表
·Delivery:发货,主要对应 order_line 表
·Stock-Level:库存,主要对应 stock 表

其他相关表:
·客户:主要对应 customer 表
·地区:主要对应 district 表
·商品:主要对应 item 表
·仓库:主要对应 warehouse 表

tpcc_start帮助
[root@localhost tpcc-mysql-master]# ./tpcc_start --help
***************************************
*** ###easy### TPC-C Load Generator ***
***************************************
./tpcc_start: invalid option -- '-'
Usage: tpcc_start -h server_host -P port -d database_name -u mysql_user -p mysql_password -w warehouses -c connections -r warmup_time -l running_time -i report_interval -f report_file -t trx_file

参数说明:
-h server_host: 服务器名
-P port : 端口号,默认为3306
-d database_name: 数据库名
-u mysql_user : 用户名
-p mysql_password : 密码
-w warehouses: 仓库的数量
-c connections : 线程数,默认为1
-r warmup_time : 热身时间,单位:s,默认为10s ,热身是为了将数据加载到内存。
-l running_time: 测试时间,单位:s,默认为20s
-i report_interval: 指定生成报告间隔时长
-f report_file: 测试结果输出文件
-t trx_file:

2)初始化

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 # Settings user and group are ignored when systemd is used. # If you need to run mysqld under a different user or group, # customize your systemd unit file for mariadb according to the # instructions in http://fedoraproject.org/wiki/Systemd [mysqld_safe] log-error=/var/log/mariadb/mariadb.log pid-file=/var/run/mariadb/mariadb.pid # # include all files from the config directory # !includedir /etc/my.cnf.d 这是MySQL数据库的配置文件,以下是每条配置的翻译: [mysqld] - datadir=/var/lib/mysql:指定MySQL数据库存储的目录。 - socket=/var/lib/mysql/mysql.sock:指定MySQL数据库与客户端通信的套接字文件。 - symbolic-links=0:禁用符号链接以预防各种安全风险。 - 在使用systemd时,user和group设置会被忽略。如果需要以不同的用户或组运行mysqld,请根据mariadb的systemd unit文件自定义配置,具体操作方式请参考http://fedoraproject.org/wiki/Systemd。 [mysqld_safe] - log-error=/var/log/mariadb/mariadb.log:指定MariaDB的错误日志文件路径。 - pid-file=/var/run/mariadb/mariadb.pid:指定MariaDB的进程ID文件路径。 !includedir /etc/my.cnf.d - 包含配置目录中的所有文件。 这些是MySQL/MariaDB数据库的配置项,用于指定数据库存储、通信、安全等方面的设置。具体的配置和参数设置可以根据需求进行调整。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值