码迷,mamicode.com
首页 > 其他好文 > 详细

RMAN备份恢复 控制文件和归档日志丢失情况

时间:2016-06-21 10:52:43      阅读:244      评论:0      收藏:0      [点我收藏+]

标签:

RMAN> backup current controlfile tag=‘bak_ctlfile‘ format=‘/home/oracle/backup/bak_ctl_%U_%T‘; 

alter system switch logfile;

alter system switch logfile;

alter system switch logfile;

多切换几次,切出几个archivelog文件,删除其中的一个

rm o1_mf_1_3_cpk5wloy_.arc

然后删除控制文件

rm /u01/app/oracle/oradata/orcl/control01.ctl

rm /u01/app/oracle/flash_recovery_area/orcl/control02.ctl

shutdown abort;

 

rman startup nomount方式启动

RMAN> restore controlfile from ‘/home/oracle/backup/bak_ctl_12r8mgn0_1_1_20160621‘;

Starting restore at 21-JUN-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/orcl/control01.ctl
output file name=/u01/app/oracle/flash_recovery_area/orcl/control02.ctl
Finished restore at 21-JUN-16

 

RMAN> mount database;

database mounted
released channel: ORA_DISK_1

 

recover数据库报找不到3号归档日志文件.
RMAN> recover database;

Starting recover at 21-JUN-16
Starting implicit crosscheck backup at 21-JUN-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
Crosschecked 10 objects
Finished implicit crosscheck backup at 21-JUN-16

Starting implicit crosscheck copy at 21-JUN-16
using channel ORA_DISK_1
Finished implicit crosscheck copy at 21-JUN-16

searching for all files in the recovery area
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2016_06_21/o1_mf_1_5_cpk5wplw_.arc

using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 4 is already on disk as file /u01/app/oracle/oradata/orcl/redo01.log
archived log for thread 1 with sequence 5 is already on disk as file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2016_06_21/o1_mf_1_5_cpk5wplw_.arc
archived log for thread 1 with sequence 6 is already on disk as file /u01/app/oracle/oradata/orcl/redo03.log
unable to find archived log
archived log thread=1 sequence=3
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 06/21/2016 09:31:51
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 3 and starting SCN of 1112349

 

需要将control file重建饶开sequence 3

SQL> alter database backup controlfile to trace;

Database altered.

SQL> SELECT d.VALUE || ‘/‘ || LOWER(RTRIM(i.INSTANCE, CHR(0))) || ‘_ora_‘ || p.spid || ‘.trc‘ trace_file_name FROM (SELECT p.spid FROM v$mystat m, v$session s, v$process p WHERE m.statistic# = 1 AND s.SID = m.SID AND p.addr = s.paddr) p, (SELECT t.INSTANCE FROM v$thread t, v$parameter v WHERE v.NAME = ‘thread‘ AND (v.VALUE = 0 OR t.thread# = TO_NUMBER(v.VALUE))) i, (SELECT VALUE FROM v$parameter WHERE NAME = ‘user_dump_dest‘) d;

TRACE_FILE_NAME
--------------------------------------------------------------------------------
/u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_4016.trc

 

打开trace文件,然后按照reset log方式恢复

 

SQL> startup force nomount;
ORACLE instance started.

Total System Global Area 835104768 bytes
Fixed Size 2217952 bytes
Variable Size 520095776 bytes
Database Buffers 310378496 bytes
Redo Buffers 2412544 bytes

 

SQL> CREATE CONTROLFILE REUSE DATABASE "ORCL" RESETLOGS ARCHIVELOG
2 MAXLOGFILES 16
3 MAXLOGMEMBERS 3
4 MAXDATAFILES 100
5 MAXINSTANCES 8
6 MAXLOGHISTORY 292
7 LOGFILE
8 GROUP 1 ‘/u01/app/oracle/oradata/orcl/redo01.log‘ SIZE 50M BLOCKSIZE 512,
9 GROUP 2 ‘/u01/app/oracle/oradata/orcl/redo02.log‘ SIZE 50M BLOCKSIZE 512,
10 GROUP 3 ‘/u01/app/oracle/oradata/orcl/redo03.log‘ SIZE 50M BLOCKSIZE 512
11 -- STANDBY LOGFILE
12 DATAFILE
13 ‘/u01/app/oracle/oradata/orcl/system01.dbf‘,
14 ‘/u01/app/oracle/oradata/orcl/sysaux01.dbf‘,
15 ‘/u01/app/oracle/oradata/orcl/undotbs01.dbf‘,
16 ‘/u01/app/oracle/oradata/orcl/users01.dbf‘,
17 ‘/u01/app/oracle/oradata/orcl/example01.dbf‘,
18 ‘/u01/app/oracle/oradata/orcl/test01.dbf‘
19 CHARACTER SET AL32UTF8
20 ;

Control file created.

SQL> recover database;
ORA-00283: recovery session canceled due to errors
ORA-01610: recovery using the BACKUP CONTROLFILE option must be done


SQL> recover database using backup controlfile
ORA-00279: change 1132418 generated at 06/21/2016 09:46:44 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2016_06_21/o1_mf_1_7_%u_.arc
ORA-00280: change 1132418 for thread 1 is in sequence #7


Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/u01/app/oracle/oradata/orcl/redo01.log
Log applied.
Media recovery complete.

继续执行后续语句,但不要recover

SQL> VARIABLE RECNO NUMBER;
SQL> EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG(‘RETENTION POLICY‘,‘TO REDUNDANCY 1‘);
-- Commands to re-create incarnation table

PL/SQL procedure successfully completed.

SQL> SQL> -- Below log names MUST be changed to existing filenames on
SQL> -- disk. Any one log file from each branch can be used to
SQL> -- re-create incarnation records.
SQL> -- ALTER DATABASE REGISTER LOGFILE ‘/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2016_06_21/o1_mf_1_1_%u_.arc‘;
SQL> -- ALTER DATABASE REGISTER LOGFILE ‘/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2016_06_21/o1_mf_1_1_%u_.arc‘;
SQL> -- ALTER DATABASE REGISTER LOGFILE ‘/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2016_06_21/o1_mf_1_1_%u_.arc‘;
SQL> -- ALTER DATABASE REGISTER LOGFILE ‘/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2016_06_21/o1_mf_1_1_%u_.arc‘;
SQL> -- ALTER DATABASE REGISTER LOGFILE ‘/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2016_06_21/o1_mf_1_1_%u_.arc‘;

SQL> ALTER DATABASE OPEN RESETLOGS;

Database altered.

SQL> ALTER TABLESPACE TEMP ADD TEMPFILE ‘/u01/app/oracle/oradata/orcl/temp01.dbf‘ REUSE;

Tablespace altered.

 

RMAN备份恢复 控制文件和归档日志丢失情况

标签:

原文地址:http://www.cnblogs.com/ericnie/p/5602714.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!