11g rman備份恢復資料檔案datafile到新的位置

wisdomone1發表於2013-06-06

----備份資料檔案5
-bash-3.2$ rman target sys/system
backup datafile 5 format '/oracle/rmanbackup/backupwisdomone.dbf';

----恢復資料檔案5到新的位置
-bash-3.2$ rman target sys/system

Recovery Manager: Release 11.2.0.1.0 - Production on Thu Jun 6 05:04:27 2013

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ZXY (DBID=1701163695)

----注意:run與{在同一行,不然執行會報錯  
run{
   sql 'alter database datafile 5 offline';--恢復資料檔案前先離線
   set newname for datafile 5 to '/oracle/newwisdomone.dbf';--指定資料檔案5新的儲存位置
   restore datafile 5;--還原資料檔案
   switch datafile 5;--切換資料檔案
   recover datafile 5;--恢復資料檔案
   sql 'alter database datafile 5 online';--資料檔案線上
8> }

using target database control file instead of recovery catalog
sql statement: alter database datafile 5 offline

executing command: SET NEWNAME

Starting restore at 06-JUN-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=37 device type=DISK

datafile 5 is already restored to file /oracle/newwisdomone.dbf
restore not done; all files read only, offline, or already restored
Finished restore at 06-JUN-13

datafile 5 switched to datafile copy
input datafile copy RECID=3 STAMP=817362275 file name=/oracle/newwisdomone.dbf

Starting recover at 06-JUN-13
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:00

Finished recover at 06-JUN-13

sql statement: alter database datafile 5 online

RMAN> exit


Recovery Manager complete.
-bash-3.2$ sqlplus sys/system as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Thu Jun 6 05:04:46 2013

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

----檢查資料檔案是否變更為新的儲存位置
SQL> select file#,name from v$datafile;

     FILE#
----------
NAME
--------------------------------------------------------------------------------
         1
/oracle/app/oracle/oradata/zxy/system01.dbf

         2
/oracle/app/oracle/oradata/zxy/sysaux01.dbf

         3
/oracle/app/oracle/oradata/zxy/undotbs01.dbf


     FILE#
----------
NAME
--------------------------------------------------------------------------------
         4
/oracle/app/oracle/oradata/zxy/users01.dbf

         5
/oracle/newwisdomone.dbf ---這個OK了

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-763202/,如需轉載,請註明出處,否則將追究法律責任。

相關文章