当前位置:网站首页>Several ways to recover tidb data from accidental deletion
Several ways to recover tidb data from accidental deletion
2022-06-11 17:33:00 【On the way to data communication】
One 、 background
In the daily operation, it is unavoidable to make some mistakes , What can I do at this time , There are different ways for a database that doesn't work , Most of them are restored by backup , There are other unique methods , Such as mysql Of binlog, that tidb What is the unique method , Let's introduce
Two 、 Environmental preparation
# Create tables and prepare data
create table recover_test(id int(10));
insert into recover_test values(1),(2),(3),(4);
# see gc Related parameters ,tikv_gc_life_time,tikv_gc_safe_point,tikv_gc_safe_point
select * from mysql.tidb where VARIABLE_NAME like '%gc%';
tikv_gc_life_time
3、 ... and 、 Recovery method
1.flashback
describe : DROP or TRUNCATE The deleted table is in tikv_gc_safe_point After time , Can be used FLASHBACK TABLE Syntax to restore .
Be careful : Downstream is mysql Because of mysql This syntax is not supported to cause cdc perhaps binlog Synchronization failure
# Clear the table
truncate table recover_test;
# Restore table data
flashback table recover_test to recover_test_1;
# Delete table
drop table recover_test;
# Restore table
flashback table recover_test;
# Second recovery table , You can see an error report below , because FLASHBACK Of the recovered table table ID Or the deleted table table ID, and TiDB All remaining tables are required table ID It has to be globally unique , So delete the table once , Cannot recover twice
flashback table recover_test to recover_test_2;
ERROR 1050 (42S01): Table 'recover_test' already been flashback to 'recover_test', can't be flashback repeatedly
2.recover
describe : DROP The deleted table is in tikv_gc_safe_point After time , use recover Syntax to restore .
Be careful : Downstream is mysql Because of mysql This syntax is not supported to cause cdc perhaps binlog Synchronization failure
# Delete table
drop table recover_test;
# Restore table
recover table recover_test;
3.dumpling --snapshot
describe : dml Update table or drop,truncaate Is in tikv_gc_safe_point After time , use snapshot Syntax to restore .
# Delete data
delete from recover_test where id = 3;
# Export snapshot time , Note that this time should be greater than tikv_gc_safe_point
dumpling --snapshot "2022-06-02 17:12:45"
# Import the exported file
lighting ...
4.select into outfile
describe : dml Update table or drop,truncaate Is in tikv_gc_safe_point After time , use snapshot Syntax to restore .
# Delete data
delete from recover_test where id = 3;
# Set the snapshot time
set @@tidb_snapshot="2022-06-02 15:50:26";
# select into outfile export , Be careful , Which is connected tidb, Where is the location of the exported file tidb On
select * from recover_test into outfile '/data/tidb/a.txt';
# Import data
load data ...
5. Historical backup recovery
lighting
br
边栏推荐
- DFS and BFS notes (I) breadth first search based on C language
- 删除链表的倒数第N个节点---2022/02/22
- Mathematical foundations of information security Chapter 3 - finite fields (II)
- Service学习笔记01-启动方式与生命周期
- Chapter II relational database
- 有效的括号---2022/02/23
- Activity | authing's first channel cooperation activity came to a successful conclusion
- CLP information -5 keywords to see the development trend of the financial industry in 2022
- threejs中设置物体的贴图+场景的6面贴图 +创建空间
- What subclasses inherit, polymorphism, and upward transformation
猜你喜欢

C language: use H and C. summary of problems encountered in documents

RecyclerView缓存复用解析,源码解读

Connect the server with springboard / fortress through xshell

Service learning notes 01 start method and life cycle

Kubernetes deploys elk and collects container logs using filebeat

Dynamic: capturing network dynamics using dynamic graph representation learning

What subclasses inherit, polymorphism, and upward transformation

Don't you understand the design and principle of thread pool? Break it up and crush it. I'll teach you how to design the thread pool

【线上问题】Timeout waiting for connection from pool 问题排查

adb 命令学习笔记
随机推荐
Biden ordered to enforce the zero trust structure
Xie Yang, CEO of authing, was selected into Forbes' 30 under 30 Asia list in 2021
信息安全数学基础 Chapter 2——同余
Is it safe for Xiaobai to open an account directly on the flush?
6-1 从文件读取字符串(*)
String to numeric value
6-8 创建、遍历链表
论文阅读 dyngraph2vec: Capturing Network Dynamics using Dynamic Graph Representation Learning
Kubernetes deploys elk and collects container logs using filebeat
6-2 写文章(*)
spawn ./gradlew EACCES at Process.ChildProcess._handle.onexit
6-7 文件读写操作
拜登下令强制推行零信任架构
Hash表、 继承
删除链表的倒数第N个节点---2022/02/22
tidb-cdc同步mysql没有的特性到mysql时的处理
TypeScipt基础
tidb-cdc日志tables are not eligible to replicate
Service learning notes 03 front desk service practice
从制造到“智造”,探索制造企业破局之道