客户需求,RMAN备份时间过长,想缩短备份时间,优化备份。
客户基于表空间进行历史数据归档的方式,将历史的表空间进行read only,想让RMAN跳过只读表空间,减少RMAN备份的数据总量,从而缩短备份时间。
一、对表空间调整为只读模式
SQL> alter tablespace test read only; SQL> select segment_name,owner from dba_segments where tablespace_name='TEST'; SEGMENT_NAME OWNER ------------------------------ EMP1 SCOTT SQL> select * from scott.emp1; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ---------- -------------- ---------- ---------- ---------- 7369 SMITH CLERK 7902 17-12月-80 800 20 SQL> delete scott.emp1; delete scott.emp1 * 第 1 行出现错误: ORA-00372: 此时无法修改文件 7 ORA-01110: 数据文件 7: 'C:WIN_ORACLE_11_DATABASEAPPORADATAWIN11TEST01.DBF' 开启备份优化,对read only 无效,并不会跳过read only的备份 RMAN> run { CONFIGURE BACKUP OPTIMIZATION ON; backup as compressed backupset database format 'C:win_oracle_11_database manbackupdbFULLBAK_%U_%d_%s.bak'; } 通过参数设置 RMAN>run { CONFIGURE BACKUP OPTIMIZATION ON; CONFIGURE RETENTION POLICY TO NONE; backup as compressed backupset database format 'C:win_oracle_11_database manbackupdbFULLBAK_%U_%d_%s.bak'; } 当第二次备份时,将跳过已备份的文件,但是由于RMAN保留参数配置为默认值,无法删除历史的备份文件,浪费空间存储,不符合实际情况。 使用如下参数,将无法进行跳过read only备份 RMAN>run { CONFIGURE BACKUP OPTIMIZATION ON; CONFIGURE RETENTION POLICY TO REDUNDANCY 2; backup as compressed backupset database format 'C:win_oracle_11_database manbackupdbFULLBAK_%U_%d_%s.bak'; } 使用SKIP READO参数进行备份 RMAN> delete backup; RMAN>run { CONFIGURE BACKUP OPTIMIZATION ON; CONFIGURE RETENTION POLICY TO REDUNDANCY 2; backup as compressed backupset database SKIP READONLY format 'C:win_oracle_11_database manbackupdbFULLBAK_%U_%d_%s.bak'; } 加上参数SKIP READONLY 即可
RMAN>run { CONFIGURE RETENTION POLICY TO REDUNDANCY 2; backup as compressed backupset
database SKIP READONLY format 'C:win_oracle_11_database manbackupdbFULLBAK_%U_%d_%s.bak'; }