MySQL TPC-C模型数据导入

测试步骤

解压编译

[root@sd2 mysql]# unzip tpcc-mysql-master.zip
[root@sd2 mysql]# cd tpcc-mysql-master
[root@sd2 tpcc-mysql-master]# ls
add_fkey_idx.sql  count.sql  create_table.sql  Dockerfile  drop_cons.sql  load_multi_schema.sh  load.sh  README.md  schema2  scripts  src
[root@sd2 tpcc-mysql-master]# cd src
[root@sd2 src]# ll
total 192
-rw-r--r--. 1 root root  7875 Jan 21  2017 delivery.c
-rw-r--r--. 1 root root 10163 Jan 21  2017 driver.c
-rw-r--r--. 1 root root 36435 Jan 21  2017 load.c
-rw-r--r--. 1 root root 25966 Jan 21  2017 main.c
-rw-r--r--. 1 root root   594 Jan 21  2017 Makefile
-rw-r--r--. 1 root root 16241 Jan 21  2017 neword.c
-rw-r--r--. 1 root root 10607 Jan 21  2017 ordstat.c
-rw-r--r--. 1 root root   617 Jan 21  2017 parse_port.h
-rw-r--r--. 1 root root 17302 Jan 21  2017 payment.c
-rw-r--r--. 1 root root  2990 Jan 21  2017 rthist.c
-rw-r--r--. 1 root root   142 Jan 21  2017 rthist.h
-rw-r--r--. 1 root root  3372 Jan 21  2017 sb_percentile.c
-rw-r--r--. 1 root root  1570 Jan 21  2017 sb_percentile.h
-rw-r--r--. 1 root root  1200 Jan 21  2017 sequence.c
-rw-r--r--. 1 root root    89 Jan 21  2017 sequence.h
-rw-r--r--. 1 root root  5291 Jan 21  2017 slev.c
-rw-r--r--. 1 root root   497 Jan 21  2017 spt_proc.c
-rw-r--r--. 1 root root   123 Jan 21  2017 spt_proc.h
-rw-r--r--. 1 root root  3656 Jan 21  2017 support.c
-rw-r--r--. 1 root root  2261 Jan 21  2017 tpc.h
-rw-r--r--. 1 root root   688 Jan 21  2017 trans_if.h
[root@sd2 src]# make
cc -w -O3 -g -I. `mysql_config --include`  -c load.c
cc -w -O3 -g -I. `mysql_config --include`  -c support.c
cc load.o support.o `mysql_config --libs_r` -lrt -o ../tpcc_load
cc -w -O3 -g -I. `mysql_config --include`  -c main.c
cc -w -O3 -g -I. `mysql_config --include`  -c spt_proc.c
cc -w -O3 -g -I. `mysql_config --include`  -c driver.c
cc -w -O3 -g -I. `mysql_config --include`  -c sequence.c
cc -w -O3 -g -I. `mysql_config --include`  -c rthist.c
cc -w -O3 -g -I. `mysql_config --include`  -c sb_percentile.c
cc -w -O3 -g -I. `mysql_config --include`  -c neword.c
cc -w -O3 -g -I. `mysql_config --include`  -c payment.c
cc -w -O3 -g -I. `mysql_config --include`  -c ordstat.c
cc -w -O3 -g -I. `mysql_config --include`  -c delivery.c
cc -w -O3 -g -I. `mysql_config --include`  -c slev.c
cc main.o spt_proc.o driver.o support.o sequence.o rthist.o sb_percentile.o neword.o payment.o ordstat.o delivery.o slev.o `mysql_config --libs_r` -lrt -o ../tpcc_start
[root@sd2 src]# ll
total 700
-rw-r--r--. 1 root root   7875 Jan 21  2017 delivery.c
-rw-r--r--. 1 root root  25864 Mar  2 10:40 delivery.o
-rw-r--r--. 1 root root  10163 Jan 21  2017 driver.c
-rw-r--r--. 1 root root  34192 Mar  2 10:40 driver.o
-rw-r--r--. 1 root root  36435 Jan 21  2017 load.c
-rw-r--r--. 1 root root 111096 Mar  2 10:40 load.o
-rw-r--r--. 1 root root  25966 Jan 21  2017 main.c
-rw-r--r--. 1 root root 120312 Mar  2 10:40 main.o
-rw-r--r--. 1 root root    594 Jan 21  2017 Makefile
-rw-r--r--. 1 root root  16241 Jan 21  2017 neword.c
-rw-r--r--. 1 root root  35712 Mar  2 10:40 neword.o
-rw-r--r--. 1 root root  10607 Jan 21  2017 ordstat.c
-rw-r--r--. 1 root root  28392 Mar  2 10:40 ordstat.o
-rw-r--r--. 1 root root    617 Jan 21  2017 parse_port.h
-rw-r--r--. 1 root root  17302 Jan 21  2017 payment.c
-rw-r--r--. 1 root root  34264 Mar  2 10:40 payment.o
-rw-r--r--. 1 root root   2990 Jan 21  2017 rthist.c
-rw-r--r--. 1 root root    142 Jan 21  2017 rthist.h
-rw-r--r--. 1 root root  13216 Mar  2 10:40 rthist.o
-rw-r--r--. 1 root root   3372 Jan 21  2017 sb_percentile.c
-rw-r--r--. 1 root root   1570 Jan 21  2017 sb_percentile.h
-rw-r--r--. 1 root root  11936 Mar  2 10:40 sb_percentile.o
-rw-r--r--. 1 root root   1200 Jan 21  2017 sequence.c
-rw-r--r--. 1 root root     89 Jan 21  2017 sequence.h
-rw-r--r--. 1 root root  15280 Mar  2 10:40 sequence.o
-rw-r--r--. 1 root root   5291 Jan 21  2017 slev.c
-rw-r--r--. 1 root root  24432 Mar  2 10:40 slev.o
-rw-r--r--. 1 root root    497 Jan 21  2017 spt_proc.c
-rw-r--r--. 1 root root    123 Jan 21  2017 spt_proc.h
-rw-r--r--. 1 root root  18936 Mar  2 10:40 spt_proc.o
-rw-r--r--. 1 root root   3656 Jan 21  2017 support.c
-rw-r--r--. 1 root root  20888 Mar  2 10:40 support.o
-rw-r--r--. 1 root root   2261 Jan 21  2017 tpc.h
-rw-r--r--. 1 root root    688 Jan 21  2017 trans_if.h
[root@sd2 src]# cd ../
[root@sd2 tpcc-mysql-master]# ll
total 300
-rw-r--r--. 1 root root   1621 Jan 21  2017 add_fkey_idx.sql
-rw-r--r--. 1 root root    317 Jan 21  2017 count.sql
-rw-r--r--. 1 root root   3105 Jan 21  2017 create_table.sql
-rw-r--r--. 1 root root    194 Jan 21  2017 Dockerfile
-rw-r--r--. 1 root root    763 Jan 21  2017 drop_cons.sql
-rw-r--r--. 1 root root   1079 Jan 21  2017 load_multi_schema.sh
-rw-r--r--. 1 root root    573 Jan 21  2017 load.sh
-rw-r--r--. 1 root root   2302 Jan 21  2017 README.md
drwxr-xr-x. 2 root root     92 Jan 21  2017 schema2
drwxr-xr-x. 5 root root   4096 Jan 21  2017 scripts
drwxr-xr-x. 2 root root   4096 Mar  2 10:40 src
-rwxr-xr-x. 1 root root  78808 Mar  2 10:40 tpcc_load
-rwxr-xr-x. 1 root root 181352 Mar  2 10:40 tpcc_start

#编译之后生成了tpcc_load和tpcc_start命令

创建数据库及表

(root@sd2) [(none)]> create database tpcc;
(root@sd2) [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| employees          |
| information_schema |
| mysql              |
| performance_schema |
| ranger             |
| skye               |
| sys                |
| test               |
| tpcc               |
+--------------------+
9 rows in set (0.01 sec)
(root@sd2) [(none)]> use tpcc;
Database changed
(root@sd2) [tpcc]> source /mysql/tpcc-mysql-master/create_table.sql;
(root@sd2) [tpcc]> show tables;
+----------------+
| Tables_in_tpcc |
+----------------+
| customer       |
| district       |
| history        |
| item           |
| new_orders     |
| order_line     |
| orders         |
| stock          |
| warehouse      |
+----------------+
9 rows in set (0.03 sec)

#表说明
tpcc-mysql的业务逻辑及其相关的几个表作用如下:
New-Order:新订单,一次完整的订单事务,几乎涉及到全部表
Payment:支付,主要对应 orders、history 表
Order-Status:订单状态,主要对应 orders、order_line 表
Delivery:发货,主要对应 order_line 表
Stock-Level:库存,主要对应 stock 表

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

加载数据

./tpcc_load -h sd2 -P 3306 -d tpcc -u root -p Asdf123. -w 10

(这个步骤持续时间比较长)
在这里插入图片描述

创建索引

(root@sd2) [tpcc]> source /mysql/tpcc-mysql-master/add_fkey_idx.sql;

参考

https://www.cnblogs.com/wxzhe/p/10027474.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值