[20160720]rman set newname for datafile
[20160720]rman set newname for datafile本質.txt
--前幾天在恢復歷史資料庫,因為生產系統資料庫是asm,恢復必須要轉成檔案型別。
--一般指令碼執行如下:
run {
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
set until time '2015-03-01 18:00:00';
set newname for datafile 1 to '/u01/app/oracle/oradata/dbcn1/datafile/system.308.862160493';
....
set newname for datafile 43 to '/u01/app/oracle/oradata/dbcn1/datafile/portal_emrca01.dbf';
restore database;
switch datafile all;
recover database;
release channel c1;
release channel c2;
release channel c3;
}
--自己也在測試環境做一些探究,看看一些細節:
1.環境:
SCOTT@book> @ &r/ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
CREATE TABLESPACE TEA DATAFILE
'/mnt/ramdisk/book/tea01.dbf' SIZE 5M AUTOEXTEND ON NEXT 1M MAXSIZE 1G
LOGGING
ONLINE
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO
FLASHBACK ON;
RMAN> list archivelog all ;
specification does not match any archived log in the repository
RMAN> list backupset ;
specification does not match any backup in the repository
--//清除archive log資訊以及備份集。
2.建立資料檔案7備份:
--//注:tea表空間的資料檔案僅僅1個,file#=7.
RMAN> backup datafile 7 format '/home/oracle/backup/datafile_7_%u.bak';
Starting backup at 2016-07-20 11:26:36
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00007 name=/mnt/ramdisk/book/tea01.dbf
channel ORA_DISK_1: starting piece 1 at 2016-07-20 11:26:36
channel ORA_DISK_1: finished piece 1 at 2016-07-20 11:26:37
piece handle=/home/oracle/backup/datafile_7_64rb5r3c.bak tag=TAG20160720T112636 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2016-07-20 11:26:37
3.測試:
--僅僅恢復資料檔案7看看,建立指令碼如下:
run
{
set newname for datafile 7 to '/home/oracle/backup/tea01.dbf';
restore datafile 7;
}
executing command: SET NEWNAME
Starting restore at 2016-07-20 11:30:05
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=123 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=134 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=145 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 00007 to /home/oracle/backup/tea01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/datafile_7_64rb5r3c.bak
channel ORA_DISK_1: piece handle=/home/oracle/backup/datafile_7_64rb5r3c.bak tag=TAG20160720T112636
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 2016-07-20 11:30:08
RMAN> **end-of-file**
RMAN> list copy of datafile 7;
List of Datafile Copies
=======================
Key File S Completion Time Ckp SCN Ckp Time
------- ---- - ------------------- ---------- -------------------
20 7 A 2016-07-20 11:30:07 13244560062 2016-07-20 11:26:36
Name: /home/oracle/backup/tea01.dbf
RMAN> list archivelog all ;
specification does not match any archived log in the repository
RMAN> list copy of datafile 7;
List of Datafile Copies
=======================
Key File S Completion Time Ckp SCN Ckp Time
------- ---- - ------------------- ---------- -------------------
20 7 A 2016-07-20 11:30:07 13244560062 2016-07-20 11:26:36
Name: /home/oracle/backup/tea01.dbf
--//從這裡可以看出set之後,加入restore相當於建立資料檔案的copy,並且這些資訊記錄在控制檔案中。
--//而指令碼中執行switch datafile all;相當於切換到複製的資料檔案作為資料檔案。
--//如果單獨切換資料檔案7可以寫成:
switch datafile number|name to copy;
switch datafile number|name ;
--//注:第2種語法僅僅執行在run內。第1種可以rman的提示符下使用,測試看看:
RMAN> switch datafile 7 to copy;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of switch to copy command at 07/20/2016 11:48:46
RMAN-06572: database is open and datafile 7 is not offline
--//注:資料檔案7必須offline.
RMAN> sql 'alter database datafile 7 offline';
sql statement: alter database datafile 7 offline
RMAN> switch datafile 7 to copy;
datafile 7 switched to datafile copy "/home/oracle/backup/tea01.dbf"
RMAN> list copy of datafile 7;
List of Datafile Copies
=======================
Key File S Completion Time Ckp SCN Ckp Time
------- ---- - ------------------- ---------- -------------------
21 7 A 2016-07-20 11:49:35 13244560062 2016-07-20 11:26:36
Name: /mnt/ramdisk/book/tea01.dbf
--這樣原來的資料檔案變成了資料檔案copy。再交換回來。
RMAN> switch datafile 7 to copy;
datafile 7 switched to datafile copy "/mnt/ramdisk/book/tea01.dbf"
RMAN> sql 'alter database datafile 7 online';
sql statement: alter database datafile 7 online
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of sql command on default channel at 07/20/2016 11:51:01
RMAN-11003: failure during parse/execution of SQL statement: alter database datafile 7 online
ORA-01113: file 7 needs media recovery
ORA-01110: data file 7: '/mnt/ramdisk/book/tea01.dbf'
--//說明offline沒有寫檢查點,online要先恢復。
RMAN> recover datafile 7;
Starting recover at 2016-07-20 11:51:50
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 2016-07-20 11:51:50
RMAN> sql 'alter database datafile 7 online';
sql statement: alter database datafile 7 online
--總結:
--從以上測試可以發現set newname for datafile以後在restore,相當於建立了一個資料檔案複製。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2122270/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- RMAN SET NEWNAME
- rman set newname switch 用法
- oracle10g_rman_syntac testing_set newname_switch tempfile_datafile_all_tagOracle
- RMAN : set newname for命令的一點研究
- 關於rman中set newname的探討
- SET NEWNAME FOR
- oracle rman 異機還原測試--set newnameOracle
- [20201103]set newname for datafile.txt
- rman copy asm datafile(rename asm datafile)ASM
- 解決set newname 極慢的問題
- 【備份恢復】set newname切換日誌
- SET NEWNAME 切換檔案並恢復影像副本
- rman datafile恢復(歸檔模式)模式
- rman restore database(spfile,controlfile, datafile)RESTDatabase
- Oracle 使用RMAN COPY 移動 Datafile 位置Oracle
- How to copy a datafile from ASM to a file system not using RMANASM
- RMAN-06100: no channel to restore a backup or copy of datafileREST
- RMAN說,我能備份(16)--RMAN中的SET命令
- RMAN-06023 no backup or copy of datafile 1 found to restoreREST
- 【RMAN】RMAN-20020: DATABASE INCARNATION NOT SETDatabase
- Oracle OCP 1Z0 053 Q564(Datafile Recovery with RMAN)Oracle
- RMAN備份時出現RMAN-06056: could not access datafile 6 錯誤,解決方法!!
- Oracle OCP 1Z0 053 Q505(RMAN DATAFILE BACKUP COPIES)Oracle
- 監控和優化RMAN之SET COMMAND ID優化
- 應對 "RMAN-06023: no backup or copy of datafile 1 found to restore"錯誤REST
- 【Datafile】Oracle單個datafile大小的限制Oracle
- Oracle datafileOracle
- RMAN中SET命令的常見用法的小結 (ZT)
- 11g rman備份恢復資料檔案datafile到新的位置
- v$datafile_header 查詢datafile 狀態Header
- [20160720]檢視了解oracle跟蹤事件.txtOracle事件
- alter database create datafileDatabase
- alter database create datafile '' as ''Database
- how to remove datafile pathREM
- RMAN restore fails with ORA-01180: can not create datafile 1 (文件 ID 1265151.1)RESTAI
- Oracle OCP 1Z0 053 Q94(RMAN SET COMMAND ID)Oracle
- alter database datafile offline drop 與 alter tablespace drop datafile 區別Database
- Renaming a Datafile in the Primary DatabaseDatabase