|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
×
是否确定要删除以上对象 (输入 YES 或 NO)? yes
已删除备份段
备份段 handle=D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\ROME\BACKUPSET
\2007_0 1_30\O1_MF_NNNDF_TAG20070130T161822_2VXZTH2G_.BKP recid=110
stamp=613239503 1 对象已删除
多个通道执行交叉验证和删除备份
在执行CROSSCHECK和DELETE之前可以配置或者手工分配多个通道,RMAN将搜索和删除在不同类型的设备上执行的备份文件。适用以下情况:
1、 用一个命令交叉验证或者删除在不同设备上备份的文件(例如磁带和磁盘上都有备份文件)。
2、 交叉验证或者删除工作在RAC环境下备份到每个节点上的备份文件。
RMAN如何在多通道下执行CROSSCHECK和DELETE:
举个例子,我们的备份文件全部在磁盘上,磁带上没有备份文件,而我们给出了如下备份脚本,那么RMAN将会执行前边的两个磁盘CROSSCHECK而不会执行第三条磁带CROSSCHECK.
RUN
...{ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE DISK CONNECT 'SYS/oracle@
node1';
AlLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE DISK CONNECT 'SYS/oracle@node2';
ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE sbt;
CROSSCHECK BACKUP OF DATABASE;
}
注意:如果RMAN标记为EXPIRED状态的备份文件被修复后,我们执行DELETE EXPIRED BACKUP;命令后将会收到如下提示:
RMAN> delete expired backup;
使用通道 ORA_DISK_1
备份段列表
BP 关键字 BS 关键字 Pc# Cp# 状态 设备类型段名称
------- ------- --- --- ----------- ----------- ----------
112 117 1 1 EXPIRED DISK D:\ORACLE\PRODUCT\10.2.0\
FLASH_RECOVERY_AREA\ROME\BACKUPSET\2007_02_05\O1_MF_NNNDF_TAG20070205T113315_
2WF9CYG5_.BKP
是否确定要删除以上对象 (输入 YES 或 NO)? yes
RMAN-06207: 警告: 由于状态不匹配, 所以不能删除 1 对象 (对于 DISK 通道)。
RMAN-06208: 请用 CROSSCHECK 命令修正状态
RMAN-06210: 不匹配对象的列表
RMAN-06211: ==========================
RMAN-06212: 对象类型 文件名/句柄
RMAN-06213: --------------- ------------------------------------------------
RMAN-06214: Backup Piece D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\ROME
\BACKUPSET\2007_02_05\O1_MF_NNNDF_TAG20070205T113315_2WF9CYG5_.BKP
一个命令交叉验证磁盘和磁带备份的例子:
CONFIGURE DEVICE TYPE sbt PARALLELISM 1;
CONFIGURE DEFAULT DEVICE TYPE to sbt;
CROSSCHECK BACKUP OF DATABASE;
示例输出文件如下:
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: sid=12 devtype=SBT_TAPE
channel ORA_SBT_TAPE_1: WARNING: Oracle Test Disk API
using channel ORA_DISK_1
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/oracle/dbs/16c5esv4_1_1 recid=36 stamp=408384484
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/oracle/dbs/c-674966176-20000915-01 recid=37 stamp=
408384496
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=12c5erb2_1_1 recid=32 stamp=408382820
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=13c5erba_1_1 recid=33 stamp=408382829
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=14c5erce_1_1 recid=34 stamp=408382863
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=c-674966176-20000915-00 recid=35 stamp=408382869
如果没有配置磁带备份设备,也可以手工执行分配通道:
ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE sbt;
CROSSCHECK BACKUP OF DATABASE;
RAC环境下交叉验证的例子:
CONFIGURE DEVICE TYPE DISK PARALLELISM 2;
CONFIGURE CHANNEL 1 DEVICE TYPE DISK CONNECT 'SYS/oracle@node_1';
CONFIGURE CHANNEL 2 DEVICE TYPE DISK CONNECT 'SYS/oracle@node_2';
CROSSCHECK BACKUP;
一个删除磁带和磁盘备份的例子:
CONFIGURE DEVICE TYPE sbt PARALLELISM 1;
CONFIGURE DEFAULT DEVICE TYPE TO sbt;
DELETE BACKUPSET;
示例输出文件如下:
using channel ORA_SBT_TAPE_1
using channel ORA_DISK_1
List of Backup Pieces
BP Key BS Key Pc# Cp# Status Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
388 387 1 1 AVAILABLE SBT_TAPE 12c5erb2_1_1
397 396 1 1 UNAVAILABLE SBT_TAPE 13c5erba_1_1
424 423 1 1 AVAILABLE SBT_TAPE 14c5erce_1_1
428 427 1 1 AVAILABLE SBT_TAPE c-674966176-20000915-00
433 432 1 1 AVAILABLE DISK /oracle/dbs/16c5esv4_1_1
437 436 1 1 AVAILABLE DISK /oracle/dbs/c-674966176-
20000915-01
Do you really want to delete the above objects (enter YES or NO)? y
deleted backup piece
backup piece handle=/oracle/dbs/16c5esv4_1_1 recid=36 stamp=408384484
deleted backup piece
backup piece handle=/oracle/dbs/c-674966176-20000915-01 recid=37
stamp=408384496
deleted backup piece
backup piece handle=12c5erb2_1_1 recid=32 stamp=408382820
deleted backup piece
backup piece handle=13c5erba_1_1 recid=33 stamp=408382829
deleted backup piece
backup piece handle=14c5erce_1_1 recid=34 stamp=408382863
deleted backup piece
backup piece handle=c-674966176-20000915-00 recid=35 stamp=408382869
释放多个通道,如下命令可以释放所有通道:
RELEASE CHANNEL;
使用RMAN删除数据库
RMAN连接到处于MOUNT状态的TARGET数据库,就可以删除TARGET数据库,而不需要连接恢复目录;如果RMAN同时连接到恢复目录,并且指定INCLUDE COPIES AND BACKUPS参数,RMAN将删除恢复目录中的备份记录。
生成备份文件目录:
RMAN>catalog start with 'd:\oracle\product\10.2.0\flash_recovery_area';
RMAN> DELETE BACKUPSET; # deletes all backups
RMAN> DELETE COPY; # delete all image copies (including archived logs)
RMAN> DROP DATABASE; # delete all database files and unregister the database
修改备份记录的状态:
CHANGE DATAFILECOPY '/tmp/control01.ctl' UNAVAILABLE;
CHANGE COPY OF ARCHIVELOG SEQUENCE BETWEEN 1000 AND 1012 UNAVAILABLE;
CHANGE BACKUPSET 12 UNAVAILABLE;
CHANGE BACKUP OF SPFILE TAG "TAG20020208T154556" UNAVAILABLE;
CHANGE DATAFILECOPY '/tmp/system01.dbf' AVAILABLE;
CHANGE BACKUPSET 12 AVAILABLE;
CHANGE BACKUP OF SPFILE TAG "TAG20020208T154556" AVAILABLE;
修改备份记录状态使得保留冗余策略外的备份不被删除。
我们可以在执行备份的时候直接指定BACKUP……KEEP来把备份文件标记为长期备份。有一点需要注意,如果使用恢复目录来存储备份记录的话,我们应该执行BACKUP……KEEP FOREVER.
我们也可以用CHANGE命令来把一个备份标记为长期备份:
CHANGE BACKUPSET 231 KEEP;
CHANGE BACKUPSET 231 NOKEEP;
CHANGE DATAFILECOPY '/tmp/system01.dbf' KEEP UNTIL 'SYSDATE+180';
维护存储库目录
如果我们的备份文件中一部分是其他RMAN程序产生的,而我们的RMAN存储库中没有这些备份的记录,我们可以用CATALOG命令来维护我们的备份记录。
以下情况需要维护存储库的备份记录:
1、我们利用其他命令(如系统命令等)产生了备份文件,想把这些文件加入RMAN存储库。
2、利用备份控制文件执行恢复并且在恢复过程中改变了归档日志的路径或者格式,存储库中没有恢复需要的归档日志文件,我们必须把这些日志加入到RAMN存储库。
如果我们执行数据文件拷贝备份,没有LEVEL0备份而我们又想直接可以执行LEVEL1的增量备份,我们可以通过增加RMAN存储库的目录来实现。虽然不建议这么做,但是的确可以。
数据库版本升级,开始使用RMAN,我们可以把以前的热备份文件等加入到RMAN存储库。
给几个例子,维护用户备份文件到存储库目录:
SQL> ALTER TABLESPACE users BEGIN BACKUP;
% cp $ORACLE_HOME/oradata/trgt/users01.dbf /tmp/users01.dbf;
SQL> ALTER TABLESPACE users END BACKUP;
RMAN> CATALOG DATAFILECOPY '/tmp/users01.dbf';
CATALOG BACKUPPIECE '/disk2/09dtq55d_1_2', '/disk2/0bdtqdou_1_1';
维护备份集到存储库目录:
CATALOG BACKUPPIECE '/disk2/09dtq55d_1_2', '/disk2/0bdtqdou_1_1';
备份集文件加入到存储库目录后可以在如下系统视图查找:
V$BACKUP_PIECE, V$BACKUP_SET, V$BACKUP_DATAFILE, V$BACKUP_REDOLOG, and
V$BACKUP_SPFILE.
维护所有备份文件到存储库目录:
RMAN> CATALOG RECOVERY AREA; # catalog all files in the recovery area
RMAN> CATALOG START WITH '+disk'; # catalog all files from an ASM disk group
RMAN> CATALOG START WITH '/fs1/datafiles/'; # catalog all files in directory
从存储库目录删除记录:
CHANGE ARCHIVELOG ... UNCATALOG.
CHANGE CONTROLFILECOPY '/tmp/control01.ctl' UNCATALOG;
CHANGE DATAFILECOPY '/tmp/system01.dbf' UNCATALOG; |
|