RMAN进行备份恢复

--RMAN备份是完全联机热备份
RMAN> connect target sys/lubinsu@orcl

connected to target database: ORCL (DBID=1326384392)

RMAN> backup database;

Starting backup at 12-JUN-13
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 full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00004 name=/home/oracle/oracle/product/10.2.0/oradata/orcl/users01.dbf
input datafile fno=00001 name=/home/oracle/oracle/product/10.2.0/oradata/orcl/system01.dbf
input datafile fno=00007 name=/home/oracle/oracle/product/10.2.0/oradata/orcl/tbs_data.dbf
input datafile fno=00002 name=/home/oracle/oracle/product/10.2.0/oradata/orcl/undotbs01.dbf
input datafile fno=00003 name=/home/oracle/oracle/product/10.2.0/oradata/orcl/sysaux01.dbf
input datafile fno=00005 name=/home/oracle/oracle/product/10.2.0/db_1/dbs/TBS_ORCL_DATA01.DBF
input datafile fno=00006 name=/home/oracle/oracle/product/10.2.0/db_1/dbs/TBS_ORCL_IDX01.DBF
channel ORA_DISK_1: starting piece 1 at 12-JUN-13
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 06/12/2013 12:11:36
ORA-19809: limit exceeded for recovery files
ORA-19804: cannot reclaim 52428800 bytes disk space from 2147483648 limit
continuing other job steps, job failed will not be re-run
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 12-JUN-13
channel ORA_DISK_1: finished piece 1 at 12-JUN-13
piece handle=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_ncsnf_TAG20130612T120900_8vhx7tnw_.bkp tag=TAG20130612T120900 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:05
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================

RMAN-03009: failure of backup command on ORA_DISK_1 channel at 06/12/2013 12:11:36
ORA-19809: limit exceeded for recovery files
ORA-19804: cannot reclaim 52428800 bytes disk space from 2147483648 LIMIT

--这里提示空间不足了,我们来查看下详细的跟踪日志:

[lubinsu@localhost ~]$ cat /home/oracle/oracle/product/10.2.0/db_1/admin/orcl/udump/orclsid_ora_5086.trc
/home/oracle/oracle/product/10.2.0/db_1/admin/orcl/udump/orclsid_ora_5086.trc
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
ORACLE_HOME = /home/oracle/oracle/product/10.2.0/db_1
System name:    Linux
Node name:      localhost.localdomain
Release:        2.6.18-8.el5
Version:        #1 SMP Fri Jan 26 14:15:21 EST 2007
Machine:        i686
Instance name: orclsid
Redo thread mounted by this instance: 0 <none>
Oracle process number: 15
Unix process pid: 5086, image: [email protected] (TNS V1-V3)

*** SERVICE NAME:() 2013-05-25 09:58:17.633
*** SESSION ID:(159.1) 2013-05-25 09:58:17.633
kccsga_update_ckpt: num_1 = 8, num_2 = 0, num_3 = 0, lbn_2 = 0, lbn_3 = 0
/home/oracle/oracle/product/10.2.0/db_1/admin/orcl/udump/orclsid_ora_5086.trc
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
ORACLE_HOME = /home/oracle/oracle/product/10.2.0/db_1
System name:    Linux
Node name:      localhost.localdomain
Release:        2.6.18-8.el5
Version:        #1 SMP Fri Jan 26 14:15:21 EST 2007
Machine:        i686
Instance name: orclsid
Redo thread mounted by this instance: 1
Oracle process number: 23
Unix process pid: 5086, image: [email protected]

*** 2013-06-12 12:10:18.861
*** ACTION NAME:(0000022 STARTED16) 2013-06-12 12:10:18.826
*** MODULE NAME:(backup full datafile) 2013-06-12 12:10:18.826
*** SERVICE NAME:(orcl) 2013-06-12 12:10:18.826
*** SESSION ID:(148.13) 2013-06-12 12:10:18.826
ORA-19815: WARNING: db_recovery_file_dest_size of 2147483648 bytes is 86.98% used, and has 279703040 remaining bytes available.
*** 2013-06-12 12:10:18.862
************************************************************************
You have following choices to free up space from flash recovery area:
1. Consider changing RMAN RETENTION POLICY. If you are using Data Guard,
   then consider changing RMAN ARCHIVELOG DELETION POLICY.
2. Back up files to tertiary device such as tape using RMAN
   BACKUP RECOVERY AREA command.
3. Add disk space and increase db_recovery_file_dest_size parameter to
   reflect the new space.
4. Delete unnecessary files using RMAN DELETE command. If an operating
   system command was used to delete files, then use RMAN CROSSCHECK and
   DELETE EXPIRED commands.
************************************************************************
*** 2013-06-12 12:11:15.771
ORA-19815: WARNING: db_recovery_file_dest_size of 2147483648 bytes is 99.18% used, and has 17559040 remaining bytes available.
*** 2013-06-12 12:11:15.771
************************************************************************
You have following choices to free up space from flash recovery area:
1. Consider changing RMAN RETENTION POLICY. If you are using Data Guard,
   then consider changing RMAN ARCHIVELOG DELETION POLICY.
2. Back up files to tertiary device such as tape using RMAN
   BACKUP RECOVERY AREA command.
3. Add disk space and increase db_recovery_file_dest_size parameter to
   reflect the new space.
4. Delete unnecessary files using RMAN DELETE command. If an operating
   system command was used to delete files, then use RMAN CROSSCHECK and
   DELETE EXPIRED commands.
************************************************************************
*** 2013-06-12 12:11:27.166
ORA-19815: WARNING: db_recovery_file_dest_size of 2147483648 bytes is 100.00% used, and has 0 remaining bytes available.
*** 2013-06-12 12:11:27.166
************************************************************************
You have following choices to free up space from flash recovery area:
1. Consider changing RMAN RETENTION POLICY. If you are using Data Guard,
   then consider changing RMAN ARCHIVELOG DELETION POLICY.
2. Back up files to tertiary device such as tape using RMAN
   BACKUP RECOVERY AREA command.
3. Add disk space and increase db_recovery_file_dest_size parameter to
   reflect the new space.
4. Delete unnecessary files using RMAN DELETE command. If an operating
   system command was used to delete files, then use RMAN CROSSCHECK and
   DELETE EXPIRED commands.
************************************************************************
*** 2013-06-12 12:11:39.945
*** ACTION NAME:(0000039 STARTED16) 2013-06-12 12:11:39.945

--这里提示 db_recovery_file_dest_size 备份时空间不足了,并且给出了几个建议:
************************************************************************
You have following choices to free up space from flash recovery area:
1. Consider changing RMAN RETENTION POLICY. If you are using Data Guard,
   then consider changing RMAN ARCHIVELOG DELETION POLICY.
2. Back up files to tertiary device such as tape using RMAN
   BACKUP RECOVERY AREA command.
3. Add disk space and increase db_recovery_file_dest_size parameter to
   reflect the new space.
4. Delete unnecessary files using RMAN DELETE command. If an operating
   system command was used to delete files, then use RMAN CROSSCHECK and
   DELETE EXPIRED commands.
************************************************************************
4. Delete unnecessary files using RMAN DELETE command. If an operating
   system command was used to delete files, then use RMAN CROSSCHECK and
   DELETE EXPIRED commands.

--删除不需要的文件
RMAN> delete backup;

using channel ORA_DISK_1

List of Backup Pieces
BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
1       1       1   1   AVAILABLE   DISK        /home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_ncsnf_TAG20130612T120900_8vhx7tnw_.bkp

Do you really want to delete the above objects (enter YES or NO)? YES
deleted backup piece
backup piece handle=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_ncsnf_TAG20130612T120900_8vhx7tnw_.bkp recid=1 stamp=817906298
Deleted 1 objects

--删除过期的无效的归档日志:
--先检查
RMAN> crosscheck archivelog all;

released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=148 devtype=DISK
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2012_12_10/o1_mf_1_72_8dcsh508_.arc recid=34 stamp=801697130
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2012_12_12/o1_mf_1_73_8djkpdg1_.arc recid=35 stamp=801853007
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2012_12_16/o1_mf_1_74_8dty7734_.arc recid=36 stamp=802193512
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2012_12_16/o1_mf_1_75_8dv32wrf_.arc recid=37 stamp=802198497
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2012_12_16/o1_mf_1_76_8dv3394w_.arc recid=38 stamp=802198509
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2012_12_16/o1_mf_1_77_8dv33zdy_.arc recid=39 stamp=802198534
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2012_12_16/o1_mf_1_78_8dv34j4b_.arc recid=40 stamp=802198548
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2012_12_16/o1_mf_1_79_8dv35fs2_.arc recid=41 stamp=802198578
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2012_12_16/o1_mf_1_80_8dv35wg3_.arc recid=42 stamp=802198593
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2012_12_16/o1_mf_1_81_8dv36drn_.arc recid=43 stamp=802198610
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2012_12_16/o1_mf_1_82_8dv36zf5_.arc recid=44 stamp=802198627
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2012_12_16/o1_mf_1_83_8dv3brz0_.arc recid=45 stamp=802198754
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2012_12_16/o1_mf_1_84_8dv3cf6m_.arc recid=46 stamp=802198772
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2012_12_16/o1_mf_1_85_8dv3nj6v_.arc recid=47 stamp=802199058
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2012_12_22/o1_mf_1_86_8fbtklty_.arc recid=48 stamp=802714050
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2012_12_22/o1_mf_1_87_8fbtknvh_.arc recid=49 stamp=802714055
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2012_12_22/o1_mf_1_88_8fbtl818_.arc recid=50 stamp=802714072
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2012_12_22/o1_mf_1_89_8fbv6jhj_.arc recid=52 stamp=802714717
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2012_12_22/o1_mf_1_90_8fbv6k8d_.arc recid=51 stamp=802714717
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2012_12_22/o1_mf_1_91_8fbv6yy0_.arc recid=53 stamp=802714733
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_05_19/o1_mf_1_144_8skprlh0_.arc recid=54 stamp=815868056
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_05_20/o1_mf_1_145_8slyg3lw_.arc recid=55 stamp=815908677
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_05_23/o1_mf_1_146_8sv4vd1v_.arc recid=56 stamp=816177391
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_05_23/o1_mf_1_147_8sw8lnfx_.arc recid=57 stamp=816213980
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_05_25/o1_mf_1_148_8t06p19b_.arc recid=58 stamp=816343106
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_05_25/o1_mf_1_149_8t0cl6ly_.arc recid=59 stamp=816348108
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_05_25/o1_mf_1_150_8t0d1kq6_.arc recid=60 stamp=816348598
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_05_25/o1_mf_1_151_8t0fv9xr_.arc recid=61 stamp=816350443
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_05_25/o1_mf_1_152_8t0gkshz_.arc recid=62 stamp=816351164
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_05_25/o1_mf_1_153_8t0p049t_.arc recid=63 stamp=816358790
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_06_02/o1_mf_1_154_8tobp66g_.arc recid=64 stamp=817035344
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_06_02/o1_mf_1_155_8tocwsgw_.arc recid=65 stamp=817036573
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_06_02/o1_mf_1_156_8tocz0l8_.arc recid=66 stamp=817036643
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_06_02/o1_mf_1_157_8tod4rmb_.arc recid=67 stamp=817036828
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_06_02/o1_mf_1_158_8toddjdx_.arc recid=68 stamp=817037075
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_06_02/o1_mf_1_159_8todgr72_.arc recid=69 stamp=817037144
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_06_02/o1_mf_1_160_8todmx79_.arc recid=70 stamp=817037309
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_06_02/o1_mf_1_161_8tofqzz1_.arc recid=71 stamp=817038465
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_06_02/o1_mf_1_162_8tog2s28_.arc recid=72 stamp=817038809
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_06_02/o1_mf_1_163_8tog69ty_.arc recid=73 stamp=817038921
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_06_02/o1_mf_1_164_8tojbz0v_.arc recid=74 stamp=817041119
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_06_02/o1_mf_1_165_8tojd2mx_.arc recid=75 stamp=817041154
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_06_02/o1_mf_1_166_8tojf7dd_.arc recid=76 stamp=817041191
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_06_02/o1_mf_1_167_8tojg8nw_.arc recid=77 stamp=817041224
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_06_02/o1_mf_1_168_8tojh6p8_.arc recid=78 stamp=817041254
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_06_02/o1_mf_1_169_8tojhoh1_.arc recid=79 stamp=817041269
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_06_02/o1_mf_1_170_8tojjbq0_.arc recid=80 stamp=817041290
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_06_02/o1_mf_1_171_8tojjwqj_.arc recid=81 stamp=817041308
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_06_02/o1_mf_1_172_8toxrkhf_.arc recid=82 stamp=817054866
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_06_02/o1_mf_1_173_8toyq5pz_.arc recid=83 stamp=817055845
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_06_02/o1_mf_1_174_8toyqtt7_.arc recid=84 stamp=817055866
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_06_02/o1_mf_1_175_8toyqyg1_.arc recid=85 stamp=817055870
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_06_02/o1_mf_1_176_8toyqyq9_.arc recid=86 stamp=817055870
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_06_02/o1_mf_1_177_8toyr3tp_.arc recid=87 stamp=817055875
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_06_02/o1_mf_1_178_8tpohwjv_.arc recid=88 stamp=817079165
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_06_03/o1_mf_1_179_8ts7wknt_.arc recid=89 stamp=817163538
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_06_07/o1_mf_1_180_8v3mt2h6_.arc recid=90 stamp=817503427
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_06_07/o1_mf_1_181_8v3rrjnq_.arc recid=91 stamp=817508501
validation succeeded for archived log
archive log filename=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/archivelog/2013_06_12/o1_mf_1_182_8vhwx38v_.arc recid=92 stamp=817905955
Crosschecked 59 objects

RMAN> delete expired archivelog all; 

released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=148 devtype=DISK
specification does not match any archive log in the recovery catalog
--看来没有找到匹配的可以删除的无效的归档日志

--扩大 db_recovery_file_dest_size 空间的大小
SQL> alter system set db_recovery_file_dest_size=8G scope=both;

System altered.

--现在重新备份下:
RMAN> backup database;

Starting backup at 12-JUN-13
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=/home/oracle/oracle/product/10.2.0/oradata/orcl/users01.dbf
input datafile fno=00001 name=/home/oracle/oracle/product/10.2.0/oradata/orcl/system01.dbf
input datafile fno=00007 name=/home/oracle/oracle/product/10.2.0/oradata/orcl/tbs_data.dbf
input datafile fno=00002 name=/home/oracle/oracle/product/10.2.0/oradata/orcl/undotbs01.dbf
input datafile fno=00003 name=/home/oracle/oracle/product/10.2.0/oradata/orcl/sysaux01.dbf
input datafile fno=00005 name=/home/oracle/oracle/product/10.2.0/db_1/dbs/TBS_ORCL_DATA01.DBF
input datafile fno=00006 name=/home/oracle/oracle/product/10.2.0/db_1/dbs/TBS_ORCL_IDX01.DBF
channel ORA_DISK_1: starting piece 1 at 12-JUN-13
channel ORA_DISK_1: finished piece 1 at 12-JUN-13
piece handle=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_nnndf_TAG20130612T125054_8vhzkgdt_.bkp tag=TAG20130612T125054 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:06:26
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 12-JUN-13
channel ORA_DISK_1: finished piece 1 at 12-JUN-13
piece handle=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_ncsnf_TAG20130612T125054_8vhzxlf2_.bkp tag=TAG20130612T125054 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:05
Finished backup at 12-JUN-13

--我们可以看到Oracle帮我们把数据文件,控制文件还有spfile都备份了,备份在了目录:/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/中

--还可以对备份进行压缩,打开多个通道,这里的通道相当于进程,并且会创建对应的Session,同时运行多条命令等操作。
--这时多个通道会同时处理多个操作。
RMAN> run{    
2> allocate channel c1 device type disk;
3> allocate channel c2 device type disk;
4> backup as compressed backupset database;
5> }

RMAN> run{    
2> allocate channel c1 device type disk;
3> allocate channel c2 device type disk;
4> backup as compressed backupset database;
5> }

released channel: ORA_DISK_1--有私有通道的时候会释放通道,RMAN起起来的时候默认会有一个公共通道,私有通道执行完就自动释放了。
allocated channel: c1
channel c1: sid=148 devtype=DISK

allocated channel: c2
channel c2: sid=136 devtype=DISK

Starting backup at 12-JUN-13
channel c1: starting compressed full datafile backupset
channel c1: specifying datafile(s) in backupset
input datafile fno=00004 name=/home/oracle/oracle/product/10.2.0/oradata/orcl/users01.dbf
input datafile fno=00003 name=/home/oracle/oracle/product/10.2.0/oradata/orcl/sysaux01.dbf
input datafile fno=00006 name=/home/oracle/oracle/product/10.2.0/db_1/dbs/TBS_ORCL_IDX01.DBF
channel c1: starting piece 1 at 12-JUN-13
channel c2: starting compressed full datafile backupset
channel c2: specifying datafile(s) in backupset
input datafile fno=00001 name=/home/oracle/oracle/product/10.2.0/oradata/orcl/system01.dbf
input datafile fno=00007 name=/home/oracle/oracle/product/10.2.0/oradata/orcl/tbs_data.dbf
input datafile fno=00002 name=/home/oracle/oracle/product/10.2.0/oradata/orcl/undotbs01.dbf
input datafile fno=00005 name=/home/oracle/oracle/product/10.2.0/db_1/dbs/TBS_ORCL_DATA01.DBF
channel c2: starting piece 1 at 12-JUN-13

user interrupt received
Finished backup at 12-JUN-13

user interrupt received
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03099: job cancelled at user request

--备份完,我们可以查看备份集列表:如果不控制备份集大小,一个通道会产生一个备份集。
RMAN> list backup;

List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2       Full    2.30G      DISK        00:06:17     12-JUN-13      
        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20130612T125054
        Piece Name: /home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_nnndf_TAG20130612T125054_8vhzkgdt_.bkp
  List of Datafiles in backup set 2
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 13229464105956 12-JUN-13 /home/oracle/oracle/product/10.2.0/oradata/orcl/system01.dbf
  2       Full 13229464105956 12-JUN-13 /home/oracle/oracle/product/10.2.0/oradata/orcl/undotbs01.dbf
  3       Full 13229464105956 12-JUN-13 /home/oracle/oracle/product/10.2.0/oradata/orcl/sysaux01.dbf
  4       Full 13229464105956 12-JUN-13 /home/oracle/oracle/product/10.2.0/oradata/orcl/users01.dbf
  5       Full 13229464105956 12-JUN-13 /home/oracle/oracle/product/10.2.0/db_1/dbs/TBS_ORCL_DATA01.DBF
  6       Full 13229464105956 12-JUN-13 /home/oracle/oracle/product/10.2.0/db_1/dbs/TBS_ORCL_IDX01.DBF
  7       Full 13229464105956 12-JUN-13 /home/oracle/oracle/product/10.2.0/oradata/orcl/tbs_data.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3       Full    6.89M      DISK        00:00:03     12-JUN-13      
        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20130612T125054
        Piece Name: /home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_ncsnf_TAG20130612T125054_8vhzxlf2_.bkp
  Control File Included: Ckp SCN: 13229464106126   Ckp time: 12-JUN-13
  SPFILE Included: Modification time: 12-JUN-13
  
--备份完当然是需要进行恢复了:
--1.我们先移除一个数据文件:
[oracle@localhost orcl]$ mv tbs_data.dbf tbs_data.dbf_bak
--此时只能将数据库打开到mount状态,无法读取数据文件:
[lubinsu@localhost oracle]$ rman target sys/lubinsu@orcl

Recovery Manager: Release 10.2.0.1.0 - Production on Wed Jun 12 13:59:33 2013

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database (not started)

RMAN> startup mount

Oracle instance started
database mounted

Total System Global Area     285212672 bytes

Fixed Size                     1218968 bytes
Variable Size                 92276328 bytes
Database Buffers             184549376 bytes
Redo Buffers                   7168000 bytes

RMAN> alter database open 
2> ;

using target database control file instead of recovery catalog
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 06/12/2013 14:00:01
ORA-01157: cannot identify/lock data file 7 - see DBWR trace file
ORA-01110: data file 7: '/home/oracle/oracle/product/10.2.0/oradata/orcl/tbs_data.dbf'

--查看现有的备份:
RMAN> list backup;

RMAN> list backup;


List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2       Full    2.30G      DISK        00:06:17     12-JUN-13      
        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20130612T125054
        Piece Name: /home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_nnndf_TAG20130612T125054_8vhzkgdt_.bkp
  List of Datafiles in backup set 2
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 13229464105956 12-JUN-13 /home/oracle/oracle/product/10.2.0/oradata/orcl/system01.dbf
  2       Full 13229464105956 12-JUN-13 /home/oracle/oracle/product/10.2.0/oradata/orcl/undotbs01.dbf
  3       Full 13229464105956 12-JUN-13 /home/oracle/oracle/product/10.2.0/oradata/orcl/sysaux01.dbf
  4       Full 13229464105956 12-JUN-13 /home/oracle/oracle/product/10.2.0/oradata/orcl/users01.dbf
  5       Full 13229464105956 12-JUN-13 /home/oracle/oracle/product/10.2.0/db_1/dbs/TBS_ORCL_DATA01.DBF
  6       Full 13229464105956 12-JUN-13 /home/oracle/oracle/product/10.2.0/db_1/dbs/TBS_ORCL_IDX01.DBF
  7       Full 13229464105956 12-JUN-13 /home/oracle/oracle/product/10.2.0/oradata/orcl/tbs_data.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3       Full    6.89M      DISK        00:00:03     12-JUN-13      
        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20130612T125054
        Piece Name: /home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_ncsnf_TAG20130612T125054_8vhzxlf2_.bkp
  Control File Included: Ckp SCN: 13229464106126   Ckp time: 12-JUN-13
  SPFILE Included: Modification time: 12-JUN-13

RMAN> list backup of database;

List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2       Full    2.30G      DISK        00:06:17     12-JUN-13      
        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20130612T125054
        Piece Name: /home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_nnndf_TAG20130612T125054_8vhzkgdt_.bkp
  List of Datafiles in backup set 2
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 13229464105956 12-JUN-13 /home/oracle/oracle/product/10.2.0/oradata/orcl/system01.dbf
  2       Full 13229464105956 12-JUN-13 /home/oracle/oracle/product/10.2.0/oradata/orcl/undotbs01.dbf
  3       Full 13229464105956 12-JUN-13 /home/oracle/oracle/product/10.2.0/oradata/orcl/sysaux01.dbf
  4       Full 13229464105956 12-JUN-13 /home/oracle/oracle/product/10.2.0/oradata/orcl/users01.dbf
  5       Full 13229464105956 12-JUN-13 /home/oracle/oracle/product/10.2.0/db_1/dbs/TBS_ORCL_DATA01.DBF
  6       Full 13229464105956 12-JUN-13 /home/oracle/oracle/product/10.2.0/db_1/dbs/TBS_ORCL_IDX01.DBF
  7       Full 13229464105956 12-JUN-13 /home/oracle/oracle/product/10.2.0/oradata/orcl/tbs_data.dbf

RMAN> list backup of controlfile;

List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3       Full    6.89M      DISK        00:00:03     12-JUN-13      
        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20130612T125054
        Piece Name: /home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_ncsnf_TAG20130612T125054_8vhzxlf2_.bkp
  Control File Included: Ckp SCN: 13229464106126   Ckp time: 12-JUN-13

RMAN> list backup of spfile;

List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3       Full    6.89M      DISK        00:00:03     12-JUN-13      
        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20130612T125054
        Piece Name: /home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_ncsnf_TAG20130612T125054_8vhzxlf2_.bkp
  SPFILE Included: Modification time: 12-JUN-13

--RMAN可以使用恢复预览:
RMAN> restore preview database;

Starting restore at 12-JUN-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=157 devtype=DISK

List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2       Full    2.30G      DISK        00:06:17     12-JUN-13      
        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20130612T125054
        Piece Name: /home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_nnndf_TAG20130612T125054_8vhzkgdt_.bkp
  List of Datafiles in backup set 2
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 13229464105956 12-JUN-13 /home/oracle/oracle/product/10.2.0/oradata/orcl/system01.dbf
  2       Full 13229464105956 12-JUN-13 /home/oracle/oracle/product/10.2.0/oradata/orcl/undotbs01.dbf
  3       Full 13229464105956 12-JUN-13 /home/oracle/oracle/product/10.2.0/oradata/orcl/sysaux01.dbf
  4       Full 13229464105956 12-JUN-13 /home/oracle/oracle/product/10.2.0/oradata/orcl/users01.dbf
  5       Full 13229464105956 12-JUN-13 /home/oracle/oracle/product/10.2.0/db_1/dbs/TBS_ORCL_DATA01.DBF
  6       Full 13229464105956 12-JUN-13 /home/oracle/oracle/product/10.2.0/db_1/dbs/TBS_ORCL_IDX01.DBF
  7       Full 13229464105956 12-JUN-13 /home/oracle/oracle/product/10.2.0/oradata/orcl/tbs_data.dbf
using channel ORA_DISK_1
--这里提示出错,实际上并没有问题,只是有部分日志并未归档,但是在日志文件中还是存在的。
archive logs generated after SCN 13229464105956 not found in repository
Media recovery start SCN is 13229464105956
Recovery must be done beyond SCN 13229464105956 to clear data files fuzziness
Finished restore at 12-JUN-13

--开始恢复
RMAN> restore database;

Starting restore at 12-JUN-13
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 /home/oracle/oracle/product/10.2.0/oradata/orcl/system01.dbf
restoring datafile 00002 to /home/oracle/oracle/product/10.2.0/oradata/orcl/undotbs01.dbf
restoring datafile 00003 to /home/oracle/oracle/product/10.2.0/oradata/orcl/sysaux01.dbf
restoring datafile 00004 to /home/oracle/oracle/product/10.2.0/oradata/orcl/users01.dbf
restoring datafile 00005 to /home/oracle/oracle/product/10.2.0/db_1/dbs/TBS_ORCL_DATA01.DBF
restoring datafile 00006 to /home/oracle/oracle/product/10.2.0/db_1/dbs/TBS_ORCL_IDX01.DBF
restoring datafile 00007 to /home/oracle/oracle/product/10.2.0/oradata/orcl/tbs_data.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_nnndf_TAG20130612T125054_8vhzkgdt_.bkp
channel ORA_DISK_1: restored backup piece 1
piece handle=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_nnndf_TAG20130612T125054_8vhzkgdt_.bkp tag=TAG20130612T125054
channel ORA_DISK_1: restore complete, elapsed time: 00:04:37
Finished restore at 12-JUN-13

RMAN> alter database open;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 06/12/2013 14:14:14
ORA-01113: file 1 needs media recovery
ORA-01110: data file 1: '/home/oracle/oracle/product/10.2.0/oradata/orcl/system01.dbf'

--这里就需要使用归档日志进行介质恢复了:
RMAN> recover database;

Starting recover at 12-JUN-13
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:22

Finished recover at 12-JUN-13

--恢复成功:
RMAN> alter database open;

database opened

--另外RMAN还可以单独备份数据文件,数据库表空间:
BACKUP DATAFILE 3,4;--逗号隔开
BACKUP TABLESPACE XXX,XXX2;--逗号隔开

BACKUP CURRENT CONTROLFILE;

BACKUP SPFILE;


************************************************************************
--附录:关于scope=both的说明:
Question:  I don't understand the scope=memory option.  Does scope=memory only apply to SGA parameters?  
How is scope=memory different than a standard alter system command?

Answer:  scope is a parameter used in conjunction with the alter system command when you are changing any initialization parameter of an spfile.  
It is vital to understand how to use this parameter to achieve the desired effect.  
There are three values that the scope parameter can take:

scope = memory
scope = spfile
scope = both
For the value in question, scope = memory, Oracle will make the change specified by the alter system command for the life of the instance.  
The next time the database is bounced, for any reason, the change will be reverted to the default value.

For scope=spfile the change made in the alter system command will take place starting from the next startup but will not affect the current instance. 

If you want the alter system command to take place immediately you can use the scope = both value, which will make the change for the current instance and preserve it through any future bounces.'
************************************************************************

你可能感兴趣的:(oracle,数据库,备份,rman)