ITPub博客

首页 > 数据库 > Oracle > 基于时间的备份保留策略的rman研究

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

原创 Oracle 作者:幕南风 时间:2014-07-03 13:28:56 0 删除 编辑

 

    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/2012_10_09/o1_mf_nnndf_TAG20121009T101445_87724os6_.bkp


 

[root@think ~]# export LANG=en_US
[root@think ~]# date
Mon Oct 15 10:28:03 CST 2012
[root@think ~]# date -s "Mon Oct 9 10:28:03 CST 2012"
Tue Oct  9 10:28:03 CST 2012
[root@think ~]# date
Tue Oct  9 10:28:06 CST 2012
[root@think ~]# su - oracle
[oracle@think ~]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Tue Oct 9 10:28:20 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: ORCL (DBID=1312966189)

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
no obsolete backups found


 

 

    3 对report need backup的影响

Recovery Manager: Release 10.2.0.1.0 - Production on Tue Oct 9 11:14:16 2012
RMAN> list backup;
BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
3       Full    13.09M     DISK        00:00:01     2012-10-09:10:14:46
......
BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
4       Full    13.09M     DISK        00:00:01     2012-10-09:10:17:13
......
RMAN> report need backup;

RMAN retention policy will be applied to the command
RMAN retention policy is set to recovery window of 1 days
Report of files that must be backed up to satisfy 1 days recovery window
File Days  Name
---- ----- -----------------------------------------------------
1    2658  /u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_7wvsw7b2_.dbf
2    2658  /u01/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_7wvsw7gf_.dbf
3    2658  /u01/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_7wvsw7bd_.dbf
5    126   /u01/app/oracle/oradata/ORCL/datafile/o1_mf_example_7wvsxyqt_.dbf
6    122   /u01/app/oracle/oradata/ORCL/datafile/o1_mf_ts_1_7x5v2q05_.dbf

[root@think ~]# export LANG=en_US
[root@think ~]# date
Wed Oct 10 21:20:03 CST 2012
[root@think ~]# date -s "Wed Oct 11 21:20:03 CST 2012"
Thu Oct 11 21:20:03 CST 2012
[root@think ~]# date
Thu Oct 11 21:20:06 CST 2012
Recovery Manager: Release 10.2.0.1.0 - Production on Thu Oct 11 21:20:54 2012
RMAN> report need backup;

RMAN retention policy will be applied to the command
RMAN retention policy is set to recovery window of 1 days
Report of files that must be backed up to satisfy 1 days recovery window
File Days  Name
---- ----- -----------------------------------------------------
1    2660  /u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_7wvsw7b2_.dbf
2    2660  /u01/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_7wvsw7gf_.dbf
3    2660  /u01/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_7wvsw7bd_.dbf
4    2     /u01/app/oracle/oradata/ORCL/datafile/o1_mf_users_7wvsw7hg_.dbf
5    128   /u01/app/oracle/oradata/ORCL/datafile/o1_mf_example_7wvsxyqt_.dbf
6    124   /u01/app/oracle/oradata/ORCL/datafile/o1_mf_ts_1_7x5v2q05_.dbf


 

    那么当出现report obsolete时,会立即报告report need backup?

[root@think ~]# export LANG=en_US
[root@think ~]# date
Wed Oct 10 10:19:16 CST 2012
[root@think ~]# date -s "Tue Oct  10 10:17:00 CST 2012"
Wed Oct 10 10:17:00 CST 2012
[root@think ~]# date
Wed Oct 10 10:17:03 CST 2012
[root@think ~]# su - oracle
[oracle@think ~]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Wed Oct 10 10:17:14 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: ORCL (DBID=1312966189)

RMAN> report obsolete
2> ;

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/2012_10_09/o1_mf_nnndf_TAG20121009T101445_87724os6_.bkp

RMAN> report need backup;

RMAN retention policy will be applied to the command
RMAN retention policy is set to recovery window of 1 days
Report of files that must be backed up to satisfy 1 days recovery window
File Days  Name
---- ----- -----------------------------------------------------
1    2659  /u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_7wvsw7b2_.dbf
2    2659  /u01/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_7wvsw7gf_.dbf
3    2659  /u01/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_7wvsw7bd_.dbf
5    127   /u01/app/oracle/oradata/ORCL/datafile/o1_mf_example_7wvsxyqt_.dbf
6    123   /u01/app/oracle/oradata/ORCL/datafile/o1_mf_ts_1_7x5v2q05_.dbf


 

   

    4 对optimization的影响

    备份优化与速度无关,而是针对是否对只读表空间进行备份

SQL> alter tablespace users read only;

Tablespace altered.


RMAN> CONFIGURE BACKUP OPTIMIZATION on;

new RMAN configuration parameters:
CONFIGURE BACKUP OPTIMIZATION ON;
new RMAN configuration parameters are successfully stored

RMAN> backup database;  //虽然users下线,而且备份优化也开了,但是第一次rman仍然会把users拿去备份

Starting backup at 2012-10-09:12:16:15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=139 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_7wvsw7b2_.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_7wvsw7bd_.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_users_7wvsw7hg_.dbf
input datafile fno=00005 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_example_7wvsxyqt_.dbf
input datafile fno=00006 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_ts_1_7x5v2q05_.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_7wvsw7gf_.dbf
channel ORA_DISK_1: starting piece 1 at 2012-10-09:12:16:16
channel ORA_DISK_1: finished piece 1 at 2012-10-09:12:17:01
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2012_10_09/o1_mf_nnndf_TAG20121009T121616_87798jhg_.bkp tag=TAG20121009T121616 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 2012-10-09:12:17:03
channel ORA_DISK_1: finished piece 1 at 2012-10-09:12:17:04
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2012_10_09/o1_mf_ncsnf_TAG20121009T121616_87799z8h_.bkp tag=TAG20121009T121616 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 2012-10-09:12:17:04

RMAN> backup database;  //第二次users就被rman自动踢掉了

Starting backup at 2012-10-09:12:17:22
using channel ORA_DISK_1
skipping datafile 4; already backed up 1 time(s)
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_7wvsw7b2_.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_7wvsw7bd_.dbf
input datafile fno=00005 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_example_7wvsxyqt_.dbf
input datafile fno=00006 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_ts_1_7x5v2q05_.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_7wvsw7gf_.dbf
channel ORA_DISK_1: starting piece 1 at 2012-10-09:12:17:23


 

[root@think ~]# export LANG=en_US
[root@think ~]# date
Tue Oct  9 12:21:44 CST 2012
[root@think ~]# date -s "Tue Oct  10 10:21:44 CST 2012"
Wed Oct 10 10:21:44 CST 2012
[root@think ~]# date
Wed Oct 10 10:21:45 CST 2012

Recovery Manager: Release 10.2.0.1.0 - Production on Wed Oct 10 10:21:59 2012
RMAN> backup database;

Starting backup at 2012-10-10:10:22:11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=145 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_7wvsw7b2_.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_7wvsw7bd_.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_users_7wvsw7hg_.dbf
input datafile fno=00005 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_example_7wvsxyqt_.dbf
input datafile fno=00006 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_ts_1_7x5v2q05_.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_7wvsw7gf_.dbf
channel ORA_DISK_1: starting piece 1 at 2012-10-10:10:22:12


 

    5 实验总结:

 

    在recovery window of 1 days的假设下(此处的半天、一整天、1.5天是个大概的量):

          ㈠ optimization和read only下:半天
          ㈡ report obsolete:一整天
          ㈢ report need backup:1.5天

 


 

<!-- Baidu Button BEGIN -->

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26515977/viewspace-1207815/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: until cancel的意义和使用场景
下一篇: 理解锁和闩(1)与锁相关的数据结构
请登录后发表评论 登录
全部评论
腾讯数据库工程师

注册时间:2012-05-10

最新文章