当前位置:网站首页>Accidentally deleted the data file of Clickhouse, can it be restored?
Accidentally deleted the data file of Clickhouse, can it be restored?
2022-07-04 05:35:00 【Common program ape】
I believe that for those who want to use it in the production environment clickhouse For children's shoes , We will definitely pay attention to the reliability of data storage , There are three common ways to achieve this :
- Bottom disk do RAID : This method is similar to CH It doesn't matter , It belongs to the protection mechanism at the hardware level
- utilize CH Provided ReplicatedMergeTree The engine stores multiple copies , This is the focus of this article , Let's talk about it in detail later
- Backup data regularly , When you need to restore, manually execute the command to import , This method is detailed in above
What will be described below is on the premise of making copies , Same old thing , Let's start the journey of exploration by asking and answering ~~
Q1: Go straight ahead , Let's say you accidentally deleted the data file , Can you recover ?
The answer must be yes , But the premise is that what I said above ReplicatedMergeTree The engine made a copy , And the copy data is not damaged .
Q2: Will it automatically recover ? Still need to execute any command ?
forehead , I can only say that it is semi-automatic , Because if you accidentally delete one parts In the catalog bin file , The system will not detect it automatically , Unless you restart the service ( I think in most cases we are definitely unwilling to do so ..). When will it be tested ? When you again select When querying this table , The detection will be triggered immediately , for the first time select The query will throw you an exception , Prompt that the file corresponding to this block cannot be found , Here's the picture :
If you query again, you won't report an error , Of course, you can't find the missing data in this local table , Isn't that a lie ? I thought it could be restored automatically ? Don't worry. , Because it's no use rushing , because CH Data loss has been detected in the background , It will throw the task of data recovery into a queue , But it will not immediately perform the tasks in the queue , But will wait for a period of time , I'm not sure how long it will take , My observation here is about ten minutes , When I checked the lost data again, I found that the data had been recovered . Do I have to wait so long ? Can you trigger automatic recovery immediately ? unfortunately , I haven't found the corresponding method , If any friend knows , Welcome to leave a message ~~
Q3: Then how do you know that there are tasks waiting in line behind the scenes ?
The two methods :
- One is to read the log
/var/log/clickhouse-server/clickhouse-server.log, You can see it when you query again ReplicatedMergeTreePartCheckThread Log
- Look at the system table
system.replication_queue
Q4: Go a little deeper , How does it judge that my file is damaged ?
It must be inseparable from you zookeeper Brother ,zookeeper Metadata information of each fragment and replica is recorded in , The checking thread compares the local file with zk Whether the metadata on is consistent , If it's not consistent , Will put the previous parts Directory move to detached Under the table of contents , And will parts The directory name is prefixed broken, And write a background task to the queue , Tell it to get from the replica node . When this task is actually called , It will send a request to the replica node , Copy the lost data back from the remote .
There is zk Under the circumstances , In case zk I don't work anymore ? Will still check , But this time it parts Directory move to detached After the catalog , The prefix added becomes unexpected, At this time, no background tasks will be submitted , There is no way to recover automatically .
summary
Let's summarize briefly , Three conditions for lost data recovery :
- This table uses ReplicatedMergeTree engine
- zookeeper Normal work
- The copy file was not damaged during this period
Meet the above three conditions , Your data will be more secure ~~
边栏推荐
- [interested reading] advantageous filtering modeling on long term user behavior sequences for click through rate pre
- Signification des lettres du module optique et abréviation des paramètres Daquan
- VB. Net GIF (making and disassembling - optimizing code, class library - 5)
- [matlab] general function of communication signal modulation - generation of narrow-band Gaussian white noise
- Letter meaning and parameter abbreviation of optical module Daquan
- Unity is connected to the weather system
- 724. 寻找数组的中心下标
- VB.net 简单的处理图片,黑白(类库——7)
- Trie数-字典树
- ANSYS command
猜你喜欢

724. 寻找数组的中心下标

19.Frambuffer应用编程

Flutter ‘/usr/lib/libswiftCore. dylib‘ (no such file)
![[paper summary] zero shot semantic segmentation](/img/78/ee64118d86a7e43ec4d1cb97191fbe.jpg)
[paper summary] zero shot semantic segmentation

企业级日志分析系统ELK(如果事与愿违那一定另有安排)

Flask
![[high concurrency, high performance and high availability of massive data MySQL practice-7] - memory data drop disk](/img/b9/cf4db4f8a5d2ef3fb344258f0e30f5.jpg)
[high concurrency, high performance and high availability of massive data MySQL practice-7] - memory data drop disk

2022年A特种设备相关管理(电梯)考试题模拟考试平台操作
![BUU-Crypto-[GXYCTF2019]CheckIn](/img/b8/ad6c05977f6943f30e9975acb6eb6e.jpg)
BUU-Crypto-[GXYCTF2019]CheckIn
![[Excel] 数据透视图](/img/45/be87e4428a1d8ef66ef34a63d12fd4.png)
[Excel] 数据透视图
随机推荐
Yyds dry goods inventory TCP & UDP
Appearance of LabVIEW error dialog box
Thinkphp6.0 middleware with limited access frequency think throttle
BUU-Crypto-[GUET-CTF2019]BabyRSA
LM小型可编程控制器软件(基于CoDeSys)笔记二十一:错误3703
LM small programmable controller software (based on CoDeSys) note XXI: error 3703
C语言简易学生管理系统(含源码)
[matlab] matlab simulation - simulate the AM modulation process of the modulation system
光模塊字母含義及參數簡稱大全
[matlab] matlab simulates digital bandpass transmission systems - QPSK and OQPSK systems
数据标注是一块肥肉,盯上这块肉的不止中国丨曼孚科技
Zhanrui tankbang | jointly build, cooperate and win-win zhanrui core ecology
[matlab] communication signal modulation general function interpolation function
Integer type of C language
力扣(LeetCode)184. 部门工资最高的员工(2022.07.03)
简易零钱通
Penetration tool - sqlmap
2022G2电站锅炉司炉特种作业证考试题库及答案
transformer坑了多少算力
1480. Dynamic sum of one-dimensional array