在归档模式下丢失system表空间的数据文件,该如何恢复?以下是恢复的简单的演示:
----归档模式下丢失关键数据文件:
---查看数据库的归档模式:
sys@PROD>archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1
Next log sequence to archive 1
Current log sequence 1
---备份系统表空间:
[oracle@enmo ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Tue Nov 22 11:38:26 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database (not started)
RMAN> quit
Recovery Manager complete.
[oracle@enmo ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Tue Nov 22 11:40:27 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: PROD (DBID=338469376)
RMAN>
RMAN> backup tablespace system;
Starting backup at 22-NOV-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=26 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/PROD/system01.dbf
channel ORA_DISK_1: starting piece 1 at 22-NOV-16
channel ORA_DISK_1: finished piece 1 at 22-NOV-16
piece handle=/u01/app/backup/db_0nrli388_1_1.rmn tag=TAG20161122T114200 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:47
Finished backup at 22-NOV-16
Starting Control File and SPFILE Autobackup at 22-NOV-16
piece handle=/u01/app/FRA/PROD/autobackup/2016_11_22/o1_mf_s_928583027_d37hqom2_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 22-NOV-16
RMAN>
---删除系统数据文件:
sys@PROD>!rm /u01/app/oracle/oradata/PROD/system01.dbf
sys@PROD>!ls /u01/app/oracle/oradata/PROD/system01.dbf
ls: /u01/app/oracle/oradata/PROD/system01.dbf: No such file or directory
#已经删除。
---关库并尝试重启数据库:
sys@PROD>shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
sys@PROD>
sys@PROD>startup
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2257840 bytes
Variable Size 507513936 bytes
Database Buffers 322961408 bytes
Redo Buffers 2371584 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '/u01/app/oracle/oradata/PROD/system01.dbf'
#丢失了系统数据文件。
---通过rman尝试重载并恢复并打开数据库:
--重载系统关键数据文件:
RMAN> restore datafile 1;
Starting restore at 22-NOV-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=17 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/PROD/system01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/backup/db_0nrli388_1_1.rmn
channel ORA_DISK_1: piece handle=/u01/app/backup/db_0nrli388_1_1.rmn tag=TAG20161122T114200
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:25
Finished restore at 22-NOV-16
---恢复数据库:
RMAN> recover database;
Starting recover at 22-NOV-16
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:01
Finished recover at 22-NOV-16
--alert日志的记录:
Full restore complete of datafile 1 /u01/app/oracle/oradata/PROD/system01.dbf. Elapsed time: 0:01:11
checkpoint is 2137364
last deallocation scn is 1896097
Undo Optimization current scn is 2121545
Tue Nov 22 11:57:49 2016
alter database recover datafile list clear
Completed: alter database recover datafile list clear
alter database recover datafile list
1 , 2 , 3 , 4 , 5 , 6 , 7 , 8
Completed: alter database recover datafile list
1 , 2 , 3 , 4 , 5 , 6 , 7 , 8
alter database recover if needed
start
Media Recovery Start
Serial Media Recovery started
Recovery of Online Redo Log: Thread 1 Group 1 Seq 1 Reading mem 0
Mem# 0: /u01/app/oracle/oradata/PROD/redo01.log
Mem# 1: /u01/app/oracle/oradata/PROD/redo01b.log
Media Recovery Complete (PROD)
Completed: alter database recover if needed
Start
---尝试打开数据库:
RMAN> alter database open;
database opened
#已打开。
sys@PROD>select status from v$instance;
STATUS
------------
OPEN
--归档模式下恢复数据库,只需有有效的备份,再加上
重做日志文件的记录,就可以完全恢复数据库。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31392094/viewspace-2128965/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/31392094/viewspace-2128965/