当前位置:网站首页>DM8 database recovery based on point in time
DM8 database recovery based on point in time
2022-07-04 08:11:00 【Song Xiaorong】
In the production environment , When we delete important data by mistake , You can use flashback queries to retrieve the original data , But when the table is deleted or the database does not turn on the flashback function , You cannot use flash back to get the original table data ; At this point, we can use point in time recovery based on archived logs ( Incomplete recovery ) To recover data or tables .
Point in time based recovery
01
Backup database
The premise of database failure restoration is to have backup files , Here create an original database backup file , have access to DMRMAN Offline backup files , It can also be an online backup file . Take online backup as an example ( Before online backup , You need to ensure that the database has been opened and configured for archiving ). Use SYSDBA User login database , Execute the following statement to back up the database :
SQL> backup database full backupset 'DMTESTFULL_ONLINE0723';
02
Manufacturing data , Generate archive logs
establish test user , And in test The user creates a table t_table And insert data , This process generates archive logs .
SQL> create user test IDENTIFIED by dameng123 DEFAULT TABLESPACE main;SQL> create table test.t_table as select * from SYSOBJECTS;

03
Analog fault , Delete table
Analog fault , Delete test The user is shown in the following table t_table. And record the system time when deleting the table .

04
Using backup and archive logs will
The database is restored to the specified point in time
t_table Table deleted , To retrieve the data of this table , The database can only be restored to the moment before the table is deleted . The recovery steps are as follows :
① Restore the database with backup files
Execute the following command to stop the database :
[[email protected] bin]$ DmServiceDMTESTSERVER stopUse steps 1 The backup file of restores the database to the state at the time of backup :
RMAN> restore database '/dm8/data/DMTEST/dm.ini' from backupset 'DMTESTFULL_ONLINE0723';
② Restore the database to a specified point in time using archived logs
Execute the following command , Appoint with archivedir Parameter use archive recovery , And designate until time Parameter restore the database to the time before deleting the table , By step 3 hear , We'll probably be here 2020-07-23 10:48:53 The table data was deleted at the previous time , Restore the database to 2020-07-23 10:48:40 Time for ( The more accurate the time, the better , It cannot be estimated accurately ).
RMAN> recover database '/dm8/data/DMTEST/dm.ini' with archivedir '/dm8/data/DMTEST/arch' until time '2020-07-23 10:48:40';As can be seen from the screenshot below , Archive recovery is not 100%( Because it is incomplete recovery , Not all archived logs have been completely redone ), Just restore to 93%.

③ Update database magic number
Execute the following command to update the magic number of the database db_magic Information .
RMAN> recover database '/dm8/data/DMTEST/dm.ini' update db_magic;here , Database recovery complete .
perform DmServiceDMTESTSERVER start Start database , Connect to database query test Under the user t_table Table data , You can see t_test Table restored .

summary :
Use RECOVER Command to restore the database , It can be backup set based recovery , It can also be the recovery of local archived logs . Point in time based recovery is one of the ways to recover using local archived logs .
In addition to the specified point in time , You can also specify LSN Resume .DM Each of them REDO Each log record corresponds to a unique LSN value , Appoint LSN Value later , The database will be accurately restored to produce this LSN The state of the point in time . be based on LSN The recovery of is to use UNTIL LSN The parameter is restored to the specified LSN The state of the point in time .
Based on point in time or LSN All recoveries are incomplete , Restore to the latest state based on archived logs is full recovery .
In the actual production environment , If you just delete a table or data , It is recommended to restore the database to another machine ( Target database ) On , Then copy the archive log of the production environment to restore the target database to the specified point in time , To retrieve table data without affecting the generation environment , Reduce the impact on the generation environment .
边栏推荐
- What does range mean in PHP
- BUUCTF(4)
- How to use C language code to realize the addition and subtraction of complex numbers and output structure
- PCIE知识点-010:PCIE 热插拔资料从哪获取
- Go h*ck yourself:online reconnaissance (online reconnaissance)
- 弈柯莱生物冲刺科创板:年营收3.3亿 弘晖基金与淡马锡是股东
- [go basics] 2 - go basic sentences
- Application of isnull in database query
- Activiti常見操作數據錶關系
- Cannot click button when method is running - C #
猜你喜欢

弈柯莱生物冲刺科创板:年营收3.3亿 弘晖基金与淡马锡是股东

NPM run build error

SSRF vulnerability exploitation - attack redis

如何用MOS管来实现电源防反接电路

Advanced MySQL: Basics (5-8 Lectures)

In the era of low code development, is it still needed?

运动【跑步 01】一个程序员的半马挑战:跑前准备+跑中调整+跑后恢复(经验分享)

L2-013 red alarm (C language) and relevant knowledge of parallel search

Google's official response: we have not given up tensorflow and will develop side by side with Jax in the future

This monitoring system can monitor the turnover intention and fishing all, and the product page has 404 after the dispute appears
随机推荐
Is l1-029 too fat (5 points)
yolov5 xml数据集转换为VOC数据集
deno debugger
System architecture design of circle of friends
Google's official response: we have not given up tensorflow and will develop side by side with Jax in the future
R language uses cforest function in Party package to build random forest based on conditional inference trees, uses varimp function to check feature importance, and uses table function to calculate co
string. Format without decimal places will generate unexpected rounding - C #
【性能测试】一文读懂Jmeter
弈柯莱生物冲刺科创板:年营收3.3亿 弘晖基金与淡马锡是股东
PCIE知识点-010:PCIE 热插拔资料从哪获取
Sports [running 01] a programmer's half horse challenge: preparation before running + adjustment during running + recovery after running (experience sharing)
Ecole bio rushes to the scientific innovation board: the annual revenue is 330million. Honghui fund and Temasek are shareholders
Text processing function sorting in mysql, quick search of collection
Li Kou today's question -1200 Minimum absolute difference
In the era of low code development, is it still needed?
团体程序设计天梯赛-练习集 L2-002 链表去重
BUUCTF(4)
促进OKR落地的工作总结该如何写?
墨者学院-Webmin未经身份验证的远程代码执行
学习Nuxt.js