1.crosscheck命令使用

  1. 1、核对所有备份集 RMAN> crosscheck backup;
  2. 2、核对所有数据文件的备份集 RMAN> crosscheck backup of database;
  3. 3、核对特定表空间的备份集 RMAN> crosscheck backup of tablespace users;
  4. 4、核对特定数据文件的备份集 RMAN> crosscheck backup of datafile 4;
  5. 5、核对控制文件的备份集 RMAN> crosscheck backup of controlfile;
  6. 6、核对SPFILE的备份集 RMAN> crosscheck backup of spfile;
  7. 7、核对归档日志的备份集 RMAN> crosscheck backup of archivelog sequence 3;
  8. 8、核对所有映像副本 RMAN> crosscheck copy;
  9. 9、核对所有数据文件的映像副本 RMAN> crosscheck copy of database;
  10. 10、核对特定表空间的映像副本 RMAN> crosscheck copy of tablespace users;
  11. 11、核对特定数据文件的映像副本 RMAN> crosscheck copy of datafile 6;
  12. 12、核对归档日志的映像副本 RMAN> crosscheck copy of archivelog sequence 4;
  13. 13、核对控制文件的映像副本 RMAN> crosscheck copy of controlfile;
  14. 14. 核对所有归档日志 RMAN> crosscheck archivelog all; --- 清理delete expired archivelog all ;

2.修改控制文件记录时间

控制文件保留时间和永久保留备份冲突

  1. alter system set control_file_record_keep_time=30;
  2. -----------------------------------
  3. RMAN> backup keep forever database;
  4. ------------------------------------

3.rman list backup/list copy命令

  1. list backup of datafile 1;
  2. list backupset 8;
  3. list backupset tag 'TAG20180419T213849
  4. list backup of tablespace system;
  5. list backup by file;列出每个备份的备份集和备份片
  6. list backup summary;
  7. list backup of database;
  8. list backup;
  9. list copye
  10. list copy of datafile 1;
  11. list copy of database;
  12. list copy of tablespace users;
  13. list copy of archivelog all;
  14. list copy of controlfile;
  15. LIST RESTORE POINT ALL; 列出RMAN 资料档案库已知的所有还原
  16. LIST RESTORE POINT 'rsname';显示特定的还原点
  17. list archivelog all; 列出所有归档日志备份
  18. list incarnation of database;列出数据库化身
  19. list expired backup of archivelog all summary;
  20. list recoverable backup of database;列出可用于恢复的备份集
  21. list expired backup;显示过期备份
  22. list backup of controlfile;
  23. list backup of spfile;
  24. list db_unique_name all;

4.report 命令

  1. report schema;查看数据库结构
  2. RMAN> report need backup; 查看需要备份数据文件
  3. report need backup incremental=3;
  4. report need backup days 3; 查看3天未备份的文件
  5. RMAN> report need backup redundancy 3; 查询没有3次备份集的数据文件
  6. report need backup recovery windows of 2 days;
  7. report obsolete 查询超过备份策略的文件
  8. report unrecoverable;
  9. delete obsolete 删除超过备份策略的文件
  10. delete backupset;
  11. delete expired backupset;删除不存的备份集的rman信息
  12. delete expired:不删除任何文件,只更新RMAN的存储库。
  13. delete noprompt backupset;不提示直接删除,一般用于脚本中

5.restore …preview命令

检查恢复所需要的备份

  1. restore database preview;
  2. restore tablespace users preview;
  3. restore datafile 1 preview;
  4. restore archivelog all preview;
  5. restore controlfile preview;

6.restore ….validate 命令

检查恢复时所需要的备份集完整性
restore ….validate 和validate的区别在于validate只检查文件头,而restore ….validate则逐块检查备份

  1. restore database validate check logical;
  2. restore datafile 1 validate check logical;
  3. restore archivelog all validate check logical;
  4. restore tablespace users validate check logical;
  5. restore controlfile validate check logical;

7.validate 命令

validate命令检查之后,结果将填充v$database_block_corruption 视图

  1. validate database include current controlfile plus archivelog;
  2. validate datafile 1;
  3. validate tablespace users;
  4. validate corruption list;
  5. validate backupset 50;
  6. validate recovery area;

8.chang命令

改变特定备份集为不可用

  1. change backup of database tag='gold' unavailable;
  2. change backup of database like '%gold%' unavailable;
  3. change backupset 33 unavailable;
  4. change backupset 33 available;
  5. change archivelog '/opt/oracle/fast_recover_area/archivelog/archo_o1.arc' unavailable;
  6. change archivelog all backed up t times to device type disk unavailable;
  7. change backup of database device type disk unavailable;
  8. ---------------------------------
  9. 删除指定备份集
  10. RMAN> change backupset 70 delete;
  11. change backuppiece 1304 delete;
  12. 删除指定范围归档日志
  13. change archivelog until logseq=533 delete;
  14. 删除目录中的备份片
  15. change backuppiece '/opt/oracle/back/mydb_bak.bak' uncatalog;

9.delete命令

  1. delete expired;
  2. delete obsolete;
  3. delete noprompt obsolete;
  4. delete nopromt obsolete force;没有使用fra的情况下需要强制删除
  5. delete noprompt archivelog until time 'sysdate-7';

10.手工注册备份集和归档日志

  1. 2.手工注册备份集和归档日志
  2. 1.移走备份集
  3. 2.删除备份集
  4. 3.注册备份集
  5. 3.1注册单个备份片
  6. mv o1_mf_s_1018364319_gq6o8zw3_.bkp /opt/oracle/
  7. crosscheck backup;
  8. delete expired backup;
  9. mv /opt/oracle/o1_mf_s_1018364319_gq6o8zw3_.bkp ./
  10. RMAN> catalog backuppiece '/opt/oracle/fast_recovery_area/ORCLCDB/autobackup/2019_09_07/o1_mf_s_1018364319_
  11. gq6o8zw3_.bkp';
  12. 3.2注册整个目录
  13. [oracle@instance-ej1hspdt ORCLCDB]$ mkdir /opt/oracle/back
  14. [oracle@instance-ej1hspdt ORCLCDB]$ mv autobackup/* /opt/oracle/back/
  15. RMAN> crosscheck backup;
  16. RMAN> delete expired backup;
  17. [oracle@instance-ej1hspdt ORCLCDB]$ mv /opt/oracle/back/* autobackup/
  18. RMAN> catalog start with '/opt/oracle/fast_recovery_area/ORCLCDB/autobackup';
  19. -----------------------------------------------------
  20. mv o1_mf_1_11_gq2b9n9f_.arc /opt/oracle/back/
  21. RMAN> crosscheck archivelog all;
  22. delete expired archivelog all;
  23. sqlplus / as sysdba
  24. 注册单个归档日志
  25. SQL> alter database register physical logfile '/opt/oracle/fast_recovery_area/ORCLCDB/archivelog/2019_09_0
  26. 5/o1_mf_1_11_gq2b9n9f_.arc';
  27. Database altered.
  28. -----------------------------------------------------------------
  29. 注册归档日志目录
  30. mv archivelog/* /opt/oracle/back/
  31. crosscheck archivelog all;
  32. delete expired archivelog all;
  33. RMAN> catalog start '/opt/oracle/fast_recovery_area/ORCLCDB/archivelog';

11.导出命令输出日志

  1. 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
列,用于指定多部分备份的每个部分中的块数。零意味着对整个文件进行备份

  1. BACKUP DATAFILE 5 SECTION SIZE = 25M TAG 'section25mb';