rman下备份的一些小实验

一、在非归档模式下,进行数据库全备的一些测试;

1.首先进入rman界面,在noachivelog模式下,将数据库进行全备份。

2.在操作系统上将备份的数据库删除,进入rman模式下,仍可以查到备份过的数据库。

3.通过acrosscheck backup;命令检查所有备份集,系统就说报告一个已经expired的备份,也就是之前全备份之后在操作系统上被删除的备份机。

4.通过delete expired backup删除所有过期的副本。

实验问题:可以通过list backup可以列出所有的备份信息。

但是运行list backup of database;无法显示出全库备份的内容。

SQL> select * from v$version;

BANNER

----------------------------------------------------------------

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod

PL/SQL Release 10.2.0.1.0 - Production

CORE    10.2.0.1.0      Production

TNS for Linux: Version 10.2.0.1.0 - Production

NLSRTL Version 10.2.0.1.0 - Production

[cs@localhost ~]$ rman target /

 Recovery Manager: Release 10.2.0.1.0 - Production on Tue Jul 3 11:27:20 2012
 
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
 
connected to target database: ORCL (DBID=1306062595)
 
RMAN> backup database format '/home/cs/bak_%U';
 
Starting backup at 03-JUL-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=136 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 07/03/2012 11:39:04
ORA-19602: cannot backup or copy active file in NOARCHIVELOG mode
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 03-JUL-12
channel ORA_DISK_1: finished piece 1 at 03-JUL-12
piece handle=/home/cs/bak_02nf5jeo_1_1 tag=TAG20120703T113903 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:04
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
 
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 07/03/2012 11:39:04
ORA-19602: cannot backup or copy active file in NOARCHIVELOG mode
 
 
RMAN> list backup;
 
 List of Backup Sets
===================
 
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1       Full    6.80M      DISK        00:00:03     03-JUL-12      
        BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20120703T113903
        Piece Name: /home/cs/bak_02nf5jeo_1_1
  Control File Included: Ckp SCN: 770077       Ckp time: 03-JUL-12
  SPFILE Included: Modification time: 03-JUL-12
 
 
RMAN> crosscheck backup;
 
using channel ORA_DISK_1
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/home/cs/bak_02nf5jeo_1_1 recid=1 stamp=787664345
Crosschecked 1 objects
 
RMAN> list backup;
 
 List of Backup Sets
===================
 
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1       Full    6.80M      DISK        00:00:03     03-JUL-12      
        BP Key: 1   Status: EXPIRED  Compressed: NO  Tag: TAG20120703T113903
        Piece Name: /home/cs/bak_02nf5jeo_1_1
  Control File Included: Ckp SCN: 770077       Ckp time: 03-JUL-12
  SPFILE Included: Modification time: 03-JUL-12
 
RMAN> delete expired 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   EXPIRED     DISK        /home/cs/bak_02nf5jeo_1_1
 
Do you really want to delete the above objects (enter YES or NO)? y
deleted backup piece
backup piece handle=/home/cs/bak_02nf5jeo_1_1 recid=1 stamp=787664345
Deleted 1 EXPIRED objects
 
 
RMAN> list backup;
 
 
二,在归档模式下,进行的数据库全被的一些测试
果然在归档模式下,list的信息就显示的很全。
归档的日志文件是默认保存在flash_recovery_area。
Oracle 10g 有一项新功能称为:自动的基于磁盘的备份与恢复( Automatic Disk-Based Backup and Recovery )。实现该功能的基础为本文要讲述的闪回恢复区( Flash Recovery Area )。闪回恢复区是 Oracle 10g 中的新事物。简单的说,闪回恢复区是一块用以存储恢复相关的文件的存储空间。 允许用户集中存储所有恢复相关的文件。
 
闪回恢复区可以放在如下几种存储形式上:
 
目录
一个文件系统
自动存储管理(ASM)磁盘组
在 RAC 环境中,这个该位置必须为 集群文件系统 (cluster file system) 或是 ASM 磁盘组亦或是通过 NFS 控制的文件共享目录,还要注意的是,所有实例的位置和操作系统的磁盘限额 (disk quota) 必须一致。
 
如下几种文件可以放到闪回恢复区中:
 
控制文件
归档的日志文件(注:Oracle 手册上所说的在设定flash recovery area之后,LOG_ARCHIVE_DEST_10的值将自动设定为flash recovery area的位置,这个变化在笔者测试过程中观察不到)
闪回日志
控制文件和 SPFILE 自动备份
RMAN 备份集
数据文件拷贝
RMAN> backup database format '/home/cs/bak_%U';
 
Starting backup at 03-JUL-12
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=/home/cs/oracle/oradata/ORCL/system01.dbf
input datafile fno=00003 name=/home/cs/oracle/oradata/ORCL/sysaux01.dbf
input datafile fno=00005 name=/home/cs/oracle/oradata/ORCL/example01.dbf
input datafile fno=00002 name=/home/cs/oracle/oradata/ORCL/undotbs01.dbf
input datafile fno=00004 name=/home/cs/oracle/oradata/ORCL/users01.dbf
channel ORA_DISK_1: starting piece 1 at 03-JUL-12
channel ORA_DISK_1: finished piece 1 at 03-JUL-12
piece handle=/home/cs/bak_03nf5uqc_1_1 tag=TAG20120703T145259 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:04:20
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 03-JUL-12
channel ORA_DISK_1: finished piece 1 at 03-JUL-12
piece handle=/home/cs/bak_04nf5v2g_1_1 tag=TAG20120703T145259 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:08
Finished backup at 03-JUL-12
 
 
RMAN> list backup of database;
 
List of Backup Sets
===================
 
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2       Full    609.70M    DISK        00:04:18     03-JUL-12      
        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20120703T145259
        Piece Name: /home/cs/bak_03nf5uqc_1_1
  List of Datafiles in backup set 2
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 781840     03-JUL-12 /home/cs/oracle/oradata/ORCL/system01.dbf
  2       Full 781840     03-JUL-12 /home/cs/oracle/oradata/ORCL/undotbs01.dbf
  3       Full 781840     03-JUL-12 /home/cs/oracle/oradata/ORCL/sysaux01.dbf
  4       Full 781840     03-JUL-12 /home/cs/oracle/oradata/ORCL/users01.dbf
  5       Full 781840     03-JUL-12 /home/cs/oracle/oradata/ORCL/example01.dbf
 
 
RMAN> list backup;
 
List of Backup Sets
===================
 
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2       Full    609.70M    DISK        00:04:18     03-JUL-12      
        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20120703T145259
        Piece Name: /home/cs/bak_03nf5uqc_1_1
  List of Datafiles in backup set 2
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 781840     03-JUL-12 /home/cs/oracle/oradata/ORCL/system01.dbf
  2       Full 781840     03-JUL-12 /home/cs/oracle/oradata/ORCL/undotbs01.dbf
  3       Full 781840     03-JUL-12 /home/cs/oracle/oradata/ORCL/sysaux01.dbf
  4       Full 781840     03-JUL-12 /home/cs/oracle/oradata/ORCL/users01.dbf
  5       Full 781840     03-JUL-12 /home/cs/oracle/oradata/ORCL/example01.dbf
 
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3       Full    6.80M      DISK        00:00:04     03-JUL-12      
        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20120703T145259
        Piece Name: /home/cs/bak_04nf5v2g_1_1
  Control File Included: Ckp SCN: 781919       Ckp time: 03-JUL-12
  SPFILE Included: Modification time: 03-JUL-12
 
RMAN> list backup of database;
 
List of Backup Sets
===================
 
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2       Full    609.70M    DISK        00:04:18     03-JUL-12      
        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20120703T145259
        Piece Name: /home/cs/bak_03nf5uqc_1_1
  List of Datafiles in backup set 2
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 781840     03-JUL-12 /home/cs/oracle/oradata/ORCL/system01.dbf
  2       Full 781840     03-JUL-12 /home/cs/oracle/oradata/ORCL/undotbs01.dbf
  3       Full 781840     03-JUL-12 /home/cs/oracle/oradata/ORCL/sysaux01.dbf
  4       Full 781840     03-JUL-12 /home/cs/oracle/oradata/ORCL/users01.dbf
  5       Full 781840     03-JUL-12 /home/cs/oracle/oradata/ORCL/example01.dbf
 
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
4       Full    1.89M      DISK        00:00:00     03-JUL-12      
        BP Key: 4   Status: AVAILABLE  Compressed: NO  Tag: TAG20120703T150346
        Piece Name: /home/cs/oracle/flash_recovery_area/ORCL/backupset/2012_07_03/o1_mf_nnndf_TAG20120703T150346_7z56bl6v_.bkp
  List of Datafiles in backup set 4
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  4       Full 782326     03-JUL-12 /home/cs/oracle/oradata/ORCL/users01.dbf
 
RMAN> delete backupset 4;
 
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/cs/oracle/flash_recovery_area/ORCL/backupset/2012_07_03/o1_mf_nnndf_TAG20120703T150346_7z56bl6v_.bkp
 
Do you really want to delete the above objects (enter YES or NO)? y
deleted backup piece
backup piece handle=/home/cs/oracle/flash_recovery_area/ORCL/backupset/2012_07_03/o1_mf_nnndf_TAG20120703T150346_7z56bl6v_.bkp recid=4 stamp=787676626
Deleted 1 objects
 
三、recovery catalog实验
1.先建立一个表空间rmantbs
2.创建一个schema 给予connect,resource,recovery_catalog_owner权限
3.进入rman catalog rmanct/rmanct;
4.在rman中创建catalog;create catalog tablespace rmantbs;
5.连接到catalog. rman taget / catalog rmanct/rmanct
 注册数据库 register database;
 取消注册数据库 unregister database;
 
SQL> create tablespace rmantbs datafile '/home/cs/rmantbs01.dbf' size 50m;
 
Tablespace created.
 
SQL> grant connect,resource,recovery_catalog_owner to rmanct identified by rmanct;
 
Grant succeeded.
 
 
[cs@localhost ~]$ rman catalog rmanct/rmanct
 
Recovery Manager: Release 10.2.0.1.0 - Production on Tue Jul 3 15:48:26 2012
 
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
 
connected to recovery catalog database
 
RMAN> create catalog tablespace rmantbs;
 
recovery catalog created
 
[cs@localhost ~]$ rman target / catalog rmanct/rmanct
 
Recovery Manager: Release 10.2.0.1.0 - Production on Tue Jul 3 15:55:36 2012
 
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
 
connected to target database: ORCL (DBID=1306062595)
connected to recovery catalog database
 
RMAN> register database;
 
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete

本文出自 “无双城” 博客,谢绝转载!

你可能感兴趣的:(数据库,linux,version,的)