注册
达梦利用归档恢复丢失数据
培训园地/ 文章详情 /

达梦利用归档恢复丢失数据

zero 2022/11/16 1428 0 0

一、场景说明
利用归档恢复数据常常是出现了误操作,部分数据或者表被删除修改等情况,根据误操作发生时间,另外找环境恢复一个数据库后,寻找丢失数据。
二、前提条件
利用归档恢复需要保证数据库有完整备份且归档连续
如数据库采用以下备份策略:
周六完全备份,其他时间差异增量备份
假如在周四发生误操作删除了某张表的数据,可利用周六全备与周天到周三的增备+周四的归档恢复。
三、恢复步骤
首先确定恢复时间,如果数据库开启了审计可通过审计日志进行查看误操作时间,如未开启,只有通过操作者提供的时间进行恢复。
3.1 指定最近一次增备进行完成恢复
达梦可指定增备进行完全备份恢复,要求完全备份与增量备份存在同一目录,在生产环境谨慎操作,以免造成二次事故,建议将备份及归档文件拷贝至测试环境操作

RMAN> restore database '/data/dmdata/CQGYJJXT/dm.ini' from backupset '/data/dmdata/dmbak/DB_CQGYJJXT_INCREMENT_2022_11_07_23_30_56'
restore database '/data/dmdata/CQGYJJXT/dm.ini' from backupset '/data/dmdata/dmbak/DB_CQGYJJXT_INCREMENT_2021_11_07_23_30_56'
[Percent:0.00%][Speed:0.00M/s][Cost:00:00:00][Remaining:00:00:00]                                   
[Percent:0.00%][Speed:0.00M/s][Cost:00:00:00][Remaining:00:00:00]Normal of FAST                     
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
[Percent:99.98%][Speed:0.00M/s][Cost:00:00:49][Remaining:00:00:00]                                  
restore successfully.
time used: 00:00:49.888

3.2 恢复备份过程中产生的日志

RMAN> recover database '/data/dmdata/CQGYJJXT/dm.ini' from backupset '/data/dmdata/dmbak/DB_CQGYJJXT_INCREMENT_2022_11_07_23_30_56'
recover database '/data/dmdata/CQGYJJXT/dm.ini' from backupset '/data/dmdata/dmbak/DB_CQGYJJXT_INCREMENT_2022_11_07_23_30_56'
Database mode = 0, oguid = 0
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
EP[0]'s cur_lsn[6191786], file_lsn[6191786]
EP:0 total 8 pkgs applied, percent: 10%
EP:0 total 16 pkgs applied, percent: 20%
EP:0 total 24 pkgs applied, percent: 31%
EP:0 total 32 pkgs applied, percent: 41%
EP:0 total 40 pkgs applied, percent: 51%
EP:0 total 48 pkgs applied, percent: 62%
EP:0 total 56 pkgs applied, percent: 72%
EP:0 total 64 pkgs applied, percent: 83%
EP:0 total 72 pkgs applied, percent: 93%
EP:0 total 77 pkgs applied, percent: 100%
recover successfully!
time used: 826.904(ms)

3.3 利用归档恢复到指定时间点

recover database '/data/dmdata/CQGYJJXT/dm.ini' with archivedir ' /data/dmdata/dmarch' until time '2022-11-08 11:30:00';
Database mode = 0, oguid = 0
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
EP[0]'s cur_lsn[6191874], file_lsn[6191874]
EP:0 total 1202 pkgs applied, percent: 1%
EP:0 total 2404 pkgs applied, percent: 2%
EP:0 total 3606 pkgs applied, percent: 3%
EP:0 total 4808 pkgs applied, percent: 4%
EP:0 total 6010 pkgs applied, percent: 5%
EP:0 total 7212 pkgs applied, percent: 6%
EP:0 total 8414 pkgs applied, percent: 7%
EP:0 total 9616 pkgs applied, percent: 8%
EP:0 total 10818 pkgs applied, percent: 9%
EP:0 total 12020 pkgs applied, percent: 10%
EP:0 total 13222 pkgs applied, percent: 11%
EP:0 total 14424 pkgs applied, percent: 12%
EP:0 total 15626 pkgs applied, percent: 13%
EP:0 total 16828 pkgs applied, percent: 14%
EP:0 total 18030 pkgs applied, percent: 15%
EP:0 total 19232 pkgs applied, percent: 16%
EP:0 total 20434 pkgs applied, percent: 17%
EP:0 total 21636 pkgs applied, percent: 18%
EP:0 total 22838 pkgs applied, percent: 19%
EP:0 total 24040 pkgs applied, percent: 20%
EP:0 total 25242 pkgs applied, percent: 21%
EP:0 total 26444 pkgs applied, percent: 22%
EP:0 total 27646 pkgs applied, percent: 23%
EP:0 total 28848 pkgs applied, percent: 24%
EP:0 total 30050 pkgs applied, percent: 25%
EP:0 total 31252 pkgs applied, percent: 26%
EP:0 total 32454 pkgs applied, percent: 27%
EP:0 total 33656 pkgs applied, percent: 28%
EP:0 total 34858 pkgs applied, percent: 29%
EP:0 total 36060 pkgs applied, percent: 30%
EP:0 total 37262 pkgs applied, percent: 31%
EP:0 total 38464 pkgs applied, percent: 32%
EP:0 total 39666 pkgs applied, percent: 33%
EP:0 total 40868 pkgs applied, percent: 34%
EP:0 total 42070 pkgs applied, percent: 35%
EP:0 total 43272 pkgs applied, percent: 36%
EP:0 total 44474 pkgs applied, percent: 37%
EP:0 total 45676 pkgs applied, percent: 38%
EP:0 total 46878 pkgs applied, percent: 39%
EP:0 total 48080 pkgs applied, percent: 40%
EP:0 total 49282 pkgs applied, percent: 41%
EP:0 total 50484 pkgs applied, percent: 42%
EP:0 total 51686 pkgs applied, percent: 43%
EP:0 total 52888 pkgs applied, percent: 44%
EP:0 total 54090 pkgs applied, percent: 45%
EP:0 total 55292 pkgs applied, percent: 46%
EP:0 total 56494 pkgs applied, percent: 47%
EP:0 total 57696 pkgs applied, percent: 48%
EP:0 total 58898 pkgs applied, percent: 49%
EP:0 total 60100 pkgs applied, percent: 50%
EP:0 total 61302 pkgs applied, percent: 51%
EP:0 total 62504 pkgs applied, percent: 52%
EP:0 total 63706 pkgs applied, percent: 53%
EP:0 total 64908 pkgs applied, percent: 54%
EP:0 total 66110 pkgs applied, percent: 55%
EP:0 total 67312 pkgs applied, percent: 56%
EP:0 total 68514 pkgs applied, percent: 57%
EP:0 total 69716 pkgs applied, percent: 58%
EP:0 total 70918 pkgs applied, percent: 59%
EP:0 total 72120 pkgs applied, percent: 60%
EP:0 total 73322 pkgs applied, percent: 61%
EP:0 total 74524 pkgs applied, percent: 62%
EP:0 total 75726 pkgs applied, percent: 63%
EP:0 total 76928 pkgs applied, percent: 64%
EP:0 total 78130 pkgs applied, percent: 65%
recover successfully!
time used: 00:00:04.244

3.4 更新魔数

RMAN> recover database '/data/dmdata/CQGYJJXT/dm.ini' update db_magic;
recover database '/data/dmdata/CQGYJJXT/dm.ini' update db_magic;
Database mode = 0, oguid = 0
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
EP[0]'s cur_lsn[6624449], file_lsn[6624449]
recover successfully!
time used: 00:00:01.393
RMAN> exit 
time used: 0.018(ms)

恢复完成,启动数据库后寻找丢失数据。
四、结语
数据备份虽然是数据安全必不可少的保障,但用户也应该健全自己的一套安全管理制度,可以通过账号权限分离,变更操作二次审核等方式来避免使用人员误操作造成事故。

评论
后发表回复

作者

文章

阅读量

获赞

扫一扫
联系客服