关于RMAN目录管理和维护的相关知识:
LIST,
REPORT,
CROSSCHECK,
VALIDATE,
CHANGE.
1. LIST LIST命令将使RMAN读取目录或控制文件来显示 备份的有关细节,主要是列出已有的备份的相关信息。可以添加过滤条件来查看特定的备份集、表空间、数据文件、控制文件、归档日志文件等。 1). 列出 数据库形态incranation信息 RMAN> list incarnation; List of Database Incarnations DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time ------- ------- -------- ---------------- --- ---------- ---------- 1 8 RGBU 1248130447 PARENT 1 30-JUN-05 1 2 RGBU 1248130447 CURRENT 446075 01-DEC-07 2). 列出所有备份信息 RMAN> list backup; 3). 列出所有备份集的信息 RMAN> list backupset; 4). 列出所有拷贝备份的信息 RMAN> list copy; 5). 过滤条件,列出数据库备份、特定表空间、特定数据文件、控制文件 RMAN> list backup of database; RMAN> list backup of tablespace 'SYSTEM','USERS'; RMAN> list backup of datafile 1,2,3; RMAN> list backup of controlfile; 6). 列出所有归档日志备份的信息 RMAN>list backup of archivelog all; 添加条件:时间,SCN, 日志序列号 (From ..., Until ...) RMAN> list backup of archivelog like '%ar_%'; RMAN> list backup of archivelog from time 'SYSDATE - 14'; RMAN> list backup of archivelog until time 'SYSDATE - 7'; RMAN> list backup of archivelog from scn 503284 until scn 603432; RMAN> list backup of archivelog from logseq 1 until logseq 10; 7). 根据备份完成时间条件列出备份信息 RMAN> list backup completed before 'sysdate'; RMAN> list backup completed after 'sysdate -1'; RMAN> list backup completed between 'sysdate-7' and 'sysdate'; 8). 列出可用于恢复的备份 RMAN> list backup recoverable; RMAN> list backup recoverable until time 'sysdate - 10'; 9). 其它的过滤条件 RMAN> list backup tag= 'DB_INC0'; RMAN> list backup device type disk; RMAN> list backup of tablespace 'USERS' completed after 'LAST_DAY(ADD_MONTHS(SYSDATE,-1))+1' TAG = DB_INC0 device type disk; 2. REPORT REPORT主要是列出未来需要的信息: need backup, unrecoverable, obsolete, schema RMAN> report schema; // 显示目标数据库的数据库物理模式 RMAN> report obsolete; // 说明不再需要的备份可以被删除,它是根据默认的retention policy来判断的 RMAN> report obsolete redundancy 2; RMAN> report unrecoverable; // 说明需要备份的数据文件中的数据块发生了不可恢复的操作。 RMAN> report need backup; // 说明要达到完整备份还需要哪些条件(日期、增量级别、冗余数)的新备份 RMAN> report need backup days 2 database; RMAN> report need backup incremental 3 database; RMAN> report need backup redundancy 2; 3. 交叉检查crosscheck 了解备份信息的关键是确定当前备份情况是否已经处于有序状态,使用list, report只能得知RMAN对当前备份的了解程度。如果在操作系统下删除了备份片,那控制文件和恢复目录都不知道这个操作。因此经常进行交叉检查以确定目录包含了有关备份片的正确信息。 RMAN> allocate channel for maintenance device type disk; RMAN> crosscheck backup; RMAN> crosscheck backup of datafile 1; RMAN> crosscheck backup completed between 'sysdate -7' and 'sysdate'; RMAN> crosscheck backup tag DB_INC0; RMAN> crosscheck backup of archivelog all; RMAN> release channel; 4). 验证备份 RMAN提供了validate工具来模拟restore时的还原能力。这样可以模拟restore过程来保证备份的有效性。 4.1) 还原验证 RMAN> run { allocate channel c1 type disk; restore database validate; restore archivelog all validate; } 4.2)验证备份集 RMAN> run { allocate channel c1 type disk; validate backupset 193,265; } 5). 清除冗余的备份 5.1). 查找孤立的备份 RMAN> report obsolete redundancy 2; RMAN> report obsolete until time 'sysdate - 7'; RMAN> list backup completed before 'sysdate -7'; 5.2). 删除孤立的备份 RMAN> report obsolete redundancy 2; RMAN> allocate channel for delete type disk; RMAN> change backupset 193,221,372,575,811 delete; RMAN> release channel; RMAN> delete obsolete; 5.3). 删除过期的备份 RMAN> list expired backup; RMAN> delete expired backup; |