难题2. 控制文件恢复
这个又怎么恢复呢? 用rman的自动备份控制文件的rman备份吗? 是的没错,只有从rman备份文件中提取出来的controlfile才能使用rman备份文件恢复datafile的.
那么这里有来种办法来实现从rman备份文件中提取出controlfie了.
方法1.
RMAN>restore controlfile from ‘/…备份文件..’;
恢复的控制文件将放在$ORACLE_HOME/dbs/cncontrl.dbf不过这个方法有时恢复的控制文件中记录的dbname与实际不一致.
方法2: 利用dbms_backup_restore提取controlfile
步骤:
[oracle@foway dbs]$sqlplus /nolog
SQL*Plus: Release 10.2.0.4.0 - Production on Fri Jul 18 21:38:21 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn /as sysdba
Connected.
由于在刚才使用rman时执行了startup nomount,所以这里是connected,下面我们到nomount状态
SQL> startup force nomount
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 1218316 bytes
Variable Size 62916852 bytes
Database Buffers 100663296 bytes
Redo Buffers 2973696 bytes
SQL>DECLARE
2devtype varchar2(256);
3done boolean;
4BEGIN
5devtype:=sys.dbms_backup_restore.deviceAllocate(type=>'',ident=>'T1');
6sys.dbms_backup_restore.restoreSetDatafile;
7sys.dbms_backup_restore.restoreControlfileTo(cfname=>'/opt/oracle/oradata/orcl/control01.ctl');
8sys.dbms_backup_restore.restoreBackupPiece(done=>done,handle=>'/opt/oracle/flash_recovery_area/ORCL/backupset/2008_07_18/o1_mf_ncsnf_TAG20080718T203240_482fls2h_.bkp',params=>null);
9 sys.dbms_backup_restore.deviceDeallocate;
10 end;
11/
PL/SQL procedure successfully completed.
下面验证control01.ctl是否恢复:
[oracle@foway dbs]$ ls /opt/oracle/oradata/orcl/
control01.ctl
[oracle@foway dbs]$
看到了control01.ctl 恭喜你:难题2 解决了.
于是我们可以启动数据库到mount状态了.
[oracle@foway dbs]$sqlplus /nolog
SQL*Plus: Release 10.2.0.4 - Production on Fri Jul 18 21:45:32 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn /as sysdba
Connected.
SQL> startup force mount
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 1218316 bytes
Variable Size 62916852 bytes
Database Buffers 100663296 bytes
Redo Buffers 2973696 bytes
ORA-00205: error in identifying control file, check alert log for more info
我们已经恢复了控制文件了,怎么还是有错误呢,其实不用担心,看看spfile中的记录先
SQL> show parameter control_files
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files string /opt/oracle/oradata/orcl/contr
ol01.ctl, /opt/oracle/oradata/
orcl/control02.ctl, /opt/oracl
e/oradata/orcl/control03.ctl
SQL>
既然如此,我们就把控制文件同步下好了.
SQL> ho cp /opt/oracle/oradata/orcl/control01.ctl /opt/oracle/oradata/orcl/control02.ctl
SQL> ho cp /opt/oracle/oradata/orcl/control01.ctl /opt/oracle/oradata/orcl/control03.ctl
SQL> alter database mount;
Database altered.
SQL> ho ls /opt/oracle/oradata/orcl/
control01.ctl control02.ctl control03.ctl
好了到这里我们已经成功解决了难题2了.
有了恢复后的控制文件,我们就可以使用rman查看与使用以前的rman备份了.
恢复datafile 步骤:
rman target / nocatalog
Recovery Manager: Release 10.2.0.4 - Production on Fri Jul 18 21:49:10 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1188209463, not open)
using target database control file instead of recovery catalog
RMAN>
看到了 红色部分了吗,太好了终于看到了正常的rman登陆信息了.
那就list copy|backup 看看能找到我们的
o1_mf_ncsnf_TAG20080718T203240_482fls2h_.bkp
o1_mf_nnndf_TAG20080718T203240_482fkb0k_.bkp
文件吗.
RMAN> list copy;
specification does not match any archive log in the recovery catalog
RMAN> list backup;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1 Full 495.41M DISK 00:00:41 18-JUL-08
BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20080718T203240
Piece Name: /opt/oracle/flash_recovery_area/ORCL/backupset/2008_07_18/o1_mf_nnndf_TAG20080718T203240_482fkb0k_.bkp
List of Datafiles in backup set 1
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 453304 18-JUL-08 /opt/oracle/oradata/orcl/system01.dbf
2 Full 453304 18-JUL-08 /opt/oracle/oradata/orcl/undotbs01.dbf
3 Full 453304 18-JUL-08 /opt/oracle/oradata/orcl/sysaux01.dbf
4 Full 453304 18-JUL-08 /opt/oracle/oradata/orcl/users01.dbf
RMAN>
太好了,总于可以使用restore,recover来恢复datafile了.
RMAN> restore database;
Starting restore at 18-JUL-08
Starting implicit crosscheck backup at 18-JUL-08
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
Crosschecked 1 objects
Finished implicit crosscheck backup at 18-JUL-08
Starting implicit crosscheck copy at 18-JUL-08
using channel ORA_DISK_1
Finished implicit crosscheck copy at 18-JUL-08
searching for all files in the recovery area
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /opt/oracle/flash_recovery_area/ORCL/backupset/2008_07_18/o1_mf_ncsnf_TAG20080718T203240_482fls2h_.bkp
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /opt/oracle/oradata/orcl/system01.dbf
restoring datafile 00002 to /opt/oracle/oradata/orcl/undotbs01.dbf
restoring datafile 00003 to /opt/oracle/oradata/orcl/sysaux01.dbf
restoring datafile 00004 to /opt/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: reading from backup piece /opt/oracle/flash_recovery_area/ORCL/backupset/2008_07_18/o1_mf_nnndf_TAG20080718T203240_482fkb0k_.bkp
channel ORA_DISK_1: restored backup piece 1
piece handle=/opt/oracle/flash_recovery_area/ORCL/backupset/2008_07_18/o1_mf_nnndf_TAG20080718T203240_482fkb0k_.bkp tag=TAG20080718T203240
channel ORA_DISK_1: restore complete, elapsed time: 00:00:56
Finished restore at 18-JUL-08
RMAN>
此时可以在$ORACLE_BASE/oradata/orcl/下看到期望已久的datafile了.
[oracle@foway dbs] ls /opt/oracle/oradata/orcl/
control01.ctl control02.ctl control03.ctl sysaux01.dbf system01.dbf undotbs01.dbf users01.dbf
[oracle@foway dbs]
不过此时还没有完哈,需要在接在励.
由于没有redo log日志文件所以我们不应用日志恢复:
RMAN> recover database noredo;
Starting recover at 18-JUL-08
using channel ORA_DISK_1
Finished recover at 18-JUL-08
RMAN>
到目前我们已经拥有了参数文件,控制文件,数据文件了:
[oracle@foway dbs] ls /opt/oracle/oradata/orcl/
ls /opt/oracle/oradata/orcl/
control01.ctl control02.ctl control03.ctl sysaux01.dbf system01.dbf
undotbs01.dbf users01.dbf
[oracle@foway dbs] ls /opt/oracle/10g/dbs/
alert_orcl.log hc_orcl.dat initdw.ora init.ora lkORCL spfileorcl.ora
还差一个密码文件,以及相关的日志文件了.
先解决密码文件:
[oracle@foway dbs] orapwd file=/opt/oracle/10g/dbs/orapworcl password=uplooking entries=5
[oracle@foway dbs] ls /opt/oracle/10g/dbs/
ls /opt/oracle/10g/dbs/
alert_orcl.log initdw.ora lkORCL spfileorcl.ora
hc_orcl.dat init.ora orapworcl
下面需要大家坚持不懈的完成最后一个工作了.
那就是通过已经恢复的controlfile and datafile 来演算出redo log file了.
步骤:
[oracle@foway dbs]sqlplus /nolog
SQL*Plus: Release 10.2.0.4 - Production on Fri Jul 18 21:58:05 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn /as sysdba
Connected.
SQL> startup force mount
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 1218316 bytes
Variable Size 62916852 bytes
Database Buffers 100663296 bytes
Redo Buffers 2973696 bytes
Database mounted.
SQL>alter system set "_allow_resetlogs_corruption"=TRUE;
alter system set "_allow_resetlogs_corruption"=TRUE
*
ERROR at line 1:
ORA-02095: specified initialization parameter cannot be modified
SQL> alter system set "_allow_resetlogs_corruption"=TRUE scope=spfile;
System altered.
SQL>ho ls /opt/oracle/oradata/orcl/
control01.ctl control03.ctl sysaux01.dbf undotbs01.dbf
control02.ctl orapworcl system01.dbf users01.dbf
下面没有redo log file ,下面我将演算出redo log
SQL>startup force
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 1218316 bytes
Variable Size 62916852 bytes
Database Buffers 100663296 bytes
Redo Buffers 2973696 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL>alter database open resetlogs;
Database altered.
SQL> ho ls /opt/oracle/oradata/orcl/
control01.ctl orapworcl redo03.log temp01.dbf
control02.ctl redo01.log sysaux01.dbf undotbs01.dbf
control03.ctl redo02.log system01.dbf users01.dbf
SQL>
好了到这里,非常高兴了,你已经成功的从只有rman备份文件中恢复了参数文件,控制文件,所有数据文件,日志文件了. |