使用備份的控制檔案恢復資料庫
-- 備份控制檔案,備份系統表空間會自動備份控制檔案
RMAN> backup tablespace system;
Starting backup at 29-SEP-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=38 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/system01.dbf
channel ORA_DISK_1: starting piece 1 at 29-SEP-13
channel ORA_DISK_1: finished piece 1 at 29-SEP-13
piece handle=/u01/app/oracle/flash_recovery_area/WAILON/backupset/2013_09_29/o1_mf_nnndf_TAG20130929T164720_94ht8s6l_.bkp tag=TAG20130929T164720 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:26
Finished backup at 29-SEP-13
Starting Control File and SPFILE Autobackup at 29-SEP-13
piece handle=/u01/app/oracle/flash_recovery_area/WAILON/autobackup/2013_09_29/o1_mf_s_827426866_94ht9mkz_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 29-SEP-13
-- 模擬資料產生並切換日誌
16:48:37 SCOTT@wailon> create table a tablespace wailon as select * from tab;
Table created.
16:48:56 SCOTT@wailon> select * from a;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
A TABLE
BONUS TABLE
CHECKPOINT TABLE
CHECKPOINT_LOX TABLE
DEPT TABLE
EMP TABLE
GGS_DDL_COLUMNS TABLE
GGS_DDL_HIST TABLE
GGS_DDL_HIST_ALT TABLE
GGS_DDL_LOG_GROUPS TABLE
GGS_DDL_OBJECTS TABLE
GGS_DDL_PARTITIONS TABLE
GGS_DDL_PRIMARY_KEYS TABLE
GGS_DDL_RULES TABLE
GGS_DDL_RULES_LOG TABLE
GGS_MARKER TABLE
GGS_SETUP TABLE
GGS_STICK TABLE
GGS_TEMP_COLS TABLE
GGS_TEMP_UK TABLE
OB TABLE
SALGRADE TABLE
SYS_EXPORT_SCHEMA_01 TABLE
23 rows selected.
16:49:01 SCOTT@wailon> alter system switch logfile;
System altered.
16:49:08 SCOTT@wailon> create table b tablespace wailon as select * from a;
Table created.
16:49:32 SCOTT@wailon> alter system switch logfile;
System altered.
16:50:08 SCOTT@wailon> alter system checkpoint;
System altered.
-- 確認當前日誌序號
16:50:20 SCOTT@wailon> select group#,sequence#,status from v$log;
GROUP# SEQUENCE# STATUS
---------- --------------- ----------------
1 244 INACTIVE
3 246 CURRENT
2 245 INACTIVE
16:50:30 SYS@wailon> select group#,member from v$logfile;
GROUP# MEMBER
---------- --------------------------------------------------
2 /u01/app/oracle/oradata/wailon/redo02.log
1 /u01/app/oracle/oradata/wailon/redo01.log
3 /u01/app/oracle/oradata/wailon/redo03.log
16:50:52 SCOTT@wailon> col name for a50
16:51:02 SCOTT@wailon> select * from v$controlfile;
STATUS NAME IS_ BLOCK_SIZE FILE_SIZE_BLKS
------- -------------------------------------------------- --- ---------- --------------
/u01/app/oracle/oradata/wailon/control01.ctl NO 16384 596
/u01/app/oracle/oradata/wailon/control02.ctl NO 16384 596
-- 模擬系統意外斷電,並且控制檔案丟失
16:51:17 SYS@wailon> shutdown abort;
ORACLE instance shut down.
16:51:31 SYS@wailon> host rm /u01/app/oracle/oradata/wailon/control*.ctl
16:51:38 SYS@wailon> host ls -ls /u01/app/oracle/oradata/wailon/control*
ls: cannot access /u01/app/oracle/oradata/wailon/control*: No such file or directory
-- 嘗試啟動資料庫,找不到控制檔案報錯
16:51:49 SYS@wailon> startup
ORACLE instance started.
Total System Global Area 417546240 bytes
Fixed Size 2228944 bytes
Variable Size 343936304 bytes
Database Buffers 62914560 bytes
Redo Buffers 8466432 bytes
ORA-00205: error in identifying control file, check alert log for more info
[oracle@dg ~(16:54:08)]$ cd /u01/app/oracle/diag/rdbms/wailon/wailon/trace/
[oracle@dg trace(16:54:40)]$ tail -20 alert_wailon.log
Sun Sep 29 16:51:59 2013
MMNL started with pid=16, OS id=17782
starting up 1 dispatcher(s) for network address '(ADDRESS=(PARTIAL=YES)(PROTOCOL=TCP))'...
starting up 1 shared server(s) ...
ORACLE_BASE from environment = /u01/app/oracle
Sun Sep 29 16:51:59 2013
ALTER DATABASE MOUNT
ORA-00210: ???????????
ORA-00202: ????: ''/u01/app/oracle/oradata/wailon/control02.ctl''
ORA-27037: ????????
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
ORA-00210: ???????????
ORA-00202: ????: ''/u01/app/oracle/oradata/wailon/control01.ctl''
ORA-27037: ????????
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
ORA-205 signalled during: ALTER DATABASE MOUNT...
Sun Sep 29 16:52:00 2013
Checker run found 2 new persistent data failures
-- 恢復之前備份的控制檔案
[oracle@dg trace(16:54:49)]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Sun Sep 29 16:55:07 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: WAILON (not mounted)
RMAN> restore controlfile from '/u01/app/oracle/flash_recovery_area/WAILON/autobackup/2013_09_29/o1_mf_s_827426866_94ht9mkz_.bkp';
Starting restore at 29-SEP-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=10 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/wailon/control01.ctl
output file name=/u01/app/oracle/oradata/wailon/control02.ctl
Finished restore at 29-SEP-13
-- 檢視系統啟動狀態及日誌序號,日誌序號已變成舊的
16:56:10 SYS@wailon> select status from v$instance;
STATUS
------------------------
STARTED
16:56:20 SYS@wailon> alter database mount;
Database altered.
16:56:29 SYS@wailon> select group#,sequence#,status from v$log;
GROUP# SEQUENCE# STATUS
---------- --------------- --------------------------------
1 244 CURRENT
3 243 INACTIVE
2 242 INACTIVE
-- 嘗試恢復資料庫,提示需要使用BACKUP CONTROLFILE
-- 兩種情況需要使用BACKUP CONTROLFILE恢復資料
-- 1. 使用備份的控制檔案
-- 2. 使用resetlogs重建控制檔案
16:57:47 SYS@wailon> recover database;
ORA-00283: 恢復會話因錯誤而取消 ORA-01610:
使用 BACKUP CONTROLFILE 選項的恢復必須已完成
-- 提示輸入歸檔日誌時,直接按Enter鍵會自動查詢相應的歸檔日誌;如果找不到,就從聯機日誌檔案裡面找
16:59:13 SYS@wailon> recover database using backup controlfile;
ORA-00279: change 3001398 generated at 09/29/2013 16:49:08 needed for thread 1
ORA-00289: suggestion : /u01/app/oracle/flash_recovery_area/WAILON/archivelog/2013_09_29/o1_mf_1_245_94htf3fq_.arc
ORA-00280: change 3001398 for thread 1 is in sequence #245
16:59:18 Specify log: {
-- 找到一個歸檔日誌並應用成功,找另外一個歸檔日誌時沒有找到,需要從聯機日誌中找
ORA-00279: change 3001442 generated at 09/29/2013 16:49:39 needed for thread 1
ORA-00289: suggestion : /u01/app/oracle/flash_recovery_area/WAILON/archivelog/2013_09_29/o1_mf_1_246_%u_.arc
ORA-00280: change 3001442 for thread 1 is in sequence #246
ORA-00278: log file '/u01/app/oracle/flash_recovery_area/WAILON/archivelog/2013_09_29/o1_mf_1_245_94htf3fq_.arc' no
longer needed for this recovery
16:59:22 Specify log: {
ORA-00308: 無法開啟歸檔日誌 '/u01/app/oracle/flash_recovery_area/WAILON/archivelog/2013_09_29/o1_mf_1_246_%u_.arc'
ORA-27037: 無法獲得檔案狀態
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
16:59:57 SYS@wailon> recover database using backup controlfile;
ORA-00279: change 3001442 generated at 09/29/2013 16:49:39 needed for thread 1
ORA-00289: suggestion : /u01/app/oracle/flash_recovery_area/WAILON/archivelog/2013_09_29/o1_mf_1_246_%u_.arc
ORA-00280: change 3001442 for thread 1 is in sequence #246
-- 輸入正確的聯機日誌後,恢復成功
17:00:03 Specify log: {
Log applied.
Media recovery complete.
-- 雖然是完全恢復,沒有資料丟失,但由於使用了BACKUP CONTROLFILE必須使用OPEN RESETLOGS開啟資料庫
17:00:05 SYS@wailon> alter database open;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
-- 使用OPEN RESETLOGS開啟資料庫的情況
-- 1. 使用備份的控制檔案
-- 2. 不完全恢復(介質恢復)
17:00:21 SYS@wailon> alter database open resetlogs;
Database altered.
-- 使用OPEN RESETLOGS後,聯機日誌序號重新從1開始編號
17:00:50 SYS@wailon> select group#,sequence#,status from v$log;
GROUP# SEQUENCE# STATUS
---------- --------------- ------------------------------------------------
1 1 CURRENT
3 0 UNUSED
2 0 UNUSED
-- 驗證資料恢復
17:01:50 SYS@wailon> col tname for a30
17:01:58 SYS@wailon> select * from scott.a;
TNAME TABTYPE CLUSTERID
------------------------------ --------------------- ----------
A TABLE
BONUS TABLE
CHECKPOINT TABLE
CHECKPOINT_LOX TABLE
DEPT TABLE
EMP TABLE
GGS_DDL_COLUMNS TABLE
GGS_DDL_HIST TABLE
GGS_DDL_HIST_ALT TABLE
GGS_DDL_LOG_GROUPS TABLE
GGS_DDL_OBJECTS TABLE
GGS_DDL_PARTITIONS TABLE
GGS_DDL_PRIMARY_KEYS TABLE
GGS_DDL_RULES TABLE
GGS_DDL_RULES_LOG TABLE
GGS_MARKER TABLE
GGS_SETUP TABLE
GGS_STICK TABLE
GGS_TEMP_COLS TABLE
GGS_TEMP_UK TABLE
OB TABLE
SALGRADE TABLE
SYS_EXPORT_SCHEMA_01 TABLE
23 rows selected.
17:01:59 SYS@wailon> select * from scott.b;
TNAME TABTYPE CLUSTERID
------------------------------ --------------------- ----------
A TABLE
BONUS TABLE
CHECKPOINT TABLE
CHECKPOINT_LOX TABLE
DEPT TABLE
EMP TABLE
GGS_DDL_COLUMNS TABLE
GGS_DDL_HIST TABLE
GGS_DDL_HIST_ALT TABLE
GGS_DDL_LOG_GROUPS TABLE
GGS_DDL_OBJECTS TABLE
GGS_DDL_PARTITIONS TABLE
GGS_DDL_PRIMARY_KEYS TABLE
GGS_DDL_RULES TABLE
GGS_DDL_RULES_LOG TABLE
GGS_MARKER TABLE
GGS_SETUP TABLE
GGS_STICK TABLE
GGS_TEMP_COLS TABLE
GGS_TEMP_UK TABLE
OB TABLE
SALGRADE TABLE
SYS_EXPORT_SCHEMA_01 TABLE
23 rows selected.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/429786/viewspace-777152/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 備份與恢復:polardb資料庫備份與恢復資料庫
- 資料庫備份恢復資料庫
- 使用Mysqldump備份和恢復MySQL資料庫MySql資料庫
- 12 使用RMAN備份和恢復檔案
- PostgreSql資料庫的備份和恢復SQL資料庫
- SqlServer資料庫恢復備份資料的方法SQLServer資料庫
- Mysql資料庫備份及恢復MySql資料庫
- 達夢資料庫備份恢復資料庫
- postgresql備份與恢復資料庫SQL資料庫
- mysqldump使用方法(MySQL資料庫的備份與恢復)MySql資料庫
- 資料庫備份與恢復技術資料庫
- Mongo 資料庫備份和恢復命令Go資料庫
- pg_dump 備份,恢復資料庫資料庫
- Oracle為什麼使用備份的控制檔案恢復後一定要resetlogsOracle
- Oracle使用備份檔案集恢復歸檔日誌Oracle
- 怎樣恢復Mac檔案及資料夾資料?BackupLoupe for mac(資料恢復備份助手)3.5.4Mac資料恢復
- RMAN備份恢復典型案例——資料檔案存在壞快
- 【資料庫資料恢復】透過恢復NDF檔案修復資料庫的資料恢復過程資料庫資料恢復
- 資料庫資料恢復—無備份,binlog未開啟的Mysql資料庫資料恢復案例資料庫資料恢復MySql
- XFS檔案系統的備份、恢復、修復
- 【資料庫資料恢復】MongoDB資料庫檔案損壞的資料恢復案例資料庫資料恢復MongoDB
- Linux下MySQL資料庫的備份與恢復LinuxMySql資料庫
- 如何恢復在全備後新增了資料檔案的資料庫資料庫
- SQL SERVER備份資料庫檔案(使用SSMS)SQLServer資料庫SSM
- mongodb資料庫備份與恢復(資料庫資料遷移)MongoDB資料庫
- vivo 資料庫備份恢復系統演化資料庫
- MySQL-19.資料庫備份與恢復MySql資料庫
- PG-pg_dump備份/恢復資料庫資料庫
- 備份與恢復:Polardb資料庫資料基於時間點恢復資料庫
- 從備份片中恢復某個指定得歸檔或者資料檔案
- Dedecms備份的資料檔案位置及備份資料庫的方法資料庫
- Dedecms資料庫恢復與備份的兩種方法資料庫
- 淺談達夢資料庫的備份與恢復資料庫
- gitlab的資料備份和恢復Gitlab
- 【資料庫資料恢復】Sql Server資料庫檔案丟失的資料恢復過程資料庫資料恢復SQLServer
- NoSQL 資料庫案例實戰 -- MongoDB資料備份、恢復SQL資料庫MongoDB
- RMAN備份恢復典型案例——資料庫卡頓資料庫
- 檔案的基本管理和XFS檔案系統備份恢復
- oracle uncatalog資料庫備份檔案Oracle資料庫