兄弟们 我回来了,趁着第二次做数据恢复 我验证了部分的猜想。我在rman备份前查看了数据库的archive log list 并记录下来了
详情如下【一共做了两个库的恢复,库A和库B】
库A
【我认为备份脚本的执行语句也会影响当前归档日志,我在数据库备份前执行了 alter system archive log current】
以下为我执行后的archive log list
Oldest online log sequence 18343
Next log sequence to archive 18345
Current log sequence 18345
可以看到当前日志序列sequence号为18345
为了恢复 我上传了从18343——18359的archive log文件到 测试环境
恢复情况如下:【请重点关注加粗加下划线的部分语句】
RMAN> recover database;
Starting recover at 28-DEC-22
using channel ORA_DISK_1
starting media recovery
archived log file name=/oracle/app/product/11.2.0/db_1/dbs/arch/1_18345_1053708266.dbf thread=1 sequence=18345
archived log file name=/oracle/app/product/11.2.0/db_1/dbs/arch/1_18346_1053708266.dbf thread=1 sequence=18346
archived log file name=/oracle/app/product/11.2.0/db_1/dbs/arch/1_18347_1053708266.dbf thread=1 sequence=18347
archived log file name=/oracle/app/product/11.2.0/db_1/dbs/arch/1_18348_1053708266.dbf thread=1 sequence=18348
archived log file name=/oracle/app/product/11.2.0/db_1/dbs/arch/1_18349_1053708266.dbf thread=1 sequence=18349
archived log file name=/oracle/app/product/11.2.0/db_1/dbs/arch/1_18350_1053708266.dbf thread=1 sequence=18350
archived log file name=/oracle/app/product/11.2.0/db_1/dbs/arch/1_18351_1053708266.dbf thread=1 sequence=18351
archived log file name=/oracle/app/product/11.2.0/db_1/dbs/arch/1_18352_1053708266.dbf thread=1 sequence=18352
archived log file name=/oracle/app/product/11.2.0/db_1/dbs/arch/1_18353_1053708266.dbf thread=1 sequence=18353
archived log file name=/oracle/app/product/11.2.0/db_1/dbs/arch/1_18354_1053708266.dbf thread=1 sequence=18354
archived log file name=/oracle/app/product/11.2.0/db_1/dbs/arch/1_18355_1053708266.dbf thread=1 sequence=18355
archived log file name=/oracle/app/product/11.2.0/db_1/dbs/arch/1_18356_1053708266.dbf thread=1 sequence=18356
archived log file name=/oracle/app/product/11.2.0/db_1/dbs/arch/1_18357_1053708266.dbf thread=1 sequence=18357
archived log file name=/oracle/app/product/11.2.0/db_1/dbs/arch/1_18358_1053708266.dbf thread=1 sequence=18358
archived log file name=/oracle/app/product/11.2.0/db_1/dbs/arch/1_18359_1053708266.dbf thread=1 sequence=18359
unable to find archived log
archived log thread=1 sequence=18360
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 12/28/2022 12:23:15
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 18360 and starting SCN of 70557253
RMAN> alter database open resetlogs;
database opened
如上可看到,rman恢复已经告诉我他是从哪个squence的日志文件开始读取的。所以是从18345这个文件开始
开始验证
为了缩小范围archive log的范围,我恢复了库B
库B 【备份语句相同,但是这次我只拿了一个archivelog进行恢复】
以下为我执行archive log list的返回值
Oldest online log sequence 77071
Next log sequence to archive 77072
Current log sequence 77072
以上可知是77072的squence日志文件
恢复情况如下:【请重点关注加粗加下划线的部分语句】
RMAN> recover database;
Starting recover at 03-JAN-23
using channel ORA_DISK_1
starting media recovery
archived log file name=/d01/oracle/PROD/db/tech_st/11.1.0/dbs/arch/1_77072_86599995.dbf thread=1 sequence=77072
unable to find archived log
archived log thread=1 sequence=77073
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 01/03/2023 13:41:30
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 77073 and starting SCN of 17811459280
RMAN> alter database open resetlogs;
database opened
结论:
可知 如必须只放一个日志文件就是Current log sequence序号的文件
遗憾:
1、只进行了正向论证,没有反向论证。应剔除current log sequence的日志文件进行恢复 看会报什么错误。
2、因为我的数据库ddl和dml的时间基本都在跑批的时候,所以没办法验证 【当数据库备份期间,因为跑了大量ddl导致current log sequence改变,那到时候我需要放哪几个sequence序号的日志呢?】