Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: 有没有推荐的SQL回放工具
[TiDB Usage Environment] Testing/PoC
[TiDB Version] 7.5
I plan to use an SQL playback tool to record MySQL statements into TiDB to test SQL compatibility and performance. Could you recommend any good tools for this?
Have you tried it on the TiDB cluster, how is the effect, and what issues should we pay attention to? We want to learn.
Got it, I’ll study and research.
TiDB’s own tool DM can do it.
Got it, I’ll give it a try if needed after studying gopacket.
Support! Although I haven’t practiced it, it seems quite useful.
What scenario is this replay for?
Freshly released by the expert:
# 工具说明
解析 tshark 工具生成的 MySQL SQL、解析响应时间(响应时间按照 SQL 第一次返回数据包计算,不考虑应用流式读取数据时发送结果的时间)
tshark 需提前安装:
```
yum install -y wireshark # Centos 7 自带的版本较低,但也能工作,建议编译安装 3.2.3 版本
```
# 使用说明
## 1. 使用 tshark 抓取 MySQL 数据包(tcpdump 抓取的数据包 parse-tshark 工具无法正确处理)
### 方式一:使用 tshark 进行 port+mysql 过滤(不推荐)
该方式会直接生成 parse-tshark 工具可读取的文件,生成的文件比较小,但在资源不够时对 MySQL 性能影响大(不推荐在生产使用)
```
sudo tshark -i eth0 -Y "mysql.query or ( tcp.srcport==3306)" -d tcp.port==3306,mysql -o tcp.calculate_timestamps:true -T fields -e tcp.stream -e tcp.len -e tcp.time_delta -e ip.src -e tcp.srcport -e ip.dst -e tcp.dstport -e frame.time_epoch -e mysql.query -E separator='|' >> tshark.log
```
### 方式二:使用 tshark 进行 port 过滤,再二次过滤文件中的 mysql.query 和 响应时间
该方式生成的文件比较大,但对生产性能影响小
#### 抓包
This file has been truncated. show original
OK, thank you. I will look into it.
I really haven’t used this.
Waiting for the original poster to share practical cases~