RMAN结合Read Only、Exclude的备份策略

启动数据库,我是通过一个批处理脚本来完成的:
E:>9i

E:>echo off
OracleServiceEEYGLE 服务正在启动 .........................................................
OracleServiceEEYGLE 服务已经启动成功。


登陆数据库,将部分表空间更改为Read Only:
E:>sqlplus "/ as sysdba"

SQL*Plus: Release 9.2.0.8.0 - Production on Tue Apr 21 09:09:45 2009

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.


Connected to:
Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
D:ORACLEORADATAEEYGLESYSTEM01.DBF
D:ORACLEORADATAEEYGLEUNDOTBS01.DBF
D:ORACLEORADATAEEYGLECWMLITE01.DBF
D:ORACLEORADATAEEYGLEDRSYS01.DBF
D:ORACLEORADATAEEYGLEEXAMPLE01.DBF
D:ORACLEORADATAEEYGLEINDX01.DBF
D:ORACLEORADATAEEYGLEODM01.DBF
D:ORACLEORADATAEEYGLETOOLS01.DBF
D:ORACLEORADATAEEYGLEUSERS01.DBF
D:ORACLEORADATAEEYGLEXDB01.DBF
D:ORACLEORADATAEEYGLEPERFSTAT.DBF

11 rows selected.

SQL> select sum(bytes)/1024/1024/1024 from v$datafile;

SUM(BYTES)/1024/1024/1024
-------------------------
1.65161133

SQL> archive log list;
Database log mode Archive Mode
Automatic archival Disabled
Archive destination D:oracleoradataEEYGLEARCHIVE
Oldest online log sequence 52
Next log sequence to archive 53
Current log sequence 54

SQL> alter tablespace tools read only;

Tablespace altered.

SQL> alter tablespace perfstat read only;

Tablespace altered.


SQL> select 'alter tablespace '||tablespace_name ||' read only;' from dba_tablespaces;

'ALTERTABLESPACE'||TABLESPACE_NAME||'READONLY;'
----------------------------------------------------------
alter tablespace SYSTEM read only;
alter tablespace UNDOTBS1 read only;
alter tablespace TEMP read only;
alter tablespace CWMLITE read only;
alter tablespace DRSYS read only;
alter tablespace EXAMPLE read only;
alter tablespace INDX read only;
alter tablespace ODM read only;
alter tablespace TOOLS read only;
alter tablespace USERS read only;
alter tablespace XDB read only;

'ALTERTABLESPACE'||TABLESPACE_NAME||'READONLY;'
----------------------------------------------------------
alter tablespace PERFSTAT read only;

12 rows selected.

SQL> alter tablespace CWMLITE read only;

Tablespace altered.

SQL> alter tablespace DRSYS read only;

Tablespace altered.

SQL> alter tablespace EXAMPLE read only;

Tablespace altered.

SQL> exit
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production

使用RMAN进行一次0级备份,注意根据skip readonly子句,Read ONLY表空间会被自动跳过:
E:>rman target /

Recovery Manager: Release 9.2.0.8.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.

connected to target database: EEYGLE (DBID=1052376487)


RMAN> run{
2> allocate channel c1 type disk;
3> backup incremental level 0 tag 'db0' format 'e:tempdb0%u_%s_%p'
4> database skip readonly;
5> sql 'alter system archive log current';
6> backup filesperset 3 format 'e:temparch%u_%s_%p' archivelog all delete input;
7> release channel c1;
8> }

using target database controlfile instead of recovery catalog
allocated channel: c1
channel c1: sid=10 devtype=DISK

Starting backup at 21-APR-09
skipping read-only file 3
skipping read-only file 4
skipping read-only file 5
skipping read-only file 8
skipping read-only file 11
channel c1: starting incremental level 0 datafile backupset
channel c1: specifying datafile(s) in backupset
including current SPFILE in backupset
including current controlfile in backupset
input datafile fno=00002 name=D:ORACLEORADATAEEYGLEUNDOTBS01.DBF
input datafile fno=00001 name=D:ORACLEORADATAEEYGLESYSTEM01.DBF
input datafile fno=00010 name=D:ORACLEORADATAEEYGLEXDB01.DBF
input datafile fno=00009 name=D:ORACLEORADATAEEYGLEUSERS01.DBF
input datafile fno=00006 name=D:ORACLEORADATAEEYGLEINDX01.DBF
input datafile fno=00007 name=D:ORACLEORADATAEEYGLEODM01.DBF
channel c1: starting piece 1 at 21-APR-09
channel c1: finished piece 1 at 21-APR-09
piece handle=E:TEMPDB008KD10DI_8_1 comment=NONE
channel c1: backup set complete, elapsed time: 00:04:08
Finished backup at 21-APR-09

sql statement: alter system archive log current

Starting backup at 21-APR-09
current log archived
channel c1: starting archive log backupset
channel c1: specifying archive log(s) in backup set
input archive log thread=1 sequence=51 recid=76 stamp=656093277
input archive log thread=1 sequence=52 recid=77 stamp=656093480
input archive log thread=1 sequence=53 recid=78 stamp=684753587
channel c1: starting piece 1 at 21-APR-09
channel c1: finished piece 1 at 21-APR-09
piece handle=E:TEMPARCH09KD10M8_9_1 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:09
channel c1: deleting archive log(s)
archive log filename=D:ORACLEORADATAEEYGLEARCHIVEARC00051.001 recid=76 stamp=656093277
archive log filename=D:ORACLEORADATAEEYGLEARCHIVEARC00052.001 recid=77 stamp=656093480
archive log filename=D:ORACLEORADATAEEYGLEARCHIVEARC00053.001 recid=78 stamp=684753587
channel c1: starting archive log backupset
channel c1: specifying archive log(s) in backup set
input archive log thread=1 sequence=54 recid=79 stamp=684753596
channel c1: starting piece 1 at 21-APR-09
channel c1: finished piece 1 at 21-APR-09
piece handle=E:TEMPARCH0AKD10MJ_10_1 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:17
channel c1: deleting archive log(s)
archive log filename=D:ORACLEORADATAEEYGLEARCHIVEARC00054.001 recid=79 stamp=684753596
channel c1: starting archive log backupset
channel c1: specifying archive log(s) in backup set
input archive log thread=1 sequence=55 recid=80 stamp=684753601
channel c1: starting piece 1 at 21-APR-09
channel c1: finished piece 1 at 21-APR-09
piece handle=E:TEMPARCH0BKD10N5_11_1 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:04
channel c1: deleting archive log(s)
archive log filename=D:ORACLEORADATAEEYGLEARCHIVEARC00055.001 recid=80 stamp=684753601
Finished backup at 21-APR-09

released channel: c1

RMAN> exit


Recovery Manager complete.

备份完成之后修改部分数据:
E:>sqlplus /nolog

SQL*Plus: Release 9.2.0.8.0 - Production on Tue Apr 21 09:39:34 2009

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

SQL> connect eygle/eygle
Connected.

SQL> create table eygle as select * from dba_objects;

Table created.

SQL> alter system switch logfile;

System altered.

SQL> exit
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production

进行Level 1级的增量备份:
E:>rman target /

Recovery Manager: Release 9.2.0.8.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.

connected to target database: EEYGLE (DBID=1052376487)

RMAN> run{
2> allocate channel c1 type disk;
3> backup incremental level 1 tag 'db1' format 'e:tempdb1%u_%s_%p'
4> database skip readonly;
5> sql 'alter system archive log current';
6> backup filesperset 3 format 'e:temparch%u_%s_%p'
7> archivelog all delete input;
8> release channel c1;
9> }

using target database controlfile instead of recovery catalog
allocated channel: c1
channel c1: sid=11 devtype=DISK

Starting backup at 21-APR-09
skipping read-only file 3
skipping read-only file 4
skipping read-only file 5
skipping read-only file 8
skipping read-only file 11
channel c1: starting incremental level 1 datafile backupset
channel c1: specifying datafile(s) in backupset
including current SPFILE in backupset
including current controlfile in backupset
input datafile fno=00002 name=D:ORACLEORADATAEEYGLEUNDOTBS01.DBF
input datafile fno=00001 name=D:ORACLEORADATAEEYGLESYSTEM01.DBF
input datafile fno=00010 name=D:ORACLEORADATAEEYGLEXDB01.DBF
input datafile fno=00009 name=D:ORACLEORADATAEEYGLEUSERS01.DBF
input datafile fno=00006 name=D:ORACLEORADATAEEYGLEINDX01.DBF
input datafile fno=00007 name=D:ORACLEORADATAEEYGLEODM01.DBF
channel c1: starting piece 1 at 21-APR-09
channel c1: finished piece 1 at 21-APR-09
piece handle=E:TEMPDB10CKD120F_12_1 comment=NONE
channel c1: backup set complete, elapsed time: 00:01:07
Finished backup at 21-APR-09

sql statement: alter system archive log current

Starting backup at 21-APR-09
current log archived
channel c1: starting archive log backupset
channel c1: specifying archive log(s) in backup set
input archive log thread=1 sequence=56 recid=81 stamp=684755029
input archive log thread=1 sequence=57 recid=82 stamp=684755031
input archive log thread=1 sequence=58 recid=83 stamp=684755033
channel c1: starting piece 1 at 21-APR-09
channel c1: finished piece 1 at 21-APR-09
piece handle=E:TEMPARCH0DKD122P_13_1 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:05
channel c1: deleting archive log(s)
archive log filename=D:ORACLEORADATAEEYGLEARCHIVEARC00056.001 recid=81 stamp=684755029
archive log filename=D:ORACLEORADATAEEYGLEARCHIVEARC00057.001 recid=82 stamp=684755031
archive log filename=D:ORACLEORADATAEEYGLEARCHIVEARC00058.001 recid=83 stamp=684755033
Finished backup at 21-APR-09

released channel: c1

RMAN> exit


Recovery Manager complete.


再更改数据库内容:

E:>sqlplus "/ as sysdba"

SQL*Plus: Release 9.2.0.8.0 - Production on Tue Apr 21 09:45:52 2009

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.


Connected to:
Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production

SQL> connect eygle/eygle
Connected.
SQL> drop table test;

Table dropped.

SQL> drop table eygle;

Table dropped.

SQL> exit
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production

使用RMAN配置Exclude排除表空间,注意此处测试排除多个表空间的备份:

E:>rman target /

Recovery Manager: Release 9.2.0.8.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.

connected to target database: EEYGLE (DBID=1052376487)

RMAN> configure exclude for tablespace INDX;

using target database controlfile instead of recovery catalog
tablespace INDX will be excluded from future whole database backups
new RMAN configuration parameters are successfully stored

RMAN> show exclude;

RMAN configuration parameters are:
CONFIGURE EXCLUDE FOR TABLESPACE 'INDX';

RMAN> configure exclude for tablespace ODM;

tablespace ODM will be excluded from future whole database backups
new RMAN configuration parameters are successfully stored

RMAN> show exclude;

RMAN configuration parameters are:
CONFIGURE EXCLUDE FOR TABLESPACE 'INDX';
CONFIGURE EXCLUDE FOR TABLESPACE 'ODM';

RMAN> configure exclude for tablespace TOOLS;

tablespace TOOLS will be excluded from future whole database backups
new RMAN configuration parameters are successfully stored

RMAN>

RMAN> configure exclude for tablespace XDB;

tablespace XDB will be excluded from future whole database backups
new RMAN configuration parameters are successfully stored

RMAN> show exclude;

RMAN configuration parameters are:
CONFIGURE EXCLUDE FOR TABLESPACE 'INDX';
CONFIGURE EXCLUDE FOR TABLESPACE 'ODM';
CONFIGURE EXCLUDE FOR TABLESPACE 'TOOLS';
CONFIGURE EXCLUDE FOR TABLESPACE 'XDB';

RMAN> configure exclude for tablespace USERS;

tablespace USERS will be excluded from future whole database backups
new RMAN configuration parameters are successfully stored

RMAN> show exclude;

RMAN configuration parameters are:
CONFIGURE EXCLUDE FOR TABLESPACE 'INDX';
CONFIGURE EXCLUDE FOR TABLESPACE 'ODM';
CONFIGURE EXCLUDE FOR TABLESPACE 'TOOLS';
CONFIGURE EXCLUDE FOR TABLESPACE 'USERS';
CONFIGURE EXCLUDE FOR TABLESPACE 'XDB';

RMAN> run{
2> allocate channel c1 type disk;
3> backup incremental level 1 tag 'db1' format 'e:tempdb1%u_%s_%p'
4> database skip readonly;
5> sql 'alter system archive log current';
6> backup filesperset 3 format 'e:temparch%u_%s_%p'
7> archivelog all delete input;
8> release channel c1;
9> }

allocated channel: c1
channel c1: sid=10 devtype=DISK

Starting backup at 21-APR-09
skipping read-only file 3
skipping read-only file 4
skipping read-only file 5
file 6 is excluded from whole database backup
file 7 is excluded from whole database backup
file 8 is excluded from whole database backup
file 9 is excluded from whole database backup
file 10 is excluded from whole database backup
skipping read-only file 11
channel c1: starting incremental level 1 datafile backupset
channel c1: specifying datafile(s) in backupset
including current SPFILE in backupset
including current controlfile in backupset
input datafile fno=00002 name=D:ORACLEORADATAEEYGLEUNDOTBS01.DBF
input datafile fno=00001 name=D:ORACLEORADATAEEYGLESYSTEM01.DBF
channel c1: starting piece 1 at 21-APR-09
channel c1: finished piece 1 at 21-APR-09
piece handle=E:TEMPDB10EKD12B2_14_1 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:57
Finished backup at 21-APR-09

sql statement: alter system archive log current

Starting backup at 21-APR-09
current log archived
channel c1: starting archive log backupset
channel c1: specifying archive log(s) in backup set
input archive log thread=1 sequence=59 recid=84 stamp=684755357
input archive log thread=1 sequence=60 recid=85 stamp=684755360
channel c1: starting piece 1 at 21-APR-09
channel c1: finished piece 1 at 21-APR-09
piece handle=E:TEMPARCH0FKD12D1_15_1 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:04
channel c1: deleting archive log(s)
archive log filename=D:ORACLEORADATAEEYGLEARCHIVEARC00059.001 recid=84 stamp=684755357
archive log filename=D:ORACLEORADATAEEYGLEARCHIVEARC00060.001 recid=85 stamp=684755360
Finished backup at 21-APR-09

released channel: c1

RMAN>

通过排除多个表空间、跳过Read Only表空间,可以简化我们的备份策略,在特定条件下,有助于我们的数据库管理与维护。

-The End-
相关文章 随机文章
RMAN排除备份 Exclude带来的Obsolete影响
如何快速找到备份过最近、最大序号的归档日志
RAC环境下根据sequence恢复指定日志
使用RMAN进行排除表空间备份
使用Catalog命令注册RMAN备份集
Oracle HowTo:如何在Oracle10g中启动和关闭OEM
SAP之ORA-20005: object statistics are locked
新年快乐-一个非常漂亮的Flash
Tools:Windows Service Install/Remove Wizard
DBA生存之四大守则
链接: [@more@]

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

转载于:http://blog.itpub.net/13879334/viewspace-1035204/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值