(4)恢复时需要提供DBID
*****************************************查询DBID****************************************
SQL> select dbid from v$database;
DBID
----------
715093527
----------
715093527
SQL>
SQL>
SQL>
SQL> !
SQL>
SQL> !
*****************************************先备份数据库****************************************
[oracle@ora11 ~]$ cd /tmp
[oracle@ora11 tmp]$ mkdir backup
[oracle@ora11 tmp]$ cd
[oracle@ora11 ~]$ rman target /
[oracle@ora11 tmp]$ mkdir backup
[oracle@ora11 tmp]$ cd
[oracle@ora11 ~]$ rman target /
Recovery Manager: Release 11.2.0.1.0 - Production on Thu Jan 26 15:38:57 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORA11 (DBID=715093527)
RMAN> list backup;
using target database control file instead of recovery catalog
specification does not match any backup in the repository
specification does not match any backup in the repository
RMAN> backup database format '/tmp/backup/ora11_%u';
Starting backup at 26-JAN-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=138 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/oracle/oracle11/oradata/ora11/system01.dbf
input datafile file number=00002 name=/u01/oracle/oracle11/oradata/ora11/sysaux01.dbf
input datafile file number=00005 name=/u01/oracle/oracle11/oradata/ora11/example01.dbf
input datafile file number=00003 name=/u01/oracle/oracle11/oradata/ora11/undotbs01.dbf
input datafile file number=00004 name=/u01/oracle/oracle11/oradata/ora11/users01.dbf
channel ORA_DISK_1: starting piece 1 at 26-JAN-12
channel ORA_DISK_1: finished piece 1 at 26-JAN-12
piece handle=/tmp/backup/ora11_01n1o8em tag=TAG20120126T154005 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:07:07
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 26-JAN-12
channel ORA_DISK_1: finished piece 1 at 26-JAN-12
piece handle=/tmp/backup/ora11_02n1o8s3 tag=TAG20120126T154005 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 26-JAN-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=138 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/oracle/oracle11/oradata/ora11/system01.dbf
input datafile file number=00002 name=/u01/oracle/oracle11/oradata/ora11/sysaux01.dbf
input datafile file number=00005 name=/u01/oracle/oracle11/oradata/ora11/example01.dbf
input datafile file number=00003 name=/u01/oracle/oracle11/oradata/ora11/undotbs01.dbf
input datafile file number=00004 name=/u01/oracle/oracle11/oradata/ora11/users01.dbf
channel ORA_DISK_1: starting piece 1 at 26-JAN-12
channel ORA_DISK_1: finished piece 1 at 26-JAN-12
piece handle=/tmp/backup/ora11_01n1o8em tag=TAG20120126T154005 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:07:07
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 26-JAN-12
channel ORA_DISK_1: finished piece 1 at 26-JAN-12
piece handle=/tmp/backup/ora11_02n1o8s3 tag=TAG20120126T154005 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 26-JAN-12
RMAN> exit
Recovery Manager complete.
*****************************************模拟控制文件损坏****************************************
[oracle@ora11 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jan 26 15:48:27 2012
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> show parameter flash
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_flash_cache_file string
db_flash_cache_size big integer 0
db_flashback_retention_target integer 1440
SQL> show parameter db_recover
------------------------------------ ----------- ------------------------------
db_flash_cache_file string
db_flash_cache_size big integer 0
db_flashback_retention_target integer 1440
SQL> show parameter db_recover
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string /u01/oracle/oracle11/flash_rec
overy_area
db_recovery_file_dest_size big integer 3852M
SQL>
SQL> ! rm /u01/oracle/oracle11/oradata/ora11/control01.ctl
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string /u01/oracle/oracle11/flash_rec
overy_area
db_recovery_file_dest_size big integer 3852M
SQL>
SQL> ! rm /u01/oracle/oracle11/oradata/ora11/control01.ctl
SQL> ! rm /u01/oracle/oracle11/flash_recovery_area/ora11/control02.ctl
*****************************************从备份restore控制文件****************************************
RMAN> restore controlfile from autobackup;
Starting restore at 26-JAN-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=134 device type=DISK
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=134 device type=DISK
recovery area destination: /u01/oracle/oracle11/flash_recovery_area
database name (or database unique name) used for search: ORA11
channel ORA_DISK_1: no AUTOBACKUPS found in the recovery area
AUTOBACKUP search with format "%F" not attempted because DBID was not set-------------------->提示没有提供DBID
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 01/26/2012 15:57:58
RMAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece
database name (or database unique name) used for search: ORA11
channel ORA_DISK_1: no AUTOBACKUPS found in the recovery area
AUTOBACKUP search with format "%F" not attempted because DBID was not set-------------------->提示没有提供DBID
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 01/26/2012 15:57:58
RMAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece
RMAN> set dbid 715093527---------------->设置DBID
executing command: SET DBID
RMAN> restore controlfile from autobackup;
Starting restore at 26-JAN-12
using channel ORA_DISK_1
using channel ORA_DISK_1
recovery area destination: /u01/oracle/oracle11/flash_recovery_area
database name (or database unique name) used for search: ORA11
channel ORA_DISK_1: no AUTOBACKUPS found in the recovery area
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20120126
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20120125
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20120124
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20120123
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20120122
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20120121
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20120120
channel ORA_DISK_1: no AUTOBACKUP in 7 days found
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 01/26/2012 15:59:02
RMAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece------------------->提示rman没有采用自动备份控制文件功能
database name (or database unique name) used for search: ORA11
channel ORA_DISK_1: no AUTOBACKUPS found in the recovery area
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20120126
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20120125
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20120124
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20120123
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20120122
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20120121
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20120120
channel ORA_DISK_1: no AUTOBACKUP in 7 days found
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 01/26/2012 15:59:02
RMAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece------------------->提示rman没有采用自动备份控制文件功能
[RMAN> show all;
RMAN configuration parameters for database with db_unique_name ORA11 are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default--------------------------->可以看出rman没有采用自动备份控制文件功能
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default--------------------------->可以看出rman没有采用自动备份控制文件功能
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
RMAN> list backup of controlfile;--------------->查看控制文件的备份信息
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2 Full 9.36M DISK 00:00:08 26-JAN-12
BP Key: 2 Status: AVAILABLE Compressed: NO Tag: TAG20120126T154005
Piece Name: /tmp/backup/ora11_02n1o8s3
Control File Included: Ckp SCN: 870508 Ckp time: 26-JAN-12
RMAN> restore controlfile from '/tmp/backup/ora11_02n1o8s3';
Starting restore at 26-JAN-12
using channel ORA_DISK_1
using channel ORA_DISK_1
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
output file name=/u01/oracle/oracle11/oradata/ora11/control01.ctl
output file name=/u01/oracle/oracle11/flash_recovery_area/ora11/control02.ctl
Finished restore at 26-JAN-12
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
output file name=/u01/oracle/oracle11/oradata/ora11/control01.ctl
output file name=/u01/oracle/oracle11/flash_recovery_area/ora11/control02.ctl
Finished restore at 26-JAN-12
*****************************************尝试打开数据库****************************************
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
released channel: ORA_DISK_1
RMAN> alter database open;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 01/26/2012 16:00:57
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 01/26/2012 16:00:57
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
RMAN> alter database open RESETLOGS;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 01/26/2012 16:01:11
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/u01/oracle/oracle11/oradata/ora11/system01.dbf'
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 01/26/2012 16:01:11
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/u01/oracle/oracle11/oradata/ora11/system01.dbf'
RMAN> recover database;
Starting recover at 26-JAN-12
Starting implicit crosscheck backup at 26-JAN-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=135 device type=DISK
Crosschecked 1 objects
Finished implicit crosscheck backup at 26-JAN-12
Starting implicit crosscheck backup at 26-JAN-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=135 device type=DISK
Crosschecked 1 objects
Finished implicit crosscheck backup at 26-JAN-12
Starting implicit crosscheck copy at 26-JAN-12
using channel ORA_DISK_1
Finished implicit crosscheck copy at 26-JAN-12
using channel ORA_DISK_1
Finished implicit crosscheck copy at 26-JAN-12
searching for all files in the recovery area
cataloging files...
no files cataloged
cataloging files...
no files cataloged
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 6 is already on disk as file /u01/oracle/oracle11/oradata/ora11/redo03.log
archived log file name=/u01/oracle/oracle11/oradata/ora11/redo03.log thread=1 sequence=6
media recovery complete, elapsed time: 00:00:07
Finished recover at 26-JAN-12
archived log file name=/u01/oracle/oracle11/oradata/ora11/redo03.log thread=1 sequence=6
media recovery complete, elapsed time: 00:00:07
Finished recover at 26-JAN-12
RMAN> alter database open RESETLOGS;---------------->ok.至此恢复完毕
database opened
RMAN>
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/28278387/viewspace-746680/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/28278387/viewspace-746680/