rman中的conver命令主要用户跨平台传输表空间,也可以完成从ASM何本地文件系统中拷贝文件,比用dbms_file_transfer方法要简单
从ASM拷贝到文件系统:
拷贝表空间
在拷贝表空间的时候,必须首先将表空间设置为只读,否则会出错,如下:
RMAN> convert tablespace kel format '/home/oracle/kel1_%U.dbf';
Starting backup at 10-JUL-14
using channel ORA_DISK_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of backup command at 07/10/2014 23:45:00
RMAN-06599: tablespace KEL is not read-only
将表空间设置为只读:
SQL> alter tablespace kel read only;
Tablespace altered.
拷贝表空间:
RMAN> convert tablespace kel format '/home/oracle/kel1_%U.dbf';
Starting backup at 10-JUL-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile conversion
input datafile fno=00005 name=+RECOVER/omf/datafile/kel.dbf
converted datafile=/home/oracle/kel1_data_D-OMF_I-680034237_TS-KEL_FNO-5_05pd33mi.dbf
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:25
Finished backup at 10-JUL-14
拷贝数据文件
拷贝数据文件的文件的时候,直接进行拷贝即可:
RMAN> convert datafile '+recover/omf/datafile/CONVERT.274.852579119' format '/home/oracle/con_%U.dbf';
Starting backup at 10-JUL-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile conversion
input filename=+RECOVER/omf/datafile/convert.274.852579119
converted datafile=/home/oracle/con_data_D-OMF_I-680034237_TS-CONVERT_FNO-6_06pd33s7.dbf
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:16
Finished backup at 10-JUL-14
从文件系统拷贝到ASM中
RMAN> convert datafile '/home/oracle/kel.dbf' format '+recover';
Starting backup at 10-JUL-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile conversion
input filename=/home/oracle/kel.dbf
converted datafile=+RECOVER/omf/datafile/kel.276.852594751
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:25
Finished backup at 10-JUL-14
在从文件系统拷贝到ASM之后,可以将数据文件先offline
SQL> alter database datafile '+RECOVER/omf/datafile/kel.dbf' offline;
Database altered.
然后将数据库文件进行更名
SQL> alter database rename file '+RECOVER/omf/datafile/kel.dbf' to '+RECOVER/omf/datafile/KEL.276.852594751';
Database altered.
在online的时候报错:
SQL> alter database datafile '+RECOVER/omf/datafile/KEL.276.852594751' online;
alter database datafile '+RECOVER/omf/datafile/KEL.276.852594751' online
*
ERROR at line 1:
ORA-01113: file 5 needs media recovery
ORA-01110: data file 5: '+RECOVER/omf/datafile/kel.276.852594751'
对数据文件进行恢复;
RMAN> recover datafile 5;
Starting recover at 11-JUL-14
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:05
Finished recover at 11-JUL-14
然后将数据文件online:
SQL> alter database datafile '+RECOVER/omf/datafile/KEL.276.852594751' online;
Database altered.