[20160421]backup as copy问题2.txt
http://blog.itpub.net/267265/viewspace-2070878/
--前面提到使用backup as copy datafile 1 format '/home/oracle/backup/%b' ;这样的方式会报错
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 03/29/2016 09:24:29
ORA-19715: invalid format b for generated name
ORA-27302: failure occurred at: slgpn
--只要因为要system文件,会触发oracle自动备份spfile以及控制文件产生触发错误。
--可以使用DB_FILE_NAME_CONVERT来实现,不过很奇怪的是database必须放在最后。
BACKUP AS COPY DB_FILE_NAME_CONVERT=('/mnt/ramdisk/book/','/home/oracle/backup/') FORMAT='/home/oracle/backup/spfile_and_control_%U' database;
RMAN> BACKUP AS COPY DB_FILE_NAME_CONVERT=('/mnt/ramdisk/book/','/home/oracle/backup/') FORMAT='/home/oracle/backup/spfile_and_control_%U' datafile 1;
--实际上还可以这样操作:
copy datafile 1 to '/home/oracle/backup/system01.dbf'
copy datafile 1 to '/home/oracle/backup/system01.dbf' ,current controlfile to '/home/oracle/backup/control.bak';
RMAN> copy datafile 1 to '/home/oracle/backup/system01.dbf' ,current controlfile to '/home/oracle/backup/control.bak';
Starting backup at 2016-04-21 08:38:52
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/mnt/ramdisk/book/system01.dbf
output file name=/home/oracle/backup/system01.dbf tag=TAG20160421T083852 RECID=35 STAMP=909736733
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=/home/oracle/backup/control.bak tag=TAG20160421T083852 RECID=36 STAMP=909736735
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2016-04-21 08:38:56
--不过很奇怪的是如果写成如下:
RMAN> backup as copy datafile 1 to '/home/oracle/backup/system01.dbf';
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "single-quoted-string": expecting one of: "destination"
RMAN-01007: at line 1 column 30 file: standard input
--不过感觉oracle会废除rman的copy命令.如果要copy整个数据库你可以发现
RMAN> copy
2>
3>
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "end-of-file": expecting one of: "archivelog, backup, check, controlfilecopy, current, datafilecopy, datafile, keep, level, nochecksum, nokeep, reuse, tag, ("
RMAN-01007: at line 3 column 1 file: standard input
--copy 命令并不支持database参数.要一个一个数据文件写.
SYS@book> select 'datafile '||file#||' to '''||replace(name,'/mnt/ramdisk/book/','/home/oracle/backup/')||''',' c60 from v$datafile;
C60
------------------------------------------------------------
datafile 1 to '/home/oracle/backup/system01.dbf',
datafile 2 to '/home/oracle/backup/sysaux01.dbf',
datafile 3 to '/home/oracle/backup/undotbs01.dbf',
datafile 4 to '/home/oracle/backup/users01.dbf',
datafile 5 to '/home/oracle/backup/example01.dbf',
datafile 6 to '/home/oracle/backup/sugar01.dbf',
datafile 7 to '/home/oracle/backup/tea01.dbf',
7 rows selected.
--这样写成如下:
copy
datafile 1 to '/home/oracle/backup/system01.dbf',
datafile 2 to '/home/oracle/backup/sysaux01.dbf',
datafile 3 to '/home/oracle/backup/undotbs01.dbf',
datafile 4 to '/home/oracle/backup/users01.dbf',
datafile 5 to '/home/oracle/backup/example01.dbf',
datafile 6 to '/home/oracle/backup/sugar01.dbf',
datafile 7 to '/home/oracle/backup/tea01.dbf',
current controlfile to '/home/oracle/backup/control.bak';
--打开并行会快一些.
RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 3 BACKUP TYPE TO BACKUPSET;
new RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK PARALLELISM 3 BACKUP TYPE TO BACKUPSET;
new RMAN configuration parameters are successfully stored
released channel: ORA_DISK_1