概念
要使用恢复管理器制作所有数据文件的映像副本,请按照以下步骤执行:
1. 连接到RMAN 并在装载模式下启动:
RMAN> STARTUP MOUNT
2. 获取目标数据库的数据文件列表:
RMAN> REPORT SCHEMA;
3. 使用COPY 命令或脚本创建上面列出的所有数据文件的副本:
RMAN> COPY datafile 1 TO ’BACKUP/df1.cpy’
datafile 2 TO ’BACKUP/df2.cpy ’...;
4. 使用LIST COPY 命令验证副本:
RMAN> LIST COPY;
可以使用CURRENT CONTROLFILE 命令将控制文件包含在副本中。此外,如果
CONFIGURE CONTROLFILE AUTOBACKUP 为ON,则在执行COPY 命令后,RMAN 将
自动备份控制文件。
具体操作
备份数据库文件
$ rman target /
Recovery Manager: Release 10.2.0.4.0 - Production on Thu Jul 30 09:50:09 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database (not started)
RMAN> startup mount;
Oracle instance started
database mounted
Total System Global Area 1610612736 bytes
Fixed Size 2056504 bytes
Variable Size 704646856 bytes
Database Buffers 889192448 bytes
Redo Buffers 14716928 bytes
RMAN> report schema;
using target database control file instead of recovery catalog
Report of database schema
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 8192 SYSTEM *** +DG_DATA/cctt/datafile/system.256.684757403
2 8192 UNDOTBS1 *** +DG_DATA/cctt/datafile/undotbs1.258.684757403
3 1024 SYSAUX *** +DG_DATA/cctt/datafile/sysaux.257.684757403
4 512 USERS *** +DG_DATA/cctt/datafile/users.259.684757403
5 512 EXAMPLE *** +DG_DATA/cctt/datafile/example.264.684757477
6 25 UNDOTBS2 *** +DG_DATA/cctt/datafile/undotbs2.265.684757563
7 256 TEST *** +DG_DATA/test1
8 16383 CC_DATA1 *** +DG_DATA/cctt/datafile/ccdata101.dbf
9 16383 CC_DATA *** +DG_DATA/cctt/datafile/ccdata001.dbf
10 16383 CC_DATA *** +DG_DATA/cctt/datafile/ccdata002.dbf
11 16383 CC_DATA2 *** +DG_DATA/cctt/datafile/ccdata201.dbf
12 16383 CC_DATA3 *** +DG_DATA/cctt/datafile/ccdata301.dbf
13 16383 CC_DATA4 *** +DG_DATA/cctt/datafile/ccdata401.dbf
14 16383 CC_DATA4 *** +DG_DATA/cctt/datafile/ccdata402.dbf
15 16383 CC_DATA4 *** +DG_DATA/cctt/datafile/ccdata403.dbf
16 16383 CC_DATA4 *** +DG_DATA/cctt/datafile/ccdata404.dbf
17 16383 CC_DATA4 *** +DG_DATA/cctt/datafile/ccdata405.dbf
18 16383 CC_DATA1 *** +DG_DATA/cctt/datafile/ccdata102.dbf
19 16383 CC_DATA2 *** +DG_DATA/cctt/datafile/ccdata202.dbf
20 16383 CC_DATA3 *** +DG_DATA/cctt/datafile/ccdata302.dbf
21 16383 TS_VCMSDATA *** +DG_DATA/cctt/datafile/vcmsdata01.dbf
22 16383 TS_VCMSDATA *** +DG_DATA/cctt/datafile/vcmsdata02.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 8192 TEMP 8192 +DG_DATA/cctt/tempfile/temp.263.684757475
2 16383 CC_TEMP 16383 +DG_DATA/cctt/datafile/cctemp01.dbf
RMAN> copy datafile 9 to '/app/df1.cpy';
Starting backup at 30-JUL-09
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=1633 instance=cctt1 devtype=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 07/30/2009 09:51:31
ORA-01138: database must either be open in this instance or not at all
RMAN> copy datafile 9 to '/app/df1.cpy';
Starting backup at 30-JUL-09
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile fno=00009 name=+DG_DATA/cctt/datafile/ccdata001.dbf
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 07/30/2009 09:53:31
ORA-19504: failed to create file "/app/df1.cpy"
ORA-27040: file create error, unable to create file
HPUX-ia64 Error: 13: Permission denied
RMAN> copy datafile 9 to '/app/rmantest/df1.cpy';
Starting backup at 30-JUL-09
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile fno=00009 name=+DG_DATA/cctt/datafile/ccdata001.dbf
output filename=/app/rmantest/df1.cpy tag=TAG20090730T095412 recid=644 stamp=693568843
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:06:35
Finished backup at 30-JUL-09
Starting Control File and SPFILE Autobackup at 30-JUL-09
piece handle=+DG_BACK/cctt/autobackup/2009_07_30/s_693568375.400.693568849 comment=NONE
Finished Control File and SPFILE Autobackup at 30-JUL-09
RMAN> list copy;
List of Datafile Copies
Key File S Completion Time Ckp SCN Ckp Time Name
------- ---- - --------------- ---------- --------------- ----
630 1 A 29-JUL-09 15621058 28-JUL-09 +DG_BACK/cctt/datafile/system.337.690914859
638 2 A 29-JUL-09 15621058 28-JUL-09 +DG_BACK/cctt/datafile/undotbs1.338.690914903
643 3 A 29-JUL-09 15621058 28-JUL-09 +DG_BACK/cctt/datafile/sysaux.328.690913371
641 4 A 29-JUL-09 15621058 28-JUL-09 +DG_BACK/cctt/datafile/users.329.690913385
642 5 A 29-JUL-09 15621058 28-JUL-09 +DG_BACK/cctt/datafile/example.330.690913391
639 6 A 29-JUL-09 15621058 28-JUL-09 +DG_BACK/cctt/datafile/undotbs2.332.690913401
640 7 A 29-JUL-09 15621058 28-JUL-09 +DG_BACK/cctt/datafile/test.331.690913399
622 8 A 29-JUL-09 15621058 28-JUL-09 +DG_BACK/cctt/datafile/cc_data1.315.690912319
644 9 A 30-JUL-09 15891696 30-JUL-09 /app/rmantest/df1.cpy
623 9 A 29-JUL-09 15618565 28-JUL-09 +DG_BACK/cctt/datafile/cc_data.305.690912405
599 9 A 28-JUL-09 15615034 28-JUL-09 /app/rmantest/ccdata001.dbf
624 10 A 29-JUL-09 15618565 28-JUL-09 +DG_BACK/cctt/datafile/cc_data.318.690912489
625 11 A 29-JUL-09 15621058 28-JUL-09 +DG_BACK/cctt/datafile/cc_data2.319.690912575
626 12 A 29-JUL-09 15621058 28-JUL-09 +DG_BACK/cctt/datafile/cc_data3.320.690912661
627 13 A 29-JUL-09 15621058 28-JUL-09 +DG_BACK/cctt/datafile/cc_data4.321.690912755
628 14 A 29-JUL-09 15621058 28-JUL-09 +DG_BACK/cctt/datafile/cc_data4.322.690912841
629 15 A 29-JUL-09 15621058 28-JUL-09 +DG_BACK/cctt/datafile/cc_data4.323.690912935
631 16 A 29-JUL-09 15621058 28-JUL-09 +DG_BACK/cctt/datafile/cc_data4.324.690913021
632 17 A 29-JUL-09 15621058 28-JUL-09 +DG_BACK/cctt/datafile/cc_data4.325.690913107
633 18 A 29-JUL-09 15621058 28-JUL-09 +DG_BACK/cctt/datafile/cc_data1.326.690913191
634 19 A 29-JUL-09 15621058 28-JUL-09 +DG_BACK/cctt/datafile/cc_data2.327.690913277
635 20 A 29-JUL-09 15621058 28-JUL-09 +DG_BACK/cctt/datafile/cc_data3.334.690914601
636 21 A 29-JUL-09 15621058 28-JUL-09 +DG_BACK/cctt/datafile/ts_vcmsdata.335.690914687
637 22 A 29-JUL-09 15621058 28-JUL-09 +DG_BACK/cctt/datafile/ts_vcmsdata.336.690914773