当前位置:网站首页>Implementation technology of recovery
Implementation technology of recovery
2022-07-05 21:58:00 【Short section senior】
Key issues involved in recovery mechanism
1. How to build redundant data
Data dump (backup)
Register log files (logging)
2. How to use these redundant data to implement database recovery
Data dump
What is data dump
Dump means that the database administrator periodically copies the entire database to tape 、 The process of saving on disk or other storage medium
The backup data text is called the backup copy (backup) Or backup copy
After the database is destroyed, the backup copy can be reloaded
Reinstalling a backup copy can only restore the database to the state it was in when it was dumped
To recover to the state when the fault occurred , All update transactions since the dump must be rerun
Above picture :
The system is in Ta Stop running transactions at any time , Perform database dump
stay Tb Time dump is complete , obtain Tb A consistent copy of the database at all times
The system runs to Tf Always break down
To restore the database , First, the database administrator reinstalls the backup copy of the database , Restore the database to Tb The state of the moment
Rerun from Tb~Tf All update transactions at any time , Restore the database to a consistent state before the failure
Dump method
Static dump
Dump operation when there is no running transaction in the system
The database is in a consistent state at the beginning of the dump
No access to the database is allowed during dump 、 To amend
The result must be a consistent copy of the data
advantage : Implement a simple
shortcoming : Reduced database availability
The dump must wait for the end of the running user transaction
The new transaction must wait for the dump to end
Dynamic dump
Dump operations are performed concurrently with user transactions
Allow access to or modification of the database during dump
advantage
Don't wait for a running user transaction to end
Does not affect the operation of new transactions
Disadvantages of dynamic dump
There is no guarantee that the data in the copy is correct and valid
Example: at a certain time during the dump period Tc, The system sends the data A=100 Dump to tape , And at the next moment Td, A transaction will A Change it to 200.
On the backup copy A Out of date
Use the replica obtained by dynamic dump for fault recovery
It is necessary to register the modification activities of each transaction to the database during dynamic dump , Create a log file
The backup copy plus the log file can restore the database to the correct state at a certain time
Mass dump : Dump all databases at a time
Incremental dump : Dump only the data updated since the last dump
Comparison between mass dump and incremental dump
From a recovery perspective , It is often more convenient to use the backup copy obtained from mass dump for recovery
If the database is large , Transaction processing is very frequent , Then incremental dump is more practical and effective
Dump method classification
Register log files
Format and content of log file
What is a log file
Log files (log file) It is used to record the update operation of transaction to database
Format of log file
Log files in units of records
Log files in blocks
Log file content in record units
Start mark of each transaction (BEGIN TRANSACTION)
The end tag of each transaction (COMMIT or ROLLBACK)
All update operations for each transaction
All of the above are recorded as a log in the log file (log record)
Log files in units of records , The content of each log record
Transaction ID ( Indicate which business )
Operation type ( Insert 、 Delete or modify )
Action object ( Record ID、Block NO.)
Old value of data before update ( For insertion operations , This item is null )
The new value of the updated data ( For delete operations , This item is null )
Log files in blocks , The content of each log record
Transaction ID
Updated data block
The role of log files
purpose
Perform transaction recovery
Carry out system fault recovery
Assist backup copy in media recovery
Specific role
Log files must be used for transaction recovery and system recovery .
Log files must be created in dynamic dump mode , Only by combining backup copy with log files can the database be recovered effectively .
In static dump mode , You can also create log files .
When the database is destroyed, the backup copy can be reloaded to restore the database to the correct state at the end of the dump
Using log files , Redo a completed transaction
Undo the unfinished transaction at the time of failure
The database can be restored to the correct state at a certain time before the failure without running those completed transaction programs again
Register log files
To ensure that the database is recoverable , Two principles must be followed when registering log files
The registration order is strictly in accordance with the time sequence of concurrent transactions
You have to write a log file first , Write database after
Write log file operation : Write the log record indicating this modification to the log file
Write database operation : Write the changes to the data into the database
Why write a log file first
Writing a database and a log file are two different operations
There may be a fault between these two operations
If the database modification is written first , This change is not registered in the log file , Then we can't restore this modification later
If you write a log first , But it didn't change the database , It is unnecessary to perform the log file recovery only once more UNDO operation , It doesn't affect the correctness of the database
Welcome to join me for wechat exchange and discussion ( Please note csdn Add )
边栏推荐
- EBS Oracle 11g 克隆步骤(单节点)
- Image editor for their AutoLayout environment
- Poj 3237 Tree (Tree Chain Split)
- Shell script, awk condition judgment and logic comparison &||
- 华为游戏多媒体调用切换房间方法出现异常Internal system error. Reason:90000017
- Summary of El and JSTL precautions
- EL与JSTL注意事项汇总
- Alibaba cloud award winning experience: build a highly available system with polardb-x
- 深信服X计划-网络协议基础 DNS
- 阿里云有奖体验:用PolarDB-X搭建一个高可用系统
猜你喜欢
华为云ModelArts文本分类–外卖评论
Oracle checkpoint queue - Analysis of the principle of instance crash recovery
Defect detection - Halcon surface scratch detection
A number of ventilator giants' products have been recalled recently, and the ventilator market is still in incremental competition
MMAP learning
MySQL disconnection reports an error MySQL ldb_ exceptions. OperationalError 4031, The client was disconnected by the server
深信服X计划-网络协议基础 DNS
Huawei cloud modelarts text classification - takeout comments
微服务入门(RestTemplate、Eureka、Nacos、Feign、Gateway)
华为游戏多媒体调用切换房间方法出现异常Internal system error. Reason:90000017
随机推荐
KingbaseES V8R3集群维护案例之---在线添加备库管理节点
力扣------经营摩天轮的最大利润
Alibaba cloud award winning experience: build a highly available system with polardb-x
Three components of openpyxl
ICMP introduction
SecureCRT使用提示
Recursive query of multi-level menu data
poj 3237 Tree(樹鏈拆分)
微服务链路风险分析
HDU 4391 paint the wall segment tree (water
datagrid直接编辑保存“设计缺陷”
Shell script, awk condition judgment and logic comparison &||
Kingbasees v8r3 data security case - audit record clearing case
The Blue Bridge Cup web application development simulation competition is open for the first time! Contestants fast forward!
The solution to the problem that Oracle hugepages are not used, causing the server to be too laggy
matlab绘制hsv色轮图
Sorting out the problems encountered in MySQL built by pycharm connecting virtual machines
NET中小型企业项目开发框架系列(一个)
Code bug correction, char is converted to int high-order symbol extension, resulting in changes in positivity and negativity and values. Int num = (int) (unsigned int) a, which will occur in older com
华为游戏多媒体服务调用屏蔽指定玩家语音方法,返回错误码3010