备份的终极目的是为了更好的将数据恢复和还原过来,在前面的章节中我们已经重点谈完了rman的备份,实际上也穿插的谈了些复杂的完
备份的终极目的是为了更好的将数据恢复和还原过来,在前面的章节中我们已经重点谈完了rman的备份,实际上也穿插的谈了些复杂的完整恢复。当然在这节我们将会由浅入深的详细谈谈在几种不同情况下的数据库恢复。
1、 数据文件的丢失恢复
1.1 在wwl表空间上创建5张表,并添加数据。
sql> create table wwl01 (id number(3),namevarchar2(10));
table created.
sql> insert into wwl01 values(1,'wwl');
1 row created.
sql> insert into wwl01 values(2,'wm');
1 row created.
sql> insert into wwl01 values(3,'zq');
1 row created.
sql> insert into wwl01 values(4,'wbq');
1 row created.
sql> insert into wwl01 values(5,'wq');
1 row created.
sql> create table wwl02 as select * from wwl01;
table created.
sql> create table wwl03 as select * from wwl01;
table created.
sql> create table wwl04 as select * from wwl01;
table created.
sql> create table wwl05 as select * from wwl01;
table created.
查看表中的数据:
sql> select * from tab;
tname tabtype clusterid
---------- ------- ----------
wwl01 table
wwl02 table
wwl03 table
wwl04 table
wwl05 table
1.2 执行全库备份
[oracle@wwldb ~]$ rman target /
recovery manager: release 10.2.0.1.0 - production on fri jun 2200:59:59 2012
copyright (c) 1982, 2005, oracle. all rights reserved.
connected to target database: wwl (dbid=5520179)
rman> backup database;
1.3 模拟数据丢失,手动删除数据文件wwl001.dbf
[oracle@wwldb wwl]$ rm -rfwwl001.dbf
1.4 再次启动数据库,无法启动并报错不能锁定数据文件5,查看dbwr的跟踪文件。
sql>startup force;
oracleinstance started.
totalsystem global area 285212672 bytes
fixedsize 1218968 bytes
variablesize 92276328 bytes
databasebuffers 184549376 bytes
redobuffers 7168000 bytes
databasemounted.
ora-01157:cannot identify/lock data file 5 - see dbwr trace file
ora-01110: data file 5:'/dbdata/wwl/wwl001.dbf'
1.5 检查跟踪文件,报如下错误,,非常的清楚的告诉了找不到的文件:
errors in file/dbsoft/admin/wwl/bdump/wwl_dbw0_29185.trc:
ora-01157: message 1157 not found;no message file for product=rdbms, facility=ora; arguments: [5]
ora-01110: message 1110 not found;no message file for product=rdbms, facility=ora; arguments: [5] [/dbdata/wwl/wwl001.dbf]
ora-27037: message 27037 not found;no message file for product=rdbms, facility=ora
linux error: 2: no such file ordirectory
additional information: 3
ora-1157 signalled during: alterdatabase open...
由以上信息可以得出数据库故障是由于数据文件wwl001.dbf数据文件异常丢失或者损坏导致数据库的故障,那么数据文件丢失就必然存在数据库数据的丢失,但是万幸的是,在丢失之前我们已经做过备份了,现在我们就来通过之前的备份将wwl001.dbf文件恢复回来,数据文件的恢复分为两种,一直是在不影响数据库其它业务情况下的在线联机恢复,还有一种是停机停业务的恢复,详细见如下: