日期:2014-05-16  浏览次数:20473 次

基于时间的备份保留策略的rman研究

 

    1 实验准备

 

    a)物理和逻辑上检查

SQL> col file_name for a70 wrapped
SQL> select file_name,status from dba_data_files where file_id=4;

FILE_NAME                                                              STATUS
---------------------------------- ---------
/u01/app/oracle/oradata/ORCL/datafile/o1_mf_users_7wvsw7hg_.dbf        AVAILABLE

SQL> select tablespace_name,status from dba_tablespaces where tablespace_name='USERS';

TABLESPACE_NAME                STATUS
------------------------------ ---------
USERS                          ONLINE


    b)large_pool

SQL> select * from v$sgastat where pool like '%large%';

POOL         NAME                            BYTES
------------ -------------------------- ----------
large pool   PX msg pool                    902160
large pool   free memory                   3292144

    c)NLS_DATE_FORMAT

 >vim .bash_profile
 >export NLS_DATE_FORMAT='YYYY-MM-DD:HH24:MI:SS'
 >. .bash_profile


    d)control_file_record_keep_time

SQL> show parameter control_

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time        integer     7


    e)清空环境

RMAN> list backup;


RMAN> list copy;

specification does not match any archive log in the recovery catalog

    f)配置时间窗口为1 days

RMAN> CONFIGURE RETENTION POLICY TO recovery window of 1 days;

new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 1 DAYS;
new RMAN configuration parameters are successfully stored

RMAN> show all;

RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 1 DAYS;
......


 

    2 对report obsolete的影响

RMAN> backup tablespace users;
......
Finished backup at 2012-10-09:10:14:46

RMAN> backup tablespace users; //对users备份两次,当超过备份保留策略时,rman会将老的备份标志为obsolete
......
Finished backup at 2012-10-09:10:17:13


 

[root@think ~]# date
Tue Oct  9 10:31:03 CST 2012
[root@think ~]# date -s "Tue Oct  9 23:59:00 CST 2012"
Tue Oct  9 23:59:00 CST 2012
[root@think ~]# date
Tue Oct  9 23:59:03 CST 2012
Recovery Manager: Release 10.2.0.1.0 - Production on Tue Oct 9 23:59:19 2012
RMAN> report obsolete;
...
no obsolete backups found


 

[root@think ~]# date
Tue Oct  9 10:31:03 CST 2012
[root@think ~]# date -s "Tue Oct  10 10:17:00 CST 2012"
Tue Oct  10 10:17:00 CST 2012
[root@think ~]# date
Tue Oct  10 10:17:00 CST 2012
Recovery Manager: Release 10.2.0.1.0 - Production on Tue Oct 10 10:17:5 2012
RMAN> report obsolete;

using target database control file instead of recovery catalog
RMAN retention policy will be applied to the command
RMAN retention policy is set to recovery window of 1 days
Report of obsolete backups and copies
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set           3      2012-10-09:10:14:46
  Backup Piece       3      2012-10-09:10:14:46 /u01/app/oracle/flash_recovery_area/ORCL/backupset/2