rman恢復的基本知識
1、口令檔案的恢復
口令檔案的路徑:$ORACLE_HOME/dbs目錄下
cd $ORACLE_HOME/dbs
rm orapworcl
orapwd file=orapworcl password=oracle entries=5; //重新建立一個檔案,entries的意思:DBA的使用者最多有5個
2、spfile丟失
SQL> startup nomount
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/10.2.0/db_1/dbs/initorcl.ora'
rman下
RMAN> set dbid 2694191837
executing command: SET DBID
RMAN> restore spfile from autobackup; //如果沒有成功,說明configure controlfile autobackup on 沒有配置,下次配置完成後,就可以恢復成功
Starting restore at 01-APR-14
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 04/01/2014 21:01:16
RMAN-12010: automatic channel allocation initialization failed
RMAN-06403: could not obtain a fully authorized session
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
指定路徑恢復
RMAN> set dbid 2694191837
executing command: SET DBID
RMAN> startup force nomount
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/10.2.0/db_1/dbs/initjiagulun.ora'
starting Oracle instance without parameter file for retrival of spfile
Oracle instance started
Total System Global Area 159383552 bytes
Fixed Size 2019224 bytes
Variable Size 67108968 bytes
Database Buffers 83886080 bytes
Redo Buffers 6369280 bytes
RMAN> restore spfile from '/home/oracle/rmanbak/inc0_0hp4lqu4_20140401'; //該路徑可以在以前備份日誌上找到
Starting restore at 01-APR-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=36 devtype=DISK
channel ORA_DISK_1: autobackup found: /home/oracle/rmanbak/inc0_0hp4lqu4_20140401
channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 01-APR-14
3、controlfile 丟失:
SQL> SHOW PARAMETER CONTROL_FILES //檢視備份檔案位置
SQL> startup nomount; //丟失control檔案可以到nomount階段
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 2020192 bytes
Variable Size 125832352 bytes
Database Buffers 150994944 bytes
Redo Buffers 6365184 bytes
SQL> alter database mount;
alter database mount
*
ERROR at line 1:
ORA-00205: error in identifying control file, check alert log for more info
SQL> shutdown immediate
ORA-01507: database not mounted
在RMAN下
RMAN> startup nomount;
Oracle instance started
Total System Global Area 285212672 bytes
Fixed Size 2020192 bytes
Variable Size 125832352 bytes
Database Buffers 150994944 bytes
Redo Buffers 6365184 bytes
RMAN> restore controlfile from autobackup;//因為沒有啟用autobackup,所以失敗
Starting restore at 01-APR-14
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 04/01/2014 21:43:22
RMAN-12010: automatic channel allocation initialization failed
RMAN-06403: could not obtain a fully authorized session
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
RMAN> restore controlfile from '/home/oracle/rmanbak/inc0_0gp4lqtt_20140401';
Starting restore at 01-APR-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=157 devtype=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output filename=/u01/app/oracle/oradata/JIAGULUN/controlfile/o1_mf_9mojz9ot_.ctl
output filename=/u01/app/oracle/flash_recovery_area/ORCL/controlfile/o1_mf_9mojzb1m_.ctl
Finished restore at 01-APR-14
恢復成功。
但是在sql下,還是無法開啟
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> alter database open RESETLOGS;
alter database open RESETLOGS
*
ERROR at line 1:
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1:
'/u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_7p5b14xs_.dbf'
出錯, redo log的scn記錄在controlfile裡面的,因為我們有新的controlfile,所以需要resetlogs;
RMAN下
RMAN> recover database; //以當前的控制檔案裡所記錄的SCN來恢復資料檔案的資料塊
Starting recover at 01-APR-14
Starting implicit crosscheck backup at 01-APR-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=155 devtype=DISK
Crosschecked 1 objects
Finished implicit crosscheck backup at 01-APR-14
Starting implicit crosscheck copy at 01-APR-14
using channel ORA_DISK_1
using channel ORA_DISK_2
Finished implicit crosscheck copy at 01-APR-14
searching for all files in the recovery area
cataloging files...
no files cataloged
using channel ORA_DISK_1
using channel ORA_DISK_2
starting media recovery
archive log thread 1 sequence 102 is already on disk as file /u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/o1_mf_2_7p5b34v6_.log
archive log thread 1 sequence 103 is already on disk as file /u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/o1_mf_3_7p5b36x4_.log
archive log thread 1 sequence 104 is already on disk as file /u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/o1_mf_1_7p5b31mg_.log
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/onlinelog/o1_mf_2_7p5b34v6_.log thread=1 sequence=102
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/onlinelog/o1_mf_3_7p5b36x4_.log thread=1 sequence=103
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/onlinelog/o1_mf_1_7p5b31mg_.log thread=1 sequence=104
media recovery complete, elapsed time: 00:00:02
Finished recover at 01-APR-14
成功開啟資料庫
SQL> alter database open RESETLOGS;//RESETLOGS會把online redelog file清空,資料檔案丟失.所以這個時候要做一個全備份。否則下次恢復會出錯
Database altered.
4、redo log 丟失
SQL> select group# , member from v$logfile;//檢視redolog檔案位置
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 2020192 bytes
Variable Size 88083616 bytes
Database Buffers 188743680 bytes
Redo Buffers 6365184 bytes
Database mounted.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: '/u01/app/oracle/oradata/orcl/redo01.log'
SQL> recover database until cancel;
Media recovery complete.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> alter database open resetlogs;//RESETLOGS會把online redelog file清空,資料檔案丟失.所以這個時候要做一個全備份。否則下次恢復會出錯
Database altered.
5、資料檔案恢復
SQL> select FILE#, NAME,STATUS from v$datafile; //檢視資料檔案位置狀態
RMAN> sql "alter database datafile 4 offline";//模擬丟失
using target database control file instead of recovery catalog
sql statement: alter database datafile 4 offline
恢復:
RMAN> restore datafile 4 ;
Starting restore at 01-APR-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=141 devtype=DISK
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00004 to /u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/rmanbak/inc0_0bp4m461_20140401
channel ORA_DISK_1: restored backup piece 1
piece handle=/home/oracle/rmanbak/inc0_0bp4m461_20140401 tag=LEVEL0
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
Finished restore at 01-APR-14
RMAN> recover datafile 4;
Starting recover at 01-APR-14
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:05
Finished recover at 01-APR-14
RMAN> sql "alter database datafile 4 online";
sql statement: alter database datafile 4 online
6、表空間丟失
SQL> select tablespace_name ,sum(bytes)/1024/1024 M from dba_data_files group by tablespace_name;//檢視錶空間及大小
RMAN> sql "alter tablespace users offline";//模擬丟失
using target database control file instead of recovery catalog
sql statement: alter tablespace users offline
恢復:
RMAN> restore tablespace users;
Starting restore at 01-APR-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=140 devtype=DISK
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00004 to /u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/rmanbak/inc0_0bp4m461_20140401
channel ORA_DISK_1: restored backup piece 1
piece handle=/home/oracle/rmanbak/inc0_0bp4m461_20140401 tag=LEVEL0
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 01-APR-14
RMAN> recover tablespace users;
Starting recover at 01-APR-14
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:03
Finished recover at 01-APR-14
RMAN> sql "alter tablespace users online";
sql statement: alter tablespace users online
口令檔案的路徑:$ORACLE_HOME/dbs目錄下
cd $ORACLE_HOME/dbs
rm orapworcl
orapwd file=orapworcl password=oracle entries=5; //重新建立一個檔案,entries的意思:DBA的使用者最多有5個
2、spfile丟失
SQL> startup nomount
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/10.2.0/db_1/dbs/initorcl.ora'
rman下
RMAN> set dbid 2694191837
executing command: SET DBID
RMAN> restore spfile from autobackup; //如果沒有成功,說明configure controlfile autobackup on 沒有配置,下次配置完成後,就可以恢復成功
Starting restore at 01-APR-14
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 04/01/2014 21:01:16
RMAN-12010: automatic channel allocation initialization failed
RMAN-06403: could not obtain a fully authorized session
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
指定路徑恢復
RMAN> set dbid 2694191837
executing command: SET DBID
RMAN> startup force nomount
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/10.2.0/db_1/dbs/initjiagulun.ora'
starting Oracle instance without parameter file for retrival of spfile
Oracle instance started
Total System Global Area 159383552 bytes
Fixed Size 2019224 bytes
Variable Size 67108968 bytes
Database Buffers 83886080 bytes
Redo Buffers 6369280 bytes
RMAN> restore spfile from '/home/oracle/rmanbak/inc0_0hp4lqu4_20140401'; //該路徑可以在以前備份日誌上找到
Starting restore at 01-APR-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=36 devtype=DISK
channel ORA_DISK_1: autobackup found: /home/oracle/rmanbak/inc0_0hp4lqu4_20140401
channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 01-APR-14
3、controlfile 丟失:
SQL> SHOW PARAMETER CONTROL_FILES //檢視備份檔案位置
SQL> startup nomount; //丟失control檔案可以到nomount階段
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 2020192 bytes
Variable Size 125832352 bytes
Database Buffers 150994944 bytes
Redo Buffers 6365184 bytes
SQL> alter database mount;
alter database mount
*
ERROR at line 1:
ORA-00205: error in identifying control file, check alert log for more info
SQL> shutdown immediate
ORA-01507: database not mounted
在RMAN下
RMAN> startup nomount;
Oracle instance started
Total System Global Area 285212672 bytes
Fixed Size 2020192 bytes
Variable Size 125832352 bytes
Database Buffers 150994944 bytes
Redo Buffers 6365184 bytes
RMAN> restore controlfile from autobackup;//因為沒有啟用autobackup,所以失敗
Starting restore at 01-APR-14
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 04/01/2014 21:43:22
RMAN-12010: automatic channel allocation initialization failed
RMAN-06403: could not obtain a fully authorized session
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
RMAN> restore controlfile from '/home/oracle/rmanbak/inc0_0gp4lqtt_20140401';
Starting restore at 01-APR-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=157 devtype=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output filename=/u01/app/oracle/oradata/JIAGULUN/controlfile/o1_mf_9mojz9ot_.ctl
output filename=/u01/app/oracle/flash_recovery_area/ORCL/controlfile/o1_mf_9mojzb1m_.ctl
Finished restore at 01-APR-14
恢復成功。
但是在sql下,還是無法開啟
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> alter database open RESETLOGS;
alter database open RESETLOGS
*
ERROR at line 1:
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1:
'/u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_7p5b14xs_.dbf'
出錯, redo log的scn記錄在controlfile裡面的,因為我們有新的controlfile,所以需要resetlogs;
RMAN下
RMAN> recover database; //以當前的控制檔案裡所記錄的SCN來恢復資料檔案的資料塊
Starting recover at 01-APR-14
Starting implicit crosscheck backup at 01-APR-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=155 devtype=DISK
Crosschecked 1 objects
Finished implicit crosscheck backup at 01-APR-14
Starting implicit crosscheck copy at 01-APR-14
using channel ORA_DISK_1
using channel ORA_DISK_2
Finished implicit crosscheck copy at 01-APR-14
searching for all files in the recovery area
cataloging files...
no files cataloged
using channel ORA_DISK_1
using channel ORA_DISK_2
starting media recovery
archive log thread 1 sequence 102 is already on disk as file /u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/o1_mf_2_7p5b34v6_.log
archive log thread 1 sequence 103 is already on disk as file /u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/o1_mf_3_7p5b36x4_.log
archive log thread 1 sequence 104 is already on disk as file /u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/o1_mf_1_7p5b31mg_.log
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/onlinelog/o1_mf_2_7p5b34v6_.log thread=1 sequence=102
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/onlinelog/o1_mf_3_7p5b36x4_.log thread=1 sequence=103
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/onlinelog/o1_mf_1_7p5b31mg_.log thread=1 sequence=104
media recovery complete, elapsed time: 00:00:02
Finished recover at 01-APR-14
成功開啟資料庫
SQL> alter database open RESETLOGS;//RESETLOGS會把online redelog file清空,資料檔案丟失.所以這個時候要做一個全備份。否則下次恢復會出錯
Database altered.
4、redo log 丟失
SQL> select group# , member from v$logfile;//檢視redolog檔案位置
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 2020192 bytes
Variable Size 88083616 bytes
Database Buffers 188743680 bytes
Redo Buffers 6365184 bytes
Database mounted.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: '/u01/app/oracle/oradata/orcl/redo01.log'
SQL> recover database until cancel;
Media recovery complete.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> alter database open resetlogs;//RESETLOGS會把online redelog file清空,資料檔案丟失.所以這個時候要做一個全備份。否則下次恢復會出錯
Database altered.
5、資料檔案恢復
SQL> select FILE#, NAME,STATUS from v$datafile; //檢視資料檔案位置狀態
RMAN> sql "alter database datafile 4 offline";//模擬丟失
using target database control file instead of recovery catalog
sql statement: alter database datafile 4 offline
恢復:
RMAN> restore datafile 4 ;
Starting restore at 01-APR-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=141 devtype=DISK
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00004 to /u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/rmanbak/inc0_0bp4m461_20140401
channel ORA_DISK_1: restored backup piece 1
piece handle=/home/oracle/rmanbak/inc0_0bp4m461_20140401 tag=LEVEL0
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
Finished restore at 01-APR-14
RMAN> recover datafile 4;
Starting recover at 01-APR-14
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:05
Finished recover at 01-APR-14
RMAN> sql "alter database datafile 4 online";
sql statement: alter database datafile 4 online
6、表空間丟失
SQL> select tablespace_name ,sum(bytes)/1024/1024 M from dba_data_files group by tablespace_name;//檢視錶空間及大小
RMAN> sql "alter tablespace users offline";//模擬丟失
using target database control file instead of recovery catalog
sql statement: alter tablespace users offline
恢復:
RMAN> restore tablespace users;
Starting restore at 01-APR-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=140 devtype=DISK
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00004 to /u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/rmanbak/inc0_0bp4m461_20140401
channel ORA_DISK_1: restored backup piece 1
piece handle=/home/oracle/rmanbak/inc0_0bp4m461_20140401 tag=LEVEL0
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 01-APR-14
RMAN> recover tablespace users;
Starting recover at 01-APR-14
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:03
Finished recover at 01-APR-14
RMAN> sql "alter tablespace users online";
sql statement: alter tablespace users online
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/27500440/viewspace-1136796/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- RMAN增量恢復
- RMAN恢復實踐
- RMAN恢復之RMAN-06555處理
- rman 增量備份恢復
- Oracle RMAN恢復測試Oracle
- RMAN備份恢復技巧
- 在rman恢復中incarnation的概念
- 查詢RMAN恢復進度
- Oracle RMAN 表空間恢復Oracle
- RMAN備份異機恢復
- RMAN備份恢復典型案例——異機恢復未知DBID
- RMAN備份恢復效能優化優化
- RMAN備份與恢復測試
- 【RMAN】在多租戶環境下的RMAN備份及恢復
- Oracle 備份恢復篇之RMAN catalogOracle
- ORACLE DG從庫 Rman備份恢復Oracle
- rman備份異機恢復(原創)
- RMAN備份恢復典型案例——RMAN備份&系統變慢
- 影像的基本知識
- 使用nub恢復資料庫的知識擴充套件資料庫套件
- 儲存器資料恢復相關知識資料恢復
- rman恢復控制檔案的一個小錯誤
- 【RMAN】Oracle12c以後rman 備份恢復命令參考Oracle
- Oracle 12C新特性-RMAN恢復表Oracle
- 12 使用RMAN備份和恢復檔案
- RMAN備份恢復典型案例——ORA-00245
- 透過搭建恢復目錄實現RMAN異地備份和恢復
- Oracle9i RMAN 的優缺點及RMAN 備份及恢復步驟Oracle
- Javascript物件的基本知識JavaScript物件
- js 基本知識JS
- DAX 基本知識
- 1、基本知識
- Uboot基本知識boot
- javaweb基本知識JavaWeb
- shell基本知識
- git基本知識Git
- 磁碟的基本知識和基本命令
- 一次rman恢復引起的nologging問題模擬
- [20190718]12c rman新特性 表恢復.txt