{
  "date": "2017-10-22T19:02:31",
  "slug": "archivelog-deletion-policy-on-data-guard-configuration",
  "link": "https://www.dbi-services.com/blog/archivelog-deletion-policy-on-data-guard-configuration/",
  "title": {
    "rendered": "Archivelog deletion policy on Data Guard configuration"
  },
  "content": {
    "rendered": "<h2>By Franck Pachot</h2>\n<p>.<br />\nThe deletion policy on a dataguard configuration should be:</p>\n<pre><code>\nCONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY;\n</code></pre>\n<p>for the site where you don&#8217;t backup. It can be the standby or the primary.</p>\n<p>and:</p>\n<pre><code>\nCONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY BACKED UP 1 TIMES TO DISK;\n</code></pre>\n<p>for the site where you do the backups. It can be the primary or the standby.</p>\n<p>I&#8217;ve always configured it in this way, but I recently discovered that the order of the subclause matters. Do not CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO DISK APPLIED ON ALL STANDBY; because no archivelogs will be reclaimable, and your recovery area will be full. This is probably a bug. I&#8217;ll update this post when I have more information about this.</p>\n<p><!--more--></p>\n<h3>Test case</h3>\n<p>I&#8217;m on the standby database where I do the backups:</p>\n<pre><code>\n&nbsp;\nRecovery Manager: Release 12.2.0.1.0 - Production on Sun Oct 22 17:37:18 2017\n&nbsp;\nCopyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.\n&nbsp;\nRMAN-06568: connected to target database: CDB2 (DBID=693620717, not open)\n&nbsp;\nRMAN&gt; \nRMAN-03029: echo set on\n&nbsp;\n</code></pre>\n<p>I start with all default configuration:</p>\n<pre><code>\nRMAN&gt; show all;\nRMAN-06607: RMAN configuration parameters for database with db_unique_name CDB2B are:\nRMAN-01005: CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default\nRMAN-01005: CONFIGURE BACKUP OPTIMIZATION OFF; # default\nRMAN-01005: CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default\nRMAN-01005: CONFIGURE CONTROLFILE AUTOBACKUP ON; # default\nRMAN-01005: CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default\nRMAN-01005: CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default\nRMAN-01005: CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default\nRMAN-01005: CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default\nRMAN-01005: CONFIGURE MAXSETSIZE TO UNLIMITED; # default\nRMAN-01005: CONFIGURE ENCRYPTION FOR DATABASE OFF; # default\nRMAN-01005: CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default\nRMAN-01005: CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default\nRMAN-01005: CONFIGURE RMAN OUTPUT TO KEEP FOR 7 DAYS; # default\nRMAN-01005: CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default\nRMAN-01005: CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/12.2.0/dbhome_1/dbs/snapcf_CDB2B.f'; # default\n</code></pre>\n<p>I have one full backup and then some archivelog backups:</p>\n<pre><code>\nRMAN&gt; list backup summary;\nRMAN-06345: List of Backups\nRMAN-06346: ===============\nRMAN-06347: Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag\nRMAN-06348: ------- -- -- - ----------- --------------- ------- ------- ---------- ---\nRMAN-06349: 9       B  F  A DISK        22-OCT 17:05:16 1       1       NO         TAG20171022T170250\nRMAN-06349: 10      B  F  A DISK        22-OCT 17:06:23 1       1       NO         TAG20171022T170250\nRMAN-06349: 11      B  F  A DISK        22-OCT 17:07:18 1       1       NO         TAG20171022T170250\nRMAN-06349: 12      B  F  A DISK        22-OCT 17:07:35 1       1       NO         TAG20171022T170732\nRMAN-06349: 13      B  A  A DISK        22-OCT 17:15:09 1       1       NO         TAG20171022T171502\nRMAN-06349: 14      B  F  A DISK        22-OCT 17:15:19 1       1       NO         TAG20171022T171518\nRMAN-06349: 15      B  A  A DISK        22-OCT 17:27:28 1       1       NO         TAG20171022T172721\nRMAN-06349: 16      B  F  A DISK        22-OCT 17:27:39 1       1       NO         TAG20171022T172737\n</code></pre>\n<p>I have no obsolete backups:</p>\n<pre><code>\nRMAN&gt; report obsolete;\nRMAN-06524: RMAN retention policy will be applied to the command\nRMAN-06511: RMAN retention policy is set to redundancy 1\nRMAN-06147: no obsolete backups found\n</code></pre>\n<h3>APPLIED ON ALL STANDBY</h3>\n<p>I have 1.8% of the recovery area that has been applied:</p>\n<pre><code>\nRMAN&gt; configure archivelog deletion policy to applied on all standby;\nRMAN-06601: new RMAN configuration parameters:\nRMAN-01005: CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY;\nRMAN-06604: new RMAN configuration parameters are successfully stored\n&nbsp;\n&nbsp;\nRMAN&gt; select percent_space_used,percent_space_reclaimable,number_of_files from v$recovery_area_usage where file_type='ARCHIVED LOG';\nRMAN-01005: PERCENT_SPACE_USED PERCENT_SPACE_RECLAIMABLE NUMBER_OF_FILES\nRMAN-01005: ------------------ ------------------------- ---------------\nRMAN-01005:                1.3                      1.08               3\n</code></pre>\n<h3>BACKED UP 1 TIMES TO DISK</h3>\n<p>I have 1.3% of the recovery area that has been backed up:</p>\n<pre><code>\nRMAN&gt; configure archivelog deletion policy to backed up 1 times to disk;\nRMAN-06600: old RMAN configuration parameters:\nRMAN-01005: CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY;\nRMAN-06601: new RMAN configuration parameters:\nRMAN-01005: CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO DISK;\nRMAN-06604: new RMAN configuration parameters are successfully stored\n&nbsp;\n&nbsp;\nRMAN&gt; select percent_space_used,percent_space_reclaimable,number_of_files from v$recovery_area_usage where file_type='ARCHIVED LOG';\nRMAN-01005: PERCENT_SPACE_USED PERCENT_SPACE_RECLAIMABLE NUMBER_OF_FILES\nRMAN-01005: ------------------ ------------------------- ---------------\nRMAN-01005:                1.3                       1.3               3\n</code></pre>\n<p>This looks good. I have some archived logs that have been applied but not backed up yet.</p>\n<h3>Both in the &#8216;bad&#8217; order</h3>\n<p>But now I want to combine both:</p>\n<pre><code>\nRMAN&gt; configure archivelog deletion policy to backed up 1 times to disk applied on all standby;\nRMAN-06600: old RMAN configuration parameters:\nRMAN-01005: CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO DISK;\nRMAN-06601: new RMAN configuration parameters:\nRMAN-01005: CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO DISK APPLIED ON ALL STANDBY;\nRMAN-06604: new RMAN configuration parameters are successfully stored\n&nbsp;\n&nbsp;\nRMAN&gt; select percent_space_used,percent_space_reclaimable,number_of_files from v$recovery_area_usage where file_type='ARCHIVED LOG';\nRMAN-01005: PERCENT_SPACE_USED PERCENT_SPACE_RECLAIMABLE NUMBER_OF_FILES\nRMAN-01005: ------------------ ------------------------- ---------------\nRMAN-01005:                1.3                         0               3\n</code></pre>\n<p>Nothing is recoverable here, wich is in my opinion a bug.</p>\n<h3>Both in the &#8216;right&#8217; order</h3>\n<p>Trying the same but with different order:</p>\n<pre><code>\nRMAN&gt; configure archivelog deletion policy to applied on all standby backed up 1 times to disk;\nRMAN-06600: old RMAN configuration parameters:\nRMAN-01005: CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO DISK APPLIED ON ALL STANDBY;\nRMAN-06601: new RMAN configuration parameters:\nRMAN-01005: CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY BACKED UP 1 TIMES TO DISK;\nRMAN-06604: new RMAN configuration parameters are successfully stored\n&nbsp;\n&nbsp;\nRMAN&gt; select percent_space_used,percent_space_reclaimable,number_of_files from v$recovery_area_usage where file_type='ARCHIVED LOG';\nRMAN-01005: PERCENT_SPACE_USED PERCENT_SPACE_RECLAIMABLE NUMBER_OF_FILES\nRMAN-01005: ------------------ ------------------------- ---------------\nRMAN-01005:                1.3                      1.08               3\n</code></pre>\n<p>This look good. 1.08% have been applied and backed up.</p>\n<p>I&#8217;ve verified the same behavior when backups are done on primary, or on standby, and same in 11.2.0.4, 12.1 and 12.2 with latest RU.<br />\nWhen the deletion policy is starting with the backup clause before the standby clause, the files are not marked as reclaimable. However, they are deleted with a &#8216;delete archivelog&#8217; statement without the &#8216;force&#8217; option.<br />\nThe behavior is the same with &#8216;shipped to&#8217; instead of &#8216;applied on&#8217;.</p>\n<h3>So what?</h3>\n<p>Be careful with the syntax: the &#8216;applied&#8217; or &#8216;shipped&#8217; clause must be written before the &#8216;backup&#8217; one.<br />\nCheck that archived logs are reclaimable. The query I use for that is in: <a href=\"https://www.dbi-services.com/blog/archivelog-deletion-policy-for-standby-database-in-oracle-data-guard/\" target=\"_blank\" rel=\"noopener noreferrer\">https://www.dbi-services.com/blog/archivelog-deletion-policy-for-standby-database-in-oracle-data-guard/</a>. When more archived log detail is required, I&#8217;ve also this query: <a href=\"https://www.dbi-services.com/blog/drilling-down-vrecoveryareausage/\" target=\"_blank\" rel=\"noopener noreferrer\">https://www.dbi-services.com/blog/drilling-down-vrecoveryareausage/</a><br />\nAlways have a look at the recovery area usage after you change the deletion policy, the site where you backup, or after a switchover.</p>\n",
    "protected": false
  }
}
