当前位置:网站首页>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
边栏推荐
- 6-1 需要多少单词可以组成一句话?
- QLineEdit 设置输入掩码
- 搜狐全員遭詐騙,暴露哪些問題?
- How does Sister Feng change to ice?
- Bentley uses authing to quickly integrate application system and identity
- 6-6 批量求和(*)
- 信息安全数学基础 Chapter 3——有限域(一)
- C language: use H and C. summary of problems encountered in documents
- 聚类方法汇总
- What subclasses inherit, polymorphism, and upward transformation
猜你喜欢

【深度学习基础】神经网络的学习(3)

Custom or subscription? What is the future development trend of China's SaaS industry?

搜狐全員遭詐騙,暴露哪些問題?

ffmpeg奇偶场帧Interlace progressive命令和代码处理

vscode保存代码时自动eslint格式化

子类继承了什么、多态、 向上转型

Guide to Dama data management knowledge system: percentage of chapter scores

Service learning notes 02- actual combat startservice and bindservice

Vscode automatic eslint formatting when saving code

adb 命令学习笔记
随机推荐
Typescript learning notes (II)
括号生成---2022/02/25
6-3 读文章(*)
有效的括号---2022/02/23
MFSR:一种新的推荐系统多级模糊相似度量
spawn ./gradlew EACCES at Process.ChildProcess._handle.onexit
6-1 需要多少单词可以组成一句话?
ADB command learning notes
How to become an optimist organization?
Mathematical foundations of information security Chapter 3 - finite fields (II)
Dynamic: capturing network dynamics using dynamic graph representation learning
Is it safe for Xiaobai to open an account directly on the flush?
信息安全数学基础 Chapter 4——二次剩余与方根
Read and understand the development plan for software and information technology service industry during the "14th five year plan"
搜狐全員遭詐騙,暴露哪些問題?
为什么udp流设置1316字节
Use exe4j to convert The jar file is packaged as Exe file
Service learning notes 02- actual combat startservice and bindservice
【题解】Codeforces Round #798 (Div. 2)
What subclasses inherit, polymorphism, and upward transformation