RMAN与外部环境
连接到RMAN
本地连接
[oracle@oracle ~]$ rman target sys/admin1@orcl
Recovery Manager: Release 10.2.0.1.0 - Production on Thu Oct 15 11:40:00 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1226104724)
RMAN> exit
Recovery Manager complete.
远程连接
[oracle@oracle ~]$ rman target sys/admin1@orcl
Recovery Manager: Release 10.2.0.1.0 - Production on Thu Oct 15 11:40:00 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1226104724)
在RMAN中启动/关闭数据库
[oracle@oracle ~]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Thu Oct 15 11:40:09 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1226104724)
RMAN> shutdown immediate
using target database control file instead of recovery catalog
database closed
database dismounted
Oracle instance shut down
RMAN> startup
connected to target database (not started)
Oracle instance started
database mounted
database opened
Total System Global Area 281018368 bytes
Fixed Size 1218968 bytes
Variable Size 71304808 bytes
Database Buffers 205520896 bytes
Redo Buffers 2973696 bytes
在RMAN中使用操作系统命令
RMAN> host;
[oracle@oracle ~]$ ll
总用量 332
-rw-r--r-- 1 oracle oinstall 26930 10月 14 07:58 aaa.txt
drwxr-xr-x 4 oracle oinstall 4096 10月 14 12:57 backup
drwxr-xr-x 2 oracle oinstall 4096 9月 6 21:30 Desktop
-rw-r--r-- 1 oracle oinstall 27015 10月 14 07:29 exact1.txt
-rw-r--r-- 1 oracle oinstall 26930 10月 14 07:43 exact2.txt
-rw-r--r-- 1 oracle oinstall 57013 10月 14 07:17 exact.txt
-rw-r--r-- 1 oracle oinstall 39950 10月 14 07:24 force.txt
-rw-r--r-- 1 oracle oinstall 26941 10月 14 07:33 similar1.txt
-rw-r--r-- 1 oracle oinstall 27017 10月 14 07:46 similar2.txt
-rw-r--r-- 1 oracle oinstall 56961 10月 14 07:21 similar.txt
-rw-r--r-- 1 oracle oinstall 734 9月 23 08:45 sqlnet.log
-rw-r--r-- 1 oracle oinstall 16761 10月 13 13:14 t.prf
在RMAN中执行SQL
RMAN> sql 'select * from dual ' ;
sql statement: select * from dual
RMAN> host ;
[oracle@oracle ~]$ logora
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Oct 15 11:51:35 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> select * from dual
2 ;
D
-
X
RMAN配置
RMAN> show all
2> ;
using target database control file instead of recovery catalog
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/10g/dbs/snapcf_orcl.f'; # default
配置备份策略
基于恢复窗口的备份策略
RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS ;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
new RMAN configuration parameters are successfully stored
基于冗余数量的备份策略
RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS ;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
new RMAN configuration parameters are successfully stored
打开、关闭备份优化
RMAN> CONFIGURE BACKUP OPTIMIZATION ON;
new RMAN configuration parameters:
CONFIGURE BACKUP OPTIMIZATION ON;
new RMAN configuration parameters are successfully stored
RMAN> CONFIGURE BACKUP OPTIMIZATION OFF;
old RMAN configuration parameters:
CONFIGURE BACKUP OPTIMIZATION ON;
new RMAN configuration parameters:
CONFIGURE BACKUP OPTIMIZATION OFF;
new RMAN configuration parameters are successfully stored
配置设备类型
配置设备类型为磁带
RMAN> CONFIGURE DEFAULT DEVICE TYPE TO SBT ;
new RMAN configuration parameters:
CONFIGURE DEFAULT DEVICE TYPE TO 'SBT_TAPE';
new RMAN configuration parameters are successfully stored
配置设备类型为磁盘
RMAN> CONFIGURE DEFAULT DEVICE TYPE TO DISK ;
old RMAN configuration parameters:
CONFIGURE DEFAULT DEVICE TYPE TO 'SBT_TAPE';
new RMAN configuration parameters:
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
new RMAN configuration parameters are successfully stored
配置是否自动备份控制文件(强烈建议打开该功能)
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;
old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP OFF ;
old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
new RMAN configuration parameters are successfully stored
配置控制文件自动备份的命名格式
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F';
old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F';
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F';
new RMAN configuration parameters are successfully stored
配置通道并行度
RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET ;
old RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK PARALLELISM 4 BACKUP TYPE TO BACKUPSET;
new RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET;
new RMAN configuration parameters are successfully stored
配置文件冗余度
RMAN> CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1 ;
new RMAN configuration parameters:
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
new RMAN configuration parameters are successfully stored
RMAN> CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1 ;
new RMAN configuration parameters:
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
new RMAN configuration parameters are successfully stored
配置备份集最大值
RMAN> CONFIGURE MAXSETSIZE TO UNLIMITED;
new RMAN configuration parameters:
CONFIGURE MAXSETSIZE TO UNLIMITED;
new RMAN configuration parameters are successfully stored
配置加密选项
RMAN> CONFIGURE ENCRYPTION FOR DATABASE OFF;
CONFIGURE ENCRYPTION ALGORITHM 'AES128';
old RMAN configuration parameters:
CONFIGURE ENCRYPTION FOR DATABASE OFF;
new RMAN configuration parameters:
CONFIGURE ENCRYPTION FOR DATABASE OFF;
new RMAN configuration parameters are successfully stored
RMAN>
old RMAN configuration parameters:
CONFIGURE ENCRYPTION ALGORITHM 'AES128';
new RMAN configuration parameters:
CONFIGURE ENCRYPTION ALGORITHM 'AES128';
new RMAN configuration parameters are successfully stored
配置控制文件快照
RMAN> CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/10g/dbs/snapcf_orcl.f';
snapshot control file name set to: /u01/app/oracle/product/10g/dbs/snapcf_orcl.f
new RMAN configuration parameters are successfully stored
备份
联机备份
备份数据库并使用命名规则
RMAN> BACKUP DATABASE FORMAT '/home/oracle/backup/rman/%U' ;
Starting backup at 15-OCT-09
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile fno=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 15-OCT-09
channel ORA_DISK_1: finished piece 1 at 15-OCT-09
piece handle=/home/oracle/backup/rman/06krs3uq_1_1 tag=TAG20091015T134914 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 15-OCT-09
channel ORA_DISK_1: finished piece 1 at 15-OCT-09
piece handle=/home/oracle/backup/rman/07krs407_1_1 tag=TAG20091015T134914 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 15-OCT-09
备份表空间
RMAN> backup tablespace users ;
Starting backup at 15-OCT-09
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 15-OCT-09
channel ORA_DISK_1: finished piece 1 at 15-OCT-09
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_15/o1_mf_nnndf_TAG20091015T135215_5ffg4hyp_.bkp tag=TAG2009E
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 15-OCT-09
备份指定的数据文件
RMAN> backup datafile '/u01/app/oracle/oradata/orcl/system01.dbf'
2> ;
Starting backup at 15-OCT-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=137 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
channel ORA_DISK_1: starting piece 1 at 15-OCT-09
channel ORA_DISK_1: finished piece 1 at 15-OCT-09
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_15/o1_mf_nnndf_TAG20091015T135451_5ffg9cvo_.bkp tag=TAG2009E
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 15-OCT-09
channel ORA_DISK_1: finished piece 1 at 15-OCT-09
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_15/o1_mf_ncsnf_TAG20091015T135451_5ffgb6g7_.bkp tag=TAG2009E
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 15-OCT-09
配置自动备份控制文件
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP on ;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
备份归档日志文件-全部
RMAN> BACKUP ARCHIVELOG ALL;
Starting backup at 16-OCT-09
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=10 recid=1 stamp=700393575
channel ORA_DISK_1: starting piece 1 at 16-OCT-09
channel ORA_DISK_1: finished piece 1 at 16-OCT-09
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_16/o1_mf_annnn_TAG20091016T094615_5fhn396d_.bkp tag=TAG2009E
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 16-OCT-09
Starting Control File and SPFILE Autobackup at 16-OCT-09
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/autobackup/2009_10_16/o1_mf_s_700393578_5fhn3bkd_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 16-OCT-09
根据日志序号备份-根据日志序号备份(开放区间)
SQL> select * from v$log ;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIME
------------- ------------ ---------- ---------- ---------- ---------- ---------- --- ----------------
1 1 29 52428800 1 NO CURRENT 730771 22-OCT-09
RMAN> backup archivelog from sequence 1 ;
Starting backup at 22-OCT-09
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=148 devtype=DISK
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=9 recid=1 stamp=700921401
input archive log thread=1 sequence=10 recid=2 stamp=700921404
input archive log thread=1 sequence=11 recid=3 stamp=700921411
input archive log thread=1 sequence=12 recid=4 stamp=700921412
input archive log thread=1 sequence=13 recid=5 stamp=700921414
input archive log thread=1 sequence=14 recid=6 stamp=700921414
input archive log thread=1 sequence=15 recid=7 stamp=700921420
input archive log thread=1 sequence=16 recid=8 stamp=700921420
input archive log thread=1 sequence=17 recid=9 stamp=700921425
input archive log thread=1 sequence=18 recid=10 stamp=700921425
input archive log thread=1 sequence=19 recid=11 stamp=700921430
input archive log thread=1 sequence=20 recid=12 stamp=700921430
input archive log thread=1 sequence=21 recid=13 stamp=700921435
input archive log thread=1 sequence=22 recid=14 stamp=700921435
input archive log thread=1 sequence=23 recid=15 stamp=700921440
input archive log thread=1 sequence=24 recid=16 stamp=700921440
input archive log thread=1 sequence=25 recid=17 stamp=700921445
input archive log thread=1 sequence=26 recid=18 stamp=700921445
input archive log thread=1 sequence=27 recid=19 stamp=700921450
input archive log thread=1 sequence=28 recid=20 stamp=700921451
input archive log thread=1 sequence=29 recid=21 stamp=700921597
channel ORA_DISK_1: starting piece 1 at 22-OCT-09
channel ORA_DISK_1: finished piece 1 at 22-OCT-09
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_22/o1_mf_annnn_TAG20091022T122638_5fzqr0ov_.bkp tag=TAG2009E
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 22-OCT-09
根据日志序号备份-根据日志序号备份(闭合区间)
RMAN> backup archivelog from sequence 1 until sequence 25 ;
Starting backup at 22-OCT-09
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=9 recid=1 stamp=700921401
input archive log thread=1 sequence=10 recid=2 stamp=700921404
input archive log thread=1 sequence=11 recid=3 stamp=700921411
input archive log thread=1 sequence=12 recid=4 stamp=700921412
input archive log thread=1 sequence=13 recid=5 stamp=700921414
input archive log thread=1 sequence=14 recid=6 stamp=700921414
input archive log thread=1 sequence=15 recid=7 stamp=700921420
input archive log thread=1 sequence=16 recid=8 stamp=700921420
input archive log thread=1 sequence=17 recid=9 stamp=700921425
input archive log thread=1 sequence=18 recid=10 stamp=700921425
input archive log thread=1 sequence=19 recid=11 stamp=700921430
input archive log thread=1 sequence=20 recid=12 stamp=700921430
input archive log thread=1 sequence=21 recid=13 stamp=700921435
input archive log thread=1 sequence=22 recid=14 stamp=700921435
input archive log thread=1 sequence=23 recid=15 stamp=700921440
input archive log thread=1 sequence=24 recid=16 stamp=700921440
input archive log thread=1 sequence=25 recid=17 stamp=700921445
channel ORA_DISK_1: starting piece 1 at 22-OCT-09
channel ORA_DISK_1: finished piece 1 at 22-OCT-09
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_22/o1_mf_annnn_TAG20091022T122829_5fzqvgld_.bkp tag=TAG2009E
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 22-OCT-09
备份数据库时同时备份日志文件
RMAN> backup tablespace users plus archivelog ;
Starting backup at 22-OCT-09
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=9 recid=1 stamp=700921401
input archive log thread=1 sequence=10 recid=2 stamp=700921404
input archive log thread=1 sequence=11 recid=3 stamp=700921411
input archive log thread=1 sequence=12 recid=4 stamp=700921412
input archive log thread=1 sequence=13 recid=5 stamp=700921414
input archive log thread=1 sequence=14 recid=6 stamp=700921414
input archive log thread=1 sequence=15 recid=7 stamp=700921420
input archive log thread=1 sequence=16 recid=8 stamp=700921420
input archive log thread=1 sequence=17 recid=9 stamp=700921425
input archive log thread=1 sequence=18 recid=10 stamp=700921425
input archive log thread=1 sequence=19 recid=11 stamp=700921430
input archive log thread=1 sequence=20 recid=12 stamp=700921430
input archive log thread=1 sequence=21 recid=13 stamp=700921435
input archive log thread=1 sequence=22 recid=14 stamp=700921435
input archive log thread=1 sequence=23 recid=15 stamp=700921440
input archive log thread=1 sequence=24 recid=16 stamp=700921440
input archive log thread=1 sequence=25 recid=17 stamp=700921445
input archive log thread=1 sequence=26 recid=18 stamp=700921445
input archive log thread=1 sequence=27 recid=19 stamp=700921450
input archive log thread=1 sequence=28 recid=20 stamp=700921451
input archive log thread=1 sequence=29 recid=21 stamp=700921597
input archive log thread=1 sequence=30 recid=22 stamp=700921854
channel ORA_DISK_1: starting piece 1 at 22-OCT-09
channel ORA_DISK_1: finished piece 1 at 22-OCT-09
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_22/o1_mf_annnn_TAG20091022T123055_5fzr00d7_.bkp tag=TAG2009E
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 22-OCT-09
Starting backup at 22-OCT-09
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 22-OCT-09
channel ORA_DISK_1: finished piece 1 at 22-OCT-09
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_22/o1_mf_nnndf_TAG20091022T123057_5fzr01tr_.bkp tag=TAG2009E
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 22-OCT-09
Starting backup at 22-OCT-09
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=31 recid=23 stamp=700921864
channel ORA_DISK_1: starting piece 1 at 22-OCT-09
channel ORA_DISK_1: finished piece 1 at 22-OCT-09
备份归档日志后删除输入文件
RMAN> backup archivelog all delete input ;
Starting backup at 16-OCT-09
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=10 recid=1 stamp=700393575
input archive log thread=1 sequence=11 recid=2 stamp=700399887
channel ORA_DISK_1: starting piece 1 at 16-OCT-09
channel ORA_DISK_1: finished piece 1 at 16-OCT-09
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_16/o1_mf_annnn_TAG20091016T113127_5fht8jcb_.bkp tag=TAG2009E
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
channel ORA_DISK_1: deleting archive log(s)
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_16/o1_mf_1_10_5fhn371f_.arc recid=1 stamp=700393575
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_16/o1_mf_1_11_5fht8gsf_.arc recid=2 stamp=700399887
Finished backup at 16-OCT-09
Starting Control File and SPFILE Autobackup at 16-OCT-09
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/autobackup/2009_10_16/o1_mf_s_700399889_5fht8krz_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 16-OCT-09
镜像备份
镜像备份数据库
RMAN> backup as copy database ;
Starting backup at 16-OCT-09
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile fno=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
output filename=/u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_system_5fhtlp2q_.dbf tag=TAG20091016T113653 recid=2 stamp=77
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile fno=00003 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
output filename=/u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_sysaux_5fhtmh87_.dbf tag=TAG20091016T113653 recid=3 stamp=79
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile fno=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf
output filename=/u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_example_5fhtmycv_.dbf tag=TAG20091016T113653 recid=4 stamp=7
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile fno=00002 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
output filename=/u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_undotbs1_5fhtn5kp_.dbf tag=TAG20091016T113653 recid=5 stamp2
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile fno=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
output filename=/u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_5fhtn8ql_.dbf tag=TAG20091016T113653 recid=6 stamp=706
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 16-OCT-09
镜像备份表空间
RMAN> backup as copy tablespace 'USERS';
Starting backup at 16-OCT-09
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile fno=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
output filename=/u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_5fhv3ghm_.dbf tag=TAG20091016T114550 recid=7 stamp=701
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 16-OCT-09
Starting Control File and SPFILE Autobackup at 16-OCT-09
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/autobackup/2009_10_16/o1_mf_s_700400751_5fhv3hsb_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 16-OCT-09
镜像备份数据文件
RMAN> backup as copy datafile '/u01/app/oracle/oradata/orcl/system01.dbf';
Starting backup at 16-OCT-09
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile fno=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
output filename=/u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_system_5fhv4n77_.dbf tag=TAG20091016T114626 recid=8 stamp=72
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
Finished backup at 16-OCT-09
Starting Control File and SPFILE Autobackup at 16-OCT-09
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/autobackup/2009_10_16/o1_mf_s_700400821_5fhv5p37_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 16-OCT-09
镜像备份控制文件
RMAN> backup as copy current controlfile ;
Starting backup at 16-OCT-09
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
copying current control file
output filename=/u01/app/oracle/flash_recovery_area/ORCL/controlfile/o1_mf_TAG20091016T115053_5fhvdxq1_.ctl tag=TAG20091016T115053 3
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 16-OCT-09
Starting Control File and SPFILE Autobackup at 16-OCT-09
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/autobackup/2009_10_16/o1_mf_s_700401054_5fhvdz1q_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 16-OCT-09
镜像备份归档日志文件之后删除输入文件
RMAN> backup as copy archivelog all delete input ;
Starting backup at 16-OCT-09
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive copy
input archive log thread=1 sequence=12 recid=3 stamp=700401208
output filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_16/o1_mf_1_12_5fhvks8f_.arc recid=4 stamp=700401209
channel ORA_DISK_1: archivelog copy complete, elapsed time: 00:00:02
channel ORA_DISK_1: deleting archive log(s)
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_16/o1_mf_1_12_5fhvkqyw_.arc recid=3 stamp=700401208
Finished backup at 16-OCT-09
查看备份
查看所有备份集
RMAN> list backup
2> ;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1 Full 6.80M DISK 00:00:02 15-OCT-09
BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20091015T130655
Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_15/o1_mf_ncsnf_TAG20091015T130655_5ffchkll_.bkp
Control File Included: Ckp SCN: 737847 Ckp time: 15-OCT-09
SPFILE Included: Modification time: 15-OCT-09
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2 Full 753.64M DISK 00:00:43 15-OCT-09
BP Key: 2 Status: AVAILABLE Compressed: NO Tag: TAG20091015T132620
Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_15/o1_mf_nnndf_TAG20091015T132620_5ffdmwz7_.bkp
List of Datafiles in backup set 2
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 759373 15-OCT-09 /u01/app/oracle/oradata/orcl/system01.dbf
2 Full 759373 15-OCT-09 /u01/app/oracle/oradata/orcl/undotbs01.dbf
3 Full 759373 15-OCT-09 /u01/app/oracle/oradata/orcl/sysaux01.dbf
4 Full 759373 15-OCT-09 /u01/app/oracle/oradata/orcl/users01.dbf
5 Full 759373 15-OCT-09 /u01/app/oracle/oradata/orcl/example01.dbf
查看指定表空间的备份
RMAN> LIST BACKUP OF TABLESPACE 'SYSTEM' ;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2 Full 753.64M DISK 00:00:43 15-OCT-09
BP Key: 2 Status: AVAILABLE Compressed: NO Tag: TAG20091015T132620
Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_15/o1_mf_nnndf_TAG20091015T132620_5ffdmwz7_.bkp
List of Datafiles in backup set 2
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 759373 15-OCT-09 /u01/app/oracle/oradata/orcl/system01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
5 Full 753.66M DISK 00:00:43 15-OCT-09
BP Key: 5 Status: AVAILABLE Compressed: NO Tag: TAG20091015T134914
Piece Name: /home/oracle/backup/rman/06krs3uq_1_1
List of Datafiles in backup set 5
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 760330 15-OCT-09 /u01/app/oracle/oradata/orcl/system01.dbf
查看指定数据文件的备份
RMAN> LIST BACKUP OF DATAFILE '/u01/app/oracle/oradata/orcl/system01.dbf' ;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2 Full 753.64M DISK 00:00:43 15-OCT-09
BP Key: 2 Status: AVAILABLE Compressed: NO Tag: TAG20091015T132620
Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_15/o1_mf_nnndf_TAG20091015T132620_5ffdmwz7_.bkp
List of Datafiles in backup set 2
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 759373 15-OCT-09 /u01/app/oracle/oradata/orcl/system01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
5 Full 753.66M DISK 00:00:43 15-OCT-09
BP Key: 5 Status: AVAILABLE Compressed: NO Tag: TAG20091015T134914
Piece Name: /home/oracle/backup/rman/06krs3uq_1_1
List of Datafiles in backup set 5
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 760330 15-OCT-09 /u01/app/oracle/oradata/orcl/system01.dbf
查看控制文件的的备份
RMAN> list backup of controlfile ;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1 Full 6.80M DISK 00:00:02 15-OCT-09
BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20091015T130655
Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_15/o1_mf_ncsnf_TAG20091015T130655_5ffchkll_.bkp
Control File Included: Ckp SCN: 737847 Ckp time: 15-OCT-09
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3 Full 6.80M DISK 00:00:01 15-OCT-09
BP Key: 3 Status: AVAILABLE Compressed: NO Tag: TAG20091015T132620
Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_15/o1_mf_ncsnf_TAG20091015T132620_5ffdocsh_.bkp
Control File Included: Ckp SCN: 759392 Ckp time: 15-OCT-09
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
4 Full 6.80M DISK 00:00:01 15-OCT-09
BP Key: 4 Status: AVAILABLE Compressed: NO Tag: TAG20091015T134859
Piece Name: /home/oracle/backup/rman/05krs3uc_1_1
Control File Included: Ckp SCN: 760322 Ckp time: 15-OCT-09
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
6 Full 6.80M DISK 00:00:02 15-OCT-09
BP Key: 6 Status: AVAILABLE Compressed: NO Tag: TAG20091015T134914
Piece Name: /home/oracle/backup/rman/07krs407_1_1
Control File Included: Ckp SCN: 760350 Ckp time: 15-OCT-09
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
9 Full 6.80M DISK 00:00:02 15-OCT-09
BP Key: 9 Status: AVAILABLE Compressed: NO Tag: TAG20091015T135451
Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_15/o1_mf_ncsnf_TAG20091015T135451_5ffgb6g7_.bkp
Control File Included: Ckp SCN: 760535 Ckp time: 15-OCT-09
查看归档日志的备份
RMAN> list backup of archivelog all ;
List of Backup Sets
===================
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
12 4.01M DISK 00:00:01 16-OCT-09
BP Key: 12 Status: AVAILABLE Compressed: NO Tag: TAG20091016T094615
Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_16/o1_mf_annnn_TAG20091016T094615_5fhn396d_.bkp
List of Archived Logs in backup set 12
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 10 758503 15-OCT-09 763555 16-OCT-09
查看镜像
查看所有镜像
RMAN> list copy ;
List of Datafile Copies
Key File S Completion Time Ckp SCN Ckp Time Name
------- ---- - --------------- ---------- --------------- ----
8 1 A 16-OCT-09 768303 16-OCT-09 /u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_system_5fhv4n77_.f
2 1 A 16-OCT-09 767946 16-OCT-09 /u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_system_5fhtlp2q_.f
5 2 A 16-OCT-09 767969 16-OCT-09 /u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_undotbs1_5fhtn5kpf
3 3 A 16-OCT-09 767955 16-OCT-09 /u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_sysaux_5fhtmh87_.f
7 4 A 16-OCT-09 768273 16-OCT-09 /u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_5fhv3ghm_.df
6 4 A 16-OCT-09 767971 16-OCT-09 /u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_5fhtn8ql_.df
4 5 A 16-OCT-09 767966 16-OCT-09 /u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_example_5fhtmycv_f
List of Control File Copies
Key S Completion Time Ckp SCN Ckp Time Name
------- - --------------- ---------- --------------- ----
9 A 16-OCT-09 768430 16-OCT-09 /u01/app/oracle/flash_recovery_area/ORCL/controlfile/o1_mf_TAG20091016T115053_l
List of Archived Log Copies
Key Thrd Seq S Low Time Name
------- ---- ------- - --------- ----
4 1 12 A 16-OCT-09 /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_16/o1_mf_1_12_5fhvks8f_.ar
查看指定表空间的镜像
RMAN> list copy of tablespace 'USERS' ;
List of Datafile Copies
Key File S Completion Time Ckp SCN Ckp Time Name
------- ---- - --------------- ---------- --------------- ----
7 4 A 16-OCT-09 768273 16-OCT-09 /u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_5fhv3ghm_.df
6 4 A 16-OCT-09 767971 16-OCT-09 /u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_5fhtn8ql_.df
查看指定数据文的镜像
RMAN> list copy of datafile 1 ;
List of Datafile Copies
Key File S Completion Time Ckp SCN Ckp Time Name
------- ---- - --------------- ---------- --------------- ----
8 1 A 16-OCT-09 768303 16-OCT-09 /u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_system_5fhv4n77_.f
2 1 A 16-OCT-09 767946 16-OCT-09 /u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_system_5fhtlp2q_.f
查看控制文件的镜像
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
4 Full 6.80M DISK 00:00:01 15-OCT-09
BP Key: 4 Status: AVAILABLE Compressed: NO Tag: TAG20091015T134859
Piece Name: /home/oracle/backup/rman/05krs3uc_1_1
Control File Included: Ckp SCN: 760322 Ckp time: 15-OCT-09
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
6 Full 6.80M DISK 00:00:02 15-OCT-09
BP Key: 6 Status: AVAILABLE Compressed: NO Tag: TAG20091015T134914
Piece Name: /home/oracle/backup/rman/07krs407_1_1
Control File Included: Ckp SCN: 760350 Ckp time: 15-OCT-09
BS Key Type LV Size Device Type Elapsed Time Completion Time
查看归档日志的镜像
RMAN> list copy of archivelog all;
List of Archived Log Copies
Key Thrd Seq S Low Time Name
------- ---- ------- - --------- ----
4 1 12 A 16-OCT-09 /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_16/o1_mf_1_12_5fhvks8f_.arc
查看备份摘要
RMAN> list backup summary
2> ;
List of Backups
===============
Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
1 B F A DISK 22-OCT-09 1 1 NO TAG20091022T121627
2 B F A DISK 22-OCT-09 1 1 NO TAG20091022T121627
3 B F A DISK 22-OCT-09 1 1 NO TAG20091022T121832
4 B A A DISK 22-OCT-09 1 1 NO TAG20091022T122638
5 B A A DISK 22-OCT-09 1 1 NO TAG20091022T122759
6 B A A DISK 22-OCT-09 1 1 NO TAG20091022T122829
7 B A A DISK 22-OCT-09 1 1 NO TAG20091022T123055
8 B F A DISK 22-OCT-09 1 1 NO TAG20091022T123057
9 B A A DISK 22-OCT-09 1 1 NO TAG20091022T123104
10 B 0 A DISK 22-OCT-09 1 1 NO TAG20091022T123518
11 B 0 A DISK 22-OCT-09 1 1 NO TAG20091022T123518
12 B 2 A DISK 22-OCT-09 1 1 NO TAG20091022T123758
13 B 2 A DISK 22-OCT-09 1 1 NO TAG20091022T123758
14 B 2 A DISK 22-OCT-09 1 1 NO TAG20091022T124050
15 B 2 A DISK 22-OCT-09 1 1 NO TAG20091022T124050
报告
报告最近3天没有备份的数据文件
RMAN> report need backup days 3;
Report of files whose recovery needs more than 3 days of archived logs
File Days Name
---- ----- -----------------------------------------------------
报告需要3个增量备份才可以恢复的数据文件
RMAN> report need backup incremental =3 ;
Report of files that need more than 3 incrementals during recovery
File Incrementals Name
---- ------------ ----------------------------------------------
报告为了满足冗余度为2需要备份的文件
MAN> report need backup redundancy =2 ;
Report of files with less than 2 redundant backups
File #bkps Name
---- ----- -----------------------------------------------------
报告恢复窗口为两天需要备份的文件
RMAN> report need backup recovery window of 2 days ;
Report of files that must be backed up to satisfy 2 days recovery window
File Days Name
---- ----- -----------------------------------------------------
报告不可恢复的文件
RMAN> report unrecoverable ;
Report of files that need backup due to unrecoverable operations
File Type of Backup Required Name
---- ----------------------- -----------------------------------
报告数据库模式
RMAN> report schema ;
Report of database schema
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 620 SYSTEM *** /u01/app/oracle/oradata/orcl/system01.dbf
2 30 UNDOTBS1 *** /u01/app/oracle/oradata/orcl/undotbs01.dbf
3 250 SYSAUX *** /u01/app/oracle/oradata/orcl/sysaux01.dbf
4 26 USERS *** /u01/app/oracle/oradata/orcl/users01.dbf
5 100 EXAMPLE *** /u01/app/oracle/oradata/orcl/example01.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 21 TEMP 32767 /u01/app/oracle/oradata/orcl/temp01.dbf
报告可丢弃的备份
RMAN> report obsolete ;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Report of obsolete backups and copies
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set 1 15-OCT-09
Backup Piece 1 15-OCT-09 /u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_15/o1_mf_ncsnf_TAG2009101p
Backup Set 2 15-OCT-09
Backup Piece 2 15-OCT-09 /u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_15/o1_mf_nnndf_TAG2009101p
Backup Set 3 15-OCT-09
Backup Piece 3 15-OCT-09 /u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_15/o1_mf_ncsnf_TAG2009101p
Backup Set 4 15-OCT-09
Backup Piece 4 15-OCT-09 /home/oracle/backup/rman/05krs3uc_1_1
Backup Set 6 15-OCT-09
Backup Piece 6 15-OCT-09 /home/oracle/backup/rman/07krs407_1_1
Backup Set 9 15-OCT-09
Backup Piece 9 15-OCT-09 /u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_15/o1_mf_ncsnf_TAG2009101p
Backup Set 10 16-OCT-09
Backup Piece 10 16-OCT-09 /u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_16/o1_mf_ncnnf_TAG2009101p
Backup Set 11 16-OCT-09
Backup Piece 11 16-OCT-09 /u01/app/oracle/flash_recovery_area/ORCL/autobackup/2009_10_16/o1_mf_s_700393260_5fhp
删除备份
删除备份片
RMAN> delete backuppiece '/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_15/o1_mf_nnndf_TAG20091015T132620_5ffdmwz7_.bk;
using channel ORA_DISK_1
List of Backup Pieces
BP Key BS Key Pc# Cp# Status Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
2 2 1 1 AVAILABLE DISK /u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_15/o1_mf_nnndf_TAG200910p
Do you really want to delete the above objects (enter YES or NO)? yes
deleted backup piece
backup piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_15/o1_mf_nnndf_TAG20091015T132620_5ffdmwz7_.bkp reci0
Deleted 1 objects
删除备份集
RMAN> delete backupset 7 ;
using channel ORA_DISK_1
List of Backup Pieces
BP Key BS Key Pc# Cp# Status Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
7 7 1 1 AVAILABLE DISK /u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_15/o1_mf_nnndf_TAG200910p
Do you really want to delete the above objects (enter YES or NO)? yes
deleted backup piece
backup piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_15/o1_mf_nnndf_TAG20091015T135215_5ffg4hyp_.bkp reci5
Deleted 1 objects
删除所有备份集
RMAN> delete backupset ;
using channel ORA_DISK_1
List of Backup Pieces
BP Key BS Key Pc# Cp# Status Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
4 4 1 1 AVAILABLE DISK /home/oracle/backup/rman/05krs3uc_1_1
5 5 1 1 AVAILABLE DISK /home/oracle/backup/rman/06krs3uq_1_1
6 6 1 1 AVAILABLE DISK /home/oracle/backup/rman/07krs407_1_1
9 9 1 1 AVAILABLE DISK /u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_15/o1_mf_ncsnf_TAG200910p
10 10 1 1 AVAILABLE DISK /u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_16/o1_mf_ncnnf_TAG200910p
11 11 1 1 AVAILABLE DISK /u01/app/oracle/flash_recovery_area/ORCL/autobackup/2009_10_16/o1_mf_s_700393260_5fp
12 12 1 1 AVAILABLE DISK /u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_16/o1_mf_annnn_TAG200910p
13 13 1 1 AVAILABLE DISK /u01/app/oracle/flash_recovery_area/ORCL/autobackup/2009_10_16/o1_mf_s_700393578_5fp
14 14 1 1 AVAILABLE DISK /u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_16/o1_mf_annnn_TAG200910p
15 15 1 1 AVAILABLE DISK /u01/app/oracle/flash_recovery_area/ORCL/autobackup/2009_10_16/o1_mf_s_700399889_5fp
16 16 1 1 AVAILABLE DISK /u01/app/oracle/flash_recovery_area/ORCL/autobackup/2009_10_16/o1_mf_s_700400267_5fp
17 17 1 1 AVAILABLE DISK /u01/app/oracle/flash_recovery_area/ORCL/autobackup/2009_10_16/o1_mf_s_700400751_5fp
18 18 1 1 AVAILABLE DISK /u01/app/oracle/flash_recovery_area/ORCL/autobackup/2009_10_16/o1_mf_s_700400821_5fp
19 19 1 1 AVAILABLE DISK /u01/app/oracle/flash_recovery_area/ORCL/autobackup/2009_10_16/o1_mf_s_700401054_5fp
20 20 1 1 AVAILABLE DISK /u01/app/oracle/flash_recovery_area/ORCL/autobackup/2009_10_16/o1_mf_s_700401210_5fp
Do you really want to delete the above objects (enter YES or NO)? no
删除镜像副本
RMAN> delete datafilecopy '/u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_5fhv3ghm_.dbf'
2> ;
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=133 devtype=DISK
List of Datafile Copies
Key File S Completion Time Ckp SCN Ckp Time Name
------- ---- - --------------- ---------- --------------- ----
7 4 A 16-OCT-09 768273 16-OCT-09 /u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_5fhv3ghm_.df
Do you really want to delete the above objects (enter YES or NO)? yes
deleted datafile copy
datafile copy filename=/u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_5fhv3ghm_.dbf recid=7 stamp=700400751
Deleted 1 objects
删除所有镜像副本
RMAN> delete copy;
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=141 devtype=DISK
specification does not match any archive log in the recovery catalog
List of Datafile Copies
Key File S Completion Time Ckp SCN Ckp Time Name
------- ---- - --------------- ---------- --------------- ----
3 1 A 16-OCT-09 538879 16-OCT-09 /u01/oracle/flash_recovery_area/ORCL/datafile/o1_mf_system_5fjkm5sn_.dbf
6 2 A 16-OCT-09 538899 16-OCT-09 /u01/oracle/flash_recovery_area/ORCL/datafile/o1_mf_undotbs1_5fjkncm9_.dbf
4 3 A 16-OCT-09 538885 16-OCT-09 /u01/oracle/flash_recovery_area/ORCL/datafile/o1_mf_sysaux_5fjkmo1n_.dbf
7 4 A 16-OCT-09 538901 16-OCT-09 /u01/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_5fjkngqk_.dbf
5 5 A 16-OCT-09 538891 16-OCT-09 /u01/oracle/flash_recovery_area/ORCL/datafile/o1_mf_example_5fjkn499_.dbf
List of Control File Copies
Key S Completion Time Ckp SCN Ckp Time Name
------- - --------------- ---------- --------------- ----
8 A 16-OCT-09 538902 16-OCT-09 /u01/oracle/flash_recovery_area/ORCL/controlfile/o1_mf_TAG20091016T180941_5fjkl
2 A 16-OCT-09 518473 16-OCT-09 /u01/oracle/flash_recovery_area/ORCL/controlfile/o1_mf_TAG20091016T180157_5fjkl
Do you really want to delete the above objects (enter YES or NO)? yes
deleted datafile copy
datafile copy filename=/u01/oracle/flash_recovery_area/ORCL/datafile/o1_mf_system_5fjkm5sn_.dbf recid=3 stamp=700423796
deleted datafile copy
datafile copy filename=/u01/oracle/flash_recovery_area/ORCL/datafile/o1_mf_undotbs1_5fjkncm9_.dbf recid=6 stamp=700423820
deleted datafile copy
datafile copy filename=/u01/oracle/flash_recovery_area/ORCL/datafile/o1_mf_sysaux_5fjkmo1n_.dbf recid=4 stamp=700423805
deleted datafile copy
datafile copy filename=/u01/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_5fjkngqk_.dbf recid=7 stamp=700423822
deleted datafile copy
datafile copy filename=/u01/oracle/flash_recovery_area/ORCL/datafile/o1_mf_example_5fjkn499_.dbf recid=5 stamp=700423815
deleted control file copy
control file copy filename=/u01/oracle/flash_recovery_area/ORCL/controlfile/o1_mf_TAG20091016T180941_5fjknhy2_.ctl recid=8 stamp=704
deleted control file copy
control file copy filename=/u01/oracle/flash_recovery_area/ORCL/controlfile/o1_mf_TAG20091016T180157_5fjk4pj2_.ctl recid=2 stamp=708
Deleted 7 objects
备份检查
检查联机文件
RMAN> backup validate database ;
Starting backup at 22-OCT-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=147 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 22-OCT-09
检查所有文件
RMAN> backup validate database archivelog all ;
Starting backup at 22-OCT-09
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=2 recid=1 stamp=700909731
input archive log thread=1 sequence=3 recid=2 stamp=700909732
input archive log thread=1 sequence=4 recid=3 stamp=700909737
input archive log thread=1 sequence=5 recid=4 stamp=700909737
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 22-OCT-09
非完全备份
环境准备
SQL> create tablespace test datafile '/u01/app/oracle/oradata/orcl/test1.dbf' size 20M ;
Tablespace created.
SQL> alter tablespace test read only ;
Tablespace altered.
SQL> create tablespace test_offline datafile '/u01/app/oracle/oradata/orcl/test_offline1.dbf' size 20M ;
Tablespace created.
跳过离线表空间
RMAN> backup database skip offline ;
Starting backup at 22-OCT-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=138 devtype=DISK
skipping offline file 6
RMAN-06060: WARNING: skipping datafile compromises tablespace TEST_OFFLINE recoverability
RMAN-06060: WARNING: skipping datafile compromises tablespace TEST_OFFLINE recoverability
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile fno=00005 name=/u01/app/oracle/oradata/orcl/test1.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 22-OCT-09
channel ORA_DISK_1: finished piece 1 at 22-OCT-09
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_22/o1_mf_nnndf_TAG20091022T114100_5fzo2dwl_.bkp tag=TAG2009E
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 22-OCT-09
channel ORA_DISK_1: finished piece 1 at 22-OCT-09
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_22/o1_mf_ncsnf_TAG20091022T114100_5fzo3kgb_.bkp tag=TAG2009E
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 22-OCT-09
跳过只读表空间
RMAN> backup database skip readonly ;
Starting backup at 22-OCT-09
using channel ORA_DISK_1
skipping read-only file 5
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile fno=00006 name=/u01/app/oracle/oradata/orcl/test_offline1.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 22-OCT-09
channel ORA_DISK_1: finished piece 1 at 22-OCT-09
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_22/o1_mf_nnndf_TAG20091022T114302_5fzo67cb_.bkp tag=TAG2009E
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 22-OCT-09
channel ORA_DISK_1: finished piece 1 at 22-OCT-09
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_22/o1_mf_ncsnf_TAG20091022T114302_5fzo7cwv_.bkp tag=TAG2009E
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 22-OCT-09
跳跃无法访问的表空间
情景模拟
[oracle@oracle ~]$ rm -rf /u01/app/oracle/oradata/orcl/users01.dbf
SQL> select * from scott.emp ;
select * from scott.emp
*
ERROR at line 1:
ORA-01116: error in opening database file 4
ORA-01110: data file 4: '/u01/app/oracle/oradata/orcl/users01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
跳跃无法访问的表空间
RMAN> backup database skip inaccessible ;
Starting backup at 22-OCT-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=140 devtype=DISK
could not access datafile 4
skipping inaccessible file 4
RMAN-06060: WARNING: skipping datafile compromises tablespace USERS recoverability
RMAN-06060: WARNING: skipping datafile compromises tablespace USERS recoverability
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile fno=00005 name=/u01/app/oracle/oradata/orcl/test1.dbf
input datafile fno=00006 name=/u01/app/oracle/oradata/orcl/test_offline1.dbf
channel ORA_DISK_1: starting piece 1 at 22-OCT-09
channel ORA_DISK_1: finished piece 1 at 22-OCT-09
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_22/o1_mf_nnndf_TAG20091022T114828_5fzojfcg_.bkp tag=TAG2009E
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 22-OCT-09
channel ORA_DISK_1: finished piece 1 at 22-OCT-09
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_22/o1_mf_ncsnf_TAG20091022T114828_5fzokl2v_.bkp tag=TAG2009E
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 22-OCT-09
三种类型都跳过
RMAN> backup database skip readonly skip offline skip inaccessible ;
Starting backup at 22-OCT-09
using channel ORA_DISK_1
could not access datafile 4
skipping inaccessible file 4
skipping read-only file 5
skipping offline file 6
RMAN-06060: WARNING: skipping datafile compromises tablespace USERS recoverability
RMAN-06060: WARNING: skipping datafile compromises tablespace TEST_OFFLINE recoverability
备份指定时间内没有备份的表空间
SQL> create tablespace test datafile '/u01/app/oracle/oradata/orcl/test1.dbf' size 20M ;
Tablespace created.
RMAN> backup database not backed up ;
Starting backup at 22-OCT-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=146 devtype=DISK
skipping datafile 1; already backed up on 22-OCT-09
skipping datafile 2; already backed up on 22-OCT-09
skipping datafile 3; already backed up on 22-OCT-09
skipping datafile 4; already backed up on 22-OCT-09
skipping datafile 5; already backed up on 22-OCT-09
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00006 name=/u01/app/oracle/oradata/orcl/test1.dbf
channel ORA_DISK_1: starting piece 1 at 22-OCT-09
channel ORA_DISK_1: finished piece 1 at 22-OCT-09
增量备份
基本备份 0级备份
RMAN> backup incremental level=0 database ;
Starting backup at 22-OCT-09
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 0 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile fno=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
input datafile fno=00006 name=/u01/app/oracle/oradata/orcl/test1.dbf
channel ORA_DISK_1: starting piece 1 at 22-OCT-09
channel ORA_DISK_1: finished piece 1 at 22-OCT-09
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_22/o1_mf_nnnd0_TAG20091022T123518_5fzr86vg_.bkp tag=TAG2009E
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting incremental level 0 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 22-OCT-09
channel ORA_DISK_1: finished piece 1 at 22-OCT-09
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_22/o1_mf_ncsn0_TAG20091022T123518_5fzr9ocg_.bkp tag=TAG2009E
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 22-OCT-09
增量差异备份
RMAN> backup incremental level=2 database ;
Starting backup at 22-OCT-09
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 2 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile fno=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
input datafile fno=00006 name=/u01/app/oracle/oradata/orcl/test1.dbf
channel ORA_DISK_1: starting piece 1 at 22-OCT-09
channel ORA_DISK_1: finished piece 1 at 22-OCT-09
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_22/o1_mf_nnnd2_TAG20091022T123758_5fzrf7o5_.bkp tag=TAG2009E
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting incremental level 2 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 22-OCT-09
channel ORA_DISK_1: finished piece 1 at 22-OCT-09
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_22/o1_mf_ncsn2_TAG20091022T123758_5fzrgd2w_.bkp tag=TAG2009E
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 22-OCT-09
增量累积备份
RMAN> backup incremental level=2 cumulative database ;
Starting backup at 22-OCT-09
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 2 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile fno=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
input datafile fno=00006 name=/u01/app/oracle/oradata/orcl/test1.dbf
channel ORA_DISK_1: starting piece 1 at 22-OCT-09
channel ORA_DISK_1: finished piece 1 at 22-OCT-09
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_22/o1_mf_nnnd2_TAG20091022T124050_5fzrlmc6_.bkp tag=TAG2009E
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting incremental level 2 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 22-OCT-09
channel ORA_DISK_1: finished piece 1 at 22-OCT-09
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_22/o1_mf_ncsn2_TAG20091022T124050_5fzrmqno_.bkp tag=TAG2009E
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 22-OCT-09
建议备份策略
无论是累计还是差异,都进行如下两步
1、向前寻找一个增量备份基点
2、备份这个基点以来发生变化的数据块
差异增量:向前寻找基点的方法是<=本备份级别
累计增量:先前寻找基点的方法是<本备份级别
寻找到这个基点以后,自这个基点以来发生变化的所有的数据块都进行备份。
周日零点 0级备份
周一零点 2级备份
周二零点 2级备份
周三零点 1级备份
周四零点 2级备份
周五零点 2级备份
周六零点 2级备份
对于上面的备份策略备份的数据如下
增量备份
周日零点 0级备份 对数据库进行全备
周一零点 2级备份 备份呢周日到周一的数据
周二零点 2级备份 备份周一到周二的数据
周三零点 1级备份 备份周日到周三的数据
周四零点 2级备份 备份周三到周四的数据
周五零点 2级备份 备份周四到周五的数据
周六零点 2级备份 备份周五到周六的数据
累计备份
周日零点 0级备份 对数据库进行全备
周一零点 2级备份 备份呢周日到周一的数据
周二零点 2级备份 备份周日到周二的数据
周三零点 1级备份 备份周日到周三的数据
周四零点 2级备份 备份周三到周四的数据
周五零点 2级备份 备份周三到周五的数据
周六零点 2级备份 备份周三到周六的数据
基于应用日志到备份的备份方法
基于应用日志到拷贝的备份
RMAN> run {
2> backup incremental level 1 for recover of copy with tag 'arch_copy' database ;
3> recover copy of database with tag 'arch_copy' ;
4> }
Starting backup at 30-OCT-09
using channel ORA_DISK_1
no parent backup or copy of datafile 1 found
no parent backup or copy of datafile 3 found
no parent backup or copy of datafile 2 found
no parent backup or copy of datafile 4 found
channel ORA_DISK_1: starting datafile copy
input datafile fno=00001 name=/u01/oracle/oradata/orcl/system01.dbf
output filename=/u01/oracle/flash_recovery_area/ORCL/datafile/o1_mf_system_5goq8vpo_.dbf tag=ARCH_COPY recid=10 stamp=701642035
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile fno=00003 name=/u01/oracle/oradata/orcl/sysaux01.dbf
output filename=/u01/oracle/flash_recovery_area/ORCL/datafile/o1_mf_sysaux_5goq9o07_.dbf tag=ARCH_COPY recid=11 stamp=701642050
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:16
channel ORA_DISK_1: starting datafile copy
input datafile fno=00002 name=/u01/oracle/oradata/orcl/undotbs01.dbf
output filename=/u01/oracle/flash_recovery_area/ORCL/datafile/o1_mf_undotbs1_5goqb47l_.dbf tag=ARCH_COPY recid=12 stamp=701642053
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile fno=00004 name=/u01/oracle/oradata/orcl/users01.dbf
output filename=/u01/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_5goqb7ff_.dbf tag=ARCH_COPY recid=13 stamp=701642055
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting incremental level 1 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 30-OCT-09
channel ORA_DISK_1: finished piece 1 at 30-OCT-09
piece handle=/u01/oracle/flash_recovery_area/ORCL/backupset/2009_10_30/o1_mf_ncsn1_TAG20091030T203331_5goqbbgc_.bkp tag=TAG20091030T203331 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 30-OCT-09
Starting recover at 30-OCT-09
using channel ORA_DISK_1
no copy of datafile 1 found to recover
no copy of datafile 2 found to recover
no copy of datafile 3 found to recover
no copy of datafile 4 found to recover
Finished recover at 30-OCT-09
RMAN> list backup
2> ;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3 Incr 1 6.80M DISK 00:00:02 30-OCT-09
BP Key: 3 Status: AVAILABLE Compressed: NO Tag: TAG20091030T203331
Piece Name: /u01/oracle/flash_recovery_area/ORCL/backupset/2009_10_30/o1_mf_ncsn1_TAG20091030T203331_5goqbbgc_.bkp
Control File Included: Ckp SCN: 467924 Ckp time: 30-OCT-09
SPFILE Included: Modification time: 29-OCT-09
RMAN> list copy ;
specification does not match any archive log in the recovery catalog
List of Datafile Copies
Key File S Completion Time Ckp SCN Ckp Time Name
------- ---- - --------------- ---------- --------------- ----
10 1 A 30-OCT-09 467901 30-OCT-09 /u01/oracle/flash_recovery_area/ORCL/datafile/o1_mf_system_5goq8vpo_.dbf
12 2 A 30-OCT-09 467921 30-OCT-09 /u01/oracle/flash_recovery_area/ORCL/datafile/o1_mf_undotbs1_5goqb47l_.dbf
11 3 A 30-OCT-09 467915 30-OCT-09 /u01/oracle/flash_recovery_area/ORCL/datafile/o1_mf_sysaux_5goq9o07_.dbf
13 4 A 30-OCT-09 467924 30-OCT-09 /u01/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_5goqb7ff_.dbf
[oracle@sunblaze ~]$ cd /u01/oracle/flash_recovery_area/ORCL/datafile/o1_mf_
o1_mf_sysaux_5goq9o07_.dbf o1_mf_system_5goq8vpo_.dbf o1_mf_undotbs1_5goqb47l_.dbf o1_mf_users_5goqb7ff_.dbf
[oracle@sunblaze 2009_10_30]$ du -H o1_mf_ncsn1_TAG20091030T203331_5goqbbgc_.bkp
du: WARNING: use --si, not -H; the meaning of the -H option will soon
change to be the same as that of --dereference-args (-D)
7.2M o1_mf_ncsn1_TAG20091030T203331_5goqbbgc_.bkp
第一条语句表示要生成级别为1的、tag值为'arch_copy',针对整个数据库的,并且应用于增量备份的镜像副本。
1、第一天执行该程序,执行第一句话的时候,由于我们没有0级备份,因此会生成整个数据库的镜像副本(该副本不是普通的副本,而是可以在其上应用增量备份)
执行第二条语句的时候,,因为没有增量备份,因此不会执行,但是也不会报错。
2、第二天执行该程序,由于已经有了第一天的0级备份,所以会生成一个1级别的增量备份,执行第二条语句的时候,会将第一条语句生成的增量备份应用到第一天所生成的镜像副本上。以后的每一天都会生成一个增量备份,并将该生成的增量备份应用到镜像副本上,如果过需要恢复,先恢复镜像副本,然后应用最近一次增量备份以来,所生成的所有归档日志,即可进行数据库恢复。
恢复目录
db服务器操作
[oracle@oracle ~]$ logora
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Oct 28 09:50:37 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> show parameter instance
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
active_instance_count integer
cluster_database_instances integer 1
instance_groups string
instance_name string rmandb
instance_number integer 0
instance_type string RDBMS
open_links_per_instance integer 4
parallel_instance_group string
parallel_server_instances integer 1
目录服务器操作
SQL> create tablespace rman_tbs datafile '/u01/app/oracle/oradata/rmandb/rmantbs01.dbf' size 20M ;
Tablespace created.
SQL> create user rman_user identified by admin1 default tablespace rman_tbs ;
User created.
SQL> alter user rman_user quota unlimited on rman_tbs ;
User altered.
SQL> grant recovery_catalog_owner to rman_user ;
Grant succeeded.
SQL> grant connect,resource to rman_user ;
Grant succeeded.
登录原服务器注册
RMAN> register database ;
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
恢复
数据文件,控制文件,联机日志文件丢失的恢复
RMAN> run {
set controlfile autobackup format for device type disk to '%F' ;
restore controlfile from autobackup ;
sql 'alter database mount ' ;
restore database ;
recover database noredo ;
}
executing command: SET CONTROLFILE AUTOBACKUP FORMAT
Starting restore at 23-OCT-09
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=157 devtype=DISK
recovery area destination: /u01/oracle/flash_recovery_area
database name (or database unique name) used for search: ORCL
channel ORA_DISK_1: autobackup found in the recovery area
channel ORA_DISK_1: autobackup found: /u01/oracle/flash_recovery_area/ORCL/autobackup/2009_10_23/o1_mf_s_701043101_5g3gf28y_.bkp
channel ORA_DISK_1: control file restore from autobackup complete
output filename=/u01/oracle/oradata/orcl/control01.ctl
output filename=/u01/oracle/oradata/orcl/control02.ctl
output filename=/u01/oracle/oradata/orcl/control03.ctl
Finished restore at 23-OCT-09
sql statement: alter database mount
released channel: ORA_DISK_1
Starting restore at 23-OCT-09
Starting implicit crosscheck backup at 23-OCT-09
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=157 devtype=DISK
Crosschecked 4 objects
Finished implicit crosscheck backup at 23-OCT-09
Starting implicit crosscheck copy at 23-OCT-09
using channel ORA_DISK_1
Finished implicit crosscheck copy at 23-OCT-09
searching for all files in the recovery area
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /u01/oracle/flash_recovery_area/ORCL/autobackup/2009_10_23/o1_mf_s_701043101_5g3gf28y_.bkp
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/oracle/oradata/orcl/system01.dbf
restoring datafile 00002 to /u01/oracle/oradata/orcl/undotbs01.dbf
restoring datafile 00003 to /u01/oracle/oradata/orcl/sysaux01.dbf
restoring datafile 00004 to /u01/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/oracle/flash_recovery_area/ORCL/backupset/2009_10_23/o1_mf_nnndf_TAG20091023T215p
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/oracle/flash_recovery_area/ORCL/backupset/2009_10_23/o1_mf_nnndf_TAG20091023T215725_5g3fl5so_.bkp tag=TAG200910235
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
Finished restore at 23-OCT-09
Starting recover at 23-OCT-09
using channel ORA_DISK_1
Finished recover at 23-OCT-09
SQL> recover database until cancel using backup controlfile ;
ORA-00279: change 536015 generated at 10/23/2009 22:11:21 needed for thread 1
ORA-00289: suggestion :
/u01/oracle/flash_recovery_area/ORCL/archivelog/2009_10_23/o1_mf_1_1_%u_.arc
ORA-00280: change 536015 for thread 1 is in sequence #1
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
cancel
Media recovery cancelled.
SQL> alter database open resetlogs ;
Database altered.
set controlfile autobackup format for device type disk to '%F' ;
设置自动备份的格式 以便恢复
restore controlfile from autobackup ;
恢复控制文件
sql 'alter database mount ' ;
mount
restore database ;
还原数据库
recover database noredo ;
由于联机日志已经丢失,所以需要resetlog
recover database until cancel using backup controlfile ;
使用旧的控制文件恢复数据库
alter database open resetlogs ;
重置日志,打开数据库。
所有数据文件丢失,控制文件,联机日志文件未丢失
场景模拟
SQL> select open_mode from v$database ;
OPEN_MODE
----------
READ WRITE
[oracle@oracle ~]$ cd /u01/app/oracle/oradata/orcl/
[oracle@oracle orcl]$ ll
总用量 1246440
-rw-r----- 1 oracle oinstall 7061504 10月 26 13:04 control01.ctl
-rw-r----- 1 oracle oinstall 7061504 10月 26 13:04 control02.ctl
-rw-r----- 1 oracle oinstall 7061504 10月 26 13:04 control03.ctl
-rw-r----- 1 oracle oinstall 104865792 10月 26 12:21 example01.dbf
-rw-r--r-- 1 oracle oinstall 1052 10月 26 12:09 initorcl.ora
-rw-r--r-- 1 oracle oinstall 797 10月 26 12:09 listener.ora
-rw-r----- 1 oracle oinstall 52429312 10月 26 12:21 redo01.log
-rw-r----- 1 oracle oinstall 52429312 10月 26 13:04 redo02.log
-rw-r----- 1 oracle oinstall 52429312 10月 26 12:21 redo03.log
-rw-r----- 1 oracle oinstall 3584 10月 26 12:09 spfileorcl.ora
-rw-r----- 1 oracle oinstall 262152192 10月 26 12:59 sysaux01.dbf
-rw-r----- 1 oracle oinstall 650125312 10月 26 13:02 system01.dbf
-rw-r----- 1 oracle oinstall 22028288 10月 26 12:09 temp01.dbf
-rw-r----- 1 oracle oinstall 496 10月 26 12:09 tnsnames.ora
-rw-r----- 1 oracle oinstall 31465472 10月 26 13:04 undotbs01.dbf
-rw-r----- 1 oracle oinstall 27533312 10月 26 12:21 users01.dbf
[oracle@oracle orcl]$ rm -rf *.dbf
SQL> select * from dual ;
select * from dual
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-01116: error in opening database file 1
ORA-01110: data file 1: '/u01/app/oracle/oradata/orcl/system01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
SQL> shutdown abort
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 281018368 bytes
Fixed Size 1218968 bytes
Variable Size 117442152 bytes
Database Buffers 159383552 bytes
Redo Buffers 2973696 bytes
Database mounted.
SQL> alter databaseopen
2 .
SQL> alter database open ;
alter database open
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '/u01/app/oracle/oradata/orcl/system01.dbf'
恢复操作
[oracle@oracle orcl]$ logrman
Recovery Manager: Release 10.2.0.1.0 - Production on Mon Oct 26 13:05:46 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1226104724, not open)
RMAN> run{
2> restore database ;
3> recover database ;
4> }
Starting restore at 26-OCT-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/app/oracle/oradata/orcl/system01.dbf
restoring datafile 00002 to /u01/app/oracle/oradata/orcl/undotbs01.dbf
restoring datafile 00003 to /u01/app/oracle/oradata/orcl/sysaux01.dbf
restoring datafile 00004 to /u01/app/oracle/oradata/orcl/users01.dbf
restoring datafile 00005 to /u01/app/oracle/oradata/orcl/example01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_26/o1_mf_nnndf_TAG20091026p
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_26/o1_mf_nnndf_TAG20091026T121635_5gb8o40w_.bkp tag=TAG20095
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
Finished restore at 26-OCT-09
Starting recover at 26-OCT-09
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:04
Finished recover at 26-OCT-09
系统表空间数据文件丢失,控制文件,联机日志文件未丢失
场景模拟
SQL> select open_mode from v$database ;
OPEN_MODE
----------
READ WRITE
[oracle@oracle ~]$ rm -rf /u01/app/oracle/oradata/orcl/
control01.ctl control03.ctl initorcl.ora redo01.log redo03.log sysaux01.dbf temp01.dbf undotbs01.dbf
control02.ctl example01.dbf listener.ora redo02.log spfileorcl.ora system01.dbf tnsnames.ora users01.dbf
[oracle@oracle ~]$ rm -rf /u01/app/oracle/oradata/orcl/system01.dbf
SQL> select * from dual ;
select * from dual
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-01116: error in opening database file 1
ORA-01110: data file 1: '/u01/app/oracle/oradata/orcl/system01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
SQL> shutdown abort
jORACLE instance shut down.
SQL>startup mount
ORACLE instance started.
Total System Global Area 281018368 bytes
Fixed Size 1218968 bytes
Variable Size 109053544 bytes
Database Buffers 167772160 bytes
Redo Buffers 2973696 bytes
Database mounted.
恢复操作
RMAN> run
2> {
3> restore datafile 1;
4> recover datafile 1;
5> }
Starting restore at 27-OCT-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/app/oracle/oradata/orcl/system01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_26/o1_mf_nnndf_TAG20091026p
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_26/o1_mf_nnndf_TAG20091026T121635_5gb8o40w_.bkp tag=TAG20095
channel ORA_DISK_1: restore complete, elapsed time: 00:00:36
Finished restore at 27-OCT-09
Starting recover at 27-OCT-09
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:03
Finished recover at 27-OCT-09
RMAN> sql 'alter database open ' ;
sql statement: alter database open
非系统表空间数据文件丢失,控制文件,联机日志文件丢失
场景模拟
SQL> create table scott.test as select * from v$session ;
Table created.
SQL> select count(*) from v$session ;
COUNT(*)
----------
19
oracle@oracle ~]$ rm -rf /u01/app/oracle/oradata/orcl/users01.dbf
SQL> select * from scott.dept ;
select * from scott.dept
*
ERROR at line 1:
ORA-01116: error in opening database file 4
ORA-01110: data file 4: '/u01/app/oracle/oradata/orcl/users01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
SQL> alter database datafile 4 offline ;
Database altered.
恢复操作
RMAN> run {
2> restore datafile 4;
3> recover datafile 4;
4> sql 'alter database datafile 4 online ';
5> }
Starting restore at 27-OCT-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=141 devtype=DISK
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00004 to /u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_27/o1_mf_nnndf_TAG20091027p
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_27/o1_mf_nnndf_TAG20091027T120639_5gdwghro_.bkp tag=TAG20099
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 27-OCT-09
Starting recover at 27-OCT-09
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:01
Finished recover at 27-OCT-09
sql statement: alter database datafile 4 online
RMAN> exit
Recovery Manager complete.
不完全恢复
基于时间点的不完全恢复
情景模拟
SQL> create table test as select * from dba_objects ;
Table created.
SQL> select count(*) from test ;
COUNT(*)
----------
50368
SQL> select systimestamp from dual ;
SYSTIMESTAMP
---------------------------------------------------------------------------
27-OCT-09 10.16.03.724730 AM +08:00
SQL> drop table test ;
Table dropped.
SQL> shutdown immediate
Database closed.
Database dismounted.
恢复操作
RMAN> run {
2> set until time="to_date('2009-10-27 10:16:03','yyyy-mm-dd hh24:mi:ss')";
restore database ;
recover database ;
3> 4> 5> alter database open ;
}
6>
executing command: SET until clause
Starting restore at 27-OCT-09
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/app/oracle/oradata/orcl/system01.dbf
restoring datafile 00002 to /u01/app/oracle/oradata/orcl/undotbs01.dbf
restoring datafile 00003 to /u01/app/oracle/oradata/orcl/sysaux01.dbf
restoring datafile 00004 to /u01/app/oracle/oradata/orcl/users01.dbf
restoring datafile 00005 to /u01/app/oracle/oradata/orcl/example01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_27/o1_mf_nnndf_TAG20091027p
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_27/o1_mf_nnndf_TAG20091027T101224_5gdor96t_.bkp tag=TAG20094
channel ORA_DISK_1: restore complete, elapsed time: 00:00:47
Finished restore at 27-OCT-09
Starting recover at 27-OCT-09
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:04
Finished recover at 27-OCT-09
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 10/27/2009 10:20:34
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
RMAN> alter database open resetlogs ;
database opened
RMAN> exit
验证
[oracle@oracle ~]$ logora
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Oct 27 10:21:23 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> select count(*) from test ;
COUNT(*)
----------
50368
基于日志序号的恢复
情景模拟
SQL> select * from v$log ;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS
---------- ---------- ---------- ---------- ---------- --- ----------------
FIRST_CHANGE# FIRST_TIME
------------- ------------
1 1 17 52428800 1 YES ACTIVE
731224 27-OCT-09
2 1 16 52428800 1 YES INACTIVE
731222 27-OCT-09
3 1 18 52428800 1 NO CURRENT
731228 27-OCT-09
SQL> drop table test ;
Table dropped.
SQL> alter system switch logfile ;
System altered.
SQL> shutdown abort
ORACLE instance shut down.
恢复操作
RMAN> run {
2> set until sequence 17 thread 1;
3> restore database ;
4> recover database ;
5> alter database open resetlogs ;
6> }
executing command: SET until clause
Starting restore at 27-OCT-09
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=157 devtype=DISK
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/app/oracle/oradata/orcl/system01.dbf
restoring datafile 00002 to /u01/app/oracle/oradata/orcl/undotbs01.dbf
restoring datafile 00003 to /u01/app/oracle/oradata/orcl/sysaux01.dbf
restoring datafile 00004 to /u01/app/oracle/oradata/orcl/users01.dbf
restoring datafile 00005 to /u01/app/oracle/oradata/orcl/example01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_27/o1_mf_nnndf_TAG20091027p
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_27/o1_mf_nnndf_TAG20091027T101224_5gdor96t_.bkp tag=TAG20094
channel ORA_DISK_1: restore complete, elapsed time: 00:00:46
Finished restore at 27-OCT-09
Starting recover at 27-OCT-09
using channel ORA_DISK_1
starting media recovery
archive log thread 1 sequence 9 is already on disk as file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_9c
archive log thread 1 sequence 1 is already on disk as file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_1c
archive log thread 1 sequence 2 is already on disk as file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_2c
archive log thread 1 sequence 3 is already on disk as file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_3c
archive log thread 1 sequence 4 is already on disk as file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_4c
archive log thread 1 sequence 5 is already on disk as file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_5c
archive log thread 1 sequence 6 is already on disk as file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_6c
archive log thread 1 sequence 7 is already on disk as file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_7c
archive log thread 1 sequence 8 is already on disk as file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_8c
archive log thread 1 sequence 9 is already on disk as file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_9c
archive log thread 1 sequence 10 is already on disk as file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_c
archive log thread 1 sequence 11 is already on disk as file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_c
archive log thread 1 sequence 12 is already on disk as file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_c
archive log thread 1 sequence 13 is already on disk as file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_c
archive log thread 1 sequence 14 is already on disk as file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_c
archive log thread 1 sequence 15 is already on disk as file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_c
archive log thread 1 sequence 16 is already on disk as file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_c
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_9_5gdp80qz_.arc thread=1 sequence=9
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_1_5gdpmn6m_.arc thread=1 sequence=1
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_2_5gdpmnsy_.arc thread=1 sequence=2
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_3_5gdpmr3h_.arc thread=1 sequence=3
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_4_5gdpmr8k_.arc thread=1 sequence=4
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_5_5gdpmx8w_.arc thread=1 sequence=5
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_6_5gdpmxff_.arc thread=1 sequence=6
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_7_5gdpn2gm_.arc thread=1 sequence=7
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_8_5gdpn2mn_.arc thread=1 sequence=8
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_9_5gdpn7n6_.arc thread=1 sequence=9
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_10_5gdpn7rd_.arc thread=1 sequence=10
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_11_5gdpnds8_.arc thread=1 sequence=11
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_12_5gdpndxq_.arc thread=1 sequence=12
archive log _5gdpnkyh_.arc thread=1 sequence=13
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_14_5gdpnl3c_.arc thread=1 sequence=14
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_15_5gdpnq3x_.arc thread=1 sequence=15
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2009_10_27/o1_mf_1_16_5gdpnq8h_.arc thread=1 sequence=16
media recovery complete, elapsed time: 00:00:05
Finished recover at 27-OCT-09
database opened
验证
SQL> select count(*) from test ;
COUNT(*)
----------
50368
将数据文件恢复到另外的位置
情景模拟
[oracle@oracle dbca]$ mkdir /u01/app/oracle/oradata/orcl/neworacl
[oracle@oracle ~]$ cd /u01/app/oracle/oradata/orcl/
[oracle@oracle dbca]$ ll
总用量 943384
-rw-r----- 1 oracle oinstall 7061504 10月 13 14:46 control01.ctl
-rw-r----- 1 oracle oinstall 7061504 10月 13 14:46 control02.ctl
-rw-r----- 1 oracle oinstall 7061504 10月 13 14:46 control03.ctl
-rw-r----- 1 oracle oinstall 52429312 10月 13 11:00 redo01.log
-rw-r----- 1 oracle oinstall 52429312 10月 13 14:45 redo02.log
-rw-r----- 1 oracle oinstall 52429312 10月 9 12:57 redo03.log
-rw-r----- 1 oracle oinstall 251666432 10月 13 14:45 sysaux01.dbf
-rw-r----- 1 oracle oinstall 503324672 10月 13 14:45 system01.dbf
-rw-r----- 1 oracle oinstall 20979712 10月 9 12:55 temp01.dbf
-rw-r----- 1 oracle oinstall 26222592 10月 13 14:45 undotbs01.dbf
-rw-r----- 1 oracle oinstall 5251072 10月 13 11:05 users01.dbf
[oracle@oracle dbca]$ rm –rf *.dbf
恢复操作
RMAN> run
2> {
3> set newname for datafile 1 to '/u01/app/oracle/oradata/orcl/neworacl/system01.dbf';
restore database;
4> 5> switch datafile all;
6> recover database;
alter database open;
7> 8> }
executing command: SET NEWNAME
Starting restore at 27-OCT-09
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/app/oracle/oradata/orcl/neworacl/system01.dbf
restoring datafile 00002 to /u01/app/oracle/oradata/orcl/undotbs01.dbf
restoring datafile 00003 to /u01/app/oracle/oradata/orcl/sysaux01.dbf
restoring datafile 00004 to /u01/app/oracle/oradata/orcl/users01.dbf
restoring datafile 00005 to /u01/app/oracle/oradata/orcl/example01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_27/o1_mf_nnndf_TAG20091027p
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_10_27/o1_mf_nnndf_TAG20091027T120639_5gdwghro_.bkp tag=TAG20099
channel ORA_DISK_1: restore complete, elapsed time: 00:00:47
Finished restore at 27-OCT-09
datafile 1 switched to datafile copy
input datafile copy recid=24 stamp=701355999 filename=/u01/app/oracle/oradata/orcl/neworacl/system01.dbf
Starting recover at 27-OCT-09
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:04
Finished recover at 27-OCT-09
database opened
验证
SQL> select name from v$datafile ;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/orcl/neworacl/system01.dbf
/u01/app/oracle/oradata/orcl/undotbs01.dbf
/u01/app/oracle/oradata/orcl/sysaux01.dbf
/u01/app/oracle/oradata/orcl/users01.dbf
/u01/app/oracle/oradata/orcl/example01.dbf