码迷,mamicode.com
首页 > 其他好文 > 详细

MAXPIECESIZE与FORMAT参数设置不合理导致RMAN备份失败

时间:2014-12-24 16:19:10      阅读:244      评论:0      收藏:0      [点我收藏+]

标签:oracle   rman   maxpiecesize   ora-27038   format通配符   

今天去客户那里搭建DG,当创建RMAN备份集的时候,遇到了个问题,导致备份集始终无法生成,由于客户的备份集为10G左右,一次备份就要一个多小时,开始浪费了不少时间,诊断后发现,原来问题出在MAXPIECESIZE上,下面自己做了个测试,来说明这个故障现象和解决方法:

[root@ora10g ~]# su - oracle
[oracle@ora10g ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on 24 14:32:34 2014

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


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> select open_mode from v$database;

OPEN_MODE
----------
READ WRITE

SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@ora10g ~]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on 24 14:32:52 2014

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

connected to target database: ORA10G (DBID=4175411955)

RMAN> show all;

using target database control file instead of recovery catalog
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 5;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘/u01/orabackup/backupsets/ora10g-%F.ctl‘;
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE DISK MAXPIECESIZE 10000 M;    --最大备份集限制
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM ‘AES128‘; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE;
CONFIGURE SNAPSHOT CONTROLFILE NAME TO ‘/u01/app/oracle/product/10.2.0/db_1/dbs/snapcf_ora10g.f‘; # default

RMAN> exit


Recovery Manager complete.
[oracle@ora10g ~]$ cd /u01/orabackup/scripts/
[oracle@ora10g scripts]$ ls -l
total 4
-rwxr-xr-x 1 oracle oinstall 2443 Dec 24 14:29 backup_full.sh
[oracle@ora10g scripts]$ ./backup_full.sh
RMAN> RMAN> RMAN> RMAN> RMAN> RMAN> RMAN> RMAN> RMAN> RMAN> 2> 3> RMAN> RMAN> RMAN> RMAN> [oracle@ora10g backupsets]$ ls -lrth
total 190M
-rw-r----- 1 oracle oinstall 9.8M Dec 24 14:24 ora10g-4175411955_20141224_867162246_380.arc
-rw-r----- 1 oracle oinstall 1.7M Dec 24 14:24 ora10g-4175411955_20141224_867162255_381.arc
-rw-r----- 1 oracle oinstall 439K Dec 24 14:24 ora10g-4175411955_20141224_867162257_382.arc
-rw-r----- 1 oracle oinstall 747K Dec 24 14:33 ora10g-4175411955_20141224_867162820_384.arc
-rw-r----- 1 oracle oinstall 170M Dec 24 14:36 ora10g-4175411955_20141224_867162823_385.db
-rw-r----- 1 oracle oinstall 491K Dec 24 14:36 ora10g-4175411955_20141224_867162990_386.arc
-rw-r----- 1 oracle oinstall 7.3M Dec 24 14:36 ora10g-c-4175411955-20141224-00.ctl
[oracle@ora10g backupsets]$ 

根据刚才的配置,正确的生成了RMAN备份集,总大小为190M左右,其中最大的数据文件的备份集为170M,而在RMAN脚本中配置的

在备份脚本中,配置了format格式为“$ORACLE_SID-%I_%T_%t_%s.db”,以下为脚本具体的语句:

backup as compressed backupset database format ‘$RMAN_BACKUPSETS/$ORACLE_SID-%I_%T_%t_%s.db‘ tag ‘db_bak‘ plus archivelog format ‘$RMAN_BACKUPSETS/$ORACLE_SID-%I_%T_%t_%s.arc‘ not backed up 1 times delete all input tag ‘arc_bak‘;

当把MAXPIECESIZE的值改小,比之前最大的备份集大小(170M)还要小,比方说改成100M后,再运行之前的备份脚本,然后查看RMAN输出的日志文件,发现报ORA-27038,提示文件已经存在:

[oracle@ora10g backupsets]$ cat ../logs/rman.log |grep ORA-
ORA-19504: failed to create file "/u01/orabackup/backupsets/ora10g-4175411955_20141224_867163196_389.db"
ORA-27038: created file already exists


channel ORA_DISK_1: starting piece 2 at 2014-12-24
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of backup plus archivelog command at 12/24/2014 14:41:52
ORA-19504: failed to create file "/u01/orabackup/backupsets/ora10g-4175411955_20141224_867163196_389.db"
ORA-27038: created file already exists
Additional information: 1

正常情况下,生成的最大备份集有170M,但是刚才通过修改MAXPIECESIZE参数为100M后,在生成备份集时,一旦备份集大小超过100M时,就会自动生成第2个备份片,而由于我在format中仅仅是配置了$ORACLE_SID-%I_%T_%t_%s.db”,这几个通配符的含义是:
%I -- DBID
%T -- 日期时间(年月日)
%t -- 自动生成的时间戳
%s -- 备份集序列号(Sequence)

当第一个备份片达到MAXPIECESIZE限定的100M后,想去生成第2个文件,但是由于这几个通配符不足以区分备份集中的备份片(生成了同一个文件名),当第2个备份片创建时提示文件已存在,最终导致备份失败。

解决这个问题的方法有2种:

1. 在format参数中增加%p通配符

当超过MAXPIECESIZE后,只有%p才能够生成不同的备份片,因为%t这个时间戳不足以区分不同的别分片的名称

[oracle@ora10g backupsets]$ . ../scripts/backup_full.sh 
RMAN> RMAN> RMAN> RMAN> RMAN> RMAN> RMAN> RMAN> RMAN> RMAN> 2> 3> RMAN> RMAN> RMAN> RMAN> [oracle@ora10g backupsets]$ ls -lrth ../backupsets/
total 375M
-rw-r----- 1 oracle oinstall 9.8M Dec 24 14:24 ora10g-4175411955_20141224_867162246_380.arc
-rw-r----- 1 oracle oinstall 1.7M Dec 24 14:24 ora10g-4175411955_20141224_867162255_381.arc
-rw-r----- 1 oracle oinstall 439K Dec 24 14:24 ora10g-4175411955_20141224_867162257_382.arc
-rw-r----- 1 oracle oinstall 747K Dec 24 14:33 ora10g-4175411955_20141224_867162820_384.arc
-rw-r----- 1 oracle oinstall 170M Dec 24 14:36 ora10g-4175411955_20141224_867162823_385.db
-rw-r----- 1 oracle oinstall 491K Dec 24 14:36 ora10g-4175411955_20141224_867162990_386.arc
-rw-r----- 1 oracle oinstall 7.3M Dec 24 14:36 ora10g-c-4175411955-20141224-00.ctl
-rw-r----- 1 oracle oinstall  30K Dec 24 14:39 ora10g-4175411955_20141224_867163193_388.arc
-rw-r----- 1 oracle oinstall 7.4M Dec 24 15:03 ora10g-4175411955_20141224_867164604_390_1.arc
-rw-r----- 1 oracle oinstall  99M Dec 24 15:05 ora10g-4175411955_20141224_867164614_391_1.db
-rw-r----- 1 oracle oinstall  73M Dec 24 15:06 ora10g-4175411955_20141224_867164614_391_2.db
-rw-r----- 1 oracle oinstall  22K Dec 24 15:06 ora10g-4175411955_20141224_867164776_392_1.arc
-rw-r----- 1 oracle oinstall 7.3M Dec 24 15:06 ora10g-c-4175411955-20141224-01.ctl
[oracle@ora10g backupsets]$ 

在format中增加%p通配符后,问题得到解决,通过脚本备份集又可以正常创建备份集了,注意由于配置了%p,这里db的备份集变成了2个备份片,分别为“_1”,“_2”,以100M为分割点(MAXPIECESIZE指定的大小)

[oracle@ora10g backupsets]$ cat ../logs/rman.log |grep ORA-
ORA-19504: failed to create file "/u01/orabackup/backupsets/ora10g-4175411955_20141224_867163196_389.db"
ORA-27038: created file already exists
[oracle@ora10g backupsets]$ 

由于RMAN备份日志用的是append方式,抓取出来的这个错误时之前记录进去的,没有新增的ORA-27038出现了

2. 将MAXPIECESIZE的值清空

MAXPIECESIZE设置为无限大,自然可以解决备份集超过上限的问题,也可以不用配置%p,但是不推荐使用这种方法,如果因为数据库的数据量非常大,将导致生成的备份集过大,不利于存储和恢复

RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK clear;

old RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK MAXPIECESIZE 100 M;
old RMAN configuration parameters are successfully deleted    --原来配置的MAXPIECESIZE的值清空完成

RMAN> show all;

RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 5;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘/u01/orabackup/backupsets/ora10g-%F.ctl‘;
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM ‘AES128‘; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE;
CONFIGURE SNAPSHOT CONTROLFILE NAME TO ‘/u01/app/oracle/product/10.2.0/db_1/dbs/snapcf_ora10g.f‘; # default

可以看到,刚才MAXPIECESIZE的值在show all中已经不存在了,也就是对备份片没有限制了

再次进行备份,可以通过脚本运行,也可以单独执行下面的备份语句:
RMAN> backup as compressed backupset database format ‘$RMAN_BACKUPSETS/$ORACLE_SID-%I_%T_%t_%s.db‘ tag ‘db_bak‘ plus archivelog format ‘$RMAN_BACKUPSETS/$ORACLE_SID-%I_%T_%t_%s.arc‘ not backed up 1 times delete all input tag ‘arc_bak‘;

[oracle@ora10g backupsets]$ . ../scripts/backup_full.sh 
RMAN> RMAN> RMAN> RMAN> RMAN> RMAN> RMAN> RMAN> RMAN> RMAN> 2> 3> RMAN> RMAN> RMAN> RMAN> 
[oracle@ora10g backupsets]$  ls -lrth ../backupsets/
total 553M
-rw-r----- 1 oracle oinstall 9.8M Dec 24 14:24 ora10g-4175411955_20141224_867162246_380.arc
-rw-r----- 1 oracle oinstall 1.7M Dec 24 14:24 ora10g-4175411955_20141224_867162255_381.arc
-rw-r----- 1 oracle oinstall 439K Dec 24 14:24 ora10g-4175411955_20141224_867162257_382.arc
-rw-r----- 1 oracle oinstall 747K Dec 24 14:33 ora10g-4175411955_20141224_867162820_384.arc
-rw-r----- 1 oracle oinstall 170M Dec 24 14:36 ora10g-4175411955_20141224_867162823_385.db
-rw-r----- 1 oracle oinstall 491K Dec 24 14:36 ora10g-4175411955_20141224_867162990_386.arc
-rw-r----- 1 oracle oinstall 7.3M Dec 24 14:36 ora10g-c-4175411955-20141224-00.ctl
-rw-r----- 1 oracle oinstall  30K Dec 24 14:39 ora10g-4175411955_20141224_867163193_388.arc
-rw-r----- 1 oracle oinstall 7.4M Dec 24 15:03 ora10g-4175411955_20141224_867164604_390_1.arc
-rw-r----- 1 oracle oinstall  99M Dec 24 15:05 ora10g-4175411955_20141224_867164614_391_1.db
-rw-r----- 1 oracle oinstall  73M Dec 24 15:06 ora10g-4175411955_20141224_867164614_391_2.db
-rw-r----- 1 oracle oinstall  22K Dec 24 15:06 ora10g-4175411955_20141224_867164776_392_1.arc
-rw-r----- 1 oracle oinstall 7.3M Dec 24 15:06 ora10g-c-4175411955-20141224-01.ctl
-rw-r----- 1 oracle oinstall 457K Dec 24 15:25 ora10g-4175411955_20141224_867165923_394.arc
-rw-r----- 1 oracle oinstall 170M Dec 24 15:28 ora10g-4175411955_20141224_867165927_395.db
-rw-r----- 1 oracle oinstall  20K Dec 24 15:28 ora10g-4175411955_20141224_867166094_396.arc
-rw-r----- 1 oracle oinstall 7.3M Dec 24 15:28 ora10g-c-4175411955-20141224-02.ctl
[oracle@ora10g backupsets]$ 

第3次执行备份脚本生成的备份集没有分片(因为去掉了%p参数),同时也去掉了MAXPIECESIZE的限制

总结

如果才RMAN参数中配置了MAXIECESIZE的值为一个给定的具体值时,那么再FORMAT中必须叫上%p的通配符,否则一旦备份片超过设定的上限值后,就无法生成后续备份片,导致备份失败。因此通常情况下,建议配置MAXPIECESIZE参数,并且在FORMAT中加上%U通配符,它包含了%u(自动计算出的唯一8位编号),%p(备份片号),%c(备份片拷贝数,1-256)。








MAXPIECESIZE与FORMAT参数设置不合理导致RMAN备份失败

标签:oracle   rman   maxpiecesize   ora-27038   format通配符   

原文地址:http://blog.csdn.net/aaron8219/article/details/42124671

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!