当前位置:网站首页>使用 percona 工具给 MySQL 表加字段中断后该如何操作
使用 percona 工具给 MySQL 表加字段中断后该如何操作
2022-07-02 12:13:00 【六位元素】
目录
需求
现在有一个MySQL数据库,库中有很多千万级的大表,现在需要给一个几千万级别数据量的大表加字段
方案
由于表数据量太大,通过MySQL客户端命令行直接添加字段是不可取的,因为:直接修改表结构会锁表,由于数据量巨大,执行会非常的慢,并且会影响表的读写。现在绝大多数业务系统,都需要保证7*24小时无间断的提供服务,大表直接修改会导致长时间的表被锁,造成业务中断,影响业务,这种情况肯定是不能接受的。
所以我们需要找一个可行的替代方案,有了,我们使用percona的工具pt-online-change-schema来加字段,这个工具可以在几乎不影响性能的前提下完成表结构的修改。
问题
使用pt-online-change-schema加字段的过程由于连接中断,加字段未能成功,我们重新使用该工具加字段结果报错了,报错信息如下:

这个报错是提示触发器已经存在。
分析
我们知道使用pt-online-change-schema工具来给MySQL的表加字段会创建三个触发器(insert、update、delete),所以我们需要删除这三个触发器后再使用工具给表添加字段。
解决方案
1.查询触发器
select * from information_schema.triggers;
2.删除触发器
找到对应的TRIGGER_SCHEMA和TRIGGER_NAME,比如
drop trigger test.pt_osc_test_t_tab1_ins;
drop trigger test.pt_osc_test_t_tab1_upd;
drop trigger test.pt_osc_test_t_tab1_del;3.重新使用pt-online-change-schema工具执行加字段即可。
边栏推荐
- 6090. Minimax games
- Semantic segmentation learning notes (1)
- 6090. 极大极小游戏
- [experience cloud] how to get the metadata of experience cloud in vscode
- Storage read-write speed and network measurement based on rz/g2l | ok-g2ld-c development board
- 【Experience Cloud】如何在VsCode中取得Experience Cloud的MetaData
- Custom exception
- 百变大7座,五菱佳辰产品力出众,人性化大空间,关键价格真香
- MD5 encryption
- 高考录取分数线爬取
猜你喜欢

2022 年辽宁省大学生数学建模A、B、C题(相关论文及模型程序代码网盘下载)

Semantic segmentation learning notes (1)
![[network security] network asset collection](/img/3e/6665b5af0dedfcbc7bd548cc486878.png)
[network security] network asset collection

How to intercept the value of a key from the JSON string returned by wechat?

How to find a sense of career direction

Leetcode question brushing - parity linked list 328 medium

How to avoid 7 common problems in mobile and network availability testing

LeetCode刷题——递增的三元子序列#334#Medium

Redux——详解

Leetcode skimming -- verifying the preorder serialization of binary tree # 331 # medium
随机推荐
YOLOV5 代码复现以及搭载服务器运行
[leetcode] 486 predict winners
Bing. Site Internet
6090. Minimax games
Let your HMI have more advantages. Fet-g2ld-c core board is a good choice
Leetcode question brushing - parity linked list 328 medium
【Experience Cloud】如何在VsCode中取得Experience Cloud的MetaData
Build your own semantic segmentation platform deeplabv3+
语义分割学习笔记(一)
Leetcode skimming -- incremental ternary subsequence 334 medium
夏季高考文化成绩一分一段表
Redux - detailed explanation
Deux séquences ergodiques connues pour construire des arbres binaires
6091. 划分数组使最大差为 K
[leetcode] 189 rotation array
【LeetCode】1162-地图分析
[salesforce] how to confirm your salesforce version?
[leetcode] 1020 number of enclaves
[leetcode] 1140 stone game II
【网络安全】网络资产收集