RMAN常用命令
一、默认配置 show命令
1.查看当前配置参数
RMAN> show all;
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name TEST are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE RMAN OUTPUT TO KEEP FOR 7 DAYS; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/12.2.0/db_1/dbs/snapcf_uums1.f'; # default
二、列出备份信息 -LIST 命令
1. 列出数据库中所有备份信息
RMAN> list backup;
2. 列出所有控制文件的备份信息
RMAN> list backup of controlfile;
3. 列出指定数据文件的备份信息
RMAN> list backup of datafile ‘/oradata/backup_users.dbf’;
或者
RMAN> list backup of datafile 3;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3 Incr 0 3.61G SBT_TAPE 00:00:37 05-AUG-19
BP Key: 3 Status: UNAVAILABLE Compressed: NO Tag: TAG20190805T170744
Handle: 951_UUMS_1au8f7j0_1_1 Media: V_301_2230
List of Datafiles in backup set 3
File LV Type Ckp SCN Ckp Time Abs Fuz SCN Sparse Name
---- -- ---- ---------- --------- ----------- ------ ----
3 0 Incr 4960151 05-AUG-19 NO +DATA/TEST/DATAFILE/undotbs1.263.1013957135
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
18 Incr 0 3.63G SBT_TAPE 00:00:34 06-AUG-19
BP Key: 18 Status: UNAVAILABLE Compressed: NO Tag: TAG20190806T000059
Handle: 957_UUMS_1mu8fvpr_1_1 Media: V_304_2245
List of Datafiles in backup set 18
File LV Type Ckp SCN Ckp Time Abs Fuz SCN Sparse Name
---- -- ---- ---------- --------- ----------- ------ ----
3 0 Incr 5023301 06-AUG-19 NO +DATA/TEST/DATAFILE/undotbs1.263.1013957135
注: DATAFILE 序号可以通过动态性能视图 V$DATAFILE 或者数据字典 DBA_DATA_FILES 中查询。
4. 列出某个设备上所有信息
RMAN> list device type disk backup;
5. 列出所有无效备份
RMAN> list expired backup;
三、删除命令 -DELETE 命令
1. 删除过期备份
RMAN> delete obsolete;
2. 删除无效备份
删除无效备份需要首先执行 CROSSCHECK 命令核对备份集,如果发现备份无效(比如备份应对的数据文件损坏或丢失), RMAN 会将该备份集标记为 EXPIRED 状态
RMAN> delete expired backup;
3. 删除无效副本
RMAN> delete expired copy;
4. 删除指定备份集
RMAN> delete backupset 3;
5. 删除所有备份集
RMAN> delete backup;
6. 删除所有影像副本
RMAN> delete copy;
7. 备份后删除输入对象
RMAN> delete archivelog all delete input;
四、报表显示 -REPORT 命令
1. 查看所有需要备份的文件
RMAN> report need backup;
2. 查看指定表空间是否需要备份
RMAN> report need backup tablespace users;
3. 查看过期备份
RMAN> report obsolete;
五、执行检查 -CROSSCHECK 命令
CROSSCHECK 命令用来检查备份或归档物理文件的状态,如果物理文件真的存在,并且控制文件(或恢复目录)中有匹配记录,则标记该对象的状态为 AVAILABLE (有效),如果文件已经不存在了,则标记该对象的状态为 EXPIRED (无效)
1. 检查所有归档文件
RMAN> crosscheck archivelog all;
2. 检查所有备份集
RMAN> crosscheck backup;