当前位置:网站首页>使用 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工具执行加字段即可。
边栏推荐
- Solve the problem of frequent interruption of mobaxterm remote connection
- [leetcode] 577 reverse word III in string
- [leetcode] 1254 - count the number of closed Islands
- Basic knowledge of cryptography
- [leetcode] 1140 stone game II
- 高考录取分数线爬取
- LeetCode刷题——统计各位数字都不同的数字个数#357#Medium
- 03. Preliminary use of golang
- [development environment] install the Chinese language pack for the 2013 version of visual studio community (install test agents 2013 | install visual studio 2013 simplified Chinese)
- Facing the challenge of "lack of core", how can Feiling provide a stable and strong guarantee for customers' production capacity?
猜你喜欢
[leetcode] 1162 map analysis
Let your HMI have more advantages. Fet-g2ld-c core board is a good choice
搭建自己的语义分割平台deeplabV3+
Deux séquences ergodiques connues pour construire des arbres binaires
损失函数与正负样本分配:YOLO系列
MySQL calculate n-day retention rate
Steps for Navicat to create a new database
[network security] network asset collection
6.12 critical moment of Unified Process Platform
LeetCode刷题——统计各位数字都不同的数字个数#357#Medium
随机推荐
【LeetCode】1020-飞地的数量
14_ Redis_ Optimistic lock
11_ Redis_ Hyperloglog_ command
Wechat Alipay account system and payment interface business process
MySQL -- Index Optimization -- order by
Bing. Com website
[experience cloud] how to get the metadata of experience cloud in vscode
6090. Minimax games
Let your HMI have more advantages. Fet-g2ld-c core board is a good choice
微信支付宝账户体系和支付接口业务流程
Summary of the first three passes of sqli Labs
Bing. Site Internet
2303. Calculate the total tax payable
怎样从微信返回的json字符串中截取某个key的值?
How to choose a third-party software testing organization for automated acceptance testing of mobile applications
Engineer evaluation | rk3568 development board hands-on test
已知兩種遍曆序列構造二叉樹
13_ Redis_ affair
Evaluation of embedded rz/g2l processor core board and development board of Feiling
Basic knowledge of cryptography