基於cancel的資料庫恢復
基於cancel的恢復,該種方式恢復資料庫,只能恢復到刪除日誌檔案與資料檔案之前已歸檔日誌時的狀態。
---全庫備份:
[oracle@enmo ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Mon Nov 7 13:20:57 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: PROD (DBID=338469376)
RMAN> backup as compressed backupset full database;
Starting backup at 07-NOV-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=29 device type=DISK
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/PROD/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/PROD/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/PROD/example01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/PROD/undotbs01.dbf
input datafile file number=00006 name=/u01/app/oracle/oradata/PROD/ts_xxf_01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/PROD/users01.dbf
channel ORA_DISK_1: starting piece 1 at 07-NOV-16
channel ORA_DISK_1: finished piece 1 at 07-NOV-16
piece handle=/u01/app/backup/db_0crkane1_1_1.rmn tag=TAG20161107T132105 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:25
Finished backup at 07-NOV-16
Starting Control File and SPFILE Autobackup at 07-NOV-16
piece handle=/u01/app/oracle/fast_recovery_area/PROD/autobackup/2016_11_07/o1_mf_s_927293010_d203ylz3_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 07-NOV-16
RMAN>
#全庫備份完成。
---建立測試表:
create table t1 as select 1 as id from dual;
suxing@PROD>create table t1 as select 1 as id from dual;
Table created.
suxing@PROD>select * from t1;
ID
----------
1
create table t2 as select 2 as id from dual;
suxing@PROD>create table t2 as select 2 as id from dual;
Table created.
suxing@PROD>select * from t2;
ID
----------
2
--切換當前redo日誌:
sys@PROD>alter system archive log current;
System altered.
create table t3 as select 3 as id from dual;
suxing@PROD>create table t3 as select 3 as id from dual;
Table created.
suxing@PROD>select * from t3;
ID
----------
3
--在切換一次日誌:
sys@PROD>alter system archive log current;
System altered.
--檢視3個表的資訊:
sys@PROD>select table_name,tablespace_name from dba_tables
2 where table_name LIKE 'T_';
TABLE_NAME TABLESPACE_NAME
------------------------------ ------------------------------
T1 USERS
T1 USERS
T2 USERS
T3 USERS
--刪除所有日誌檔案:
[oracle@enmo backup]$ cd /u01/app/oracle/oradata/PROD
[oracle@enmo PROD]$ ls
control01.ctl redo01.log redo03.log system01.dbf ts_xxf_01.dbf users01.dbf
example01.dbf redo02.log sysaux01.dbf temp01.dbf undotbs01.dbf
[oracle@enmo PROD]$
[oracle@enmo PROD]$ pwd
/u01/app/oracle/oradata/PROD
[oracle@enmo PROD]$ rm *.log
[oracle@enmo PROD]$ ls
control01.ctl example01.dbf sysaux01.dbf system01.dbf temp01.dbf ts_xxf_01.dbf undotbs01.dbf users01.dbf
[oracle@enmo PROD]$ rm *.dbf
[oracle@enmo PROD]$ ls
control01.ctl
---資料庫啟動到mount模式:
sys@PROD>shutdown abort;
ORACLE instance shut down.
sys@PROD>startup mount;
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2257840 bytes
Variable Size 507513936 bytes
Database Buffers 322961408 bytes
Redo Buffers 2371584 bytes
Database mounted.
sys@PROD>
[oracle@enmo ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Mon Nov 7 13:58:08 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: PROD (DBID=338469376, not open)
RMAN>
---裝載資料檔案恢復:
RMAN> restore database;
Starting restore at 07-NOV-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 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/PROD/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/PROD/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/PROD/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/PROD/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/PROD/example01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/PROD/ts_xxf_01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/backup/db_0crkane1_1_1.rmn
channel ORA_DISK_1: piece handle=/u01/app/backup/db_0crkane1_1_1.rmn tag=TAG20161107T132105
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:03:15
Finished restore at 07-NOV-16
RMAN>
#裝載完成。
---恢復資料檔案:
---直接做恢復操作:
RMAN> recover database;
Starting recover at 07-NOV-16
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 1 is already on disk as file /u01/app/oracle/fast_recovery_area/PROD/archivelog/2016_11_07/o1_mf_1_1_d204rlf1_.arc
archived log for thread 1 with sequence 2 is already on disk as file /u01/app/oracle/fast_recovery_area/PROD/archivelog/2016_11_07/o1_mf_1_2_d204v4nd_.arc
archived log file name=/u01/app/oracle/fast_recovery_area/PROD/archivelog/2016_11_07/o1_mf_1_1_d204rlf1_.arc thread=1 sequence=1
archived log file name=/u01/app/oracle/fast_recovery_area/PROD/archivelog/2016_11_07/o1_mf_1_2_d204v4nd_.arc thread=1 sequence=2
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 11/07/2016 14:06:52
ORA-00283: recovery session canceled due to errors
RMAN-11003: failure during parse/execution of SQL statement: alter database recover logfile '/u01/app/oracle/fast_recovery_area/PROD/archivelog/2016_11_07/o1_mf_1_2_d204v4nd_.arc'
ORA-00283: recovery session canceled due to errors
ORA-00313: open failed for members of log group 3 of thread 1
ORA-00312: online log 3 thread 1: '/u01/app/oracle/oradata/PROD/redo03.log'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
#報錯,原因是丟失了日誌檔案。
sys@PROD>recover database until cancel;
ORA-00279: change 1754922 generated at 11/07/2016 13:38:44 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/fast_recovery_area/PROD/archivelog/2016_11_07/o1_mf_1_3_%u_.arc
ORA-00280: change 1754922 for thread 1 is in sequence #3
Specify log: {=suggested | filename | AUTO | CANCEL}
Specify log: {=suggested | filename | AUTO | CANCEL}
Cancel
Media recovery cancelled.
#恢復到刪除之時的狀態。
---嘗試以resetlogs方式開啟資料庫:
sys@PROD>alter database open resetlogs;
Database altered.
#已經恢復到刪除前完成,併成功開啟資料庫:
---嘗試檢視之前建立的資料表:
sys@PROD>select table_name,tablespace_name from dba_tables
2 where table_name LIKE 'T_';
TABLE_NAME TABLESPACE_NAME
------------------------------ ------------------------------
T1 USERS
T1 USERS
T2 USERS
T3 USERS
#可以已經恢復到刪除日誌前已歸檔部分的狀態。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31392094/viewspace-2127962/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 基於資料塊的恢復
- 備份與恢復:Polardb資料庫資料基於時間點恢復資料庫
- 基於tsm的oracle資料庫備份及恢復Oracle資料庫
- RMAN基於時間點恢復Oracle資料庫Oracle資料庫
- 【資料庫資料恢復】SAP資料庫資料恢復案例資料庫資料恢復
- 【備份恢復】閃回資料庫(二) 基於 SCN 閃回資料庫資料庫
- 【資料庫資料恢復】透過恢復NDF檔案修復資料庫的資料恢復過程資料庫資料恢復
- 基於MySQL資料庫討論虛擬機器資料恢復MySql資料庫虛擬機資料恢復
- ORACLE資料庫基於時間點的不完全恢復Oracle資料庫
- 11gR2 基於ASM磁碟組的資料庫恢復ASM資料庫
- 寶塔資料庫恢復 mysql資料庫丟失恢復 mysql資料庫刪除庫恢復 寶塔mysql資料庫恢復資料庫MySql
- 【資料庫資料恢復】如何恢復Oracle資料庫truncate表的資料資料庫資料恢復Oracle
- 【資料庫資料恢復】windows server下SqlServer資料庫的資料恢復資料庫資料恢復WindowsServerSQL
- 【資料庫資料恢復】Sql Server資料庫資料恢復案例資料庫資料恢復SQLServer
- 基於時間執行資料庫不完全恢復資料庫
- 【資料庫資料恢復】Oracle資料庫誤truncate table的資料恢復案例資料庫資料恢復Oracle
- 【資料庫資料恢復】誤truncate table的Oracle資料庫資料恢復方案資料庫資料恢復Oracle
- RAC 資料庫恢復到單例項下並且基於時間點恢復資料庫單例
- 伺服器資料恢復—透過拼接資料庫碎片恢復SqlServer資料庫資料的資料恢復案例伺服器資料恢復資料庫SQLServer
- 資料庫修復資料恢復資料庫資料恢復
- linux下oracle rman 複製資料庫技術(until cancel不完全恢復)LinuxOracle資料庫
- 恢復資料庫資料庫
- 【資料庫資料恢復】SqlServer資料庫無法讀取的資料恢復案例資料庫資料恢復SQLServer
- 【資料庫資料恢復】sql server資料庫連線失效的資料恢復案例資料庫資料恢復SQLServer
- 【資料庫資料恢復】MongoDB資料庫檔案損壞的資料恢復案例資料庫資料恢復MongoDB
- 基於GTID恢復誤篡改資料
- 基於percona xtrabackup之innobackupex實現基於時間點資料庫恢復資料庫
- 【備份恢復】閃回資料庫(三)基於時間戳閃回資料庫資料庫時間戳
- MySQL資料庫的恢復MySql資料庫
- 【資料庫資料恢復】ASM磁碟組掉線的Oracle資料庫資料恢復案例資料庫資料恢復ASMOracle
- 【資料庫資料恢復】SQL Server資料庫磁碟空間不足的資料恢復案例資料庫資料恢復SQLServer
- 使用恢復建議恢復資料庫資料庫
- Backup And Recovery User's Guide-執行不完全資料庫恢復-執行Cancel-Based不完全恢復GUIIDE資料庫
- 【資料庫資料恢復】oracle資料庫誤truncate table怎麼恢復資料?資料庫資料恢復Oracle
- 【資料庫資料恢復】透過資料頁恢復Sql Server資料庫資料的過程資料庫資料恢復SQLServer
- 【備份恢復】閃回資料庫(四)基於可靠還原點閃回資料庫資料庫
- 【資料庫資料恢復】Sql Server資料庫檔案丟失的資料恢復過程資料庫資料恢復SQLServer
- 【資料庫資料恢復】MongoDB資料庫服務啟動失敗的資料恢復案例資料庫資料恢復MongoDB