1.crosscheck命令使用
1、核对所有备份集 RMAN> crosscheck backup;
2、核对所有数据文件的备份集 RMAN> crosscheck backup of database;
3、核对特定表空间的备份集 RMAN> crosscheck backup of tablespace users;
4、核对特定数据文件的备份集 RMAN> crosscheck backup of datafile 4;
5、核对控制文件的备份集 RMAN> crosscheck backup of controlfile;
6、核对SPFILE的备份集 RMAN> crosscheck backup of spfile;
7、核对归档日志的备份集 RMAN> crosscheck backup of archivelog sequence 3;
8、核对所有映像副本 RMAN> crosscheck copy;
9、核对所有数据文件的映像副本 RMAN> crosscheck copy of database;
10、核对特定表空间的映像副本 RMAN> crosscheck copy of tablespace users;
11、核对特定数据文件的映像副本 RMAN> crosscheck copy of datafile 6;
12、核对归档日志的映像副本 RMAN> crosscheck copy of archivelog sequence 4;
13、核对控制文件的映像副本 RMAN> crosscheck copy of controlfile;
14. 核对所有归档日志 RMAN> crosscheck archivelog all; --- 清理delete expired archivelog all ;
2.修改控制文件记录时间
控制文件保留时间和永久保留备份冲突
alter system set control_file_record_keep_time=30;
-----------------------------------
RMAN> backup keep forever database;
------------------------------------
3.rman list backup/list copy命令
list backup of datafile 1;
list backupset 8;
list backupset tag 'TAG20180419T213849
list backup of tablespace system;
list backup by file;列出每个备份的备份集和备份片
list backup summary;
list backup of database;
list backup;
list copye
list copy of datafile 1;
list copy of database;
list copy of tablespace users;
list copy of archivelog all;
list copy of controlfile;
LIST RESTORE POINT ALL; 列出RMAN 资料档案库已知的所有还原
LIST RESTORE POINT 'rsname';显示特定的还原点
list archivelog all; 列出所有归档日志备份
list incarnation of database;列出数据库化身
list expired backup of archivelog all summary;
list recoverable backup of database;列出可用于恢复的备份集
list expired backup;显示过期备份
list backup of controlfile;
list backup of spfile;
list db_unique_name all;
4.report 命令
report schema;查看数据库结构
RMAN> report need backup; 查看需要备份数据文件
report need backup incremental=3;
report need backup days 3; 查看3天未备份的文件
RMAN> report need backup redundancy 3; 查询没有3次备份集的数据文件
report need backup recovery windows of 2 days;
report obsolete 查询超过备份策略的文件
report unrecoverable;
delete obsolete 删除超过备份策略的文件
delete backupset;
delete expired backupset;删除不存的备份集的rman信息
delete expired:不删除任何文件,只更新RMAN的存储库。
delete noprompt backupset;不提示直接删除,一般用于脚本中
5.restore …preview命令
检查恢复所需要的备份
restore database preview;
restore tablespace users preview;
restore datafile 1 preview;
restore archivelog all preview;
restore controlfile preview;
6.restore ….validate 命令
检查恢复时所需要的备份集完整性
restore ….validate 和validate的区别在于validate只检查文件头,而restore ….validate则逐块检查备份
restore database validate check logical;
restore datafile 1 validate check logical;
restore archivelog all validate check logical;
restore tablespace users validate check logical;
restore controlfile validate check logical;
7.validate 命令
validate命令检查之后,结果将填充v$database_block_corruption 视图
validate database include current controlfile plus archivelog;
validate datafile 1;
validate tablespace users;
validate corruption list;
validate backupset 50;
validate recovery area;
8.chang命令
改变特定备份集为不可用
change backup of database tag='gold' unavailable;
change backup of database like '%gold%' unavailable;
change backupset 33 unavailable;
change backupset 33 available;
change archivelog '/opt/oracle/fast_recover_area/archivelog/archo_o1.arc' unavailable;
change archivelog all backed up t times to device type disk unavailable;
change backup of database device type disk unavailable;
---------------------------------
删除指定备份集
RMAN> change backupset 70 delete;
change backuppiece 1304 delete;
删除指定范围归档日志
change archivelog until logseq=533 delete;
删除目录中的备份片
change backuppiece '/opt/oracle/back/mydb_bak.bak' uncatalog;
9.delete命令
delete expired;
delete obsolete;
delete noprompt obsolete;
delete nopromt obsolete force;没有使用fra的情况下需要强制删除
delete noprompt archivelog until time 'sysdate-7';
10.手工注册备份集和归档日志
2.手工注册备份集和归档日志
1.移走备份集
2.删除备份集
3.注册备份集
3.1注册单个备份片
mv o1_mf_s_1018364319_gq6o8zw3_.bkp /opt/oracle/
crosscheck backup;
delete expired backup;
mv /opt/oracle/o1_mf_s_1018364319_gq6o8zw3_.bkp ./
RMAN> catalog backuppiece '/opt/oracle/fast_recovery_area/ORCLCDB/autobackup/2019_09_07/o1_mf_s_1018364319_
gq6o8zw3_.bkp';
3.2注册整个目录
[oracle@instance-ej1hspdt ORCLCDB]$ mkdir /opt/oracle/back
[oracle@instance-ej1hspdt ORCLCDB]$ mv autobackup/* /opt/oracle/back/
RMAN> crosscheck backup;
RMAN> delete expired backup;
[oracle@instance-ej1hspdt ORCLCDB]$ mv /opt/oracle/back/* autobackup/
RMAN> catalog start with '/opt/oracle/fast_recovery_area/ORCLCDB/autobackup';
-----------------------------------------------------
mv o1_mf_1_11_gq2b9n9f_.arc /opt/oracle/back/
RMAN> crosscheck archivelog all;
delete expired archivelog all;
sqlplus / as sysdba
注册单个归档日志
SQL> alter database register physical logfile '/opt/oracle/fast_recovery_area/ORCLCDB/archivelog/2019_09_0
5/o1_mf_1_11_gq2b9n9f_.arc';
Database altered.
-----------------------------------------------------------------
注册归档日志目录
mv archivelog/* /opt/oracle/back/
crosscheck archivelog all;
delete expired archivelog all;
RMAN> catalog start '/opt/oracle/fast_recovery_area/ORCLCDB/archivelog';
11.导出命令输出日志
RMAN> SPOOL LOG TO '/home/oracle/labs/my_lab_output.txt';
12.备份表空间设置备份片大小
查看有关特定多部分备份的元数据
• V$BACKUP_SET 和RC_BACKUP_SET 视图都有一个MULTI_SECTION 列,用于表明
是否为多部分备份。
• V$BACKUP_DATAFILE 和RC_BACKUP_DATAFILE 视图都有一个SECTION_SIZE
列,用于指定多部分备份的每个部分中的块数。零意味着对整个文件进行备份
BACKUP DATAFILE 5 SECTION SIZE = 25M TAG 'section25mb';