【RMAN】利用備份片還原資料庫

lhrbest發表於2015-05-04

RMAN】利用備份片還原資料庫

BLOG文件結構圖

 

wps6252.tmp 

 

群裡有同學說把ORACLE_BASE目錄刪掉了,現在只有備份片和歸檔檔案了,試問如何恢復。坑,,,,咋能這麼幹,ORACLE_BASE都敢刪,,試著恢復了下,並且記錄下來,當然軟體安裝部分就不記錄了。

我再說說目前的情況,只有備份片和歸檔檔案,且從檔名稱是看不出dbname和dbid的,在這種情況下其實恢復控制檔案是很重要的了,但是鬼知道備份片裡邊是不是有控制檔案的備份呢?我們可能碰到的就是這樣的情況,只有備份檔案,其它的什麼都不知道。我們且看這樣的情況下如何恢復呢?

 

演示環境:

OS: RHEL 6.5

DB: 11.2.0.3.0

 

1.1  原庫備份並傳輸到測試庫

原庫情況:

[oracle@rhel6_lhr ora11g]$ ORACLE_SID=ora11g

[oracle@rhel6_lhr ora11g]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.3.0 Production on Thu Apr 30 15:36:11 2015

 

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

 

Connected to an idle instance.

 

15:36:19 SQL> startup

ORACLE instance started.

 

Total System Global Area  409194496 bytes

Fixed Size                  2228864 bytes

Variable Size             281021824 bytes

Database Buffers          117440512 bytes

Redo Buffers                8503296 bytes

Database mounted.

Database opened.

15:37:20 SQL>

15:37:50 SQL>

15:37:50 SQL> show parameter name

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

db_file_name_convert                 string

db_name                              string      ora11g

db_unique_name                       string      ora11g

global_names                         boolean     FALSE

instance_name                        string      ora11g

lock_name_space                      string

log_file_name_convert                string

processor_group_name                 string

service_names                        string      ora11g

15:47:37 SQL> col FILE_NAME format a50

15:47:47 SQL> select FILE_NAME,FILE_ID,a.TABLESPACE_NAME, b.status ts_status ,BYTES from dba_data_files a,dba_tablespaces b where a.TABLESPACE_NAME=b.TABLESPACE_NAME;

 

FILE_NAME                                             FILE_ID TABLESPACE_NAME                TS_STATUS      BYTES

-------------------------------------------------- ---------- ------------------------------ --------- ----------

/u01/app/oracle/oradata/ora11g/users01.dbf                  4 USERS                          ONLINE       5242880

/u01/app/oracle/oradata/ora11g/undotbs01.dbf                3 UNDOTBS1                       ONLINE      99614720

/u01/app/oracle/oradata/ora11g/sysaux01.dbf                 2 SYSAUX                         ONLINE     545259520

/u01/app/oracle/oradata/ora11g/system01.dbf                 1 SYSTEM                         ONLINE     744488960

/u01/app/oracle/oradata/ora11g/example01.dbf                5 EXAMPLE                        READ ONLY  328335360

 

 

15:47:48 SQL> create table lhr.test as select * from dba_objects;

 

Table created.

 

15:47:49 SQL> select count(1) from lhr.test;

 

  COUNT(1)

----------

     75204

 

15:47:50 SQL>

 

 

 

執行備份,當然生產庫上不能這麼簡單的備份:

 

[oracle@rhel6_lhr ~]$ ORACLE_SID=ora11g

[oracle@rhel6_lhr ~]$ ps -ef|grep ora_

oracle    3282  2997  0 15:36 pts/2    00:00:00 grep ora_

[oracle@rhel6_lhr ~]$ ps -ef|grep ora_

oracle    3286  2997  0 15:36 pts/2    00:00:00 grep ora_

[oracle@rhel6_lhr ~]$ rman target /

 

Recovery Manager: Release 11.2.0.3.0 - Production on Thu Apr 30 15:36:52 2015

 

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database: ORA11G (DBID=4270446895)

 

 

RMAN> show all;

 

using target database control file instead of recovery catalog

RMAN configuration parameters for database with db_unique_name ORA11G 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

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 SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_ora11g.f'; # default

 

RMAN> list backupset;

 

using target database control file instead of recovery catalog

specification does not match any backup in the repository

 

 

RMAN> backup database plus archivelog delete input;

 

 

Starting backup at 2015-04-30 16:00:45

current log archived

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=18 device type=DISK

channel ORA_DISK_1: starting archived log backup set

channel ORA_DISK_1: specifying archived log(s) in backup set

input archived log thread=1 sequence=6 RECID=1 STAMP=878399828

input archived log thread=1 sequence=7 RECID=2 STAMP=878399829

input archived log thread=1 sequence=8 RECID=3 STAMP=878400047

channel ORA_DISK_1: starting piece 1 at 2015-04-30 16:00:48

channel ORA_DISK_1: finished piece 1 at 2015-04-30 16:00:49

piece handle=/u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_04_30/o1_mf_annnn_TAG20150430T160048_bn3r9jd7_.bkp tag=TAG20150430T160048 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

channel ORA_DISK_1: deleting archived log(s)

archived log file name=/u01/app/oracle/flash_recovery_area/ORA11G/archivelog/2015_04_30/o1_mf_1_6_bn3r2mo1_.arc RECID=1 STAMP=878399828

archived log file name=/u01/app/oracle/flash_recovery_area/ORA11G/archivelog/2015_04_30/o1_mf_1_7_bn3r2nz5_.arc RECID=2 STAMP=878399829

archived log file name=/u01/app/oracle/flash_recovery_area/ORA11G/archivelog/2015_04_30/o1_mf_1_8_bn3r9hrl_.arc RECID=3 STAMP=878400047

Finished backup at 2015-04-30 16:00:49

 

Starting backup at 2015-04-30 16:00:49

using channel ORA_DISK_1

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/app/oracle/oradata/ora11g/system01.dbf

input datafile file number=00002 name=/u01/app/oracle/oradata/ora11g/sysaux01.dbf

input datafile file number=00005 name=/u01/app/oracle/oradata/ora11g/example01.dbf

input datafile file number=00003 name=/u01/app/oracle/oradata/ora11g/undotbs01.dbf

input datafile file number=00004 name=/u01/app/oracle/oradata/ora11g/users01.dbf

channel ORA_DISK_1: starting piece 1 at 2015-04-30 16:00:49

channel ORA_DISK_1: finished piece 1 at 2015-04-30 16:02:34

piece handle=/u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_04_30/o1_mf_nnndf_TAG20150430T160049_bn3r9ksp_.bkp tag=TAG20150430T160049 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:01:45

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 2015-04-30 16:02:37

channel ORA_DISK_1: finished piece 1 at 2015-04-30 16:02:39

piece handle=/u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_04_30/o1_mf_ncsnf_TAG20150430T160049_bn3rdxyz_.bkp tag=TAG20150430T160049 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02

Finished backup at 2015-04-30 16:02:39

 

Starting backup at 2015-04-30 16:02:39

current log archived

using channel ORA_DISK_1

channel ORA_DISK_1: starting archived log backup set

channel ORA_DISK_1: specifying archived log(s) in backup set

input archived log thread=1 sequence=9 RECID=4 STAMP=878400159

channel ORA_DISK_1: starting piece 1 at 2015-04-30 16:02:39

channel ORA_DISK_1: finished piece 1 at 2015-04-30 16:02:40

piece handle=/u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_04_30/o1_mf_annnn_TAG20150430T160239_bn3rdzd7_.bkp tag=TAG20150430T160239 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

channel ORA_DISK_1: deleting archived log(s)

archived log file name=/u01/app/oracle/flash_recovery_area/ORA11G/archivelog/2015_04_30/o1_mf_1_9_bn3rdz8k_.arc RECID=4 STAMP=878400159

Finished backup at 2015-04-30 16:02:40

 

RMAN>

 

RMAN>

 

RMAN> list backupset;

 

 

List of Backup Sets

===================

 

 

BS Key  Size       Device Type Elapsed Time Completion Time   

------- ---------- ----------- ------------ -------------------

1       11.61M     DISK        00:00:00     2015-04-30 16:00:48

        BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20150430T160048

        Piece Name: /u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_04_30/o1_mf_annnn_TAG20150430T160048_bn3r9jd7_.bkp

 

  List of Archived Logs in backup set 1

  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time

  ---- ------- ---------- ------------------- ---------- ---------

  1    6       1087169    2015-03-13 14:24:40 1094093    2015-04-30 15:57:07

  1    7       1094093    2015-04-30 15:57:07 1094096    2015-04-30 15:57:08

  1    8       1094096    2015-04-30 15:57:08 1094204    2015-04-30 16:00:47

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time   

------- ---- -- ---------- ----------- ------------ -------------------

2       Full    1.13G      DISK        00:01:43     2015-04-30 16:02:32

        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20150430T160049

        Piece Name: /u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_04_30/o1_mf_nnndf_TAG20150430T160049_bn3r9ksp_.bkp

  List of Datafiles in backup set 2

  File LV Type Ckp SCN    Ckp Time            Name

  ---- -- ---- ---------- ------------------- ----

  1       Full 1094214    2015-04-30 16:00:49 /u01/app/oracle/oradata/ora11g/system01.dbf

  2       Full 1094214    2015-04-30 16:00:49 /u01/app/oracle/oradata/ora11g/sysaux01.dbf

  3       Full 1094214    2015-04-30 16:00:49 /u01/app/oracle/oradata/ora11g/undotbs01.dbf

  4       Full 1094214    2015-04-30 16:00:49 /u01/app/oracle/oradata/ora11g/users01.dbf

  5       Full 1092435    2015-04-30 15:42:04 /u01/app/oracle/oradata/ora11g/example01.dbf

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time   

------- ---- -- ---------- ----------- ------------ -------------------

3       Full    9.36M      DISK        00:00:04     2015-04-30 16:02:38

        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20150430T160049

        Piece Name: /u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_04_30/o1_mf_ncsnf_TAG20150430T160049_bn3rdxyz_.bkp

  SPFILE Included: Modification time: 2015-04-30 15:56:17

  SPFILE db_unique_name: ORA11G

  Control File Included: Ckp SCN: 1094280      Ckp time: 2015-04-30 16:02:34

 

BS Key  Size       Device Type Elapsed Time Completion Time   

------- ---------- ----------- ------------ -------------------

4       19.00K     DISK        00:00:00     2015-04-30 16:02:39

        BP Key: 4   Status: AVAILABLE  Compressed: NO  Tag: TAG20150430T160239

        Piece Name: /u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_04_30/o1_mf_annnn_TAG20150430T160239_bn3rdzd7_.bkp

 

  List of Archived Logs in backup set 4

  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time

  ---- ------- ---------- ------------------- ---------- ---------

  1    9       1094204    2015-04-30 16:00:47 1094286    2015-04-30 16:02:39

 

RMAN>

 

 

 

[root@rhel6_lhr ~]# cd /u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_04_30/

[root@rhel6_lhr 2015_04_30]# ll -h

total 1.2G

-rw-r----- 1 oracle asmadmin  12M Apr 30 16:00 o1_mf_annnn_TAG20150430T160048_bn3r9jd7_.bkp

-rw-r----- 1 oracle asmadmin  20K Apr 30 16:02 o1_mf_annnn_TAG20150430T160239_bn3rdzd7_.bkp

-rw-r----- 1 oracle asmadmin 9.4M Apr 30 16:02 o1_mf_ncsnf_TAG20150430T160049_bn3rdxyz_.bkp

-rw-r----- 1 oracle asmadmin 1.2G Apr 30 16:02 o1_mf_nnndf_TAG20150430T160049_bn3r9ksp_.bkp

[root@rhel6_lhr 2015_04_30]# cd ..

[root@rhel6_lhr backupset]# ll

total 4

drwxr-x--- 2 oracle asmadmin 4096 Apr 30 16:02 2015_04_30

[root@rhel6_lhr backupset]# scp 2015_04_30 oracle@192.168.59.157:/tmp

The authenticity of host '192.168.59.157 (192.168.59.157)' can't be established.

RSA key fingerprint is 77:e6:11:1a:7c:c7:81:7c:88:c9:21:18:51:2a:84:d1.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '192.168.59.157' (RSA) to the list of known hosts.

oracle@192.168.59.157's password:

2015_04_30: not a regular file

[root@rhel6_lhr backupset]# scp -r 2015_04_30/ oracle@192.168.59.157:/tmp

oracle@192.168.59.157's password:

o1_mf_annnn_TAG20150430T160048_bn3r9jd7_.bkp                                                                                                                                    100%   12MB  11.6MB/s   00:00   

o1_mf_nnndf_TAG20150430T160049_bn3r9ksp_.bkp                                                                                                                                    100% 1157MB  77.1MB/s   00:15   

o1_mf_ncsnf_TAG20150430T160049_bn3rdxyz_.bkp                                                                                                                                    100% 9600KB   9.4MB/s   00:00   

o1_mf_annnn_TAG20150430T160239_bn3rdzd7_.bkp                                                                                                                                    100%   20KB  19.5KB/s   00:00   

[root@rhel6_lhr backupset]#

 

 

1.2  測試庫編輯pfile檔案

11g只寫db_name即可,控制檔案可以寫上,免得後邊又回來修改。

[oracle@testdb dbs]$ pwd

/u01/app/oracle/product/11.2.0/dbhome_1/dbs

[oracle@testdb dbs]$ more initora11g.ora

db_name=ora11g

control_files='/u01/app/oracle/oradata/ora11g/control01.ctl','/u01/app/oracle/flash_recovery_area/ora11g/control02.ctl'

[oracle@testdb dbs]$

 

1.3  找回控制檔案--備份集中含有控制檔案

重點來了:

 

由於沒有控制檔案,所以首先只能啟動資料庫到nomount狀態

[oracle@testdb dbs]$ ORACLE_SID=ora11g

[oracle@testdb dbs]$ rman target /

 

Recovery Manager: Release 11.2.0.3.0 - Production on Thu Apr 30 16:16:53 2015

 

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database (not started)

 

RMAN> startup nomount;

 

Oracle instance started

 

Total System Global Area     250560512 bytes

 

Fixed Size                     2227256 bytes

Variable Size                192938952 bytes

Database Buffers              50331648 bytes

Redo Buffers                   5062656 bytes

 

RMAN>

 

 

首先我們要判斷一下備份集中是否含有控制檔案的備份,如果有我們可以直接還原,如果沒有那就只有建立控制檔案了,那麼如何判斷備份集中是否含有控制檔案的備份呢?這裡提供幾種辦法:① 推薦: 採用dbms_backup_restore.restoreControlfileTo從備份片中來嘗試找回控制檔案 ②   嘗試採用建立臨時庫來找回控制檔案  ③ 其它第三方工具來解析備份集

 

1.3.1  方法一:採用dbms_backup_restore.restoreControlfileTo從備份片中來嘗試找回控制檔案

Oracle 816 以後的版本中,Oracle提供了一個包:DBMS_BACKUP_RESTORE. DBMS_BACKUP_RESTORE 包是由dbmsbkrs.sql prvtbkrs.plb 這兩個指令碼建立的.catproc.sql 指令碼執行後會呼叫這兩個包.所以是每個資料庫都有的這個包是Oracle伺服器和作業系統之間IO操作的介面.由恢復管理器直接呼叫。由此可見,我們可以在資料庫nomount 情況下呼叫這些package ,來達到我們的恢復目的。

 

 

從前邊的備份中我們知道control檔案和spfile其實是在備份片:o1_mf_ncsnf_TAG20150430T160049_bn3rdxyz_.bkp中,但是這裡我們假裝不知道位置,然後挨個嘗試一下:

[oracle@testdb dbs]$ ORACLE_SID=ora11g

[oracle@testdb 2015_04_30]$ cd /tmp/2015_04_30/

[oracle@testdb 2015_04_30]$ ll

total 1206296

-rw-r-----. 1 oracle oinstall   12173312 Apr 30 16:06 o1_mf_annnn_TAG20150430T160048_bn3r9jd7_.bkp

-rw-r-----. 1 oracle oinstall      19968 Apr 30 16:06 o1_mf_annnn_TAG20150430T160239_bn3rdzd7_.bkp

-rw-r-----. 1 oracle oinstall    9830400 Apr 30 16:06 o1_mf_ncsnf_TAG20150430T160049_bn3rdxyz_.bkp

-rw-r-----. 1 oracle oinstall 1213218816 Apr 30 16:06 o1_mf_nnndf_TAG20150430T160049_bn3r9ksp_.bkp

[oracle@testdb 2015_04_30]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.3.0 Production on Thu Apr 30 16:56:34 2015

 

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

SQL> DECLARE

  2   devtype varchar2(256);

  3   done boolean;

  4   BEGIN

  5   devtype:=sys.dbms_backup_restore.deviceAllocate(type=>'',ident=>'T1');

  6   sys.dbms_backup_restore.restoreSetDatafile;

  7   sys.dbms_backup_restore.restoreControlfileTo(cfname=>'/tmp/2015_04_30/control01.ctl');

  8   sys.dbms_backup_restore.restoreBackupPiece(done=>done,handle=>'/tmp/2015_04_30/o1_mf_annnn_TAG20150430T160048_bn3r9jd7_.bkp', params=>null);

  9   sys.dbms_backup_restore.deviceDeallocate;

10   END;

11  /

DECLARE

*

ERROR at line 1:

ORA-19624: operation failed, retry possible

ORA-19870: error while restoring backup piece

/tmp/2015_04_30/o1_mf_annnn_TAG20150430T160048_bn3r9jd7_.bkp

ORA-19626: backup set type is archived log - can not be processed by this

conversation

ORA-06512: at "SYS.X$DBMS_BACKUP_RESTORE", line 5827

ORA-06512: at line 8

 

 

SQL> DECLARE

  2   devtype varchar2(256);

  3   done boolean;

  4   BEGIN

  5   devtype:=sys.dbms_backup_restore.deviceAllocate(type=>'',ident=>'T1');

  6   sys.dbms_backup_restore.restoreSetDatafile;

  7   sys.dbms_backup_restore.restoreControlfileTo(cfname=>'/tmp/2015_04_30/control01.ctl');

  8   sys.dbms_backup_restore.restoreBackupPiece(done=>done,handle=>'/tmp/2015_04_30/o1_mf_annnn_TAG20150430T160239_bn3rdzd7_.bkp', params=>null);

  9   sys.dbms_backup_restore.deviceDeallocate;

10   END;

11  /

DECLARE

*

ERROR at line 1:

ORA-19568: a device is already allocated to this session

ORA-06512: at "SYS.X$DBMS_BACKUP_RESTORE", line 235

ORA-06512: at "SYS.X$DBMS_BACKUP_RESTORE", line 210

ORA-06512: at line 5

 

 

SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

[oracle@testdb 2015_04_30]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.3.0 Production on Thu Apr 30 16:57:08 2015

 

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

SQL> DECLARE

  2   devtype varchar2(256);

  3   done boolean;

  4   BEGIN

  5   devtype:=sys.dbms_backup_restore.deviceAllocate(type=>'',ident=>'T1');

  6   sys.dbms_backup_restore.restoreSetDatafile;

  7   sys.dbms_backup_restore.restoreControlfileTo(cfname=>'/tmp/2015_04_30/control01.ctl');

  8   sys.dbms_backup_restore.restoreBackupPiece(done=>done,handle=>'/tmp/2015_04_30/o1_mf_annnn_TAG20150430T160239_bn3rdzd7_.bkp', params=>null);

  9   sys.dbms_backup_restore.deviceDeallocate;

10   END;

11  /

DECLARE

*

ERROR at line 1:

ORA-19624: operation failed, retry possible

ORA-19870: error while restoring backup piece

/tmp/2015_04_30/o1_mf_annnn_TAG20150430T160239_bn3rdzd7_.bkp

ORA-19626: backup set type is archived log - can not be processed by this

conversation

ORA-06512: at "SYS.X$DBMS_BACKUP_RESTORE", line 5827

ORA-06512: at line 8

 

 

SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

[oracle@testdb 2015_04_30]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.3.0 Production on Thu Apr 30 16:57:33 2015

 

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

SQL> DECLARE

  2   devtype varchar2(256);

  3   done boolean;

  4   BEGIN

  5   devtype:=sys.dbms_backup_restore.deviceAllocate(type=>'',ident=>'T1');

  6   sys.dbms_backup_restore.restoreSetDatafile;

  7   sys.dbms_backup_restore.restoreControlfileTo(cfname=>'/tmp/2015_04_30/control01.ctl');

  8   sys.dbms_backup_restore.restoreBackupPiece(done=>done,handle=>'/tmp/2015_04_30/o1_mf_nnndf_TAG20150430T160049_bn3r9ksp_.bkp', params=>null);

  9   sys.dbms_backup_restore.deviceDeallocate;

10   END;

11  /

DECLARE

*

ERROR at line 1:

ORA-19697: standby control file not found in backup set

ORA-06512: at "SYS.X$DBMS_BACKUP_RESTORE", line 5827

ORA-06512: at line 8

 

 

SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

[oracle@testdb 2015_04_30]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.3.0 Production on Thu Apr 30 16:57:46 2015

 

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

SQL> DECLARE

  2   devtype varchar2(256);

  3   done boolean;

  4   BEGIN

  5   devtype:=sys.dbms_backup_restore.deviceAllocate(type=>'',ident=>'T1');

  6   sys.dbms_backup_restore.restoreSetDatafile;

  7   sys.dbms_backup_restore.restoreControlfileTo(cfname=>'/tmp/2015_04_30/control01.ctl');

  8   sys.dbms_backup_restore.restoreBackupPiece(done=>done,handle=>'/tmp/2015_04_30/o1_mf_ncsnf_TAG20150430T160049_bn3rdxyz_.bkp', params=>null);

  9   sys.dbms_backup_restore.deviceDeallocate;

10   END;

11  /

 

PL/SQL procedure successfully completed.

 

SQL>

 

當合適的情況下,我們發現恢復了控制檔案了,接下來就是啟動資料庫到mount狀態了。

 

 

小插曲: 在同一個會話裡執行會報錯: ORA-19590: conversation already active,所以我整理了一下指令碼,如下,可以直接執行:

DECLARE

devtype varchar2(256);

done boolean;

BEGIN

devtype:=sys.dbms_backup_restore.deviceAllocate(type=>'',ident=>'T1');

sys.dbms_backup_restore.restoreSetDatafile;

sys.dbms_backup_restore.restoreControlfileTo(cfname=>'/tmp/2015_04_30/control01.ctl');

sys.dbms_backup_restore.restoreBackupPiece(done=>done,handle=>'/tmp/2015_04_30/o1_mf_annnn_TAG20150430T160048_bn3r9jd7_.bkp', params=>null);

sys.dbms_backup_restore.deviceDeallocate;

END;

/

conn / as sysdba

 

DECLARE

devtype varchar2(256);

done boolean;

BEGIN

devtype:=sys.dbms_backup_restore.deviceAllocate(type=>'',ident=>'T1');

sys.dbms_backup_restore.restoreSetDatafile;

sys.dbms_backup_restore.restoreControlfileTo(cfname=>'/tmp/2015_04_30/control01.ctl');

sys.dbms_backup_restore.restoreBackupPiece(done=>done,handle=>'/tmp/2015_04_30/o1_mf_annnn_TAG20150430T160239_bn3rdzd7_.bkp', params=>null);

sys.dbms_backup_restore.deviceDeallocate;

END;

/

conn / as sysdba

 

DECLARE

devtype varchar2(256);

done boolean;

BEGIN

devtype:=sys.dbms_backup_restore.deviceAllocate(type=>'',ident=>'T1');

sys.dbms_backup_restore.restoreSetDatafile;

sys.dbms_backup_restore.restoreControlfileTo(cfname=>'/tmp/2015_04_30/control01.ctl');

sys.dbms_backup_restore.restoreBackupPiece(done=>done,handle=>'/tmp/2015_04_30/o1_mf_ncsnf_TAG20150430T160049_bn3rdxyz_.bkp', params=>null);

sys.dbms_backup_restore.deviceDeallocate;

END;

/

 

 

conn / as sysdba

 

DECLARE

devtype varchar2(256);

done boolean;

BEGIN

devtype:=sys.dbms_backup_restore.deviceAllocate(type=>'',ident=>'T1');

sys.dbms_backup_restore.restoreSetDatafile;

sys.dbms_backup_restore.restoreControlfileTo(cfname=>'/tmp/2015_04_30/control01.ctl');

sys.dbms_backup_restore.restoreBackupPiece(done=>done,handle=>'/tmp/2015_04_30/o1_mf_nnndf_TAG20150430T160049_bn3r9ksp_.bkp', params=>null);

sys.dbms_backup_restore.deviceDeallocate;

END;

/

 

執行過程:

[oracle@testdb ora11g]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.3.0 Production on Thu Apr 30 19:13:05 2015

 

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

SQL> DECLARE

  2   devtype varchar2(256);

  3   done boolean;

  4   BEGIN

  5   devtype:=sys.dbms_backup_restore.deviceAllocate(type=>'',ident=>'T1');

  6   sys.dbms_backup_restore.restoreSetDatafile;

  7   sys.dbms_backup_restore.restoreControlfileTo(cfname=>'/tmp/2015_04_30/control01.ctl');

  8   sys.dbms_backup_restore.restoreBackupPiece(done=>done,handle=>'/tmp/2015_04_30/o1_mf_annnn_TAG20150430T160048_bn3r9jd7_.bkp', params=>null);

  9   sys.dbms_backup_restore.deviceDeallocate;

10   END;

11  /

DECLARE

*

ERROR at line 1:

ORA-19624: operation failed, retry possible

ORA-19870: error while restoring backup piece

/tmp/2015_04_30/o1_mf_annnn_TAG20150430T160048_bn3r9jd7_.bkp

ORA-19626: backup set type is archived log - can not be processed by this

conversation

ORA-06512: at "SYS.X$DBMS_BACKUP_RESTORE", line 5827

ORA-06512: at line 8

 

 

SQL> conn / as sysdba

 

Connected.

SQL> SQL> DECLARE

  2   devtype varchar2(256);

  3   done boolean;

  4   BEGIN

  5   devtype:=sys.dbms_backup_restore.deviceAllocate(type=>'',ident=>'T1');

  6   sys.dbms_backup_restore.restoreSetDatafile;

  7   sys.dbms_backup_restore.restoreControlfileTo(cfname=>'/tmp/2015_04_30/control01.ctl');

  8   sys.dbms_backup_restore.restoreBackupPiece(done=>done,handle=>'/tmp/2015_04_30/o1_mf_annnn_TAG20150430T160239_bn3rdzd7_.bkp', params=>null);

  9   sys.dbms_backup_restore.deviceDeallocate;

10   END;

11  /

DECLARE

*

ERROR at line 1:

ORA-19624: operation failed, retry possible

ORA-19870: error while restoring backup piece

/tmp/2015_04_30/o1_mf_annnn_TAG20150430T160239_bn3rdzd7_.bkp

ORA-19626: backup set type is archived log - can not be processed by this

conversation

ORA-06512: at "SYS.X$DBMS_BACKUP_RESTORE", line 5827

ORA-06512: at line 8

 

 

SQL> conn / as sysdba

 

Connected.

SQL> SQL> DECLARE

  2   devtype varchar2(256);

  3   done boolean;

  4   BEGIN

  5   devtype:=sys.dbms_backup_restore.deviceAllocate(type=>'',ident=>'T1');

  6   sys.dbms_backup_restore.restoreSetDatafile;

  7   sys.dbms_backup_restore.restoreControlfileTo(cfname=>'/tmp/2015_04_30/control01.ctl');

  8   sys.dbms_backup_restore.restoreBackupPiece(done=>done,handle=>'/tmp/2015_04_30/o1_mf_ncsnf_TAG20150430T160049_bn3rdxyz_.bkp', params=>null);

  9   sys.dbms_backup_restore.deviceDeallocate;

10   END;

11  /

 

 

conn / as sysdba

 

PL/SQL procedure successfully completed.

 

 

DECLARE

devtype varchar2(256);

done boolean;

BEGIN

Connected.

SQL> SQL>   2    3    4    5   devtype:=sys.dbms_backup_restore.deviceAllocate(type=>'',ident=>'T1');

  6   sys.dbms_backup_restore.restoreSetDatafile;

  7   sys.dbms_backup_restore.restoreControlfileTo(cfname=>'/tmp/2015_04_30/control01.ctl');

  8   sys.dbms_backup_restore.restoreBackupPiece(done=>done,handle=>'/tmp/2015_04_30/o1_mf_nnndf_TAG20150430T160049_bn3r9ksp_.bkp', params=>null);

  9   sys.dbms_backup_restore.deviceDeallocate;

10   END;

11  /

DECLARE

*

ERROR at line 1:

ORA-19697: standby control file not found in backup set

ORA-06512: at "SYS.X$DBMS_BACKUP_RESTORE", line 5827

ORA-06512: at line 8

 

 

SQL>

 

 

控制檔案恢復了,接下來的操作就容易的多了。

一、 啟動資料庫到mount狀態

 

[oracle@testdb dbs]$ more  initora11g.ora

db_name=ora11g

control_files='/u01/app/oracle/oradata/ora11g/control01.ctl','/u01/app/oracle/flash_recovery_area/ora11g/control02.ctl'

[oracle@testdb 2015_04_30]$ ll

total 1215816

-rw-r-----. 1 oracle oinstall    9748480 Apr 30 16:57 control01.ctl

-rw-r-----. 1 oracle oinstall   12173312 Apr 30 16:06 o1_mf_annnn_TAG20150430T160048_bn3r9jd7_.bkp

-rw-r-----. 1 oracle oinstall      19968 Apr 30 16:06 o1_mf_annnn_TAG20150430T160239_bn3rdzd7_.bkp

-rw-r-----. 1 oracle oinstall    9830400 Apr 30 16:06 o1_mf_ncsnf_TAG20150430T160049_bn3rdxyz_.bkp

-rw-r-----. 1 oracle oinstall 1213218816 Apr 30 16:06 o1_mf_nnndf_TAG20150430T160049_bn3r9ksp_.bkp

[oracle@testdb 2015_04_30]$ cp control01.ctl /u01/app/oracle/oradata/ora11g/control01.ctl

cp: cannot create regular file `/u01/app/oracle/oradata/ora11g/control01.ctl': No such file or directory

[oracle@testdb 2015_04_30]$ mkdir -p /u01/app/oracle/oradata/ora11g

[oracle@testdb 2015_04_30]$ cp control01.ctl /u01/app/oracle/oradata/ora11g/control01.ctl

[oracle@testdb 2015_04_30]$ cp control01.ctl /u01/app/oracle/flash_recovery_area/ora11g/control02.ctl

[oracle@testdb 2015_04_30]$

[oracle@testdb 2015_04_30]$

[oracle@testdb 2015_04_30]$

[oracle@testdb 2015_04_30]$ echo $ORACLE_SID

ora11g

[oracle@testdb 2015_04_30]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.3.0 Production on Thu Apr 30 17:03:14 2015

 

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

SQL> shutdown abort;

ORACLE instance shut down.

SQL> startup mount;

ORACLE instance started.

 

Total System Global Area  250560512 bytes

Fixed Size                  2227256 bytes

Variable Size             192938952 bytes

Database Buffers           50331648 bytes

Redo Buffers                5062656 bytes

Database mounted.

SQL>

SQL> col FILE_NAME format a50

SQL> select file#,name FILE_NAME,status from v$datafile;

 

     FILE# FILE_NAME                                          STATUS

---------- -------------------------------------------------- -------

         1 /u01/app/oracle/oradata/ora11g/system01.dbf        SYSTEM

         2 /u01/app/oracle/oradata/ora11g/sysaux01.dbf        ONLINE

         3 /u01/app/oracle/oradata/ora11g/undotbs01.dbf       ONLINE

         4 /u01/app/oracle/oradata/ora11g/users01.dbf         ONLINE

         5 /u01/app/oracle/oradata/ora11g/example01.dbf       ONLINE

 

 

 

 

 

二、 重新註冊備份集,還原spfile,還原資料庫,不完全恢復資料庫

將控制檔案中的原庫備份資訊刪除,然後重新註冊備份集。

[oracle@testdb 2015_04_30]$ rman target /

 

Recovery Manager: Release 11.2.0.3.0 - Production on Thu Apr 30 17:06:33 2015

 

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database: ORA11G (DBID=4270446895, not open)

 

RMAN> list backupset;

 

using target database control file instead of recovery catalog

 

List of Backup Sets

===================

 

 

BS Key  Size       Device Type Elapsed Time Completion Time

------- ---------- ----------- ------------ ---------------

1       11.61M     DISK        00:00:00     30-APR-15     

        BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20150430T160048

        Piece Name: /u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_04_30/o1_mf_annnn_TAG20150430T160048_bn3r9jd7_.bkp

 

  List of Archived Logs in backup set 1

  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time

  ---- ------- ---------- --------- ---------- ---------

  1    6       1087169    13-MAR-15 1094093    30-APR-15

  1    7       1094093    30-APR-15 1094096    30-APR-15

  1    8       1094096    30-APR-15 1094204    30-APR-15

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

2       Full    1.13G      DISK        00:01:43     30-APR-15     

        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20150430T160049

        Piece Name: /u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_04_30/o1_mf_nnndf_TAG20150430T160049_bn3r9ksp_.bkp

  List of Datafiles in backup set 2

  File LV Type Ckp SCN    Ckp Time  Name

  ---- -- ---- ---------- --------- ----

  1       Full 1094214    30-APR-15 /u01/app/oracle/oradata/ora11g/system01.dbf

  2       Full 1094214    30-APR-15 /u01/app/oracle/oradata/ora11g/sysaux01.dbf

  3       Full 1094214    30-APR-15 /u01/app/oracle/oradata/ora11g/undotbs01.dbf

  4       Full 1094214    30-APR-15 /u01/app/oracle/oradata/ora11g/users01.dbf

  5       Full 1092435    30-APR-15 /u01/app/oracle/oradata/ora11g/example01.dbf

 

 

RMAN> delete backupset;

 

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=170 device type=DISK

 

List of Backup Pieces

BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name

------- ------- --- --- ----------- ----------- ----------

1       1       1   1   AVAILABLE   DISK        /u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_04_30/o1_mf_annnn_TAG20150430T160048_bn3r9jd7_.bkp

2       2       1   1   AVAILABLE   DISK        /u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_04_30/o1_mf_nnndf_TAG20150430T160049_bn3r9ksp_.bkp

 

Do you really want to delete the above objects (enter YES or NO)? yes

 

RMAN-06207: WARNING: 2 objects could not be deleted for DISK channel(s) due

RMAN-06208:          to mismatched status.  Use CROSSCHECK command to fix status

RMAN-06210: List of Mismatched objects

RMAN-06211: ==========================

RMAN-06212:   Object Type   Filename/Handle

RMAN-06213: --------------- ---------------------------------------------------

RMAN-06214: Backup Piece    /u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_04_30/o1_mf_annnn_TAG20150430T160048_bn3r9jd7_.bkp

RMAN-06214: Backup Piece    /u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_04_30/o1_mf_nnndf_TAG20150430T160049_bn3r9ksp_.bkp

 

 

 

RMAN> crosscheck backupset;

 

using channel ORA_DISK_1

crosschecked backup piece: found to be 'EXPIRED'

backup piece handle=/u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_04_30/o1_mf_annnn_TAG20150430T160048_bn3r9jd7_.bkp RECID=1 STAMP=878400048

crosschecked backup piece: found to be 'EXPIRED'

backup piece handle=/u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_04_30/o1_mf_nnndf_TAG20150430T160049_bn3r9ksp_.bkp RECID=2 STAMP=878400049

Crosschecked 2 objects

 

 

RMAN> list backupset;

 

 

List of Backup Sets

===================

 

 

BS Key  Size       Device Type Elapsed Time Completion Time

------- ---------- ----------- ------------ ---------------

1       11.61M     DISK        00:00:00     30-APR-15     

        BP Key: 1   Status: EXPIRED  Compressed: NO  Tag: TAG20150430T160048

        Piece Name: /u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_04_30/o1_mf_annnn_TAG20150430T160048_bn3r9jd7_.bkp

 

  List of Archived Logs in backup set 1

  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time

  ---- ------- ---------- --------- ---------- ---------

  1    6       1087169    13-MAR-15 1094093    30-APR-15

  1    7       1094093    30-APR-15 1094096    30-APR-15

  1    8       1094096    30-APR-15 1094204    30-APR-15

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

2       Full    1.13G      DISK        00:01:43     30-APR-15     

        BP Key: 2   Status: EXPIRED Compressed: NO  Tag: TAG20150430T160049

        Piece Name: /u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_04_30/o1_mf_nnndf_TAG20150430T160049_bn3r9ksp_.bkp

  List of Datafiles in backup set 2

  File LV Type Ckp SCN    Ckp Time  Name

  ---- -- ---- ---------- --------- ----

  1       Full 1094214    30-APR-15 /u01/app/oracle/oradata/ora11g/system01.dbf

  2       Full 1094214    30-APR-15 /u01/app/oracle/oradata/ora11g/sysaux01.dbf

  3       Full 1094214    30-APR-15 /u01/app/oracle/oradata/ora11g/undotbs01.dbf

  4       Full 1094214    30-APR-15 /u01/app/oracle/oradata/ora11g/users01.dbf

  5       Full 1092435    30-APR-15 /u01/app/oracle/oradata/ora11g/example01.dbf

 

RMAN> delete backupset;

 

using channel ORA_DISK_1

 

List of Backup Pieces

BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name

------- ------- --- --- ----------- ----------- ----------

1       1       1   1   EXPIRED     DISK        /u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_04_30/o1_mf_annnn_TAG20150430T160048_bn3r9jd7_.bkp

2       2       1   1   EXPIRED     DISK        /u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_04_30/o1_mf_nnndf_TAG20150430T160049_bn3r9ksp_.bkp

 

Do you really want to delete the above objects (enter YES or NO)? yes

deleted backup piece

backup piece handle=/u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_04_30/o1_mf_annnn_TAG20150430T160048_bn3r9jd7_.bkp RECID=1 STAMP=878400048

deleted backup piece

backup piece handle=/u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_04_30/o1_mf_nnndf_TAG20150430T160049_bn3r9ksp_.bkp RECID=2 STAMP=878400049

Deleted 2 objects

 

 

RMAN> list backupset;

 

specification does not match any backup in the repository

 

RMAN> catalog start with '/tmp/2015_04_30/';

 

searching for all files that match the pattern /tmp/2015_04_30/

 

List of Files Unknown to the Database

=====================================

File Name: /tmp/2015_04_30/o1_mf_annnn_TAG20150430T160048_bn3r9jd7_.bkp

File Name: /tmp/2015_04_30/o1_mf_nnndf_TAG20150430T160049_bn3r9ksp_.bkp

File Name: /tmp/2015_04_30/o1_mf_ncsnf_TAG20150430T160049_bn3rdxyz_.bkp

File Name: /tmp/2015_04_30/o1_mf_annnn_TAG20150430T160239_bn3rdzd7_.bkp

File Name: /tmp/2015_04_30/control01.ctl

 

Do you really want to catalog the above files (enter YES or NO)? yes

cataloging files...

cataloging done

 

List of Cataloged Files

=======================

File Name: /tmp/2015_04_30/o1_mf_annnn_TAG20150430T160048_bn3r9jd7_.bkp

File Name: /tmp/2015_04_30/o1_mf_nnndf_TAG20150430T160049_bn3r9ksp_.bkp

File Name: /tmp/2015_04_30/o1_mf_ncsnf_TAG20150430T160049_bn3rdxyz_.bkp

File Name: /tmp/2015_04_30/o1_mf_annnn_TAG20150430T160239_bn3rdzd7_.bkp

File Name: /tmp/2015_04_30/control01.ctl

 

RMAN> list backupset;

 

 

List of Backup Sets

===================

 

 

BS Key  Size       Device Type Elapsed Time Completion Time

------- ---------- ----------- ------------ ---------------

3       11.61M     DISK        00:00:00     30-APR-15     

        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20150430T160048

        Piece Name: /tmp/2015_04_30/o1_mf_annnn_TAG20150430T160048_bn3r9jd7_.bkp

 

  List of Archived Logs in backup set 3

  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time

  ---- ------- ---------- --------- ---------- ---------

  1    6       1087169    13-MAR-15 1094093    30-APR-15

  1    7       1094093    30-APR-15 1094096    30-APR-15

  1    8       1094096    30-APR-15 1094204    30-APR-15

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

4       Full    1.13G      DISK        00:00:00     30-APR-15     

        BP Key: 4   Status: AVAILABLE  Compressed: NO  Tag: TAG20150430T160049

        Piece Name: /tmp/2015_04_30/o1_mf_nnndf_TAG20150430T160049_bn3r9ksp_.bkp

  List of Datafiles in backup set 4

  File LV Type Ckp SCN    Ckp Time  Name

  ---- -- ---- ---------- --------- ----

  1       Full 1094214    30-APR-15 /u01/app/oracle/oradata/ora11g/system01.dbf

  2       Full 1094214    30-APR-15 /u01/app/oracle/oradata/ora11g/sysaux01.dbf

  3       Full 1094214    30-APR-15 /u01/app/oracle/oradata/ora11g/undotbs01.dbf

  4       Full 1094214    30-APR-15 /u01/app/oracle/oradata/ora11g/users01.dbf

  5       Full 1092435    30-APR-15 /u01/app/oracle/oradata/ora11g/example01.dbf

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

5       Full    9.36M      DISK        00:00:00     30-APR-15     

        BP Key: 5   Status: AVAILABLE  Compressed: NO  Tag: TAG20150430T160049

        Piece Name: /tmp/2015_04_30/o1_mf_ncsnf_TAG20150430T160049_bn3rdxyz_.bkp

  SPFILE Included: Modification time: 30-APR-15

  SPFILE db_unique_name: ORA11G

  Control File Included: Ckp SCN: 1094280      Ckp time: 30-APR-15

 

BS Key  Size       Device Type Elapsed Time Completion Time

------- ---------- ----------- ------------ ---------------

6       19.00K     DISK        00:00:00     30-APR-15     

        BP Key: 6   Status: AVAILABLE  Compressed: NO  Tag: TAG20150430T160239

        Piece Name: /tmp/2015_04_30/o1_mf_annnn_TAG20150430T160239_bn3rdzd7_.bkp

 

  List of Archived Logs in backup set 6

  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time

  ---- ------- ---------- --------- ---------- ---------

  1    9       1094204    30-APR-15 1094286    30-APR-15

 

 

 

RMAN> restore spfile from '/tmp/2015_04_30/o1_mf_ncsnf_TAG20150430T160049_bn3rdxyz_.bkp';

 

Starting restore at 30-APR-15

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=179 device type=DISK

 

channel ORA_DISK_1: restoring spfile from AUTOBACKUP /tmp/2015_04_30/o1_mf_ncsnf_TAG20150430T160049_bn3rdxyz_.bkp

channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete

Finished restore at 30-APR-15

 

RMAN>

 

 

 

RMAN> restore database;

 

Starting restore at 30-APR-15

using channel ORA_DISK_1

 

channel ORA_DISK_1: starting datafile backup set restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/ora11g/system01.dbf

channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/ora11g/sysaux01.dbf

channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/ora11g/undotbs01.dbf

channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/ora11g/users01.dbf

channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/ora11g/example01.dbf

channel ORA_DISK_1: reading from backup piece /tmp/2015_04_30/o1_mf_nnndf_TAG20150430T160049_bn3r9ksp_.bkp

channel ORA_DISK_1: piece handle=/tmp/2015_04_30/o1_mf_nnndf_TAG20150430T160049_bn3r9ksp_.bkp tag=TAG20150430T160049

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:01:15

Finished restore at 30-APR-15

 

 

 

 

 

先嚐試做完全恢復,等到報錯再做不完全恢復:

 

RMAN> recover database;

 

Starting recover at 30-APR-15

using channel ORA_DISK_1

datafile 5 not processed because file is read-only

 

starting media recovery

 

channel ORA_DISK_1: starting archived log restore to default destination

channel ORA_DISK_1: restoring archived log

archived log thread=1 sequence=9

channel ORA_DISK_1: reading from backup piece /tmp/2015_04_30/o1_mf_annnn_TAG20150430T160239_bn3rdzd7_.bkp

channel ORA_DISK_1: piece handle=/tmp/2015_04_30/o1_mf_annnn_TAG20150430T160239_bn3rdzd7_.bkp tag=TAG20150430T160239

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

archived log file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_9_874246769.dbf thread=1 sequence=9

unable to find archived log

archived log thread=1 sequence=10

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of recover command at 04/30/2015 17:11:33

RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 10 and starting SCN of 1094286

 

RMAN> recover database until sequence 10;

 

Starting recover at 30-APR-15

using channel ORA_DISK_1

datafile 5 not processed because file is read-only

 

starting media recovery

media recovery complete, elapsed time: 00:00:00

 

Finished recover at 30-APR-15

 

 

RMAN> alter database open resetlogs;

 

database opened

 

RMAN>

RMAN> shutdown abort;

 

Oracle instance shut down

 

RMAN> exit

 

 

Recovery Manager complete.

 

 

 這裡恢復到10號停止了,10號檔案很有可能丟失或者是線上日誌,如果是線上日誌,且線上日誌可以找到,那麼我們就可以做完全恢復了,不用丟失資料了,這裡不演示了,在其它方法中演示。這裡我們重新啟動資料庫就會以spfile來啟動資料庫了,當然不建議使用shutdown abort來強制關庫:

 

[oracle@testdb 2015_04_30]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.3.0 Production on Thu Apr 30 17:42:20 2015

 

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

 

Connected to an idle instance.

 

 

SQL> startup

ORACLE instance started.

 

Total System Global Area  409194496 bytes

Fixed Size                  2228864 bytes

Variable Size             276827520 bytes

Database Buffers          121634816 bytes

Redo Buffers                8503296 bytes

Database mounted.

Database opened.

 

SQL> show parameter spfile

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

spfile                               string      /u01/app/oracle/product/11.2.0

                                                 /dbhome_1/dbs/spfileora11g.ora

SQL>

 

SQL>

SQL> select file#,name FILE_NAME  from v$dbfile;

 

     FILE# FILE_NAME

---------- --------------------------------------------------

         4 /u01/app/oracle/oradata/ora11g/users01.dbf

         3 /u01/app/oracle/oradata/ora11g/undotbs01.dbf

         2 /u01/app/oracle/oradata/ora11g/sysaux01.dbf

         1 /u01/app/oracle/oradata/ora11g/system01.dbf

         5 /u01/app/oracle/oradata/ora11g/example01.dbf

 

SQL>

SQL> col FILE_NAME format a50

SQL> select FILE_NAME,FILE_ID,a.TABLESPACE_NAME, b.status ts_status ,BYTES from dba_data_files a,dba_tablespaces b where a.TABLESPACE_NAME=b.TABLESPACE_NAME;

 

FILE_NAME                                             FILE_ID TABLESPACE_NAME                TS_STATUS      BYTES

-------------------------------------------------- ---------- ------------------------------ --------- ----------

/u01/app/oracle/oradata/ora11g/users01.dbf                  4 USERS                          ONLINE       5242880

/u01/app/oracle/oradata/ora11g/undotbs01.dbf                3 UNDOTBS1                       ONLINE      99614720

/u01/app/oracle/oradata/ora11g/sysaux01.dbf                 2 SYSAUX                         ONLINE     566231040

/u01/app/oracle/oradata/ora11g/system01.dbf                 1 SYSTEM                         ONLINE     744488960

/u01/app/oracle/oradata/ora11g/example01.dbf                5 EXAMPLE                        READ ONLY  328335360

 

 

 

17:50:35 SQL> select count(1) from lhr.test;

 

  COUNT(1)

----------

     75204

 

17:50:44 SQL>

 

 

 

好,資料庫已經恢復,後邊要做的就是備份新庫等其他操作,這裡就不演示了,至於第二種辦法且看下一篇blog。

 

 

 

在上一篇blog中我們介紹了採用dbms_backup_restore來找回控制檔案並恢復整個資料庫的方法,本篇blog我們介紹採用建立臨時庫來找回控制檔案的方法。


1.1.1  方法二:嘗試採用建立臨時庫來找回控制檔案

 

由於RMAN必須工作在MOUNT模式,所有的資料檔案都丟失,無法透過只重建控制檔案將其啟動到MOUNT模式,所以這裡利用dbca建立一個臨時資料庫環境,資料庫的名稱與原有名稱保持不變,檔案存放到預設位置即可。

 

一、 搭建臨時庫來註冊備份集

這裡我們假設有一個臨時環境供我們測試,ORACLE_SID=orcltest,由於是第二天做的測試,所以我重新對原庫做了備份並傳遞到備份庫

[root@rhel6_lhr backupset]#  scp -r 2015_05_02 oracle@192.168.59.129:/tmp

oracle@192.168.59.129's password:

o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp                                                                                                                                    100% 9728     9.5KB/s   00:00   

o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp                                                                                                                                    100%  236MB   6.6MB/s   00:36   

o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp                                                                                                                                    100% 1096MB  54.8MB/s   00:20   

o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp                                                                                                                                    100%   10MB   9.8MB/s   00:00   

o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp                                                                                                                                    100% 9600KB   9.4MB/s   00:00   

[root@rhel6_lhr backupset]#

[root@rhel6_lhr 2015_05_02]# ll -h

total 1.4G

-rw-r----- 1 oracle asmadmin 9.9M May  2 11:23 o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp

-rw-r----- 1 oracle asmadmin 9.5K May  2 11:31 o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp

-rw-r----- 1 oracle asmadmin 9.4M May  2 11:31 o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp

-rw-r----- 1 oracle asmadmin 236M May  2 10:56 o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp

-rw-r----- 1 oracle asmadmin 1.1G May  2 11:31 o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp

 

 

由下邊的方法(備份集中無控制檔案的備份)的方法得知,這裡建立一個臨時庫的方法比較麻煩,不太推薦:

 

[oracle@orcltest tmp]$ dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname orcltest -sid orcltest -sysPassword lhr -systemPassword lhr -responseFile NO_VALUE -datafileDestination /u02/app/oracle/oradata -redoLogFileSize 50 -recoveryAreaDestination /u02/app/oracle/flash_recovery_area -storageType FS -characterSet ZHS16GBK -nationalCharacterSet AL16UTF16 -sampleSchema true -memoryPercentage 30 -totalMemory 200 -databaseType OLTP -emConfiguration NONE  -automaticMemoryManagement true

Copying database files

1% complete

3% complete

10% complete

17% complete

24% complete

35% complete

Creating and starting Oracle instance

37% complete

42% complete

47% complete

52% complete

53% complete

56% complete

58% complete

Registering database with Oracle Restart

64% complete

Completing Database Creation

68% complete

71% complete

75% complete

85% complete

96% complete

100% complete

Look at the log file "/u02/app/oracle/cfgtoollogs/dbca/orcltest/orcltest0.log" for further details.

[oracle@orcltest tmp]$ crsstat

Name                           Type                       Target     State      Host      

------------------------------ -------------------------- ---------- ---------  -------  

ora.DATA.dg                    ora.diskgroup.type         ONLINE     ONLINE     orcltest 

ora.LISTENER.lsnr              ora.listener.type          ONLINE     ONLINE     orcltest 

ora.asm                        ora.asm.type               ONLINE     ONLINE     orcltest 

ora.cssd                       ora.cssd.type              ONLINE     ONLINE     orcltest 

ora.diskmon                    ora.diskmon.type           OFFLINE    OFFLINE             

ora.evmd                       ora.evm.type               ONLINE     ONLINE     orcltest 

ora.ons                        ora.ons.type               OFFLINE    OFFLINE             

ora.orcltest.db                ora.database.type          ONLINE     ONLINE     orcltest 

 

[oracle@orcltest 2015_05_02]$ ll

total 1383664

-rw-r----- 1 oracle oinstall   10278400 May  2 11:34 o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp

-rw-r----- 1 oracle oinstall       9728 May  2 11:33 o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp

-rw-r----- 1 oracle oinstall    9830400 May  2 11:34 o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp

-rw-r----- 1 oracle oinstall  247463936 May  2 11:34 o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp

-rw-r----- 1 oracle oinstall 1149280256 May  2 11:34 o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp

[oracle@orcltest 2015_05_02]$ ORACLE_SID=orcltest

[oracle@orcltest 2015_05_02]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.3.0 Production on Sat May 2 11:36:51 2015

 

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

[oracle@orcltest 2015_05_02]$

 

[oracle@orcltest 2015_05_02]$  rman target /

 

Recovery Manager: Release 11.2.0.3.0 - Production on Sat May 2 11:37:24 2015

 

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database: ORCLTEST (DBID=2626150865)

 

RMAN> list backupset;

 

specification does not match any backup in the repository

 

RMAN>

 

RMAN> catalog start with '/tmp/2015_05_02/';

 

using target database control file instead of recovery catalog

searching for all files that match the pattern /tmp/2015_05_02/

 

List of Files Unknown to the Database

=====================================

File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp

File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp

File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp

File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp

File Name: /tmp/2015_05_02/o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp

 

Do you really want to catalog the above files (enter YES or NO)? yes

cataloging files...

no files cataloged

 

List of Files Which Where Not Cataloged

=======================================

File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp

  RMAN-07518: Reason: Foreign database file DBID: 4270446895 Database Name: ORA11G

File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp

  RMAN-07518: Reason: Foreign database file DBID: 4270446895  Database Name: ORA11G

File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp

  RMAN-07518: Reason: Foreign database file DBID: 4270446895  Database Name: ORA11G

File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp

  RMAN-07518: Reason: Foreign database file DBID: 4270446895  Database Name: ORA11G

File Name: /tmp/2015_05_02/o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp

  RMAN-07518: Reason: Foreign database file DBID: 4270446895  Database Name: ORA11G

 

RMAN>

 

RMAN> catalog backuppiece '/tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp';

 

ORA-19870: error while restoring backup piece /tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp

ORA-19691: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp is from different database: id=4270446895, name=ORA11G

 

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of catalog command at 05/02/2015 11:40:26

RMAN-06209: List of failed objects

RMAN-06211: ==========================

RMAN-06212:   Object Type   Filename/Handle

RMAN-06213: --------------- ---------------------------------------------------

RMAN-06214: Backup Piece    /tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp

 

RMAN>

 

 

RMAN>

 

由此可以看出,命令catalog start with '/tmp/2015_05_02/'; 在異庫註冊可以檢視到原庫的資訊:DBID: 4270446895  Database Name: ORA11G,(10g下測試也可以獲取到這些資訊)這裡dbnamedbid都不一樣所以不能註冊在該資料庫下,將備份片的資訊加入到控制檔案的時候報錯,原因在於原有資料庫和臨時資料庫的DBID不同,那麼我們是否可以嘗試修改臨時資料庫的DBID,使它與原有資料庫DBID保持一致呢,試試唄。

 

1、 修改dbnamedbid

 

首先啟動臨時庫到open read only狀態,然後執行指令碼:

[oracle@orcltest dbs]$ ORACLE_SID=orcltest

[oracle@orcltest dbs]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.3.0 Production on Sat May 2 12:56:05 2015

 

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup open read only;

ORACLE instance started.

 

Total System Global Area  409194496 bytes

Fixed Size                  2228864 bytes

Variable Size             281021824 bytes

Database Buffers          117440512 bytes

Redo Buffers                8503296 bytes

Database mounted.

Database opened.

SQL> @?/dbs/change_dbid.sql

 

PL/SQL procedure successfully completed.

 

 

OLD_NAME

--------------------------------

ORCLTEST

 

Enter the new Database Name:ORA11G

Enter the new Database ID:4270446895

 

PL/SQL procedure successfully completed.

 

 

PL/SQL procedure successfully completed.

 

Convert ORCLTEST(2626156129) to ORA11G(4270446895)

 

PL/SQL procedure successfully completed.

 

ControlFile:

=> Change Name:1

=> Change DBID:1

DataFile: /u02/app/oracle/oradata/orcltest/system01.dbf

=> Skipped:0

=> Change Name:1

=> Change DBID:1

DataFile: /u02/app/oracle/oradata/orcltest/sysaux01.dbf

=> Skipped:0

=> Change Name:1

=> Change DBID:1

DataFile: /u02/app/oracle/oradata/orcltest/undotbs01.dbf

=> Skipped:0

=> Change Name:1

=> Change DBID:1

DataFile: /u02/app/oracle/oradata/orcltest/users01.dbf

=> Skipped:0

=> Change Name:1

=> Change DBID:1

DataFile: /u02/app/oracle/oradata/orcltest/example01.dbf

=> Skipped:0

=> Change Name:1

=> Change DBID:1

DataFile: /u02/app/oracle/oradata/orcltest/temp01.dbf

=> Skipped:0

=> Change Name:1

=> Change DBID:1

 

PL/SQL procedure successfully completed.

 

SQL> create pfile from spfile;

 

File created.

 

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

 

SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

[oracle@orcltest dbs]$ ll

total 52

-rw-r--r-- 1 oracle oinstall 2239 May  2 12:33 change_dbid.sql

-rw-rw---- 1 oracle oinstall 1544 May  2 10:56 hc_DBUA5452531.dat

-rw-rw---- 1 oracle oinstall 1544 May  2 12:45 hc_ORA11G.dat

-rw-rw---- 1 oracle oinstall 1544 May  2 12:56 hc_orcltest.dat

-rw-r----- 1 oracle oinstall  165 May  2 10:54 initDBUA5452531.ora

-rw-r--r-- 1 oracle oinstall 2851 May 15  2009 init.ora

-rw-r--r-- 1 oracle oinstall  640 May  2 12:10 initORA11G.ora

-rw-r--r-- 1 oracle oinstall  997 May  2 12:58 initorcltest.ora

-rw-r----- 1 oracle oinstall    0 May  2 10:55 lkinstDBUA5452531

-rw-r----- 1 oracle oinstall   24 May  2 12:10 lkORA11G

-rw-r----- 1 oracle oinstall   24 Apr 21 16:27 lkORCLTEST

-rw-r----- 1 oracle oinstall 1536 May  2 10:54 orapwDBUA5452531

-rw-r----- 1 oracle oinstall 1536 May  2 12:53 orapworcltest

-rw-r----- 1 oracle oinstall 3584 May  2 12:57 spfileorcltest.ora

[oracle@orcltest dbs]$ vi initorcltest.ora

。。。。

 

*.db_name='ORA11G'

。。。。

[oracle@orcltest dbs]$ mv initorcltest.ora initORA11G.ora

[oracle@orcltest dbs]$ ORACLE_SID=ORA11G

[oracle@orcltest dbs]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.3.0 Production on Sat May 2 13:04:44 2015

 

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

SQL> startup mount;

ORACLE instance started.

 

Total System Global Area  409194496 bytes

Fixed Size                  2228864 bytes

Variable Size             272633216 bytes

Database Buffers          125829120 bytes

Redo Buffers                8503296 bytes

Database mounted.

SQL> alter database open resetlogs;

 

Database altered.

 

SQL> select dbid,name from v$database;

 

      DBID NAME

---------- ---------

4270446895 ORA11G

 

SQL>

 

好了,和原庫一樣了,現在我們重新註冊

2、 重新註冊

 

[oracle@orcltest dbs]$ORACLE_SID=ORA11G

[oracle@orcltest dbs]$ rman target /

 

Recovery Manager: Release 11.2.0.3.0 - Production on Sat May 2 13:10:35 2015

 

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database: ORA11G (DBID=4270446895)

 

RMAN> catalog start with '/tmp/2015_05_02/';

 

using target database control file instead of recovery catalog

searching for all files that match the pattern /tmp/2015_05_02/

 

List of Files Unknown to the Database

=====================================

File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp

File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp

File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp

File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp

File Name: /tmp/2015_05_02/o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp

 

Do you really want to catalog the above files (enter YES or NO)? yes

cataloging files...

cataloging done

 

List of Cataloged Files

=======================

File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp

File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp

File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp

File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp

File Name: /tmp/2015_05_02/o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp

 

RMAN>

 

成功註冊,接下來就簡單了,檢視備份集中含有哪些內容

 

RMAN> list backupset;

 

 

List of Backup Sets

===================

 

 

BS Key  Size       Device Type Elapsed Time Completion Time

------- ---------- ----------- ------------ ---------------

1       9.00K      DISK        00:00:00     02-MAY-15     

        BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20150502T113152

        Piece Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp

 

  List of Archived Logs in backup set 1

  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time

  ---- ------- ---------- --------- ---------- ---------

  1    15      1145640    02-MAY-15 1145812    02-MAY-15

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

2       Full    235.99M    DISK        00:00:00     02-MAY-15     

        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20150502T105103

        Piece Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp

  List of Datafiles in backup set 2

  File LV Type Ckp SCN    Ckp Time  Name

  ---- -- ---- ---------- --------- ----

  1       Full 1122334    02-MAY-15 /u02/app/oracle/oradata/orcltest/system01.dbf

  2       Full 1122334    02-MAY-15 /u02/app/oracle/oradata/orcltest/sysaux01.dbf

  3       Full 1122334    02-MAY-15 /u02/app/oracle/oradata/orcltest/undotbs01.dbf

  4       Full 1122334    02-MAY-15 /u02/app/oracle/oradata/orcltest/users01.dbf

  5       Full 1092435    30-APR-15 /u02/app/oracle/oradata/orcltest/example01.dbf

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

3       Full    1.07G      DISK        00:00:00     02-MAY-15     

        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20150502T112355

        Piece Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp

  List of Datafiles in backup set 3

  File LV Type Ckp SCN    Ckp Time  Name

  ---- -- ---- ---------- --------- ----

  1       Full 1145650    02-MAY-15 /u02/app/oracle/oradata/orcltest/system01.dbf

  2       Full 1145650    02-MAY-15 /u02/app/oracle/oradata/orcltest/sysaux01.dbf

  3       Full 1145650    02-MAY-15 /u02/app/oracle/oradata/orcltest/undotbs01.dbf

  4       Full 1145650    02-MAY-15 /u02/app/oracle/oradata/orcltest/users01.dbf

  5       Full 1092435    30-APR-15 /u02/app/oracle/oradata/orcltest/example01.dbf

 

BS Key  Size       Device Type Elapsed Time Completion Time

------- ---------- ----------- ------------ ---------------

4       9.80M      DISK        00:00:00     02-MAY-15     

        BP Key: 4   Status: AVAILABLE  Compressed: NO  Tag: TAG20150502T112352

        Piece Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp

 

  List of Archived Logs in backup set 4

  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time

  ---- ------- ---------- --------- ---------- ---------

  1    13      1122206    02-MAY-15 1145003    02-MAY-15

  1    14      1145003    02-MAY-15 1145640    02-MAY-15

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

5       Full    9.36M      DISK        00:00:00     02-MAY-15     

        BP Key: 5   Status: AVAILABLE  Compressed: NO  Tag: TAG20150502T112355

        Piece Name: /tmp/2015_05_02/o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp

  SPFILE Included: Modification time: 02-MAY-15

  SPFILE db_unique_name: ORA11G

  Control File Included: Ckp SCN: 1145807      Ckp time: 02-MAY-15

 

RMAN>

 

我們可以看到,控制檔案和spfile都在備份檔案: /tmp/2015_05_02/o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp 中,有歸檔檔案,有資料檔案,此時我們就可以考慮還原策略了,我們可以使用備份中的spfile和控制檔案,也可以只還原資料檔案,這個根據自己的需要而定,這裡我們測試的話就從spfilecontrol filedatafile都還原吧。

 

二、 還原操作 1、 還原spfile

 

RMAN> restore spfile from '/tmp/2015_05_02/o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp';

 

Starting restore at 02-MAY-15

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=144 device type=DISK

 

channel ORA_DISK_1: restoring spfile from AUTOBACKUP /tmp/2015_05_02/o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp

channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete

Finished restore at 02-MAY-15

 

RMAN>

 

[oracle@orcltest ~]$ cd $ORACLE_HOME/dbs

[oracle@orcltest dbs]$ ll spfile*

-rw-r----- 1 oracle oinstall 2560 May  2 13:21 spfileORA11G.ora

-rw-r----- 1 oracle oinstall 3584 May  2 12:57 spfileorcltest.ora

[oracle@orcltest dbs]$

 

 

2、 還原控制檔案

 

RMAN> restore controlfile  to '/tmp/2015_05_02/cont.ctl'  from '/tmp/2015_05_02/o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp';

 

Starting restore at 02-MAY-15

using channel ORA_DISK_1

 

channel ORA_DISK_1: restoring control file

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

Finished restore at 02-MAY-15

 

RMAN>

 

這裡可以採用原資料庫的控制檔案,即現在還原出來的控制檔案,也可以採用目前臨時庫的控制檔案,都可以,當然,如果備份集中沒有控制檔案的備份的話我們可以考慮  採用臨時庫的控制檔案,或者備份片段中沒有控制檔案的備份 這個方法。

 

3、 還原database

這裡分情況,如果採用原庫的控制檔案的話,我們可以這樣還原:

 

①、 方法一:採用原庫控制檔案--推薦

 

將原庫控制檔案複製到pfile定義的相關目錄:

[oracle@orcltest orcltest]$ cp /tmp/2015_05_02/cont.ctl /u02/app/oracle/flash_recovery_area/orcltest/control02.ctl

[oracle@orcltest orcltest]$ cp /tmp/2015_05_02/cont.ctl /u02/app/oracle/oradata/orcltest/control01.ctl

[oracle@orcltest orcltest]$ cd /u01/app/oracle/oradata/ora11g/

[oracle@orcltest dbs]$ rman target /

 

Recovery Manager: Release 11.2.0.3.0 - Production on Sat May 2 13:32:55 2015

 

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database: ORA11G (DBID=4270446895, not open)

 

RMAN> list backupset;

 

using target database control file instead of recovery catalog

 

List of Backup Sets

===================

 

 

BS Key  Size       Device Type Elapsed Time Completion Time

------- ---------- ----------- ------------ ---------------

6       9.80M      DISK        00:00:00     02-MAY-15     

        BP Key: 6   Status: AVAILABLE  Compressed: NO  Tag: TAG20150502T112352

        Piece Name: /u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_05_02/o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp

 

  List of Archived Logs in backup set 6

  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time

  ---- ------- ---------- --------- ---------- ---------

  1    13      1122206    02-MAY-15 1145003    02-MAY-15

  1    14      1145003    02-MAY-15 1145640    02-MAY-15

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

7       Full    1.07G      DISK        00:07:46     02-MAY-15     

        BP Key: 7   Status: AVAILABLE  Compressed: NO  Tag: TAG20150502T112355

        Piece Name: /u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp

  List of Datafiles in backup set 7

  File LV Type Ckp SCN    Ckp Time  Name

  ---- -- ---- ---------- --------- ----

  1       Full 1145650    02-MAY-15 /u01/app/oracle/oradata/ora11g/system01.dbf

  2       Full 1145650    02-MAY-15 /u01/app/oracle/oradata/ora11g/sysaux01.dbf

  3       Full 1145650    02-MAY-15 /u01/app/oracle/oradata/ora11g/undotbs01.dbf

  4       Full 1145650    02-MAY-15 /u01/app/oracle/oradata/ora11g/users01.dbf

  5       Full 1092435    30-APR-15 /u01/app/oracle/oradata/ora11g/example01.dbf

 

RMAN> delete backupset;

 

Starting implicit crosscheck backup at 02-MAY-15

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=134 device type=DISK

Crosschecked 2 objects

Finished implicit crosscheck backup at 02-MAY-15

 

Starting implicit crosscheck copy at 02-MAY-15

using channel ORA_DISK_1

Finished implicit crosscheck copy at 02-MAY-15

 

searching for all files in the recovery area

cataloging files...

cataloging done

 

List of Cataloged Files

=======================

File Name: /u02/app/oracle/flash_recovery_area/ORA11G/archivelog/2015_05_02/o1_mf_1_2_bn8o55o8_.arc

File Name: /u02/app/oracle/flash_recovery_area/ORA11G/archivelog/2015_05_02/o1_mf_1_3_bn8o6tkw_.arc

File Name: /u02/app/oracle/flash_recovery_area/ORA11G/archivelog/2015_05_02/o1_mf_1_1_bn8o4j7z_.arc

 

using channel ORA_DISK_1

 

List of Backup Pieces

BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name

------- ------- --- --- ----------- ----------- ----------

6       6       1   1   EXPIRED     DISK        /u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_05_02/o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp

7       7       1   1   EXPIRED     DISK        /u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp

 

Do you really want to delete the above objects (enter YES or NO)? yes

deleted backup piece

backup piece handle=/u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_05_02/o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp RECID=6 STAMP=878642633

deleted backup piece

backup piece handle=/u01/app/oracle/flash_recovery_area/ORA11G/backupset/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp RECID=7 STAMP=878642635

Deleted 2 objects

 

 

RMAN> crosscheck backupset;

 

using channel ORA_DISK_1

specification does not match any backup in the repository

 

RMAN> list backupset;

 

specification does not match any backup in the repository

 

RMAN> exit

 

 

Recovery Manager complete.

[oracle@orcltest dbs]$ rman target /

 

Recovery Manager: Release 11.2.0.3.0 - Production on Sat May 2 13:33:41 2015

 

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database: ORA11G (DBID=4270446895, not open)

 

RMAN> list backupset;

 

using target database control file instead of recovery catalog

specification does not match any backup in the repository

 

RMAN> catalog start with '/tmp/2015_05_02/';

 

searching for all files that match the pattern /tmp/2015_05_02/

 

List of Files Unknown to the Database

=====================================

File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp

File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp

File Name: /tmp/2015_05_02/cont.ctl

File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp

File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp

File Name: /tmp/2015_05_02/o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp

 

Do you really want to catalog the above files (enter YES or NO)? yes

cataloging files...

cataloging done

 

List of Cataloged Files

=======================

File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp

File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp

File Name: /tmp/2015_05_02/cont.ctl

File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp

File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp

File Name: /tmp/2015_05_02/o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp

 

RMAN> list backupset;

 

 

List of Backup Sets

===================

 

 

BS Key  Size       Device Type Elapsed Time Completion Time

------- ---------- ----------- ------------ ---------------

8       9.00K      DISK        00:00:00     02-MAY-15     

        BP Key: 8   Status: AVAILABLE  Compressed: NO  Tag: TAG20150502T113152

        Piece Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp

 

  List of Archived Logs in backup set 8

  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time

  ---- ------- ---------- --------- ---------- ---------

  1    15      1145640    02-MAY-15 1145812    02-MAY-15

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

9       Full    235.99M    DISK        00:00:00     02-MAY-15     

        BP Key: 9   Status: AVAILABLE  Compressed: NO  Tag: TAG20150502T105103

        Piece Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp

  List of Datafiles in backup set 9

  File LV Type Ckp SCN    Ckp Time  Name

  ---- -- ---- ---------- --------- ----

  1       Full 1122334    02-MAY-15 /u01/app/oracle/oradata/ora11g/system01.dbf

  2       Full 1122334    02-MAY-15 /u01/app/oracle/oradata/ora11g/sysaux01.dbf

  3       Full 1122334    02-MAY-15 /u01/app/oracle/oradata/ora11g/undotbs01.dbf

  4       Full 1122334    02-MAY-15 /u01/app/oracle/oradata/ora11g/users01.dbf

  5       Full 1092435    30-APR-15 /u01/app/oracle/oradata/ora11g/example01.dbf

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

10      Full    1.07G      DISK        00:00:00     02-MAY-15     

        BP Key: 10   Status: AVAILABLE  Compressed: NO  Tag: TAG20150502T112355

        Piece Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp

  List of Datafiles in backup set 10

  File LV Type Ckp SCN    Ckp Time  Name

  ---- -- ---- ---------- --------- ----

  1       Full 1145650    02-MAY-15 /u01/app/oracle/oradata/ora11g/system01.dbf

  2       Full 1145650    02-MAY-15 /u01/app/oracle/oradata/ora11g/sysaux01.dbf

  3       Full 1145650    02-MAY-15 /u01/app/oracle/oradata/ora11g/undotbs01.dbf

  4       Full 1145650    02-MAY-15 /u01/app/oracle/oradata/ora11g/users01.dbf

  5       Full 1092435    30-APR-15 /u01/app/oracle/oradata/ora11g/example01.dbf

 

BS Key  Size       Device Type Elapsed Time Completion Time

------- ---------- ----------- ------------ ---------------

11      9.80M      DISK        00:00:00     02-MAY-15     

        BP Key: 11   Status: AVAILABLE  Compressed: NO  Tag: TAG20150502T112352

        Piece Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp

 

  List of Archived Logs in backup set 11

  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time

  ---- ------- ---------- --------- ---------- ---------

  1    13      1122206    02-MAY-15 1145003    02-MAY-15

  1    14      1145003    02-MAY-15 1145640    02-MAY-15

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

12      Full    9.36M      DISK        00:00:00     02-MAY-15     

        BP Key: 12   Status: AVAILABLE  Compressed: NO  Tag: TAG20150502T112355

        Piece Name: /tmp/2015_05_02/o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp

  SPFILE Included: Modification time: 02-MAY-15

  SPFILE db_unique_name: ORA11G

  Control File Included: Ckp SCN: 1145807      Ckp time: 02-MAY-15

 

RMAN> restore database;

 

Starting restore at 02-MAY-15

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=125 device type=DISK

 

channel ORA_DISK_1: starting datafile backup set restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/ora11g/system01.dbf

channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/ora11g/sysaux01.dbf

channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/ora11g/undotbs01.dbf

channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/ora11g/users01.dbf

channel ORA_DISK_1: reading from backup piece /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp

channel ORA_DISK_1: ORA-19870: error while restoring backup piece /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp

ORA-19504: failed to create file "/u01/app/oracle/oradata/ora11g/system01.dbf"

ORA-27040: file create error, unable to create file

Linux-x86_64 Error: 2: No such file or directory

Additional information: 1

 

channel ORA_DISK_1: starting datafile backup set restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/ora11g/example01.dbf

channel ORA_DISK_1: reading from backup piece /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp

channel ORA_DISK_1: ORA-19870: error while restoring backup piece /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp

ORA-19504: failed to create file "/u01/app/oracle/oradata/ora11g/example01.dbf"

ORA-27040: file create error, unable to create file

Linux-x86_64 Error: 2: No such file or directory

Additional information: 1

 

failover to previous backup

 

channel ORA_DISK_1: starting datafile backup set restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/ora11g/system01.dbf

channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/ora11g/sysaux01.dbf

channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/ora11g/undotbs01.dbf

channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/ora11g/users01.dbf

channel ORA_DISK_1: reading from backup piece /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp

channel ORA_DISK_1: ORA-19870: error while restoring backup piece /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp

ORA-19504: failed to create file "/u01/app/oracle/oradata/ora11g/system01.dbf"

ORA-27040: file create error, unable to create file

Linux-x86_64 Error: 2: No such file or directory

Additional information: 1

 

channel ORA_DISK_1: starting datafile backup set restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/ora11g/example01.dbf

channel ORA_DISK_1: reading from backup piece /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp

channel ORA_DISK_1: ORA-19870: error while restoring backup piece /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp

ORA-19504: failed to create file "/u01/app/oracle/oradata/ora11g/example01.dbf"

ORA-27040: file create error, unable to create file

Linux-x86_64 Error: 2: No such file or directory

Additional information: 1

 

failover to previous backup

 

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of restore command at 05/02/2015 13:34:38

RMAN-06026: some targets not found - aborting restore

RMAN-06023: no backup or copy of datafile 5 found to restore

RMAN-06023: no backup or copy of datafile 4 found to restore

RMAN-06023: no backup or copy of datafile 3 found to restore

RMAN-06023: no backup or copy of datafile 2 found to restore

RMAN-06023: no backup or copy of datafile 1 found to restore

 

 

缺少目錄,我們建立目錄重試:

[oracle@orcltest orcltest]$ mkdir -p /u01/app/oracle/oradata/ora11g/

 

 

 

RMAN> restore database;

 

Starting restore at 02-MAY-15

using channel ORA_DISK_1

 

channel ORA_DISK_1: starting datafile backup set restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/ora11g/system01.dbf

channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/ora11g/sysaux01.dbf

channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/ora11g/undotbs01.dbf

channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/ora11g/users01.dbf

channel ORA_DISK_1: reading from backup piece /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp

channel ORA_DISK_1: piece handle=/tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp tag=TAG20150502T112355

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:01:06

channel ORA_DISK_1: starting datafile backup set restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/ora11g/example01.dbf

channel ORA_DISK_1: reading from backup piece /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp

channel ORA_DISK_1: piece handle=/tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp tag=TAG20150502T105103

channel ORA_DISK_1: restored backup piece 1

restore not complete

Restore did not complete for some files from backup piece /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp (piecenum=1, pieces_done=1, done=FALSE, failover=FALSE)

Please check alert log for additional information.

failover to previous backup

 

channel ORA_DISK_1: starting datafile backup set restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/ora11g/example01.dbf

channel ORA_DISK_1: reading from backup piece /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp

channel ORA_DISK_1: piece handle=/tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp tag=TAG20150502T112355

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:25

Finished restore at 02-MAY-15

 

RMAN> recover database;

 

Starting recover at 02-MAY-15

using channel ORA_DISK_1

datafile 5 not processed because file is read-only

 

starting media recovery

 

channel ORA_DISK_1: starting archived log restore to default destination

channel ORA_DISK_1: restoring archived log

archived log thread=1 sequence=15

channel ORA_DISK_1: reading from backup piece /tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp

channel ORA_DISK_1: piece handle=/tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp tag=TAG20150502T113152

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

archived log file name=/u02/app/oracle/flash_recovery_area/ORA11G/archivelog/2015_05_02/o1_mf_1_15_bn8ro53m_.arc thread=1 sequence=15

channel default: deleting archived log(s)

archived log file name=/u02/app/oracle/flash_recovery_area/ORA11G/archivelog/2015_05_02/o1_mf_1_15_bn8ro53m_.arc RECID=10 STAMP=878650661

unable to find archived log

archived log thread=1 sequence=16

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of recover command at 05/02/2015 13:37:42

RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 16 and starting SCN of 1145812

 

RMAN> recover database until sequence  16;

 

Starting recover at 02-MAY-15

using channel ORA_DISK_1

datafile 5 not processed because file is read-only

 

starting media recovery

media recovery complete, elapsed time: 00:00:00

 

Finished recover at 02-MAY-15

 

RMAN> alter database open resetlogs;

 

database opened

 

RMAN> exit

 

 

Recovery Manager complete.

[oracle@orcltest dbs]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.3.0 Production on Sat May 2 13:40:07 2015

 

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

SQL> select count(1) from lhr.test;

 

  COUNT(1)

----------

     75204

 

SQL>

 

OK,一切搞定,其他的後續工作別忘記了。

 

 

②、 方法二:採用臨時庫的控制檔案,或者備份片段中沒有控制檔案的備份

 

如果採用臨時庫的控制檔案來還原資料庫的,會出現這樣的問題:

 

RMAN> restore database;

 

Starting restore at 02-MAY-15

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=134 device type=DISK

 

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of restore command at 05/02/2015 13:48:39

RMAN-06026: some targets not found - aborting restore

RMAN-06023: no backup or copy of datafile 5 found to restore

RMAN-06023: no backup or copy of datafile 4 found to restore

RMAN-06023: no backup or copy of datafile 3 found to restore

RMAN-06023: no backup or copy of datafile 2 found to restore

RMAN-06023: no backup or copy of datafile 1 found to restore

 

RMAN> list backupset;

 

using target database control file instead of recovery catalog

 

List of Backup Sets

===================

 

 

BS Key  Size       Device Type Elapsed Time Completion Time

------- ---------- ----------- ------------ ---------------

1       9.00K      DISK        00:00:00     02-MAY-15     

        BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20150502T113152

        Piece Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp

 

  List of Archived Logs in backup set 1

  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time

  ---- ------- ---------- --------- ---------- ---------

  1    15      1145640    02-MAY-15 1145812    02-MAY-15

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

2       Full    235.99M    DISK        00:00:00     02-MAY-15     

        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20150502T105103

        Piece Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp

  List of Datafiles in backup set 2

  File LV Type Ckp SCN    Ckp Time  Name

  ---- -- ---- ---------- --------- ----

  1       Full 1122334    02-MAY-15 /u02/app/oracle/oradata/orcltest/system01.dbf

  2       Full 1122334    02-MAY-15 /u02/app/oracle/oradata/orcltest/sysaux01.dbf

  3       Full 1122334    02-MAY-15 /u02/app/oracle/oradata/orcltest/undotbs01.dbf

  4       Full 1122334    02-MAY-15 /u02/app/oracle/oradata/orcltest/users01.dbf

  5       Full 1092435    30-APR-15 /u02/app/oracle/oradata/orcltest/example01.dbf

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

3       Full    1.07G      DISK        00:00:00     02-MAY-15     

        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20150502T112355

        Piece Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp

  List of Datafiles in backup set 3

  File LV Type Ckp SCN    Ckp Time  Name

  ---- -- ---- ---------- --------- ----

  1       Full 1145650    02-MAY-15 /u02/app/oracle/oradata/orcltest/system01.dbf

  2       Full 1145650    02-MAY-15 /u02/app/oracle/oradata/orcltest/sysaux01.dbf

  3       Full 1145650    02-MAY-15 /u02/app/oracle/oradata/orcltest/undotbs01.dbf

  4       Full 1145650    02-MAY-15 /u02/app/oracle/oradata/orcltest/users01.dbf

  5       Full 1092435    30-APR-15 /u02/app/oracle/oradata/orcltest/example01.dbf

 

BS Key  Size       Device Type Elapsed Time Completion Time

------- ---------- ----------- ------------ ---------------

4       9.80M      DISK        00:00:00     02-MAY-15     

        BP Key: 4   Status: AVAILABLE  Compressed: NO  Tag: TAG20150502T112352

        Piece Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp

 

  List of Archived Logs in backup set 4

  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time

  ---- ------- ---------- --------- ---------- ---------

  1    13      1122206    02-MAY-15 1145003    02-MAY-15

  1    14      1145003    02-MAY-15 1145640    02-MAY-15

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

5       Full    9.36M      DISK        00:00:00     02-MAY-15     

        BP Key: 5   Status: AVAILABLE  Compressed: NO  Tag: TAG20150502T112355

        Piece Name: /tmp/2015_05_02/o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp

  SPFILE Included: Modification time: 02-MAY-15

  SPFILE db_unique_name: ORA11G

  Control File Included: Ckp SCN: 1145807      Ckp time: 02-MAY-15

 

RMAN>

 

 

雖然能用list backup命令看到相關資料檔案的後設資料資訊,但是執行restore database卻無法找到相應資料檔案的備份,這時可以用到強大的DBMS_BACKUP_RESTORE包執行恢復操作,執行如下PL/SQL命令,注意如果同一個資料檔案在多個備份集中,只寫一個備份集名稱即可:

 

SQL> DECLARE

  2   devtype varchar2(256);

  3   done boolean;

  4  BEGIN

  5   devtype:=sys.dbms_backup_restore.deviceAllocate (type=>'',ident=>'t1');

  6   sys.dbms_backup_restore.restoreSetDatafile;

  7   sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>01,toname=>'/u02/app/oracle/oradata/orcltest/system01.dbf');

  8   sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>02,toname=>'/u02/app/oracle/oradata/orcltest/sysaux01.dbf');

  9   sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>03,toname=>'/u02/app/oracle/oradata/orcltest/undotbs01.dbf');

10   sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>04,toname=>'/u02/app/oracle/oradata/orcltest/users01.dbf');

11   sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>05,toname=>'/u02/app/oracle/oradata/orcltest/example01.dbf');

12   sys.dbms_backup_restore.restoreBackupPiece(done=>done,handle=>'/tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp', params=>null);

13   sys.dbms_backup_restore.deviceDeallocate;

14  END;

15  /

 

PL/SQL procedure successfully completed.

 

 

 

[oracle@orcltest orcltest]$ ll -h

total 1.7G

-rw-r----- 1 oracle oinstall 9.3M May  2 14:00 control01.ctl

-rw-r----- 1 oracle oinstall 314M May  2 13:59 example01.dbf

-rw-r----- 1 oracle oinstall 551M May  2 13:59 sysaux01.dbf

-rw-r----- 1 oracle oinstall 721M May  2 13:59 system01.dbf

-rw-r----- 1 oracle oinstall  96M May  2 13:58 undotbs01.dbf

-rw-r----- 1 oracle oinstall  16M May  2 13:58 users01.dbf

[oracle@orcltest orcltest]$

 

 

好,我們看到資料檔案已經到位,接下來就是recover操作了。

 

 

 

RMAN> recover database;

 

Starting recover at 02-MAY-15

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=134 device type=DISK

 

starting media recovery

media recovery failed

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of recover command at 05/02/2015 14:01:45

ORA-00283: recovery session canceled due to errors

RMAN-11003: failure during parse/execution of SQL statement: alter database recover if needed

start

ORA-00283: recovery session canceled due to errors

ORA-19909: datafile 1 belongs to an orphan incarnation

ORA-01110: data file 1: '/u02/app/oracle/oradata/orcltest/system01.dbf'

 

RMAN> list incarnation of database;

 

 

List of Database Incarnations

DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time

------- ------- -------- ---------------- --- ---------- ----------

1       1       ORA11G   4270446895       PARENT  995548     02-MAY-15

3       3       ORA11G   4270446895       ORPHAN  995548     13-MAR-15

2       2       ORA11G   4270446895       CURRENT 1091863    02-MAY-15

 

RMAN> reset database to incarnation 3;

 

database reset to incarnation 3

 

RMAN> list incarnation of database;

 

 

List of Database Incarnations

DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time

------- ------- -------- ---------------- --- ---------- ----------

1       1       ORA11G   4270446895       ORPHAN  995548     02-MAY-15

3       3       ORA11G   4270446895       CURRENT 995548     13-MAR-15

2       2       ORA11G   4270446895       ORPHAN  1091863    02-MAY-15

 

RMAN> recover database;

 

Starting recover at 02-MAY-15

using channel ORA_DISK_1

 

starting media recovery

media recovery failed

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of recover command at 05/02/2015 14:07:33

ORA-00283: recovery session canceled due to errors

RMAN-11003: failure during parse/execution of SQL statement: alter database recover if needed

start

ORA-00283: recovery session canceled due to errors

ORA-01206: file is not part of this database - wrong database id

ORA-01110: data file 5: '/u02/app/oracle/oradata/orcltest/example01.dbf'

 

[oracle@orcltest ~]$ oerr ora 1206

01206, 00000, "file is not part of this database - wrong database id"

// *Cause:  The database ID in the file header does not match the database id

//         in the control file. The file may be from a different database, or

//         it may not be a database file at all. If the database was rebuilt,

//         this may be a file from before the rebuild. Note that if you see

//         this error when the file is supposed to be plugged in from another

//         database via the Transportable Tablespace feature, it means the

//         database ID in the file header does not match the one expected.

// *Action: Restore a copy of the correct data file and do recovery as needed.

[oracle@orcltest ~]$

 

 

 

查了下資料發現:

ORA-01110: data file 9: 'H:xxxxxxxxx.dbf'

ORA-01206: file is not part of this database - wrong database id

Datafile 9 was a read-only tablespace, and the source database was actually created with RMAN DUPLICATE. Datafile 9 was read-only during that duplicate operation, and the status hadn’t changed since then. As you can imagine, the read-only datafiles were not changed and their headers still contained the DBID of the database that was the source of the RMAN DUPLICATE. A similar situation could probably happen if tablespaces were imported using transportable tablespaces feature, and left read only.

The fix in this case is to make tablespaces read-write for a moment, and then change back to read-only. The read-write operation will write new datafile headers and, consequently, put there the “rightDBID. IMPORTANT this has to be done before backup and not after a disaster strikes. This case just emphasizes again the most important rule of any backup/recovery strategy is to do regular test-restores.

If it’s too late and something hit the fan well, you probably have a chance to offline drop those tablespaces and, hopefully, be able to import them back, if those are transportable tablespaces, and the metadata dump file is still available.

Another idea would be to offline datafiles and then online them after OPEN RESETLOGS. Should someone try that — let us know if it works

 

 

知道了,原來example表空間是隻讀的,這個有點麻煩了,本來沒有隻讀檔案的話,直接recover做不完全恢復就OK了,這樣一來我們就必須重建控制檔案了,這裡如果沒有隻讀檔案的話直接recover就可以成功了。

 

 

 

SQL> alter database backup controlfile to trace as '/tmp/aab.txt';

 

Database altered.

 

SQL>

 

 

拿出/tmp/aab.txt中建立控制檔案的部分,直接在nomount下建立控制檔案,注意這裡去掉只讀資料檔案,關於只讀資料檔案的處理參考:http://blog.itpub.net/26736162/viewspace-1425283/

STARTUP NOMOUNT

CREATE CONTROLFILE REUSE DATABASE "ORA11G" RESETLOGS  ARCHIVELOG

    MAXLOGFILES 16

    MAXLOGMEMBERS 3

    MAXDATAFILES 100

    MAXINSTANCES 8

    MAXLOGHISTORY 292

LOGFILE

  GROUP 1 '/u02/app/oracle/oradata/orcltest/redo01.log'  SIZE 50M BLOCKSIZE 512,

  GROUP 2 '/u02/app/oracle/oradata/orcltest/redo02.log'  SIZE 50M BLOCKSIZE 512,

  GROUP 3 '/u02/app/oracle/oradata/orcltest/redo03.log'  SIZE 50M BLOCKSIZE 512

-- STANDBY LOGFILE

DATAFILE

  '/u02/app/oracle/oradata/orcltest/system01.dbf',

  '/u02/app/oracle/oradata/orcltest/sysaux01.dbf',

  '/u02/app/oracle/oradata/orcltest/undotbs01.dbf',

  '/u02/app/oracle/oradata/orcltest/users01.dbf'

-- '/u02/app/oracle/oradata/orcltest/example01.dbf'

CHARACTER SET ZHS16GBK

;

 

 

[oracle@orcltest ~]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.3.0 Production on Sat May 2 14:52:41 2015

 

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

 

Connected to an idle instance.

 

SQL>

SQL> STARTUP NOMOUNT

CREATE CONTROLFILE REUSE DATABASE "ORA11G" RESETLOGS  ARCHIVELOG

    MAXLOGFILES 16

    MAXLOGMEMBERS 3

    MAXDATAFILES 100

    MAXINSTANCES 8

    MAXLOGHISTORY 292

LOGFILE

  GROUP 1 '/u02/app/oracle/oradata/orcltest/redo01.log'  SIZE 50M BLOCKSIZE 512,

  GROUP 2 '/u02/app/oracle/oradata/orcltest/redo02.log'  SIZE 50M BLOCKSIZE 512,

  GROUP 3 '/u02/app/oracle/oradata/orcltest/redo03.log'  SIZE 50M BLOCKSIZE 512

-- STANDBY LOGFILE

DATAFILE

  '/u02/app/oracle/oradata/orcltest/system01.dbf',

  '/u02/app/oracle/oradata/orcltest/sysaux01.dbf',

  '/u02/app/oracle/oradata/orcltest/undotbs01.dbf',

  '/u02/app/oracle/oradata/orcltest/users01.dbf'

CHARACTER SET ZHS16GBK

;

ORACLE instance started.

 

Total System Global Area  409194496 bytes

Fixed Size                  2228864 bytes

Variable Size             272633216 bytes

Database Buffers          125829120 bytes

Redo Buffers                8503296 bytes

SQL>   2    3    4    5    6    7    8    9   10   11   12   13   14   15   16   17   18 

 

Control file created.

 

SQL> SQL>

SQL>

SQL>

SQL>

SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

[oracle@orcltest ~]$ rman target /

 

Recovery Manager: Release 11.2.0.3.0 - Production on Sat May 2 14:53:01 2015

 

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database: ORA11G (DBID=4270446895, not open)

 

RMAN> catalog start with '/tmp/2015_05_02/';

 

using target database control file instead of recovery catalog

searching for all files that match the pattern /tmp/2015_05_02/

 

List of Files Unknown to the Database

=====================================

File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp

File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp

File Name: /tmp/2015_05_02/cont.ctl

File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp

File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp

File Name: /tmp/2015_05_02/o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp

 

Do you really want to catalog the above files (enter YES or NO)? yes

cataloging files...

cataloging done

 

List of Cataloged Files

=======================

File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp

File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp

File Name: /tmp/2015_05_02/cont.ctl

File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp

File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp

File Name: /tmp/2015_05_02/o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp

 

RMAN> list backupset;

 

 

List of Backup Sets

===================

 

 

BS Key  Size       Device Type Elapsed Time Completion Time   

------- ---------- ----------- ------------ -------------------

1       9.00K      DISK        00:00:00     2015-05-02 11:31:52

        BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20150502T113152

        Piece Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp

 

  List of Archived Logs in backup set 1

  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time

  ---- ------- ---------- ------------------- ---------- ---------

  1    15      1145640    2015-05-02 11:23:48 1145812    2015-05-02 11:31:52

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time   

------- ---- -- ---------- ----------- ------------ -------------------

2       Full    235.99M    DISK        00:00:00     2015-05-02 10:51:03

        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20150502T105103

        Piece Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T105103_bn8gxdob_.bkp

  List of Datafiles in backup set 2

  File LV Type Ckp SCN    Ckp Time            Name

  ---- -- ---- ---------- ------------------- ----

  1       Full 1122334    2015-05-02 10:51:03 /u02/app/oracle/oradata/orcltest/system01.dbf

  2       Full 1122334    2015-05-02 10:51:03 /u02/app/oracle/oradata/orcltest/sysaux01.dbf

  3       Full 1122334    2015-05-02 10:51:03 /u02/app/oracle/oradata/orcltest/undotbs01.dbf

  4       Full 1122334    2015-05-02 10:51:03 /u02/app/oracle/oradata/orcltest/users01.dbf

  5       Full 1092435    2015-04-30 15:42:04

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time   

------- ---- -- ---------- ----------- ------------ -------------------

3       Full    1.07G      DISK        00:00:00     2015-05-02 11:23:55

        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20150502T112355

        Piece Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T112355_bn8jtcsc_.bkp

  List of Datafiles in backup set 3

  File LV Type Ckp SCN    Ckp Time            Name

  ---- -- ---- ---------- ------------------- ----

  1       Full 1145650    2015-05-02 11:23:55 /u02/app/oracle/oradata/orcltest/system01.dbf

  2       Full 1145650    2015-05-02 11:23:55 /u02/app/oracle/oradata/orcltest/sysaux01.dbf

  3       Full 1145650    2015-05-02 11:23:55 /u02/app/oracle/oradata/orcltest/undotbs01.dbf

  4       Full 1145650    2015-05-02 11:23:55 /u02/app/oracle/oradata/orcltest/users01.dbf

  5       Full 1092435    2015-04-30 15:42:04

 

BS Key  Size       Device Type Elapsed Time Completion Time   

------- ---------- ----------- ------------ -------------------

4       9.80M      DISK        00:00:00     2015-05-02 11:23:53

        BP Key: 4   Status: AVAILABLE  Compressed: NO  Tag: TAG20150502T112352

        Piece Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T112352_bn8jt975_.bkp

 

  List of Archived Logs in backup set 4

  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time

  ---- ------- ---------- ------------------- ---------- ---------

  1    13      1122206    2015-05-02 10:50:47 1145003    2015-05-02 11:21:26

  1    14      1145003    2015-05-02 11:21:26 1145640    2015-05-02 11:23:48

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time   

------- ---- -- ---------- ----------- ------------ -------------------

5       Full    9.36M      DISK        00:00:00     2015-05-02 11:31:50

        BP Key: 5   Status: AVAILABLE  Compressed: NO  Tag: TAG20150502T112355

        Piece Name: /tmp/2015_05_02/o1_mf_ncsnf_TAG20150502T112355_bn8k97pm_.bkp

  SPFILE Included: Modification time: 2015-05-02 11:21:13

  SPFILE db_unique_name: ORA11G

  Control File Included: Ckp SCN: 1145807      Ckp time: 2015-05-02 11:31:50

 

RMAN> recover database;

 

Starting recover at 2015-05-02 14:58:31

using channel ORA_DISK_1

 

starting media recovery

 

channel ORA_DISK_1: starting archived log restore to default destination

channel ORA_DISK_1: restoring archived log

archived log thread=1 sequence=15

channel ORA_DISK_1: reading from backup piece /tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp

channel ORA_DISK_1: piece handle=/tmp/2015_05_02/o1_mf_annnn_TAG20150502T113152_bn8k98y5_.bkp tag=TAG20150502T113152

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

archived log file name=/u02/app/oracle/flash_recovery_area/ORA11G/archivelog/2015_05_02/o1_mf_1_15_bn8xdzo2_.arc thread=1 sequence=15

channel default: deleting archived log(s)

archived log file name=/u02/app/oracle/flash_recovery_area/ORA11G/archivelog/2015_05_02/o1_mf_1_15_bn8xdzo2_.arc RECID=1 STAMP=878655519

unable to find archived log

archived log thread=1 sequence=16

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of recover command at 05/02/2015 14:58:46

RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 16 and starting SCN of 1145812

 

RMAN> recover database until sequence 16;

 

Starting recover at 2015-05-02 14:59:16

using channel ORA_DISK_1

 

starting media recovery

media recovery complete, elapsed time: 00:00:01

 

Finished recover at 2015-05-02 14:59:19

 

RMAN> alter database open resetlogs;

 

database opened

 

RMAN> exit

 

 

Recovery Manager complete.

 

 

 

 

recover 過程中的告警日誌:

Sat May 02 15:00:37 2015

[20103] Successfully onlined Undo Tablespace 2.

Undo initialization finished serial:0 start:13457914 end:13468244 diff:10330 (103 seconds)

Dictionary check beginning

Tablespace 'TEMP' #3 found in data dictionary,

but not in the controlfile. Adding to controlfile.

Tablespace 'EXAMPLE' #6 found in data dictionary,

but not in the controlfile. Adding to controlfile.

File #5 found in data dictionary but not in controlfile.

Creating OFFLINE file 'MISSING00005' in the controlfile.

Dictionary check complete

Verifying file header compatibility for 11g tablespace encryption..

Verifying 11g file header compatibility for tablespace encryption completed

Sat May 02 15:00:39 2015

SMON: enabling tx recovery

*********************************************************************

WARNING: The following temporary tablespaces contain no files.

         This condition can occur when a backup controlfile has

         been restored.  It may be necessary to add files to these

         tablespaces.  That can be done using the SQL statement:

 

         ALTER TABLESPACE ADD TEMPFILE

 

         Alternatively, if these temporary tablespaces are no longer

         needed, then they can be dropped.

           Empty temporary tablespace: TEMP

*********************************************************************

Database Characterset is ZHS16GBK

Sat May 02 15:00:55 2015

No Resource Manager plan active

**********************************************************

WARNING: Files may exists in db_recovery_file_dest

that are not known to the database. Use the RMAN command

CATALOG RECOVERY AREA to re-catalog any such files.

If files cannot be cataloged, then manually delete them

using OS command.

One of the following events caused this:

1. A backup controlfile was restored.

2. A standby controlfile was restored.

3. The controlfile was re-created.

4. db_recovery_file_dest had previously been enabled and

   then disabled.

**********************************************************

 

 

replication_dependency_tracking turned off (no async multimaster replication found)

 

Sat May 02 15:01:31 2015

Errors in file /u02/app/oracle/diag/rdbms/ora11g/ORA11G/trace/ORA11G_ora_20103.trc  (incident=13353):

ORA-25319: Queue table repartitioning aborted

Sat May 02 15:01:31 2015

Checker run found 2 new persistent data failures

Incident details in: /u02/app/oracle/diag/rdbms/ora11g/ORA11G/incident/incdir_13353/ORA11G_ora_20103_i13353.trc

Sat May 02 15:01:48 2015

Dumping diagnostic data in directory=[cdmp_20150502150148], requested by (instance=1, osid=20103), summary=[incident=13353].

Sat May 02 15:01:50 2015

error 25319 happened during Queue table repartitioning

Starting background process QMNC

Sat May 02 15:01:50 2015

QMNC started with pid=26, OS id=20168

LOGSTDBY: Validating controlfile with logical metadata

LOGSTDBY: Validation complete

Sat May 02 15:02:03 2015

Sweep [inc][13353]: completed

Sweep [inc2][13353]: completed

Sat May 02 15:02:24 2015

Completed: alter database open resetlogs

Sat May 02 15:02:24 2015

Errors in file /u02/app/oracle/diag/rdbms/ora11g/ORA11G/trace/ORA11G_mmon_20057.trc  (incident=13321):

ORA-25319: Queue table repartitioning aborted

Incident details in: /u02/app/oracle/diag/rdbms/ora11g/ORA11G/incident/incdir_13321/ORA11G_mmon_20057_i13321.trc

error 25319 happened during Queue table repartitioning

Sat May 02 15:02:26 2015

Dumping diagnostic data in directory=[cdmp_20150502150226], requested by (instance=1, osid=20057 (MMON)), summary=[incident=13321].

Sat May 02 15:02:36 2015

db_recovery_file_dest_size of 4122 MB is 0.00% used. This is a

user-specified limit on the amount of space that will be used by this

database for recovery-related files, and does not reflect the amount of

space available in the underlying filesystem or ASM diskgroup.

Sat May 02 15:02:39 2015

Starting background process CJQ0

Sat May 02 15:02:39 2015

CJQ0 started with pid=30, OS id=20198

Sat May 02 15:02:44 2015

Errors in file /u02/app/oracle/diag/rdbms/ora11g/ORA11G/trace/ORA11G_m000_20194.trc:

ORA-25153: Temporary Tablespace is Empty

Setting Resource Manager plan SCHEDULER[0x318E]:DEFAULT_MAINTENANCE_PLAN via scheduler window

Setting Resource Manager plan DEFAULT_MAINTENANCE_PLAN via parameter

Sat May 02 15:02:46 2015

Starting background process VKRM

Sat May 02 15:02:46 2015

VKRM started with pid=20, OS id=20204

Sat May 02 15:02:57 2015

Sweep [inc][13321]: completed

Sweep [inc2][13321]: completed

 

 

OK,基本恢復完成,還剩下只讀檔案了,我們看看只讀檔案如何恢復:

 

 

[oracle@orcltest ~]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.3.0 Production on Sat May 2 15:02:33 2015

 

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

SQL> set line 9999 pagesize 9999

SQL> col FILE_NAME format a50

SQL> select file#,name FILE_NAME,status from v$datafile;

 

     FILE# FILE_NAME                                          STATUS

---------- -------------------------------------------------- -------

         1 /u02/app/oracle/oradata/orcltest/system01.dbf      SYSTEM

         2 /u02/app/oracle/oradata/orcltest/sysaux01.dbf      ONLINE

         3 /u02/app/oracle/oradata/orcltest/undotbs01.dbf     ONLINE

         4 /u02/app/oracle/oradata/orcltest/users01.dbf       ONLINE

        5 /u02/app/oracle/product/11.2.0/dbhome_1/dbs/MISSIN OFFLINE

           G00005

 

SQL>  alter database rename file '/u02/app/oracle/product/11.2.0/dbhome_1/dbs/MISSING00005' to '/u02/app/oracle/oradata/orcltest/example01.dbf';

 

Database altered.

 

SQL> set line 9999 pagesize 9999

SQL> col FILE_NAME format a50

SQL> select file#,name FILE_NAME,status from v$datafile;

 

     FILE# FILE_NAME                                          STATUS

---------- -------------------------------------------------- -------

         1 /u02/app/oracle/oradata/orcltest/system01.dbf      SYSTEM

         2 /u02/app/oracle/oradata/orcltest/sysaux01.dbf      ONLINE

         3 /u02/app/oracle/oradata/orcltest/undotbs01.dbf     ONLINE

         4 /u02/app/oracle/oradata/orcltest/users01.dbf       ONLINE

         5 /u02/app/oracle/oradata/orcltest/example01.dbf     OFFLINE

 

SQL> select FILE_NAME,FILE_ID,a.TABLESPACE_NAME, b.status ts_status ,BYTES from dba_data_files a,dba_tablespaces b where a.TABLESPACE_NAME=b.TABLESPACE_NAME;

 

FILE_NAME                                             FILE_ID TABLESPACE_NAME                TS_STATUS      BYTES

-------------------------------------------------- ---------- ------------------------------ --------- ----------

/u02/app/oracle/oradata/orcltest/users01.dbf                4 USERS                          ONLINE      15728640

/u02/app/oracle/oradata/orcltest/undotbs01.dbf              3 UNDOTBS1                       ONLINE      99614720

/u02/app/oracle/oradata/orcltest/sysaux01.dbf               2 SYSAUX                         ONLINE     576716800

/u02/app/oracle/oradata/orcltest/system01.dbf               1 SYSTEM                         ONLINE     754974720

/u02/app/oracle/oradata/orcltest/example01.dbf              5 EXAMPLE                        READ ONLY

 

 

SQL> alter tablespace EXAMPLE online;

 

Tablespace altered.

 

SQL> select file#,name FILE_NAME,status from v$datafile;

 

     FILE# FILE_NAME                                          STATUS

---------- -------------------------------------------------- -------

         1 /u02/app/oracle/oradata/orcltest/system01.dbf      SYSTEM

         2 /u02/app/oracle/oradata/orcltest/sysaux01.dbf      ONLINE

         3 /u02/app/oracle/oradata/orcltest/undotbs01.dbf     ONLINE

         4 /u02/app/oracle/oradata/orcltest/users01.dbf       ONLINE

         5 /u02/app/oracle/oradata/orcltest/example01.dbf     ONLINE

 

SQL> select FILE_NAME,FILE_ID,a.TABLESPACE_NAME, b.status ts_status ,BYTES from dba_data_files a,dba_tablespaces b where a.TABLESPACE_NAME=b.TABLESPACE_NAME;

 

FILE_NAME                                             FILE_ID TABLESPACE_NAME                TS_STATUS      BYTES

-------------------------------------------------- ---------- ------------------------------ --------- ----------

/u02/app/oracle/oradata/orcltest/users01.dbf                4 USERS                          ONLINE      15728640

/u02/app/oracle/oradata/orcltest/undotbs01.dbf              3 UNDOTBS1                       ONLINE      99614720

/u02/app/oracle/oradata/orcltest/sysaux01.dbf               2 SYSAUX                         ONLINE     576716800

/u02/app/oracle/oradata/orcltest/system01.dbf               1 SYSTEM                         ONLINE     754974720

/u02/app/oracle/oradata/orcltest/example01.dbf              5 EXAMPLE                        READ ONLY  328335360

 

SQL> select count(1) from lhr.test;

 

  COUNT(1)

----------

    75204

 

SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

 

 

 

臨時檔案的處理:

 

SQL>

SQL> select * from v$tempfile;

 

no rows selected

 

 

SQL> create temporary tablespace TEMP01 tempfile  '/u02/app/oracle/oradata/orcltest/temp01.dbf'  size 100m autoextend on next 10m;

 

Tablespace created.

 

SQL> alter database default temporary tablespace temp01;

 

Database altered.

 

SQL>

 

SQL> col name for a100

SQL> select file#,name from  v$tempfile;

 

     FILE# NAME

---------- ----------------------------------------------------------------------------------------------------

         1 /u02/app/oracle/oradata/orcltest/temp01.dbf

 

SQL>

 

 

好了,至此我們就恢復了資料庫了。



在上2篇blog中介紹了備份片中含有控制檔案的備份的情況下,如何從備份集中找回控制檔案的備份並恢復資料庫,本篇blog來介紹下在備份片中沒有控制檔案的備份的情況下如何恢復資料庫

 

 

1.1  備份集中無控制檔案情況下的資料庫恢復

如果採用本文中所描述的3種方式均判斷沒有控制檔案的備份的時候,那麼我們唯一能做的就是重建控制檔案了,而resetlogs方式重建控制檔案之前需要控制檔案指令碼中的所有資料檔案到位才能重建控制檔案。

 

 

[root@orcltest 2015_05_02]# ll -h

total 1.2G

-rw-r----- 1 oracle oinstall  30M May  2 15:49 o1_mf_annnn_TAG20150502T154402_bn9022tb_.bkp

-rw-r----- 1 oracle oinstall 4.0K May  2 15:49 o1_mf_annnn_TAG20150502T154451_bn903mln_.bkp

-rw-r----- 1 oracle oinstall 1.1G May  2 15:49 o1_mf_nnndf_TAG20150502T154404_bn9025w1_.bkp

 

[root@orcltest 2015_05_02]# pwd

/tmp/2015_05_02

 

[oracle@orcltest dbs]$ cd $ORACLE_HOME/dbs

[oracle@orcltest dbs]$ more  inittmp.ora

db_name=tmp

[oracle@orcltest dbs]$ ORACLE_SID=tmp

[oracle@orcltest dbs]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.1.0 Production on Sun May 3 14:45:45 2015

 

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

 

Connected to an idle instance.

 

SQL> startup nomount;

ORACLE instance started.

 

Total System Global Area  217157632 bytes

Fixed Size                  2211928 bytes

Variable Size             159387560 bytes

Database Buffers           50331648 bytes

Redo Buffers                5226496 bytes

SQL> DECLARE

  2   devtype varchar2(256);

  3   done boolean;

  4  BEGIN

  5   devtype:=sys.dbms_backup_restore.deviceAllocate (type=>'',ident=>'t1');

  6   sys.dbms_backup_restore.restoreSetDatafile;

  7   sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>01,toname=>'/tmp/2015_05_02/datafile1.dbf');

  8   sys.dbms_backup_restore.restoreBackupPiece(done=>done,handle=>'/tmp/2015_05_02/o1_mf_nnndf_TAG20150502T154404_bn9025w1_.bkp', params=>null);

  9   sys.dbms_backup_restore.deviceDeallocate;

10  END;

11  /

 

 

PL/SQL procedure successfully completed.

 

SQL> SQL> ! ls -lh /tmp/2015_05_02/

total 1.9G

-rw-r----- 1 oracle asmadmin 721M May  3 14:46 datafile1.dbf

-rw-r----- 1 oracle oinstall  30M May  2 15:49 o1_mf_annnn_TAG20150502T154402_bn9022tb_.bkp

-rw-r----- 1 oracle oinstall 4.0K May  2 15:49 o1_mf_annnn_TAG20150502T154451_bn903mln_.bkp

-rw-r----- 1 oracle oinstall 1.1G May  2 15:49 o1_mf_nnndf_TAG20150502T154404_bn9025w1_.bkp

 

SQL> CREATE CONTROLFILE REUSE DATABASE "tmp" NORESETLOGS ARCHIVELOG

  2  MAXLOGFILES 16

  3  MAXLOGMEMBERS 3

  4  MAXDATAFILES 100

  5  MAXINSTANCES 8

  6  MAXLOGHISTORY 292

  7  LOGFILE

  8  GROUP 1 '/tmp/2015_05_02/redo01.log' SIZE 50M,

  9  GROUP 2 '/tmp/2015_05_02/redo02.log' SIZE 50M

10  DATAFILE

11  '/tmp/2015_05_02/datafile1.dbf'

12  CHARACTER SET ZHS16GBK

13  ;

CREATE CONTROLFILE REUSE DATABASE "tmp" NORESETLOGS ARCHIVELOG

*

ERROR at line 1:

ORA-01503: CREATE CONTROLFILE failed

ORA-01161: database name ORA11G in file header does not match given name of TMP

ORA-01110: data file 1: '/tmp/2015_05_02/datafile1.dbf'

 

 

由此可以看出備份集中的db_nameORA11G,其實這些都是沒有必要的,哪個dba不曉得資料庫名呢?好吧,我們將pfile檔案中的db_name修改一下,採用RESETLOGS建立控制檔案,注意必須是RESETLOGSNORESETLOGS需要online log檔案在位,如下:

 

[oracle@orcltest dbs]$ more inittmp.ora

db_name=ORA11G

[oracle@orcltest dbs]$ echo $ORACLE_SID

tmp

[oracle@orcltest dbs]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.1.0 Production on Sun May 3 14:56:44 2015

 

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

 

Connected to an idle instance.

 

SQL> startup nomount;

ORACLE instance started.

 

Total System Global Area  217157632 bytes

Fixed Size                  2211928 bytes

Variable Size             159387560 bytes

Database Buffers           50331648 bytes

Redo Buffers                5226496 bytes

 

SQL> CREATE CONTROLFILE REUSE DATABASE "ORA11G" RESETLOGS DATAFILE '/tmp/2015_05_02/datafile1.dbf';

 

Control file created.

 

SQL>

SQL>  show parameter control_files

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

control_files                        string      /u01/app/oracle/product/11.2.0

                                                 /dbhome_1/dbs/cntrltmp.dbf

SQL>

 

SQL> set line 9999 pagesize 9999

SQL> col FILE_NAME format a50

SQL> select file#,name FILE_NAME,status from v$datafile;

 

     FILE# FILE_NAME                                          STATUS

---------- -------------------------------------------------- -------

         1 /tmp/2015_05_02/datafile1.dbf                      SYSTEM

 

SQL>

 

 

catalog 所有的backuppiece

 

[oracle@orcltest dbs]$ rman target /

 

Recovery Manager: Release 11.2.0.1.0 - Production on Sun May 3 15:40:32 2015

 

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database: ORA11G (DBID=4270446895, not open)

 

RMAN> list backupset;

 

using target database control file instead of recovery catalog

specification does not match any backup in the repository

 

RMAN> catalog start with '/tmp/2015_05_02/';

 

searching for all files that match the pattern /tmp/2015_05_02/

 

List of Files Unknown to the Database

=====================================

File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T154451_bn903mln_.bkp

File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T154402_bn9022tb_.bkp

File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T154404_bn9025w1_.bkp

 

Do you really want to catalog the above files (enter YES or NO)? yes

cataloging files...

cataloging done

 

List of Cataloged Files

=======================

File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T154451_bn903mln_.bkp

File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T154402_bn9022tb_.bkp

File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T154404_bn9025w1_.bkp

 

RMAN>

 

RMAN> list backupset;

 

 

List of Backup Sets

===================

 

 

BS Key  Size       Device Type Elapsed Time Completion Time   

------- ---------- ----------- ------------ -------------------

1       3.50K      DISK        00:00:00     2015-05-02 15:44:51

        BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20150502T154451

        Piece Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T154451_bn903mln_.bkp

 

  List of Archived Logs in backup set 1

  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time

  ---- ------- ---------- ------------------- ---------- ---------

  1    17      1166181    2015-05-02 15:44:02 1166209    2015-05-02 15:44:51

 

BS Key  Size       Device Type Elapsed Time Completion Time   

------- ---------- ----------- ------------ -------------------

2       29.82M     DISK        00:00:00     2015-05-02 15:44:02

        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20150502T154402

        Piece Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T154402_bn9022tb_.bkp

 

  List of Archived Logs in backup set 2

  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time

  ---- ------- ---------- ------------------- ---------- ---------

  1    16      1145812    2015-05-02 11:31:52 1166181    2015-05-02 15:44:02

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time   

------- ---- -- ---------- ----------- ------------ -------------------

3       Full    1.07G      DISK        00:00:00     2015-05-02 15:44:04

        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20150502T154404

        Piece Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T154404_bn9025w1_.bkp

  List of Datafiles in backup set 3

  File LV Type Ckp SCN    Ckp Time            Name

  ---- -- ---- ---------- ------------------- ----

  1       Full 1166189    2015-05-02 15:44:04 /tmp/2015_05_02/datafile1.dbf

  2       Full 1166189    2015-05-02 15:44:04

  3       Full 1166189    2015-05-02 15:44:04

  4       Full 1166189    2015-05-02 15:44:04

  5       Full 1166189    2015-05-02 15:44:04

  6       Full 1166189    2015-05-02 15:44:04

 

RMAN>

 

RMAN> list backupset of spfile;

 

specification does not match any backup in the repository

 

RMAN> list backupset of controlfile;

 

specification does not match any backup in the repository

 

 

RMAN> list backupset of archivelog all;

 

 

List of Backup Sets

===================

 

 

BS Key  Size       Device Type Elapsed Time Completion Time   

------- ---------- ----------- ------------ -------------------

1       3.50K      DISK        00:00:00     2015-05-02 15:44:51

        BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20150502T154451

        Piece Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T154451_bn903mln_.bkp

 

  List of Archived Logs in backup set 1

  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time

  ---- ------- ---------- ------------------- ---------- ---------

  1    17      1166181    2015-05-02 15:44:02 1166209    2015-05-02 15:44:51

 

BS Key  Size       Device Type Elapsed Time Completion Time   

------- ---------- ----------- ------------ -------------------

2       29.82M     DISK        00:00:00     2015-05-02 15:44:02

        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20150502T154402

        Piece Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T154402_bn9022tb_.bkp

 

  List of Archived Logs in backup set 2

  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time

  ---- ------- ---------- ------------------- ---------- ---------

  1    16      1145812    2015-05-02 11:31:52 1166181    2015-05-02 15:44:02

 

 

RMAN> list backupset of database;

 

 

List of Backup Sets

===================

 

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time   

------- ---- -- ---------- ----------- ------------ -------------------

3       Full    1.07G      DISK        00:00:00     2015-05-02 15:44:04

        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20150502T154404

        Piece Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T154404_bn9025w1_.bkp

  List of Datafiles in backup set 3

  File LV Type Ckp SCN    Ckp Time            Name

  ---- -- ---- ---------- ------------------- ----

  1       Full 1166189    2015-05-02 15:44:04 /tmp/2015_05_02/datafile1.dbf

  2       Full 1166189    2015-05-02 15:44:04

  3       Full 1166189    2015-05-02 15:44:04

  4       Full 1166189    2015-05-02 15:44:04

  5       Full 1166189    2015-05-02 15:44:04

  6       Full 1166189    2015-05-02 15:44:04

 

 

由備份集我們可以看出,有1617號的歸檔檔案備份,有6個資料檔案備份,這裡我們使用dbms_backup_restore package restore datafile。請注意:datafile的名字不重要,只要對於要恢復的datafile,是唯一的名字即可。

 

[oracle@orcltest dbs]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.1.0 Production on Sun May 3 15:59:43 2015

 

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

SQL>

SQL> DECLARE

  2    devtype varchar2(256);

  3    done boolean;

  4  BEGIN

  devtype := dbms_backup_restore.DeviceAllocate(type=>null, ident=>'d1');

  6    dbms_backup_restore.RestoreSetDatafile;

  7    --dbms_backup_restore.RestoreDatafileTo(dfnumber => 1,toname => '/tmp/2015_05_02/datafile1.dbf');

  8    dbms_backup_restore.RestoreDatafileTo(dfnumber => 2,toname => '/tmp/2015_05_02/datafile2.dbf');

  9    dbms_backup_restore.RestoreDatafileTo(dfnumber => 3,toname => '/tmp/2015_05_02/datafile3.dbf');

10    dbms_backup_restore.RestoreDatafileTo(dfnumber => 4,toname => '/tmp/2015_05_02/datafile4.dbf');

11    dbms_backup_restore.RestoreDatafileTo(dfnumber => 5,toname => '/tmp/2015_05_02/datafile5.dbf');

12    dbms_backup_restore.RestoreDatafileTo(dfnumber => 6,toname => '/tmp/2015_05_02/datafile6.dbf');

13    dbms_backup_restore.RestoreBackupPiece(done => done,handle =>'/tmp/2015_05_02/o1_mf_nnndf_TAG20150502T154404_bn9025w1_.bkp', params => null);

14    dbms_backup_restore.DeviceDeallocate;

15  END;

16  /

 

PL/SQL procedure successfully completed.

 

SQL>

 

SQL> set line 9999 pagesize 9999

SQL> col FILE_NAME format a50

SQL> select file#,name FILE_NAME,status from v$datafile;

 

     FILE# FILE_NAME                                          STATUS

---------- -------------------------------------------------- -------

         1 /tmp/2015_05_02/datafile1.dbf                      SYSTEM

 

SQL> shutdown abort;

ORACLE instance shut down.

SQL>

 

 

 

 

 

告警日誌:

 

Sun May 03 15:59:44 2015

Full restore complete of datafile 6 to datafile copy /tmp/2015_05_02/datafile6.dbf.  Elapsed time: 0:00:00

  checkpoint is 1166189

  last deallocation scn is 995550

Full restore complete of datafile 4 to datafile copy /tmp/2015_05_02/datafile4.dbf.  Elapsed time: 0:00:02

  checkpoint is 1166189

  last deallocation scn is 3

Full restore complete of datafile 3 to datafile copy /tmp/2015_05_02/datafile3.dbf.  Elapsed time: 0:00:02

  checkpoint is 1166189

  last deallocation scn is 1157819

  Undo Optimization current scn is 1157346

Sun May 03 16:00:30 2015

Full restore complete of datafile 5 to datafile copy /tmp/2015_05_02/datafile5.dbf.  Elapsed time: 0:00:44

  checkpoint is 1166189

  last deallocation scn is 1015098

Sun May 03 16:01:03 2015

Full restore complete of datafile 2 to datafile copy /tmp/2015_05_02/datafile2.dbf.  Elapsed time: 0:01:18

  checkpoint is 1166189

  last deallocation scn is 1090388

 

 

後設資料顯示只有datafile 1,不奇怪,剛剛建立控制檔案的時候只帶了一個sysem檔案,那我們就需要重建控制檔案以便帶上所有需要恢復的datafiles

 

 

STARTUP NOMOUNT

CREATE CONTROLFILE REUSE DATABASE "ORA11G" RESETLOGS  ARCHIVELOG

    MAXLOGFILES 16

    MAXLOGMEMBERS 3

    MAXDATAFILES 100

    MAXINSTANCES 8

    MAXLOGHISTORY 292

LOGFILE

  GROUP 1 '/tmp/2015_05_02/redo01.log'  SIZE 50M BLOCKSIZE 512,

  GROUP 2 '/tmp/2015_05_02/redo02.log'  SIZE 50M BLOCKSIZE 512,

  GROUP 3 '/tmp/2015_05_02/redo03.log'  SIZE 50M BLOCKSIZE 512

-- STANDBY LOGFILE

DATAFILE

  '/tmp/2015_05_02/datafile1.dbf',

  '/tmp/2015_05_02/datafile2.dbf',

  '/tmp/2015_05_02/datafile3.dbf',

  '/tmp/2015_05_02/datafile4.dbf',

  '/tmp/2015_05_02/datafile5.dbf',

  '/tmp/2015_05_02/datafile6.dbf'

CHARACTER SET ZHS16GBK

;

 

 

 

 

SQL> startup nomount;

ORACLE instance started.

 

Total System Global Area  217157632 bytes

Fixed Size                  2211928 bytes

Variable Size             159387560 bytes

Database Buffers           50331648 bytes

Redo Buffers                5226496 bytes

SQL>

 

SQL> CREATE CONTROLFILE REUSE DATABASE "ORA11G" RESETLOGS  ARCHIVELOG

  2      MAXLOGFILES 16

  3      MAXLOGMEMBERS 3

  4      MAXDATAFILES 100

  5      MAXINSTANCES 8

  6      MAXLOGHISTORY 292

  7  LOGFILE

  8    GROUP 1 '/tmp/2015_05_02/redo01.log'  SIZE 50M BLOCKSIZE 512,

  9    GROUP 2 '/tmp/2015_05_02/redo02.log'  SIZE 50M BLOCKSIZE 512,

10    GROUP 3 '/tmp/2015_05_02/redo03.log'  SIZE 50M BLOCKSIZE 512

11  -- STANDBY LOGFILE

12  DATAFILE

13    '/tmp/2015_05_02/datafile1.dbf',

14    '/tmp/2015_05_02/datafile2.dbf',

15    '/tmp/2015_05_02/datafile3.dbf',

16    '/tmp/2015_05_02/datafile4.dbf',

17    '/tmp/2015_05_02/datafile5.dbf',

18    '/tmp/2015_05_02/datafile6.dbf'

19  CHARACTER SET ZHS16GBK

20  ;

 

Control file created.

 

SQL>

 

SQL> set line 9999 pagesize 9999

SQL> col FILE_NAME format a50

SQL> select file#,name FILE_NAME,status from v$datafile;

 

     FILE# FILE_NAME                                          STATUS

---------- -------------------------------------------------- -------

         1 /tmp/2015_05_02/datafile1.dbf                      SYSTEM

         2 /tmp/2015_05_02/datafile2.dbf                      RECOVER

         3 /tmp/2015_05_02/datafile3.dbf                      RECOVER

         4 /tmp/2015_05_02/datafile4.dbf                      RECOVER

         5 /tmp/2015_05_02/datafile5.dbf                      RECOVER

         6 /tmp/2015_05_02/datafile6.dbf                      RECOVER

 

6 rows selected.

 

SQL>

 

 

 

若是該備份不是冷備份,那麼我們需要recover database,我們需要catalog 包括archivelogbackuppiece,然後restore archivelog,然後再recover

 

[oracle@orcltest dbs]$ rman target /

 

Recovery Manager: Release 11.2.0.1.0 - Production on Sun May 3 16:21:53 2015

 

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database: ORA11G (DBID=4270446895, not open)

 

RMAN> list backupset;

 

using target database control file instead of recovery catalog

specification does not match any backup in the repository

 

RMAN> catalog start with '/tmp/2015_05_02/';

 

searching for all files that match the pattern /tmp/2015_05_02/

 

List of Files Unknown to the Database

=====================================

File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T154451_bn903mln_.bkp

File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T154402_bn9022tb_.bkp

File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T154404_bn9025w1_.bkp

 

Do you really want to catalog the above files (enter YES or NO)? yes

cataloging files...

cataloging done

 

List of Cataloged Files

=======================

File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T154451_bn903mln_.bkp

File Name: /tmp/2015_05_02/o1_mf_annnn_TAG20150502T154402_bn9022tb_.bkp

File Name: /tmp/2015_05_02/o1_mf_nnndf_TAG20150502T154404_bn9025w1_.bkp

 

RMAN> recover database;

 

Starting recover at 2015-05-03 16:23:31

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=96 device type=DISK

 

starting media recovery

 

channel ORA_DISK_1: starting archived log restore to default destination

channel ORA_DISK_1: restoring archived log

archived log thread=1 sequence=17

channel ORA_DISK_1: reading from backup piece /tmp/2015_05_02/o1_mf_annnn_TAG20150502T154451_bn903mln_.bkp

channel ORA_DISK_1: piece handle=/tmp/2015_05_02/o1_mf_annnn_TAG20150502T154451_bn903mln_.bkp tag=TAG20150502T154451

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

archived log file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_17_874246769.dbf thread=1 sequence=17

unable to find archived log

archived log thread=1 sequence=18

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of recover command at 05/03/2015 16:23:34

RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 18 and starting SCN of 1166209

 

RMAN> recover database until sequence 18;

 

Starting recover at 2015-05-03 16:23:44

using channel ORA_DISK_1

 

starting media recovery

media recovery complete, elapsed time: 00:00:00

 

Finished recover at 2015-05-03 16:23:44

 

RMAN> alter database open resetlogs;

 

database opened

 

RMAN>

 

 

RMAN> exit

 

 

Recovery Manager complete.

[oracle@orcltest dbs]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.3.0 Production on Sun May 3 16:41:58 2015

 

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

SQL> show parameter name

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

db_file_name_convert                 string

db_name                              string      ORA11G

db_unique_name                       string      ORA11G

global_names                         boolean     FALSE

instance_name                        string      tmp

lock_name_space                      string

log_file_name_convert                string

processor_group_name                 string

service_names                        string      ORA11G

SQL>

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup

ORACLE instance started.

 

Total System Global Area  250560512 bytes

Fixed Size                  2227256 bytes

Variable Size             192938952 bytes

Database Buffers           50331648 bytes

Redo Buffers                5062656 bytes

Database mounted.

Database opened.

SQL> set line 9999 pagesize 9999

SQL> col FILE_NAME format a50

SQL> select file#,name FILE_NAME,status from v$datafile;

 

     FILE# FILE_NAME                                          STATUS

---------- -------------------------------------------------- -------

         1 /tmp/2015_05_02/datafile1.dbf                      SYSTEM

         2 /tmp/2015_05_02/datafile2.dbf                      ONLINE

         3 /tmp/2015_05_02/datafile3.dbf                      ONLINE

         4 /tmp/2015_05_02/datafile4.dbf                      ONLINE

         5 /tmp/2015_05_02/datafile5.dbf                      ONLINE

         6 /tmp/2015_05_02/datafile6.dbf                      ONLINE

 

6 rows selected.

 

SQL>

 

SQL> col FILE_NAME format a50

SQL> select FILE_NAME,FILE_ID,a.TABLESPACE_NAME, b.status ts_status ,BYTES from dba_data_files a,dba_tablespaces b where a.TABLESPACE_NAME=b.TABLESPACE_NAME;

 

 

FILE_NAME                                             FILE_ID TABLESPACE_NAME                TS_STATUS      BYTES

-------------------------------------------------- ---------- ------------------------------ --------- ----------

/tmp/2015_05_02/datafile6.dbf                               6 AA                             ONLINE       5242880

/tmp/2015_05_02/datafile5.dbf                               5 EXAMPLE                        ONLINE     328335360

/tmp/2015_05_02/datafile4.dbf                               4 USERS                          ONLINE      15728640

/tmp/2015_05_02/datafile3.dbf                               3 UNDOTBS1                       ONLINE      99614720

/tmp/2015_05_02/datafile2.dbf                               2 SYSAUX                         ONLINE     576716800

/tmp/2015_05_02/datafile1.dbf                               1 SYSTEM                         ONLINE     754974720

 

6 rows selected.

 

SQL> select count(1) from lhr.test;

 

  COUNT(1)

----------

    75204

 

 

 

 

recover 過程告警日誌:

Sun May 03 16:39:56 2015

alter database recover datafile list clear

Completed: alter database recover datafile list clear

alter database recover datafile list

1 , 2 , 3 , 4 , 5 , 6

Completed: alter database recover datafile list

1 , 2 , 3 , 4 , 5 , 6

alter database recover if needed

start until cancel using backup controlfile

Media Recovery Start

started logmerger process

Parallel Media Recovery started with 2 slaves

ORA-279 signalled during: alter database recover if needed

start until cancel using backup controlfile

...

alter database recover logfile '/u02/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_17_874246769.dbf'

Media Recovery Log /u02/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_17_874246769.dbf

ORA-279 signalled during: alter database recover logfile '/u02/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_17_874246769.dbf'...

alter database recover cancel

Media Recovery Canceled

Completed: alter database recover cancel

 

 

臨時檔案的處理:

 

SQL>

SQL> select * from v$tempfile;

 

no rows selected

 

 

SQL> create temporary tablespace TEMP01 tempfile  '/tmp/2015_05_02/temp01.dbf'  size 100m autoextend on next 10m;

 

Tablespace created.

 

SQL> alter database default temporary tablespace temp01;

 

Database altered.

 

SQL>

 

SQL> col name for a100

SQL> select file#,name from  v$tempfile;

 

     FILE# NAME

---------- ----------------------------------------------------------------------------------------------------

         1 /tmp/2015_05_02/temp01.dbf

 

SQL>

 

 

接下來就是把資料檔案命名格式化,執行如下程式碼:

shutdown immediate;

cp /tmp/2015_05_02/*.dbf /u02/app/oracle/oradata/ORA11G/

cp /tmp/2015_05_02/*.log /u02/app/oracle/oradata/ORA11G/

mv datafile1.dbf AA.dbf

mv datafile5.dbf EXAMPLE01.dbf

mv AA.dbf SYSTEM01.dbf

mv datafile4.dbf USERS01.dbf

mv datafile3.dbf UNDOTBS1.dbf

mv datafile2.dbf SYSAUX01.dbf

mv datafile6.dbf AA.dbf

 

 

startup mount

alter database rename file'/tmp/2015_05_02/datafile6.dbf'  to '/u02/app/oracle/oradata/ORA11G/AA.dbf';

alter database rename file'/tmp/2015_05_02/datafile5.dbf'  to '/u02/app/oracle/oradata/ORA11G/EXAMPLE01.dbf';

alter database rename file'/tmp/2015_05_02/datafile4.dbf'  to '/u02/app/oracle/oradata/ORA11G/USERS01.dbf';

alter database rename file'/tmp/2015_05_02/datafile3.dbf'  to '/u02/app/oracle/oradata/ORA11G/UNDOTBS1.dbf';

alter database rename file'/tmp/2015_05_02/datafile2.dbf'  to '/u02/app/oracle/oradata/ORA11G/SYSAUX01.dbf';

alter database rename file'/tmp/2015_05_02/datafile1.dbf'  to '/u02/app/oracle/oradata/ORA11G/SYSTEM01.dbf';

 

 

 

SQL> set line 9999 pagesize 9999

SQL> col FILE_NAME format a50

SQL> select file#,name FILE_NAME,status from v$datafile;

 

     FILE# FILE_NAME                                          STATUS

---------- -------------------------------------------------- -------

         1 /u02/app/oracle/oradata/ORA11G/SYSTEM01.dbf        SYSTEM

         2 /u02/app/oracle/oradata/ORA11G/SYSAUX01.dbf        ONLINE

         3 /u02/app/oracle/oradata/ORA11G/UNDOTBS1.dbf        ONLINE

         4 /u02/app/oracle/oradata/ORA11G/USERS01.dbf         ONLINE

         5 /u02/app/oracle/oradata/ORA11G/EXAMPLE01.dbf       ONLINE

         6 /u02/app/oracle/oradata/ORA11G/AA.dbf              ONLINE

 

6 rows selected.

 

SQL> alter database open;

 

Database altered.

 

SQL> set line 9999 pagesize 9999

SQL> col FILE_NAME format a50

SQL> select file#,name FILE_NAME,status from v$datafile;

 

     FILE# FILE_NAME                                          STATUS

---------- -------------------------------------------------- -------

         1 /u02/app/oracle/oradata/ORA11G/SYSTEM01.dbf        SYSTEM

         2 /u02/app/oracle/oradata/ORA11G/SYSAUX01.dbf        ONLINE

         3 /u02/app/oracle/oradata/ORA11G/UNDOTBS1.dbf        ONLINE

         4 /u02/app/oracle/oradata/ORA11G/USERS01.dbf         ONLINE

         5 /u02/app/oracle/oradata/ORA11G/EXAMPLE01.dbf       ONLINE

         6 /u02/app/oracle/oradata/ORA11G/AA.dbf              ONLINE

 

6 rows selected.

 

SQL> col FILE_NAME format a50

SQL> select FILE_NAME,FILE_ID,a.TABLESPACE_NAME, b.status ts_status ,BYTES from dba_data_files a,dba_tablespaces b where a.TABLESPACE_NAME=b.TABLESPACE_NAME;

 

FILE_NAME                                             FILE_ID TABLESPACE_NAME                TS_STATUS      BYTES

-------------------------------------------------- ---------- ------------------------------ --------- ----------

/u02/app/oracle/oradata/ORA11G/AA.dbf                       6 AA                             ONLINE       5242880

/u02/app/oracle/oradata/ORA11G/EXAMPLE01.dbf                5 EXAMPLE                        ONLINE     328335360

/u02/app/oracle/oradata/ORA11G/USERS01.dbf                  4 USERS                          ONLINE      15728640

/u02/app/oracle/oradata/ORA11G/UNDOTBS1.dbf                 3 UNDOTBS1                       ONLINE      99614720

/u02/app/oracle/oradata/ORA11G/SYSAUX01.dbf                 2 SYSAUX                         ONLINE     576716800

/u02/app/oracle/oradata/ORA11G/SYSTEM01.dbf                 1 SYSTEM                         ONLINE     754974720

 

6 rows selected.

 

SQL> 

 

 

好了,至此,整個資料庫恢復完成,至於修改INSTANCE_NAMEpfile檔案,密碼檔案、tnsnames檔案,這些都是基本功了,這裡就不贅述了。

1.2  總結

1. 只有備份片段的情況下,我們可以嘗試將備份片註冊到其它資料庫這樣來獲取dbnamedbid

2. 控制檔案備份不存在的情況下,我們可以利用dbms_backup_restore先把1號檔案恢復,然後重建控制檔案後再註冊備份集來獲取其它資料檔案。

3. 可以使用包dbms_backup_restore nomount狀態下來嘗試獲取控制檔案的備份


 

直接透過rman的restore命令來嘗試判斷備份集中是否含有控制檔案的備份


前邊的3篇blog中介紹了,在只剩下一些備份片的情況下如何從這些僅剩的備份片中判斷是否有控制檔案的備份並還原整個資料庫,我們介紹了2種① 推薦: 採用dbms_backup_restore.restoreControlfileTo從備份片中來嘗試找回控制檔案 ②   嘗試採用建立臨時庫來找回控制檔案 ③ 採用作業系統命令的strings來判斷(私聊) ,今天我們來看看如何直接透過rman的restore命令來嘗試判斷備份集中是否含有控制檔案的備份,這也是一種推薦的方法。



    假設,現在我們只有下邊的4個備份片段,不知道dbid和db_name,如果db_name不知道的話,可以任意指定一個例項名,然後嘗試從rman來啟動到nomount,這個時候會啟動預設的DUMMY資料庫,然後從各個備份集中來嘗試恢復控制檔案,如果控制檔案不在備份集中那麼就只能重建控制檔案了,參考 http://blog.itpub.net/26736162/viewspace-1621672/

 

[oracle@orcltest ~]$ cd /tmp/2015_05_02/

[oracle@orcltest 2015_05_02]$ ll

total 1161972

-rw-r----- 1 oracle oinstall   10125312 May  4 14:23 01q63iof_1_1

-rw-r----- 1 oracle oinstall   31271424 May  2 15:49 o1_mf_annnn_TAG20150502T154402_bn9022tb_.bkp

-rw-r----- 1 oracle oinstall       4096 May  2 15:49 o1_mf_annnn_TAG20150502T154451_bn903mln_.bkp

-rw-r----- 1 oracle oinstall 1148452864 May  2 15:49 o1_mf_nnndf_TAG20150502T154404_bn9025w1_.bkp

[oracle@orcltest 2015_05_02]$

[oracle@orcltest ~]$ ORACLE_SID=TEST

[oracle@orcltest ~]$ rman target /

 

Recovery Manager: Release 11.2.0.1.0 - Production on Mon May 4 14:27:00 2015

 

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database (not started)

 

RMAN> startup nomount;

 

startup failed: ORA-01078: failure in processing system parameters

LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initTEST.ora'

 

starting Oracle instance without parameter file for retrieval of spfile

Oracle instance started

 

Total System Global Area     158662656 bytes

 

Fixed Size                     2211448 bytes

Variable Size                 92275080 bytes

Database Buffers              58720256 bytes

Redo Buffers                   5455872 bytes

 

RMAN>  restore  controlfile from '/tmp/2015_05_02/o1_mf_annnn_TAG20150502T154402_bn9022tb_.bkp';

 

Starting restore at 2015-05-04 14:28:03

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=87 device type=DISK

 

channel ORA_DISK_1: restoring control file

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of restore command at 05/04/2015 14:28:04

ORA-19870: error while restoring backup piece /tmp/2015_05_02/o1_mf_annnn_TAG20150502T154402_bn9022tb_.bkp

ORA-19626: backup set type is archived log - can not be processed by this conversation

 

RMAN>  restore  controlfile from '/tmp/2015_05_02/o1_mf_annnn_TAG20150502T154451_bn903mln_.bkp';

 

Starting restore at 2015-05-04 14:28:20

using channel ORA_DISK_1

 

channel ORA_DISK_1: restoring control file

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of restore command at 05/04/2015 14:28:20

ORA-19870: error while restoring backup piece /tmp/2015_05_02/o1_mf_annnn_TAG20150502T154451_bn903mln_.bkp

ORA-19626: backup set type is archived log - can not be processed by this conversation

 

RMAN>  restore  controlfile from '/tmp/2015_05_02/o1_mf_nnndf_TAG20150502T154404_bn9025w1_.bkp';

 

Starting restore at 2015-05-04 14:28:33

using channel ORA_DISK_1

 

channel ORA_DISK_1: restoring control file

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of restore command at 05/04/2015 14:28:34

ORA-19697: standby control file not found in backup set

 

RMAN>  restore  controlfile from '/tmp/2015_05_02/01q63iof_1_1';

 

Starting restore at 2015-05-04 14:28:59

using channel ORA_DISK_1

 

channel ORA_DISK_1: restoring control file

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

output file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/cntrlTEST.dbf

Finished restore at 2015-05-04 14:29:00

 

RMAN> alter database mount;

 

using target database control file instead of recovery catalog

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of alter db command at 05/04/2015 14:44:38

ORA-01103: database name 'ORA11G' in control file is not 'DUMMY'

 

RMAN> exit

 

 

Recovery Manager complete.

[oracle@orcltest ~]$

[oracle@orcltest ~]$ rman target /

 

Recovery Manager: Release 11.2.0.1.0 - Production on Mon May 4 14:44:21 2015

 

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database: DUMMY (not mounted)

 

RMAN> exit

 

 

Recovery Manager complete.

[oracle@orcltest ~]$ ps -ef|grep ora_

oracle   25153     1  0 14:27 ?        00:00:00 ora_pmon_TEST

oracle   25155     1  0 14:27 ?        00:00:00 ora_vktm_TEST

oracle   25159     1  0 14:27 ?        00:00:00 ora_gen0_TEST

oracle   25161     1  0 14:27 ?        00:00:00 ora_diag_TEST

oracle   25163     1  0 14:27 ?        00:00:00 ora_dbrm_TEST

oracle   25165     1  0 14:27 ?        00:00:00 ora_psp0_TEST

oracle   25167     1  0 14:27 ?        00:00:00 ora_dia0_TEST

oracle   25169     1  0 14:27 ?        00:00:00 ora_mman_TEST

oracle   25171     1  0 14:27 ?        00:00:00 ora_dbw0_TEST

oracle   25173     1  0 14:27 ?        00:00:00 ora_lgwr_TEST

oracle   25175     1  0 14:27 ?        00:00:00 ora_ckpt_TEST

oracle   25177     1  0 14:27 ?        00:00:00 ora_smon_TEST

oracle   25179     1  0 14:27 ?        00:00:00 ora_reco_TEST

oracle   25181     1  0 14:27 ?        00:00:00 ora_mmon_TEST

oracle   25183     1  0 14:27 ?        00:00:00 ora_mmnl_TEST

oracle   25255 25216  0 14:46 pts/3    00:00:00 grep ora_

[oracle@orcltest ~]$

 

 

嘗試的過程中可以看到,能識別出是不是歸檔檔案的備份集,是不是資料檔案的備份集,最後mount的時候還可以識別出控制檔案中記錄的db_name,如果包含控制檔案的話,就可以直接來恢復控制檔案了,控制檔案恢復了其他恢復都很簡單了。

 





About Me

...............................................................................................................................

● 本文作者:小麥苗,只專注於資料庫的技術,更注重技術的運用

● 本文在itpub(http://blog.itpub.net/26736162)、部落格園(http://www.cnblogs.com/lhrbest)和個人微信公眾號(xiaomaimiaolhr)上有同步更新

● 本文itpub地址:http://blog.itpub.net/26736162/viewspace-1621581/

● 本文部落格園地址:http://www.cnblogs.com/lhrbest

● 本文pdf版及小麥苗雲盤地址:http://blog.itpub.net/26736162/viewspace-1624453/

● 資料庫筆試面試題庫及解答:http://blog.itpub.net/26736162/viewspace-2134706/

● QQ群:230161599     微信群:私聊

● 聯絡我請加QQ好友(646634621),註明新增緣由

● 於 2017-07-01 09:00 ~ 2017-07-31 22:00 在魔都完成

● 文章內容來源於小麥苗的學習筆記,部分整理自網路,若有侵權或不當之處還請諒解

● 版權所有,歡迎分享本文,轉載請保留出處

...............................................................................................................................

拿起手機使用微信客戶端掃描下邊的左邊圖片來關注小麥苗的微信公眾號:xiaomaimiaolhr,掃描右邊的二維碼加入小麥苗的QQ群,學習最實用的資料庫技術。

【RMAN】利用備份片還原資料庫
DBA筆試面試講解
歡迎與我聯絡

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26736162/viewspace-1621581/,如需轉載,請註明出處,否則將追究法律責任。

相關文章