[oracle@hoegh oradata]$
6.恢复数据库
首先,尝试使用alter database open;命令打开数据库,我们看到系统提示需要进行介质恢复。
接下来,使用recover database;命令恢复数据库;
最后,再次使用alter database open;命令打开数据库。
SQL>
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01113: file 1 needs media recovery
ORA-01110: data file 1: \'/u01/app/oracle/oradata/HOEGH/system01.dbf\'
SQL>
SQL> recover database;
Media recovery complete.
SQL>
SQL> alter database open;
Database altered.
SQL>
SQL> select status from v$instance;
STATUS
------------
OPEN
SQL>
此时我们看到数据库已经处于open状态了,至此我们成功地使用物理备份恢复了之前“丢失”的system数据文件。通过alert报警日志我们再来看一下介质恢复以及打开数据库的整个过程。
Sat Jul 11 09:02:46 2015
alter database open
Errors in file /u01/app/oracle/diag/rdbms/HOEGH/HOEGH/trace/HOEGH_ora_6135.trc:
ORA-01113: file 1 needs media recovery
ORA-01110: data file 1: \'/u01/app/oracle/oradata/HOEGH/system01.dbf\'
ORA-1113 signalled during: alter database open...
ALTER DATABASE RECOVER database
Media Recovery Start
started logmerger process
Sat Jul 11 09:02:53 2015
Recovering data file 1 from a fuzzy backup. It might be an online
backup taken without entering the begin backup command.
Parallel Media Recovery started with 2 slaves
Recovery of Online Redo Log: Thread 1 Group 1 Seq 7 Reading mem 0
Mem# 0: /u01/app/oracle/oradata/HOEGH/redo01.log
Recovery of Online Redo Log: Thread 1 Group 2 Seq 8 Reading mem 0
Mem# 0: /u01/app/oracle/oradata/HOEGH/redo02.log
Media Recovery Complete (HOEGH)
Completed: ALTER DATABASE RECOVER database
Sat Jul 11 09:03:23 2015
alter database open
Beginning crash recovery of 1 threads
parallel recovery started with 2 processes
Started redo scan
Completed redo scan
read 0 KB redo, 0 data blocks need recovery
Started redo application at
Thread 1: logseq 8, block 878, scn 919739
Recovery of Online Redo Log: Thread 1 Group 2 Seq 8 Reading mem 0
Mem# 0: /u01/app/oracle/oradata/HOEGH/redo02.log
Completed redo application of 0.00MB
Completed crash recovery at
Thread 1: logseq 8, block 878, scn 939740
0 data blocks read, 0 data blocks written, 0 redo k-bytes read
Sat Jul 11 09:03:24 2015
Thread 1 advanced to log sequence 9 (thread open)
Thread 1 opened at log sequence 9
Current log# 3 seq# 9 mem# 0: /u01/app/oracle/oradata/HOEGH/redo03.log
Successful open of redo thread 1
MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
Sat Jul 11 09:03:24 2015
SMON: enabling cache recovery
[6135] Successfully onlined Undo Tablespace 2.
Undo initialization finished serial:0 start:1328894 end:1328914 diff:20 (0 seconds)
Verifying file header compatibility for 11g tablespace encryption..
Verifying 11g file header compatibility for tablespace encryption completed
SMON: enabling tx recovery
Database Characterset is AL32UTF8
No Resource Manager plan active
replication_dependency_tracking turned off (no async multimaster replication found)
Starting background process QMNC
Sat Jul 11 09:03:24 2015
QMNC started with pid=22, OS id=6188
Completed: alter database open
从报警日志我们看到,数据库通过redo重做日志文件完成了介质恢复;然后,检查redo、undo等正常后,顺利打开数据库。
备份第一
备份是系统中需要考虑的最重要的事项,虽然它在系统的整个规划、开发和测试过程中甚至占不到1%,看似不太重要且默默无闻的工作只有到恢复的时候才能真正体现出其重要性,任何数据的丢失与长时间的数据down机,都是不可以被接受的。当然,仅仅依靠物理备份做不到这一点,RMAN的功能更为强大。