丢失undo文件,丢失部分归档日志的…

来源:互联网 发布:java简单计算器源代码 编辑:程序博客网 时间:2024/05/18 04:53
丢失undo,丢失部分归档日志,是完全可以进行不完全恢复的。我的测试如下:

SQL> select file_name,file_id,tablespace_name,statusfrom dba_data_files;

FILE_NAME                            FILE_IDTABLESPACE_NAME      STATUS
----------------------------------------------- --------------------------- ---------
/u01/app/oracle/oradata/yssingle/system01.dbf       SYSTEM            AVAILABLE
/u01/app/oracle/oradata/yssingle/undotbs01.dbf     UNDOTBS1          AVAILABLE
......

8 rows selected

SQL> select * from v$log;

    GROUP#  THREAD#  SEQUENCE#    BYTES   MEMBERS ARCHIVED STATUS      FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- ------------------------ ------------- -----------
                   49  209715200        1YES     ACTIVE          8685302011-2-18 上
                   50  209715200        1NO      CURRENT          8690232011-2-18 上
                   48  209715200        1YES     INACTIVE         7573302011-1-13 上

做个RMAN全备份
[oracle@yssingle1 rmanbak]$ ./rman_backup.sh
[oracle@yssingle1 rmanbak]$ ll /archive/
total 0

SQL> alter system archive log current;

System altered

SQL> alter system archive log current;

System altered

SQL> alter system archive log current;

System altered

SQL> select * from v$log;

    GROUP#  THREAD#  SEQUENCE#    BYTES   MEMBERS ARCHIVED STATUS      FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- ------------------------ ------------- -----------
                   55  209715200        1NO      CURRENT        8692442011-2-18 上
                   53  209715200        1YES     INACTIVE        8692352011-2-18 上
                   54  209715200        1YES     INACTIVE        8692402011-2-18 上

SQL>

虚拟机断电后重启,模拟断电后丢失undo文件、归档日志
[oracle@yssingle1 ~]$ cd /u01/app/oracle/oradata/yssingle/

[oracle@yssingle1 yssingle]$ mv undotbs01.dbfundotbs01.dbf.bak ――模拟断电后丢失undo文件[oracle@yssingle1yssingle]$ ll
total 1721184
-rw-r-----  1 oracleoinstall   7553024 Feb 18 10:39control01.ctl
......
-rw-r-----  1 oracle oinstall104865792 Feb 18 10:39 test01.dbf
-rw-r-----  1 oracle oinstall209723392 Feb 18 10:39 undotbs01.dbf.bak
......

[oracle@yssingle1 rmanbak]$ ll /archive/
total 44
-rw-r-----  1 oracle oinstall35840 Feb 18 10:37 1_52_723812272.dbf
-rw-r-----  1 oracleoinstall  2048 Feb 18 10:371_53_723812272.dbf
-rw-r-----  1 oracleoinstall  1536 Feb 18 10:371_54_723812272.dbf

[oracle@yssingle1 archive]$ mv 1_52_723812272.dbf1_52_723812272.dbf.bak ――模拟丢失归档日志[oracle@yssingle1 archive]$ll /archive/
total 44
-rw-r-----  1 oracle oinstall35840 Feb 18 10:37 1_52_723812272.dbf.bak
-rw-r-----  1 oracleoinstall  2048 Feb 18 10:371_53_723812272.dbf
-rw-r-----  1 oracleoinstall  1536 Feb 18 10:371_54_723812272.dbf


SQL> startup
ORACLE instance started.

Total System GlobalArea  209715200 bytes
Fixed Size              1260936bytes
Variable Size          192938616bytes
Database Buffers        12582912bytes
Redo Buffers             2932736bytes
Database mounted.
ORA-01157: cannot identify/lock data file 2 - see DBWR tracefile
ORA-01110: data file 2:'/u01/app/oracle/oradata/yssingle/undotbs01.dbf'
SQL> select open_mode from v$database;

OPEN_MODE
----------
MOUNTED

RMAN> restore archivelog sequence 51;――恢复归档日志51

Starting restore at 18-FEB-11
using channel ORA_DISK_1

channel ORA_DISK_1: starting archive log restore to defaultdestination
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=51
channel ORA_DISK_1: reading from backup piece/rmanbak/arc_t20110218_s43_p1.bak
channel ORA_DISK_1: restored backup piece 1
piece handle=/rmanbak/arc_t20110218_s43_p1.baktag=TAG20110218T103312
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
Finished restore at 18-FEB-11

RMAN> exit


Recovery Manager complete.
[oracle@yssingle1 bdump]$ ll /archive
total 60
-rw-r-----  1 oracle oinstall15360 Feb 18 11:14 1_51_723812272.dbf
-rw-r-----  1 oracle oinstall35840 Feb 18 10:37 1_52_723812272.dbf.bak
-rw-r-----  1 oracleoinstall  2048 Feb 18 10:371_53_723812272.dbf
-rw-r-----  1 oracleoinstall  1536 Feb 18 10:371_54_723812272.dbf

[oracle@yssingle1 yssingle]$ rman target /

Recovery Manager: Release 10.2.0.3.0 - Production on Fri Feb 1811:07:37 2011

Copyright (c) 1982, 2005,Oracle.  All rightsreserved.

connected to target database: YSSINGLE (DBID=1772505200, notopen)

RMAN> restoredatabase;
Starting restore at 18-FEB-11
using target database control file instead of recoverycatalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=44 devtype=DISK

channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backupset
restoring datafile 00001 to/u01/app/oracle/oradata/yssingle/system01.dbf
restoring datafile 00002 to/u01/app/oracle/oradata/yssingle/undotbs01.dbf
restoring datafile 00003 to/u01/app/oracle/oradata/yssingle/sysaux01.dbf
restoring datafile 00004 to/u01/app/oracle/oradata/yssingle/users01.dbf
restoring datafile 00005 to/u01/app/oracle/oradata/yssingle/goldengate01.dbf
restoring datafile 00006 to/u01/app/oracle/oradata/yssingle/test01.dbf
restoring datafile 00007 to/u01/app/oracle/oradata/yssingle/director01.dbf
restoring datafile 00008 to/u01/app/oracle/oradata/yssingle/veridata01.dbf
channel ORA_DISK_1: reading from backup piece/rmanbak/full_t20110218_s41_p.bak
channel ORA_DISK_1: restored backup piece 1
piece handle=/rmanbak/full_t20110218_s41_p.baktag=TAG20110218T103233
channel ORA_DISK_1: restore complete, elapsed time: 00:00:56
Finished restore at 18-FEB-11
RMAN> recover database untilsequence 52;
Starting recover at 18-FEB-11
using channel ORA_DISK_1

starting media recovery

archive log thread 1 sequence 51 is already on disk as file/archive/1_51_723812272.dbf
archive log filename=/archive/1_51_723812272.dbf thread=1sequence=51
media recovery complete, elapsed time: 00:00:00
Finished recover at 18-FEB-11
RMAN> sql "ALTER DATABASE OPEN";

sql statement: ALTER DATABASE OPEN
RMAN-00571:===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS===============
RMAN-00571:===========================================================
RMAN-03009: failure of sql command on default channel at 02/18/201111:16:58
RMAN-11003: failure during parse/execution of SQL statement: ALTERDATABASE OPENORA-01589: must use RESETLOGS or NORESETLOGS optionfor database open

RMAN> ^[[A
user interrupt received


RMAN> sql "ALTER DATABASE OPENRESETLOGS";sql statement: ALTER DATABASE OPENRESETLOGS

RMAN> exit


Recovery Manager complete.

SQL> select open_mode from v$database;

OPEN_MODE
----------
READ WRITE
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System GlobalArea  209715200 bytes
Fixed Size              1260936bytes
Variable Size          192938616bytes
Database Buffers        12582912bytes
Redo Buffers             2932736bytes
Database mounted.
Database opened.
SQL> exit
重启数据库正常。


0 0