Resolved: ORA-19809 limit exceeded for recovery files

How to fix ORA-19809 limit exceeded for recovery files.

In this article we will discuss 'how to resolve ORA-19809 and ORA-19804' error. This has very common issue while doing RMAN backup, we have faced ORA-19809 and ORA-19804 error due to recovery destination full. In this scenario we will have to remove old archivelog (expired or unwanted) or increase the  size of db_recovery_file_dest_size .

ORA-19804: cannot reclaim 67108864 bytes disk space from 5033164800 limit
















RMAN> backup tablespace users;


Starting backup at 24-SEP-19

using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=130 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=/data01/12cdatabase/oracle/oradata/gcdb1/users01.dbf
channel ORA_DISK_1: starting piece 1 at 24-SEP-19
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 09/24/2019 14:38:54
ORA-19809: limit exceeded for recovery files

ORA-19804: cannot reclaim 67108864 bytes disk space from 5033164800 limit



Check the current value of db_recovery_file_dest_size.


SQL> show parameter db_recovery


NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------
db_recovery_file_dest      string     /data01/12cdatabase/oracle/fast_recovery_area
db_recovery_file_dest_size             big integer 4800M


Now we will check the space used .


SQL> select SPACE_USED/1024/1024/1024 "SPACE_USED(GB)" ,SPACE_LIMIT/1024/1024/1024 "SPACE_LIMIT(GB)" from  v$recovery_file_dest;


SPACE_USED(GB) SPACE_LIMIT(GB)

-------------- ---------------
    4.68073177          4.6875



After that we need to increase the db_recovery_file_dest_size  


SQL>ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE=10g SCOPE=SPFILE;

SQL> shut immediate;
SQL> Startup;



If you don't want to shutdown database.You may delete the expired archive log online. We should 'delete files from recovery area using rman' on regular basis.



RMAN> delete expired archivelog all;

RMAN>delete noprompt expired backup;
RMAN>delete noprompt expired archivelog all;
RMAN>delete noprompt obsolete recovery window of 7 days;



Verify the recovery_file_dest size.



SQL> select SPACE_USED/1024/1024/1024 "SPACE_USED(GB)" ,SPACE_LIMIT/1024/1024/1024 "SPACE_LIMIT(GB)" from  v$recovery_file_dest;



SPACE_USED(GB) SPACE_LIMIT(GB)

-------------- ---------------
    4.80296659              10



Now we can start the backup as below.


[oracle@prod ~]$ rman target /


Recovery Manager: Release 12.1.0.1.0 - Production on Tue Sep 24 16:32:38 2019


Copyright (c) 1982, 2013, Oracle and/or its affiliates.  All rights reserved.


connected to target database: GCDB1 (DBID=1045104251)


RMAN> backup tablespace users;


Starting backup at 24-SEP-19

using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=305 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=/data01/12cdatabase/oracle/oradata/gcdb1/users01.dbf
channel ORA_DISK_1: starting piece 1 at 24-SEP-19
channel ORA_DISK_1: finished piece 1 at 24-SEP-19
piece handle=/data01/12cdatabase/oracle/fast_recovery_area/GCDB1/backupset/2019_09_24/o1_mf_nnndf_TAG20190924T163242_grmxymnv_.bkp tag=TAG20190924T163242 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 24-SEP-19

Starting Control File and SPFILE Autobackup at 24-SEP-19

piece handle=/data01/12cdatabase/oracle/fast_recovery_area/GCDB1/autobackup/2019_09_24/o1_mf_s_1019838764_grmxyplb_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 24-SEP-19


Now we can see in RMAN Backup logs no 'ORA-19809 limit exceeded for recovery filesshowing.

12c: Multitenant - Container Database (CDB) and Pluggable database (PDB) Backup and Recovery using RMAN.

As we know that Oracle introduced multitenant Container Database (CDB) and Pluggable Database (PDB) in 12c. Using RMAN client we can perform the backup of entire Container Database (CDB)  or individual Pluggable Database (PDB) and also perform the point-in- time recovery.

Before start the RMAN backup, we should aware about SQL interface for RMAN that another greatest and easiest feature that we can use SQL statement through RMAN. Prior to 12c, very limited SQL statement was supported with RMAN.


RMAN Backup in Container Database (CDB) and Pluggable Database (PDB)
In this article we will explain how to use RMAN backup and recovery in multi-tenant environment.


CDB, PCDB and ROOT Backup:-

We can backup the Container Database (CDB) as same as non-container database using below RMAN command.          

RMAN> BACKUP DATABASE PLUS ARCHIVELOG;

Backup Pluggable database (PDB) using below RMAN command.

RMAN> BACKUP PLUGGABLE DATABASE PDBORCL1, PDBORCL2;

Or connect to Pluggable database (PDB).


$RMAN target sys@PDBORCL1
RMAN> BACKUP DATABASE;

We can backup root using below.

RMAN> BACKUP DATABASE ROOT;


CDB,PCDB and ROOT Restore & Recovery:-

Restoration of container database (CDB) and non-container database both are same. We can restore the CDB using below scripts.

RMAN> RUN {
STARTUP MOUNT;
RESTORE DATABASE;
RECOVER DATABASE;
ALTER DATABASE OPEN;
}

Above script will restore whole container (CDB) and pluggable database (PDB).

For restoration of ROOT use below script.


RMAN> RUN {
STARTUP MOUNT;
RESTORE DATABASE ROOT;
RECOVER DATABASE ROOT;
ALTER DATABASE OPEN;
}


There are two way to restore Pluggable Database (PDB), either restore from root container or directly connect to Pluggable Database (PDB).


RMAN> RUN {
RESTORE PLUGGABLE DATABASE PDBORCL1, PDBORCL2;
RECOVER PLUGGABLE DATABASE PDBORCL1, PDBORCL2;
ALTER PLUGGABLE DATABASE PDBORCL1, PDBORCL2 OPEN;
}


Connect Pluggable database (PDB) and do the Restoration and recovery using below script.


$ RMAN TARGET=sys@PDBORCL
RMAN> RUN {
RESTORE DATABASE;
RECOVER DATABASE;
}



Point-in-time recovery of CDB and PDB:-


Follow the below steps to recover the database until a specified SCN, time or log sequence

Step 1: Shutdown and startup mount the database.

SQL> SHUTDOWN IMMEDAITE;
SQL> STARTUP MOUNT;

Step 2: First of all determine the SCN, time or log sequence that you want to recovery.

SCN – you can get the SCN from alert.log file
Sequence – v$log_history


Step 3. Perform the incomplete recovery

If specifying a time, then set NLS_LANG and NLS_DATE_FORMAT environment variables.

RUN {
SET UNTIL TIME 'SEP 10 2019 12:00:00';
# SET UNTIL SCN 400; # alternatively, specify SCN
# SET UNTIL SEQUENCE 423; # alternatively, specify log seq
RESTORE DATABASE; 
RECOVER DATABASE;
}

Note:- If datafile destination different as compare to source database. Use SET NEWNAME FOR DATAFILE  and then use SWITCH DATAFILE ALL. Pls check here for more information.



Before execute resetlogs , need to update redologfile and tempfiles. For more info check here.


Step 4. Open database with resetlogs.


SQL> ALTER DATABASE OPEN RESETLOGS;


How to move datafile online in oracle 12c

In this article we will discuss how to move/relocate datafile online in oracle. We know that Oracle introduced moving datafiles online in 12c to minimize the downtime. Prior to oracle 12c, required taking datafile offline and copy it at OS level and bring it back online again. Oracle 12c includes an enhancement to ALTER DATABASE MOVE DATAFILE command to moved, relocate or rename when database are online.


Check the existing datafiles:-

SQL>SELECT file#, name FROM v$datafile WHERE con_id = 1 ORDER BY file#;

FILE# NAME
---------- ------------------------------------------------------------------
  1 /data01/12cdatabase/oracle/oradata/gcdb1/system01.dbf
  3 /data01/12cdatabase/oracle/oradata/gcdb1/sysaux01.dbf
  4 /data01/12cdatabase/oracle/oradata/gcdb1/undotbs01.dbf
  6 /data01/12cdatabase/oracle/oradata/gcdb1/users01.dbf


Moving/relocate Datafile:-

SQL> ALTER DATABASE MOVE DATAFILE '/data01/12cdatabase/oracle/oradata/gcdb1/system01.dbf' TO '/tmp/system01.dbf';

Database altered.


SQL> SELECT file_id, file_name FROM dba_data_files WHERE file_id = 1;

 FILE_ID FILE_NAME
----------------------------------------------------------------------
  1 /tmp/system01.dbf


Renaming a datafile:-

SQL> ALTER DATABASE MOVE DATAFILE '/data01/12cdatabase/oracle/oradata/gcdb1/system01.dbf' TO '/data01/12cdatabase/oracle/oradata/gcdb1/system01.dbf';

Database altered.


The next example uses the file number for the source file and keeps the original file.

SQL> ALTER DATABASE MOVE DATAFILE 1 TO '/tmp/system01.dbf' KEEP;


Migrate/relocate a data file from non-ASM to ASM:

SQL> ALTER DATABASE MOVE DATAFILE '/u00/data/users_01.dbf' TO '+DG_DATA';


Migrate/ relocate a data file from one ASM disk group to another:

SQL> ALTER DATABASE MOVE DATAFILE '+DG_DATA/DBNAME/DATAFILE/users_01.dbf ' TO '+DG_DATA_02';


Overwrite the datafile with the same name, if it exists at the new destination:

SQL> ALTER DATABASE MOVE DATAFILE '/u00/data/users_01.dbf' TO '/u00/data_new/users_01.dbf' REUSE;


Copy the file to a new destination while retaining the old copy in the old destination:


SQL> ALTER DATABASE MOVE DATAFILE '/u00/data/users_01.dbf' TO '/u00/data_new/users_01.dbf' KEEP;