当前位置:网站首页>使用 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] 1905 statistics sub Island
- 【LeetCode】344-反转字符串
- 6092. 替换数组中的元素
- 15_ Redis_ Redis. Conf detailed explanation
- Leetcode skimming -- incremental ternary subsequence 334 medium
- 6095. Strong password checker II
- 微信支付宝账户体系和支付接口业务流程
猜你喜欢

Pytorch 保存tensor到.mat文件

I made an istio workshop. This is the first introduction

二叉树前,中,后序遍历

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

YOLOV5 代码复现以及搭载服务器运行

17_ Redis_ Redis publish subscription

Pytoch saves tensor to Mat file

Leetcode skimming -- verifying the preorder serialization of binary tree # 331 # medium

Let your HMI have more advantages. Fet-g2ld-c core board is a good choice

【LeetCode】1254-统计封闭岛屿的数量
随机推荐
College entrance examination admission score line climbing
19_ Redis_ Manually configure the host after downtime
[leetcode] 1905 statistics sub Island
Oracle primary key auto increment
Loss function and positive and negative sample allocation: Yolo series
【LeetCode】1020-飞地的数量
【LeetCode】1140-石子游戏II
6091. Divide the array so that the maximum difference is K
Equipped with Ti am62x processor, Feiling fet6254-c core board is launched!
[leetcode] 1162 map analysis
[leetcode] 876 intermediate node of linked list
2279. Maximum number of backpacks filled with stones
2022 年辽宁省大学生数学建模A、B、C题(相关论文及模型程序代码网盘下载)
[network security] network asset collection
【网络安全】网络资产收集
LeetCode刷题——递增的三元子序列#334#Medium
03.golang初步使用
(4) Flink's table API and SQL table schema
Force deduction solution summary 2029 stone game IX
Leetcode skimming -- incremental ternary subsequence 334 medium