N user2.dbf => +DATA/ORCL/DATAFILE/COPY_FILE.273.944581883
3、rman的convert和backup as copy命令
3.1 convert命令
convert命令是用于对数据文件进行字节格式转换的。Oracle可以在不同OS平台间进行表空间传(TTS),如果两个平台的字节格式不一致,则需要参数据文件进行格式转换,这个转换可以 在源数据库进行,也可以在目的数据库中执行。如果在源数据库中执行,则需要使用convert tablespace命令,如果在目的数据库中执行,则需要使用convert datafile命令。
虽然convert这个命令主要用于跨平台传输表空间,它也可以完成ASM和本地文件系统间拷贝文件,并且也是很简单的一种方法。
#使用convert datafile从ASM复制到文件系统
RMAN> convert datafile '+data/orcl/datafile/USERS.259.925306091' format '/home/oracle/user3.dbf';
Starting conversion at target at 21-MAY-17
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile conversion
input file name=+DATA/orcl/datafile/users.259.925306091
converted datafile=/home/oracle/user3.dbf
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01
Finished conversion at target at 21-MAY-17
#验证
[oracle@rac1 ~]$ ls -l /home/oracle/user3.dbf
-rw-r-----. 1 oracle asmadmin 5251072 May 21 16:00 /home/oracle/user3.dbf
#使用convert tablespace,使用时需要把users表空间置为只读
RMAN> sql 'alter tablespace users read only';
using target database control file instead of recovery catalog
sql statement: alter tablespace users read only
RMAN> convert tablespace users format '/home/oracle/users%U.dbf';
Starting conversion at source at 21-MAY-17
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=81 instance=orcl1 device type=DISK
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00004 name=+DATA/orcl/datafile/users.259.925306091
converted datafile=/home/oracle/usersdata_D-ORCL_I-1453086940_TS-USERS_FNO-4_0ns4qbtn.dbf
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01
Finished conversion at source at 21-MAY-17
#验证
[oracle@rac1 ~]$ ll /home/oracle/usersdata_D-ORCL_I-1453086940_TS-USERS_FNO-4_0ns4qbtn.dbf
-rw-r-----. 1 oracle asmadmin 5251072 May 21 16:03 /home/oracle/usersdata_D-ORCL_I-1453086940_TS-USERS_FNO-4_0ns4qbtn.dbf
#从文件系统拷贝到ASM
RMAN> convert datafile '/home/oracle/user3.dbf','/home/oracle/usersdata_D-ORCL_I-1453086940_TS-USERS_FNO-4_0ns4qbtn.dbf' format '+data';
Starting conversion at target at 21-MAY-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=64 instance=orcl1 device type=DISK
channel ORA_DISK_1: starting datafile conversion
input file name=/home/oracle/user3.dbf
converted datafile=+DATA/orcl/datafile/users.274.944582713
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting datafile conversion
input file name=/home/oracle/usersdata_D-ORCL_I-1453086940_TS-USERS_FNO-4_0ns4qbtn.dbf
converted datafile=+DATA/orcl/datafile/users.275.944582713
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01
Finished conversion at target at 21-MAY-17
#从日志中看出转换的文件名
#converted datafile=+DATA/orcl/datafile/users.274.944582713
#converted datafile=+DATA/orcl/datafile/users.274.944582713
3.2 backup as copy命令
backup as copy命令是以镜像���方式对文件进行备份,自然可以把文件从ASM复制到文件系统中。这也是从文件系统迁移到ASM时可以选择的方法之一。
#执行复制
RMAN> backup as copy datafile '+DATA/orcl/datafile/users.259.925306091' format '/home/oracle/user4.dbf';
Starting backup at 21-MAY-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=69 instance=orcl1 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=+DATA/orcl/datafile/users.259.925306091
output file name=/home/oracle/user4.dbf tag=TAG20170521T161225 RECID=17 STAMP=944583145
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 21-MAY-17
#验证
[oracle@rac1 ~]$ ls -l /home/oracle/user4.dbf
-rw-r-----. 1 oracle asmadmin 5251072 May 21 16:12 /home/oracle/user4.dbf
4.FTP方法