说明:
利用rman全备文件(控制文件、归档日志、数据文件)在别处一台oracle10g上还原
要求两台服务器的oracle版本一致并且数据文件、控制文件、归档日志文件目录结构一样
rman全备是用nocatalog方式备份的,所以备份集信息保存在控制文件里。在这里证明一点,就是利用全备方式所备份出来的控制文件含的备份集信息是不全的,如果原来的控制文件丢失会给恢复带来一定麻烦,只有通过
DBMS_BACKUP_RESTORE包来恢复。但如果打开自动备份控制文件功能就不一样了。
rman全备脚本:
#!/bin/bash
rman target sys/sysdba nocatalog <run {
allocate channel t1 type disk;
allocate channel t2 type disk;
allocate channel t3 type disk;
set limit channel t1 kbytes 4194304;
set limit channel t2 kbytes 4194304;
set limit channel t3 kbytes 4194304;
backup
format '/u01/rman/full_wapdb_%U'
(database include current controlfile);
backup
format '/u01/rman/redolog_wapdb_%U' archivelog all delete input;
sql ' alter system archive log current';
release channel t1;
release channel t2;
release channel t3;
}
exit
EOF
控制文件设置自动备份:(下面实验来证明自动备份的好处)
rman> configure controlfile autobackup on ;
全备后的文件如下:
cd /u01/rman
[oracle@test rman]$ ll
总计 754936
-rw-r----- 1 oracle oinstall 375029760 12-20 22:48 full_wapdb_01k2ot0u_1_1
-rw-r----- 1 oracle oinstall 339255296 12-20 22:48 full_wapdb_02k2ot0u_1_1
-rw-r----- 1 oracle oinstall 7110656 12-20 22:45 full_wapdb_03k2ot0u_1_1
-rw-r----- 1 oracle oinstall 50874880 12-20 22:49 redolog_wapdb_04k2ot6v_1_1
--------------------------------------------------------------------------------
由于备份是nocatalog所以备份集信息是写到控制文件里的,用全备出来的控制文件信息是不全的。
来验证一下:(把日志文件 控制文件 数据文件删除)
1.从全备文件恢复
[oracle@test ~]$ rman target /
Recovery Manager: Release 10.2.0.4.0 - Production on 星期六 12月 20 23:28:31 2008
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: oradb (not mounted)
RMAN> restore controlfile from '/u01/rman/full_wapdb_03k2ot0u_1_1';
Starting restore at 20-12月-08
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output filename=/u01/app/oracle/oradata/oradb/control01.ctl
output filename=/u01/app/oracle/oradata/oradb/control02.ctl
output filename=/u01/app/oracle/oradata/oradb/control03.ctl
Finished restore at 20-12月-08
这样三个控制文件就恢复了
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN> list backup;
using target database control file instead of recovery catalog
在恢复出来的控制文件里找不到备份的信息
2.用自动备份控制文件来恢复(把刚才的三个控制文件删除)
RMAN> startup nomount;
connected to target database (not started)
Oracle instance started
Total System Global Area 167772160 bytes
Fixed Size 1266392 bytes
Variable Size 83889448 bytes
Database Buffers 79691776 bytes
Redo Buffers 2924544 bytes
RMAN> exit
--------------------------------------------------------------------------------
2.再来看看用自动备份恢复的实验
Recovery Manager complete.
[oracle@test ~]$ rman target /
Recovery Manager: Release 10.2.0.4.0 - Production on 星期六 12月 20 23:34:45 2008
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: oradb (not mounted)
RMAN> restore controlfile from '/u01/app/oracle/flash_recovery_area/ORADB/autobackup/2008_12_20/o1_mf_s_674002170_4nt1hx4z_.bkp';
Starting restore at 20-12月-08
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
output filename=/u01/app/oracle/oradata/oradb/control01.ctl
output filename=/u01/app/oracle/oradata/oradb/control02.ctl
output filename=/u01/app/oracle/oradata/oradb/control03.ctl
Finished restore at 20-12月-08
重新从autobackup里还原三个控制文件
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN> list backup;
using target database control file instead of recovery catalog
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1 Full 6.77M DISK 00:00:06 20-12月-08
BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20081220T224548
Piece Name: /u01/rman/full_wapdb_03k2ot0u_1_1
Control File Included: Ckp SCN: 339825 Ckp time: 20-12月-08
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2 Full 357.65M DISK 00:02:44 20-12月-08
BP Key: 2 Status: AVAILABLE Compressed: NO Tag: TAG20081220T224548
Piece Name: /u01/rman/full_wapdb_01k2ot0u_1_1
List of Datafiles in backup set 2
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ---------- ----
1 Full 339824 20-12月-08 /u01/app/oracle/oradata/oradb/system01.dbf
4 Full 339824 20-12月-08 /u01/app/oracle/oradata/oradb/users01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3 Full 323.53M DISK 00:02:45 20-12月-08
BP Key: 3 Status: AVAILABLE Compressed: NO Tag: TAG20081220T224548
Piece Name: /u01/rman/full_wapdb_02k2ot0u_1_1
List of Datafiles in backup set 3
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ---------- ----
2 Full 339825 20-12月-08 /u01/app/oracle/oradata/oradb/undotbs01.dbf
3 Full 339825 20-12月-08 /u01/app/oracle/oradata/oradb/sysaux01.dbf
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
4 48.52M DISK 00:00:21 20-12月-08
BP Key: 4 Status: AVAILABLE Compressed: NO Tag: TAG20081220T224901
Piece Name: /u01/rman/redolog_wapdb_04k2ot6v_1_1
List of Archived Logs in backup set 4
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- ---------- ---------- ---------
1 29 327057 20-12月-08 340013 20-12月-08
这次rman找回了备份集的信息
3.开始恢复
RMAN> restore database;
Starting restore at 20-12月-08
Starting implicit crosscheck backup at 20-12月-08
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
Crosschecked 4 objects
Finished implicit crosscheck backup at 20-12月-08
Starting implicit crosscheck copy at 20-12月-08
using channel ORA_DISK_1
Finished implicit crosscheck copy at 20-12月-08
searching for all files in the recovery area
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /u01/app/oracle/flash_recovery_area/ORADB/autobackup/2008_12_20/o1_mf_s_674002170_4nt1hx4z_.bkp
File Name: /u01/app/oracle/flash_recovery_area/ORADB/archivelog/2008_12_20/o1_mf_1_30_4nt1jdhs_.arc
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 /u01/app/oracle/oradata/oradb/system01.dbf
restoring datafile 00004 to /u01/app/oracle/oradata/oradb/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/rman/full_wapdb_01k2ot0u_1_1
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/rman/full_wapdb_01k2ot0u_1_1 tag=TAG20081220T224548
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00002 to /u01/app/oracle/oradata/oradb/undotbs01.dbf
restoring datafile 00003 to /u01/app/oracle/oradata/oradb/sysaux01.dbf
channel ORA_DISK_1: reading from backup piece /u01/rman/full_wapdb_02k2ot0u_1_1
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/rman/full_wapdb_02k2ot0u_1_1 tag=TAG20081220T224548
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
Finished restore at 20-12月-08
RMAN> recover database noredo;
Starting recover at 20-12月-08
using channel ORA_DISK_1
Finished recover at 20-12月-08
RMAN> alter database open resetlogs;(注意在线日志不能恢复,用resetlogs打开)
database opened
RMAN> exit
恢复结束。
结论:
如果用rman选择nocatalog方式备份,因为备份信息放到控制文件里,所以控制文件非常重要,即使是全备,其里的备份信息也不全,必需打开自动备份控制文件configure controlfile autobackup on ;
一定要保存好自动备份文件。
阅读(2166) | 评论(0) | 转发(0) |