我是靠谱客的博主 壮观冬日,最近开发中收集的这篇文章主要介绍RMAN管理备份,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

--RMAN使用2,管理备份
--删除备份集:
--1.查看备份集
RMAN> list backupset 7;
List of Backup Sets
===================
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
7       Full    1.87M      DISK        00:00:01     12-JUN-13      
        BP Key: 7   Status: AVAILABLE  Compressed: NO  Tag: TAG20130612T150858
        Piece Name: /home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_nnndf_TAG20130612T150858_8vj7nbbq_.bkp
  List of Datafiles in backup set 7
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  6       Full 13229464115969 12-JUN-13 /home/oracle/oracle/product/10.2.0/db_1/dbs/TBS_ORCL_IDX01.DBF

--2.删除第七个备份集:
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        /home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_nnndf_TAG20130612T150858_8vj7nbbq_.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_nnndf_TAG20130612T150858_8vj7nbbq_.bkp recid=7 stamp=817916938
Deleted 1 objects
--查看未备份的归档日志:
RMAN> list archivelog all;
specification does not match any archive log in the recovery catalog
--查看已经备份的归档日志:
RMAN> list backup of archivelog all;
List of Backup Sets
===================
BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
4       1.47G      DISK        00:03:18     12-JUN-13      
        BP Key: 4   Status: AVAILABLE  Compressed: NO  Tag: TAG20130612T144846
        Piece Name: /home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_annnn_TAG20130612T144846_8vj6glv9_.bkp
  List of Archived Logs in backup set 4
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    72      790665     04-DEC-12 13054440590919 10-DEC-12
  1    73      13054440590919 10-DEC-12 13054440616655 12-DEC-12
  1    74      13054440616655 12-DEC-12 13054440642210 16-DEC-12
  1    75      13054440642210 16-DEC-12 13054440650662 16-DEC-12
  1    76      13054440650662 16-DEC-12 13054440651406 16-DEC-12
  1    77      13054440651406 16-DEC-12 13054440652044 16-DEC-12
  1    78      13054440652044 16-DEC-12 13054440652666 16-DEC-12
  1    79      13054440652666 16-DEC-12 13054440653806 16-DEC-12
  1    80      13054440653806 16-DEC-12 13054440654435 16-DEC-12
  1    81      13054440654435 16-DEC-12 13054440655089 16-DEC-12
  1    82      13054440655089 16-DEC-12 13054440655737 16-DEC-12
  1    83      13054440655737 16-DEC-12 13054440656499 16-DEC-12
  1    84      13054440656499 16-DEC-12 13054440657129 16-DEC-12
  1    85      13054440657129 16-DEC-12 13054440658099 16-DEC-12
  1    86      13054440658099 16-DEC-12 13054440658339 16-DEC-12
  1    87      13054440658339 16-DEC-12 13054440658574 16-DEC-12
  1    88      13054440658574 16-DEC-12 13054440660313 22-DEC-12
  1    89      13054440660313 22-DEC-12 13054440683610 22-DEC-12
  1    90      13054440683610 22-DEC-12 13054440683842 22-DEC-12
  1    91      13054440683842 22-DEC-12 13054440684168 22-DEC-12
  1    144     13229463705676 19-MAY-13 13229463732128 19-MAY-13
  1    145     13229463732128 19-MAY-13 13229463757636 20-MAY-13
  1    146     13229463757636 20-MAY-13 13229463799937 23-MAY-13
  1    147     13229463799937 23-MAY-13 13229463843004 23-MAY-13
  1    148     13229463843004 23-MAY-13 13229463866428 25-MAY-13
  1    149     13229463866428 25-MAY-13 13229463870836 25-MAY-13
  1    150     13229463870836 25-MAY-13 13229463873383 25-MAY-13
  1    151     13229463873383 25-MAY-13 13229463877829 25-MAY-13
  1    152     13229463877829 25-MAY-13 13229463881225 25-MAY-13
  1    153     13229463881225 25-MAY-13 13229463902949 25-MAY-13
  1    154     13229463902949 25-MAY-13 13229463936415 02-JUN-13
  1    155     13229463936415 02-JUN-13 13229463940988 02-JUN-13
  1    156     13229463940988 02-JUN-13 13229463941675 02-JUN-13
  1    157     13229463941675 02-JUN-13 13229463947173 02-JUN-13
  1    158     13229463947173 02-JUN-13 13229463955489 02-JUN-13
  1    159     13229463955489 02-JUN-13 13229463955519 02-JUN-13
  1    160     13229463955519 02-JUN-13 13229463955619 02-JUN-13
  1    161     13229463955619 02-JUN-13 13229463960323 02-JUN-13
  1    162     13229463960323 02-JUN-13 13229463960499 02-JUN-13
  1    163     13229463960499 02-JUN-13 13229463960567 02-JUN-13
  1    164     13229463960567 02-JUN-13 13229463961439 02-JUN-13
  1    165     13229463961439 02-JUN-13 13229463961457 02-JUN-13
  1    166     13229463961457 02-JUN-13 13229463961587 02-JUN-13
  1    167     13229463961587 02-JUN-13 13229463961601 02-JUN-13
  1    168     13229463961601 02-JUN-13 13229463961618 02-JUN-13
  1    169     13229463961618 02-JUN-13 13229463961624 02-JUN-13
  1    170     13229463961624 02-JUN-13 13229463961639 02-JUN-13
  1    171     13229463961639 02-JUN-13 13229463961652 02-JUN-13
  1    172     13229463961652 02-JUN-13 13229463986644 02-JUN-13
  1    173     13229463986644 02-JUN-13 13229463987380 02-JUN-13
  1    174     13229463987380 02-JUN-13 13229463987395 02-JUN-13
  1    175     13229463987395 02-JUN-13 13229463987400 02-JUN-13
  1    176     13229463987400 02-JUN-13 13229463987404 02-JUN-13
  1    177     13229463987404 02-JUN-13 13229463987408 02-JUN-13
  1    178     13229463987408 02-JUN-13 13229464008625 02-JUN-13
  1    179     13229464008625 02-JUN-13 13229464031402 03-JUN-13
  1    180     13229464031402 03-JUN-13 13229464055273 07-JUN-13
  1    181     13229464055273 07-JUN-13 13229464082108 07-JUN-13
  1    182     13229464082108 07-JUN-13 13229464102392 12-JUN-13
  1    183     13229464102392 12-JUN-13 13229464114766 12-JUN-13
BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
5       90.50K     DISK        00:00:01     12-JUN-13      
        BP Key: 5   Status: AVAILABLE  Compressed: NO  Tag: TAG20130612T145421
        Piece Name: /home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_annnn_TAG20130612T145421_8vj6ryn7_.bkp
  List of Archived Logs in backup set 5
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    184     13229464114766 12-JUN-13 13229464114964 12-JUN-13
BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
6       46.00K     DISK        00:00:01     12-JUN-13      
        BP Key: 6   Status: AVAILABLE  Compressed: NO  Tag: TAG20130612T145619
        Piece Name: /home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_annnn_TAG20130612T145619_8vj6wnnq_.bkp
  List of Archived Logs in backup set 6
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    185     13229464114964 12-JUN-13 13229464115033 12-JUN-13
 
--查看不是必须的,可以删除的备份:
--下面是官方的说明文档:
report obsolete:Lists full backups, data file copies, and archived redo log files recorded in the 
RMAN repository that can be deleted because they are no longer needed  The command works 
in two steps:
 
For each data file that has been backed up, RMAN identifies the oldest full 
backup, level 0 backup, or image copy that is not obsolete under the 
retention policy. Any backup of the data file older than the one identified in 
this step is considered obsolete.
Any archived redo log files and level 1 incremental backups that are older 
than the oldest nonobsolete full backup are considered obsolete. These files 
are obsolete because no full or level 0 backup exists to which they can be 
applied. Incremental level 1 backups or archived redo log files are not 
considered obsolete if they can be applied to nonobsolete level 0 or full 
backups.

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           8      12-JUN-13         
  Backup Piece       8      12-JUN-13          /home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_nnndf_TAG20130612T153458_8vj952jn_.bkp
  
--删除: delete obsolete;
RMAN> delete obsolete;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
using channel ORA_DISK_1
Deleting the following obsolete backups and copies:
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set           8      12-JUN-13         
  Backup Piece       8      12-JUN-13          /home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_nnndf_TAG20130612T153458_8vj952jn_.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_nnndf_TAG20130612T153458_8vj952jn_.bkp recid=8 stamp=817918498
Deleted 1 objects
--To get a list of all datafiles of our database, use the following command:
--可见我们数据库所有的数据文件列表如下:
RMAN> report schema;
Report of database schema
List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    490      SYSTEM               ***     /home/oracle/oracle/product/10.2.0/oradata/orcl/system01.dbf
2    295      UNDOTBS1             ***     /home/oracle/oracle/product/10.2.0/oradata/orcl/undotbs01.dbf
3    290      SYSAUX               ***     /home/oracle/oracle/product/10.2.0/oradata/orcl/sysaux01.dbf
4    1003     USERS                ***     /home/oracle/oracle/product/10.2.0/oradata/orcl/users01.dbf
5    20       TBS_ORCL_DATA        ***     /home/oracle/oracle/product/10.2.0/db_1/dbs/TBS_ORCL_DATA01.DBF
6    20       TBS_ORCL_IDX         ***     /home/oracle/oracle/product/10.2.0/db_1/dbs/TBS_ORCL_IDX01.DBF
7    490      TBS_LUBINSU_DATA     ***     /home/oracle/oracle/product/10.2.0/oradata/orcl/tbs_data.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    20       TEMP                 32767       /home/oracle/oracle/product/10.2.0/oradata/orcl/temp01.dbf

--现在来做一个完整的备份,并删除废弃的备份:
RMAN> run{
2> backup database;
3> delete noprompt obsolete;
4> backup archivelog all;
5> }
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_TAG20130612T155439_8vjbb07f_.bkp tag=TAG20130612T155439 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:08:07
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_TAG20130612T155439_8vjbs9gx_.bkp tag=TAG20130612T155439 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:05

Finished backup at 12-JUN-13


RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
using channel ORA_DISK_1
Deleting the following obsolete backups and copies:
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set           2      12-JUN-13         
  Backup Piece       2      12-JUN-13          /home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_nnndf_TAG20130612T125054_8vhzkgdt_.bkp
Backup Set           3      12-JUN-13         
  Backup Piece       3      12-JUN-13          /home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_ncsnf_TAG20130612T125054_8vhzxlf2_.bkp
Backup Set           4      12-JUN-13         
  Backup Piece       4      12-JUN-13          /home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_annnn_TAG20130612T144846_8vj6glv9_.bkp
Backup Set           5      12-JUN-13         
  Backup Piece       5      12-JUN-13          /home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_annnn_TAG20130612T145421_8vj6ryn7_.bkp
Backup Set           6      12-JUN-13         
  Backup Piece       6      12-JUN-13          /home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_annnn_TAG20130612T145619_8vj6wnnq_.bkp
Backup Set           9      12-JUN-13         
  Backup Piece       9      12-JUN-13          /home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_nnndf_TAG20130612T153504_8vj958bb_.bkp
deleted backup piece
backup piece handle=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_nnndf_TAG20130612T125054_8vhzkgdt_.bkp recid=2 stamp=817908654
deleted backup piece
backup piece handle=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_ncsnf_TAG20130612T125054_8vhzxlf2_.bkp recid=3 stamp=817909042
deleted backup piece
backup piece handle=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_annnn_TAG20130612T144846_8vj6glv9_.bkp recid=4 stamp=817915730
deleted backup piece
backup piece handle=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_annnn_TAG20130612T145421_8vj6ryn7_.bkp recid=5 stamp=817916062
deleted backup piece
backup piece handle=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_annnn_TAG20130612T145619_8vj6wnnq_.bkp recid=6 stamp=817916180
deleted backup piece
backup piece handle=/home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_nnndf_TAG20130612T153504_8vj958bb_.bkp recid=9 stamp=817918504
Deleted 6 objects

Starting backup at 12-JUN-13
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=186 recid=96 stamp=817920187
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_annnn_TAG20130612T160307_8vjbsw9s_.bkp tag=TAG20130612T160307 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 12-JUN-13

--查看下,所有备份的内容,1.数据文件  2.控制文件  3.SPFILE  4.日志文件:
RMAN> list backup;

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

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
10      Full    2.30G      DISK        00:08:05     12-JUN-13      
        BP Key: 10   Status: AVAILABLE  Compressed: NO  Tag: TAG20130612T155439
        Piece Name: /home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_nnndf_TAG20130612T155439_8vjbb07f_.bkp
  List of Datafiles in backup set 10
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 13229464117948 12-JUN-13 /home/oracle/oracle/product/10.2.0/oradata/orcl/system01.dbf
  2       Full 13229464117948 12-JUN-13 /home/oracle/oracle/product/10.2.0/oradata/orcl/undotbs01.dbf
  3       Full 13229464117948 12-JUN-13 /home/oracle/oracle/product/10.2.0/oradata/orcl/sysaux01.dbf
  4       Full 13229464117948 12-JUN-13 /home/oracle/oracle/product/10.2.0/oradata/orcl/users01.dbf
  5       Full 13229464117948 12-JUN-13 /home/oracle/oracle/product/10.2.0/db_1/dbs/TBS_ORCL_DATA01.DBF
  6       Full 13229464117948 12-JUN-13 /home/oracle/oracle/product/10.2.0/db_1/dbs/TBS_ORCL_IDX01.DBF
  7       Full 13229464117948 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
------- ---- -- ---------- ----------- ------------ ---------------
11      Full    6.89M      DISK        00:00:03     12-JUN-13      
        BP Key: 11   Status: AVAILABLE  Compressed: NO  Tag: TAG20130612T155439
        Piece Name: /home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_ncsnf_TAG20130612T155439_8vjbs9gx_.bkp
  Control File Included: Ckp SCN: 13229464118349   Ckp time: 12-JUN-13
  SPFILE Included: Modification time: 12-JUN-13

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
12      4.01M      DISK        00:00:01     12-JUN-13      
        BP Key: 12   Status: AVAILABLE  Compressed: NO  Tag: TAG20130612T160307
        Piece Name: /home/oracle/oracle/product/10.2.0/flash_recovery_area/ORCL/backupset/2013_06_12/o1_mf_annnn_TAG20130612T160307_8vjbsw9s_.bkp

  List of Archived Logs in backup set 12
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    186     13229464115033 12-JUN-13 13229464118372 12-JUN-13

最后

以上就是壮观冬日为你收集整理的RMAN管理备份的全部内容,希望文章能够帮你解决RMAN管理备份所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(53)

评论列表共有 0 条评论

立即
投稿
返回
顶部