oracle丢失归档恢复历史全备(不一致恢复)

Posted Demonson

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了oracle丢失归档恢复历史全备(不一致恢复)相关的知识,希望对你有一定的参考价值。

1.rman异机还原

shutdown immediate;

startup nomount;

restore controlfile from '/data/oracle/backup/c-1509639749-20190701-02';

alter database mount;

catalog start with '/data/oracle/backup/';

run

set newname for datafile 4 to '/u01/app/oracle/oradata/orcl/users01.dbf';
set newname for datafile 2 to '/u01/app/oracle/oradata/orcl/sysaux01.dbf';
set newname for datafile 1 to '/u01/app/oracle/oradata/orcl/system01.dbf';
...
...
...
set newname for datafile 50 to '/u01/app/oracle/oradata/orcl/index_data.265.1002733303';
restore database;
switch datafile all;




sql "alter database rename file ''+DATA/xxxxx/standby04a.log'' to ''/u01/app/oracle/oradata/orcl/standby04a.log''";
...
...
...
sql "alter database rename file ''+DATA/xxxxx/redo11b.log'' to ''/u01/app/oracle/oradata/orcl/redo11b.log''";


sql "alter system set log_archive_dest_1=''location=/u01/app/archivelog''";

recover database;

报错 缺少归档 无法恢复数据库!!!

只能不一致强制恢复!!!

2.归档丢失,无法正常恢复数据库

如遇到archivelog不足导致scn不一致无法recover database,则执行

a) 打开隐藏参数

#sqlplus / as sysbda

ALTER SYSTEM SET "_ALLOW_RESETLOGS_CORRUPTION"=TRUE SCOPE=SPFILE;--跳过数据库一致性检查
                                        
sql> alter database open resetlogs;

无法恢复 需要借助oradebug poke来推进SCN的方法,适合11.2.0.4版本,其他方法已经不适用;

b) 前推scn

/**

ORA-00600: internal error code, arguments: [2662], [2], [1424142249], [2], [1424142302], [8388649], [], []

select 2*power(2,32)+1424143000 from dual;

10014077592

2662 后面 5个参数,用 A B C D E 表示

总结公式:c * power(2,32) + d + 可适当加一点,但不要太大! ##之前不知道这个算法,我将SCN推进了比较小,数据库还是无法恢复。使用这个算法后,数据库则恢复。

c代表:Arg [c] dependent SCN WRAP

d代表:Arg [d] dependent SCN BASE

**/

oradebug setmypid
oradebug dumpvar sga kcsgscn_
oradebug poke 0x060012658 8 10014077592
oradebug dumpvar sga kcsgscn_
alter database open;

执行结果:

参数文件undo表空间指定有问题,需要导出参数文件,重新执行undo表空间,再次重启!!!

c) 生成pfile文件修改undo表空间信息

SYS@orcl> select * from v$tablespace;

       TS# NAME                           INC BIG FLA ENC
---------- ------------------------------ --- --- --- ---
         0 SYSTEM                         YES NO  YES
         1 SYSAUX                         YES NO  YES
...
...
...
        18 OGG                            YES NO  YES
         5 UNDOTBS2                       YES NO  YES

18 rows selected.

SYS@orcl> alter database open;
alter database open
*
ERROR at line 1:
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-30012: undo tablespace 'UNDOTBS1' does not exist or of wrong type
Process ID: 7749
Session ID: 191 Serial number: 3


SYS@orcl> create pfile='/home/pfile.ora' from spfile;
ERROR:
ORA-03114: not connected to ORACLE


SYS@orcl> conn /as sysdba
Connected to an idle instance.
SYS@orcl> startup mount;
ORACLE instance started.

Total System Global Area 4860362752 bytes
Fixed Size                  2261488 bytes
Variable Size             973082128 bytes
Database Buffers         3875536896 bytes
Redo Buffers                9482240 bytes
Database mounted.
SYS@orcl> create pfile='/home/pfile.ora' from spfile;
create pfile='/home/pfile.ora' from spfile
*
ERROR at line 1:
ORA-07391: sftopn: fopen error, unable to open text file.


SYS@orcl> create pfile='/u01/pfile.ora' from spfile;

File created.

SYS@orcl> shutdown immediate
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.
SYS@orcl> startup mount pfile='/u01/pfile.ora';
ORACLE instance started.

Total System Global Area 4860362752 bytes
Fixed Size                  2261488 bytes
Variable Size             973082128 bytes
Database Buffers         3875536896 bytes
Redo Buffers                9482240 bytes
Database mounted.
SYS@orcl> alter database open;

Database altered.

SYS@orcl> select sysdate from dual;

SYSDATE
---------
22-FEB-22

3.数据库恢复到这一步只能做查询操作要是想其他操作需要将整个库dump后导入新库 做一致性校验才可以

以上是关于oracle丢失归档恢复历史全备(不一致恢复)的主要内容,如果未能解决你的问题,请参考以下文章

Oracle数据库坏块的恢复

Oracle报错ORA-16433非归档丢失redo无法启动的恢复过程

Oracle RMAN备份和异机恢复

Oracle dataguard 备库归档日志不全.怎么恢复

ORACLERMAN各种情况下的备份恢复

20oracle用户管理恢复