MAXPIECESIZE与FORMAT参数设置不合理导致RMAN备份失败
如果才RMAN参数中配置了MAXIECESIZE的值为一个给定的具体值时,那么再FORMAT中必须叫上%p的通配符,否则一旦备份片超过设定的上限
今天去客户那里搭建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