用rman更改管理裸裝置檔案

imlihj2007發表於2009-04-29

--用rman更改管理裸裝置檔案
----裸裝置=>檔案系統
$ export ORACLE_SID=test
$ rman target /
Recovery Manager: Release 11.1.0.7.0 - Production on Wed Apr 29 10:35:43 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: TEST (DBID=1981273836)
RMAN> backup tablespace "TEST";
Starting backup at 29-APR-09
using channel ORA_DISK_1
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=/dev/datavg/rlihjtest1
channel ORA_DISK_1: starting piece 1 at 29-APR-09
channel ORA_DISK_1: finished piece 1 at 29-APR-09
piece handle=/opt/oradata/flash_recovery_area/TEST/backupset/2009_04_29/o1_mf_nnndf_TAG20090429T104149_4zhhmg4q_.bkp tag=TAG20090429T104149 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 29-APR-09
RMAN> run
2> {allocate channel d1 type disk;
3> set newname for datafile 7 to '/opt/oradata/oradata/test/lihjtest1';
4> restore datafile 7;
5> release channel d1;
6> }
released channel: ORA_DISK_1
allocated channel: d1
channel d1: SID=141 device type=DISK
executing command: SET NEWNAME
Starting restore at 29-APR-09
channel d1: starting datafile backup set restore
channel d1: specifying datafile(s) to restore from backup set
channel d1: restoring datafile 00007 to /opt/oradata/oradata/test/lihjtest1
channel d1: reading from backup piece /opt/oradata/flash_recovery_area/TEST/backupset/2009_04_29/o1_mf_nnndf_TAG20090429T104149_4zhhmg4q_.bkp
channel d1: piece handle=/opt/oradata/flash_recovery_area/TEST/backupset/2009_04_29/o1_mf_nnndf_TAG20090429T104149_4zhhmg4q_.bkp tag=TAG20090429T104149
channel d1: restored backup piece 1
channel d1: restore complete, elapsed time: 00:00:07
Finished restore at 29-APR-09
released channel: d1
RMAN> recover datafile 7;
---------
--sqlplus 操作!
SQL> alter database datafile 7 offline drop;
Database altered.
SQL> alter database rename file '/dev/datavg/rlihjtest1' to '/opt/oradata/oradata/test/lihjtest1';
Database altered.
SQL> alter database datafile 7 online;
Database altered.
SQL> conn test1/test
Connected.
SQL> select count(*) from dd;
COUNT(*)
----------
7
SQL> select name from v$datafile;
NAME
----------------------------------------------------------------------
/opt/oradata/oradata/test/system01.dbf
/opt/oradata/oradata/test/sysaux01.dbf
/opt/oradata/oradata/test/undotbs01.dbf
/opt/oradata/oradata/test/users01.dbf
/opt/oradata/product/11.1.0/db_2/dbs/imp.dbf
/opt/oradata/product/11.1.0/db_2/dbs/impidx.dbf
/opt/oradata/oradata/test/lihjtest1
7 rows selected.
SQL>


---------
----檔案系統=>裸裝置
$ rman target /
Recovery Manager: Release 11.1.0.7.0 - Production on Wed Apr 29 13:10:50 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: TEST (DBID=1981273836)
RMAN> run
2> {allocate channel d1 type disk;
3> set newname for datafile 7 to '/dev/datavg/rlihjtest2';
4> restore datafile 7;
5> release channel d1;
6> }
using target database control file instead of recovery catalog
allocated channel: d1
channel d1: SID=155 device type=DISK
executing command: SET NEWNAME
Starting restore at 29-APR-09
channel d1: restoring datafile 00007
input datafile copy RECID=1 STAMP=685450171 file name=/opt/oradata/oradata/test/lihjtest1
destination for restore of datafile 00007: /dev/datavg/rlihjtest2
ORA-19563: datafile copy header validation failed for file /opt/oradata/oradata/test/lihjtest1
ORA-19600: input file is datafile-copy 1 (/opt/oradata/oradata/test/lihjtest1)
ORA-19601: output file is datafile-copy 0 (/dev/datavg/rlihjtest2)
failover to previous backup
channel d1: starting datafile backup set restore
channel d1: specifying datafile(s) to restore from backup set
channel d1: restoring datafile 00007 to /dev/datavg/rlihjtest2
channel d1: reading from backup piece /opt/oradata/flash_recovery_area/TEST/backupset/2009_04_29/o1_mf_nnndf_TAG20090429T104149_4zhhmg4q_.bkp
channel d1: piece handle=/opt/oradata/flash_recovery_area/TEST/backupset/2009_04_29/o1_mf_nnndf_TAG20090429T104149_4zhhmg4q_.bkp tag=TAG20090429T104149
channel d1: restored backup piece 1
channel d1: restore complete, elapsed time: 00:00:01
Finished restore at 29-APR-09
released channel: d1
RMAN> recover datafile 7;
Starting recover at 29-APR-09
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=155 device type=DISK
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 29-APR-09
RMAN>
---------
--sqlplus 操作!
SQL> alter database datafile 7 offline drop;
Database altered.
SQL> alter database rename file '/opt/oradata/oradata/test/lihjtest1' to '/dev/datavg/rlihjtest2';
Database altered.
SQL> alter database datafile 7 online;
Database altered.
SQL> conn test1/test
Connected.
SQL> select count(*) from dd;
COUNT(*)
----------
7
SQL> select name from v$datafile;
NAME
----------------------------------------------------------------------
/opt/oradata/oradata/test/system01.dbf
/opt/oradata/oradata/test/sysaux01.dbf
/opt/oradata/oradata/test/undotbs01.dbf
/opt/oradata/oradata/test/users01.dbf
/opt/oradata/product/11.1.0/db_2/dbs/imp.dbf
/opt/oradata/product/11.1.0/db_2/dbs/impidx.dbf
/dev/datavg/rlihjtest2
7 rows selected.
SQL>

--利用匯入匯出做資料庫全移植!!

[@more@]

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

相關文章