rman恢復--丟失控制檔案的恢復
注意:在恢復控制檔案之前,必須知道目標資料庫的DBID,關於資料庫的dbid,有多中方式查詢,方法如下
DBID
----------
1362763236
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2217952 bytes
Variable Size 520095776 bytes
Database Buffers 310378496 bytes
Redo Buffers 2412544 bytes
SQL>
RMAN> set dbid=1362763236;
executing command: SET DBID
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN>
RMAN> recover database;
Starting recover at 2013-12-24 22:06:08
Starting implicit crosscheck backup at 2013-12-24 22:06:08
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK
Crosschecked 8 objects
Finished implicit crosscheck backup at 2013-12-24 22:06:10
Starting implicit crosscheck copy at 2013-12-24 22:06:10
using channel ORA_DISK_1
Finished implicit crosscheck copy at 2013-12-24 22:06:10
searching for all files in the recovery area
cataloging files...
no files cataloged
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 78 is already on disk as file /u01/app/oracle/oradata/orcl/redo03.log
archived log file name=/u01/app/oracle/oradata/orcl/redo03.log thread=1 sequence=78
media recovery complete, elapsed time: 00:00:00
Finished recover at 2013-12-24 22:06:11
RMAN>
1.查詢v$database獲得 由於DBID在控制檔案和資料檔案中都存在記錄,所以假如能夠mount資料庫就可以查詢v$database檢視獲得.
SQL> alter database mount;
Database altered.
SQL> select dbid from v$database;
DBID
----------
1362763236
2.在nomount狀態時 假如資料庫配置了自動控制檔案備份(Oracle9i以上),並且名稱是預設的,那麼我們可以從自動備份檔案獲得DBID.
[oracle@oracle ~]$ cd /u01/app/oracle/backup/control/
[oracle@oracle control]$ ll
total 28800
-rw-r----- 1 oracle oinstall 9830400 Dec 24 18:44 c-1362763236-20131224-03
-rw-r----- 1 oracle oinstall 9830400 Dec 24 19:18 c-1362763236-20131224-04
-rw-r----- 1 oracle oinstall 9830400 Dec 24 19:52 c-1362763236-20131224-05
[oracle@oracle control]$ ll
total 28800
-rw-r----- 1 oracle oinstall 9830400 Dec 24 18:44 c-1362763236-20131224-03
-rw-r----- 1 oracle oinstall 9830400 Dec 24 19:18 c-1362763236-20131224-04
-rw-r----- 1 oracle oinstall 9830400 Dec 24 19:52 c-1362763236-20131224-05
這裡的1362763236就是DBID。
1:模擬檔案丟失
由於控制檔案在資料庫open期間會被oracle程式鎖定,無法直接刪除,因為這裡要先shutdown資料庫,然後在刪除控制檔案。
SQL> show parameter control_file;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time integer 7
control_files string /u01/app/oracle/oradata/orcl/c
ontrol01.ctl, /u01/app/oracle/
flash_recovery_area/orcl/contr
ol02.ctl
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time integer 7
control_files string /u01/app/oracle/oradata/orcl/c
ontrol01.ctl, /u01/app/oracle/
flash_recovery_area/orcl/contr
ol02.ctl
找到該路徑下,將cintrolfile刪除掉。
[oracle@oracle ~]$ cd /u01/app/oracle/oradata/orcl/
[oracle@oracle orcl]$ rm control01.ctl
[oracle@oracle orcl]$ cd
[oracle@oracle ~]$ cd /u01/app/oracle/flash_recovery_area/
orcl/ ORCL/
[oracle@oracle ~]$ cd /u01/app/oracle/flash_recovery_area/orcl/
[oracle@oracle orcl]$ ll
total 9520
-rw-r----- 1 oracle oinstall 9748480 Dec 24 21:47 control02.ctl
[oracle@oracle orcl]$ rm control02.ctl
[oracle@oracle orcl]$ ll
total 0
[oracle@oracle orcl]$ cd
[oracle@oracle ~]$ cd /u01/app/oracle/flash_recovery_area/
orcl/ ORCL/
[oracle@oracle ~]$ cd /u01/app/oracle/flash_recovery_area/orcl/
[oracle@oracle orcl]$ ll
total 9520
-rw-r----- 1 oracle oinstall 9748480 Dec 24 21:47 control02.ctl
[oracle@oracle orcl]$ rm control02.ctl
[oracle@oracle orcl]$ ll
total 0
將資料庫啟動到nomount狀態
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2217952 bytes
Variable Size 520095776 bytes
Database Buffers 310378496 bytes
Redo Buffers 2412544 bytes
SQL>
由於控制檔案丟失,肯定啟動不到mount狀態,因此將資料庫啟動到nomount狀態。
2:恢復控制檔案
登陸rman介面
oracle@oracle ~]$ rman target /
Recovery Manager: Release 11.2.0.1.0 - Production on 星期二 12月 24 21:51:12 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (not mounted)
Recovery Manager: Release 11.2.0.1.0 - Production on 星期二 12月 24 21:51:12 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (not mounted)
目標資料庫控制檔案丟失,無法啟動到mount狀態,此處必須首先指定dbid
RMAN> set dbid=1362763236;
executing command: SET DBID
由於本人的備份是在nocatalog模式下進行的,因此備份資訊,備份設定等都儲存在目標資料庫的控制檔案中,現在控制檔案丟失,相當於前面的一些配置也丟失了,用show all命令檢視,可見之前所有的配置均恢復到了預設值,如下
RMAN> show all;
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name ORCL 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
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name ORCL 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
此時恢復控制檔案不能直接使用 restore controlfile from autobackup命令,因為自動備份的設定也丟失了,因此選澤顯示指定控制檔案備份集的方式恢復控制檔案,如下
RMAN> restore controlfile from '/u01/app/oracle/backup/control/c-1362763236-20131224-05'; ---此路徑是我備份controlfile路徑
Starting restore at 2013-12-24 22:00:46
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output file name=/u01/app/oracle/oradata/orcl/control01.ctl
output file name=/u01/app/oracle/flash_recovery_area/orcl/control02.ctl
Finished restore at 2013-12-24 22:00:49
RMAN>
Starting restore at 2013-12-24 22:00:46
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output file name=/u01/app/oracle/oradata/orcl/control01.ctl
output file name=/u01/app/oracle/flash_recovery_area/orcl/control02.ctl
Finished restore at 2013-12-24 22:00:49
RMAN>
有了控制檔案就可以將資料庫啟動到mount狀態了
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN>
由於只是丟失了控制檔案,資料檔案還在,因此並不需要對整個資料庫進行修復操作(restore),只需要執行recover命令,重新應用備份控制檔案之後 生成的那些重做日誌即可。
RMAN> recover database;
Starting recover at 2013-12-24 22:06:08
Starting implicit crosscheck backup at 2013-12-24 22:06:08
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK
Crosschecked 8 objects
Finished implicit crosscheck backup at 2013-12-24 22:06:10
Starting implicit crosscheck copy at 2013-12-24 22:06:10
using channel ORA_DISK_1
Finished implicit crosscheck copy at 2013-12-24 22:06:10
searching for all files in the recovery area
cataloging files...
no files cataloged
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 78 is already on disk as file /u01/app/oracle/oradata/orcl/redo03.log
archived log file name=/u01/app/oracle/oradata/orcl/redo03.log thread=1 sequence=78
media recovery complete, elapsed time: 00:00:00
Finished recover at 2013-12-24 22:06:11
RMAN>
如果上述命令都正常執行,那麼就可以開啟資料庫了
RMAN> alter database open resetlogs;
database opened
database opened
由於是通過備份的控制檔案恢復,因此開啟資料庫時,必須指定resetlogs。
切換PL SQL檢視資料是否丟失。。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28698327/viewspace-1065459/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 控制檔案丟失的RMAN恢復
- 控制檔案丟失恢復
- 【控制檔案丟失恢復】
- 恢復丟失的控制檔案
- RMAN恢復案例:丟失全部資料檔案恢復
- RMAN - "丟失控制檔案的恢復"
- RMAN恢復案例:無恢復目錄,丟失全部資料檔案、控制檔案、日誌檔案恢復
- 控制檔案丟失恢復(二)
- 控制檔案全部丟失恢復
- 控制檔案全部丟失的恢復
- 控制檔案部分丟失的恢復
- 只有rman備份集,控制檔案丟失的恢復
- 探索ORACLE之RMAN_07 控制檔案丟失恢復Oracle
- RMAN恢復案例:丟失非系統資料檔案恢復
- RMAN完全恢復丟失的資料檔案
- 【rman 備份與恢復】恢復丟失所有的控制檔案
- rman備份丟失控制檔案恢復
- rman恢復--歸檔模式有備份,丟失資料檔案的恢復模式
- rman恢復--歸檔模式無備份,丟失資料檔案的恢復模式
- 恢復案例:無歸檔,掉電,控制檔案全部丟失恢復
- 【恢復】Redo日誌檔案丟失的恢復
- 【備份恢復】 丟失一個控制檔案 之恢復操作
- 當前控制檔案全部丟失恢復
- RMAN恢復控制檔案
- 恢復案例:無歸檔,丟失全部控制檔案、日誌檔案恢復案例
- 丟失全部控制檔案後從RMAN備份集中恢復示例
- 【備份恢復】丟失所有控制檔案,利用RMAN進行恢復操作
- 模擬控制檔案丟失進行恢復。
- rman恢復--丟失聯機重做日誌的恢復
- 全部控制檔案丟失後的完全恢復(轉)
- rman 恢復---歸檔丟失and資料檔案損壞
- 使用rman恢復控制檔案
- RMAN備份恢復之控制檔案的恢復(三)
- RMAN備份恢復之控制檔案的恢復(二)
- RMAN備份恢復之控制檔案的恢復(一)
- 資料檔案丟失的恢復
- Oracle Password檔案丟失的恢復Oracle
- Oracle備份與恢復【丟失控制檔案的恢復】Oracle