{"id":2207,"date":"2023-12-22T15:57:49","date_gmt":"2023-12-22T13:57:49","guid":{"rendered":"https:\/\/www.ludovicocaldara.net\/dba\/?p=2207"},"modified":"2023-12-22T16:02:02","modified_gmt":"2023-12-22T14:02:02","slug":"prepare-database-for-data-guard","status":"publish","type":"post","link":"https:\/\/www.ludovicocaldara.net\/dba\/prepare-database-for-data-guard\/","title":{"rendered":"New in Data Guard 21c and 23c: Automatic preparation of the primary"},"content":{"rendered":"<p>Oracle Data Guard 21c came with a new command:<\/p>\n<pre class=\"lang:plsql decode:true\">prepare database for data guard\r\nwith db_unique_name is {db_unique_name}\r\ndb_recovery_file_dest_size is \"{size}\"\r\ndb_recovery_file_dest is \"{dest}\" ;\r\n<\/pre>\n<p><a href=\"https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2023\/09\/dg23c_prepare.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-2208\" src=\"https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2023\/09\/dg23c_prepare-1024x575.png\" alt=\"The command prepare database for data guard automatically sets parameters and creates standby redo logs according to best practices.\" width=\"584\" height=\"328\" srcset=\"https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2023\/09\/dg23c_prepare-1024x575.png 1024w, https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2023\/09\/dg23c_prepare-300x169.png 300w, https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2023\/09\/dg23c_prepare-768x431.png 768w, https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2023\/09\/dg23c_prepare-500x281.png 500w, https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2023\/09\/dg23c_prepare.png 1132w\" sizes=\"auto, (max-width: 584px) 100vw, 584px\" \/><\/a>This command prepares a database to become primary in a Data Guard configuration.<\/p>\n<p>It sets many recommended parameters:<\/p>\n<pre class=\"lang:plsql decode:true\">DB_FILES                      = 1024\r\nLOG_BUFFER                    = 256M\r\nDB_BLOCK_CHECKSUM             = TYPICAL\r\nDB_LOST_WRITE_PROTECT         = TYPICAL\r\nDB_FLASHBACK_RETENTION_TARGET = 120\r\nPARALLEL_THREADS_PER_CPU      = 1\r\nSTANDBY_FILE_MANAGEMENT       = AUTO\r\nDG_BROKER_START               = TRUE\r\n<\/pre>\n<p>Sets the RMAN archive deletion policy, enables flashback and force logging, creates the standby logs according to the online redo logs configuration, and creates an spfile if the database is running with an init file.<\/p>\n<p>If you tried this in 21c, you have noticed that there is an automatic restart of the database to set all the static parameters. If you weren&#8217;t expecting this, the sudden restart could be a bit brutal approach.<\/p>\n<p>In 23c, we added an additional keyword &#8220;<em>restart<\/em>&#8221; to specify that you are OK with the restart of the database. If you don&#8217;t specify it, the broker will complain that it cannot proceed without a restart:<\/p>\n<pre class=\"lang:plsql decode:true\">DGMGRL&gt; prepare database for data guard\r\n&gt; with db_unique_name is chol23c_hwq_lhr\r\n&gt; db_recovery_file_dest_size is \"200g\"\r\n&gt; db_recovery_file_dest is \"\/u03\/app\/oracle\/fast_recovery_area\"\r\n&gt; ;\r\nValidating database \"cdb1\" before executing the command.\r\n  DGM-17552: Primary database must be restarted after setting static initialization parameters.\r\n  DGM-17327: Primary database must be restarted to enable archivelog mode.\r\nFailed.\r\nDGMGRL&gt;\r\n<\/pre>\n<p>If you specify it, it will proceed with the restart:<\/p>\n<pre class=\"lang:plsql highlight:0 decode:true\">DGMGRL&gt; prepare database for data guard\r\n&gt;   with db_unique_name is chol23c_hwq_lhr\r\n&gt;   db_recovery_file_dest_size is \"200g\"\r\n&gt;   db_recovery_file_dest is \"\/u03\/app\/oracle\/fast_recovery_area\"\r\n&gt;   restart;\r\nValidating database \"chol23c_hwq_lhr\" before executing the command.\r\nPreparing database \"chol23c_hwq_lhr\" for Data Guard.\r\nInitialization parameter DB_FILES set to 1024.\r\nInitialization parameter LOG_BUFFER set to 268435456.\r\nPrimary database must be restarted after setting static initialization parameters.\r\nShutting down database \"chol23c_hwq_lhr\".\r\nDatabase closed.\r\nDatabase dismounted.\r\nORACLE instance shut down.\r\nStarting database \"chol23c_hwq_lhr\" to mounted mode.\r\nORACLE instance started.\r\nDatabase mounted.\r\nInitialization parameter DB_FLASHBACK_RETENTION_TARGET set to 120.\r\nInitialization parameter DB_LOST_WRITE_PROTECT set to 'TYPICAL'.\r\nRMAN configuration archivelog deletion policy set to SHIPPED TO ALL STANDBY.\r\nInitialization parameter DB_RECOVERY_FILE_DEST_SIZE set to '200g'.\r\nInitialization parameter DB_RECOVERY_FILE_DEST set to '\/u03\/app\/oracle\/fast_recovery_area'.\r\nLOG_ARCHIVE_DEST_n initialization parameter already set for local archival.\r\nInitialization parameter LOG_ARCHIVE_DEST_2 set to 'location=use_db_recovery_file_dest valid_for=(all_logfiles, all_roles)'.\r\nInitialization parameter LOG_ARCHIVE_DEST_STATE_2 set to 'Enable'.\r\nAdding standby log group size 1073741824 and assigning it to thread 1.\r\nAdding standby log group size 1073741824 and assigning it to thread 1.\r\nAdding standby log group size 1073741824 and assigning it to thread 1.\r\nInitialization parameter STANDBY_FILE_MANAGEMENT set to 'AUTO'.\r\nInitialization parameter DG_BROKER_START set to TRUE.\r\nDatabase set to FLASHBACK ON.\r\nDatabase opened.\r\nSucceeded.\r\nDGMGRL&gt;<\/pre>\n<p>Notice that if you already have these static parameters set, the broker will just set the missing dynamic parameters without the need for a restart:<\/p>\n<pre class=\"lang:plsql decode:true \">DGMGRL&gt; prepare database for data guard\r\n&gt;   with db_unique_name is chol23c_hwq_lhr\r\n&gt;   db_recovery_file_dest_size is \"200g\"\r\n&gt;   db_recovery_file_dest is \"\/u03\/app\/oracle\/fast_recovery_area\"\r\n&gt; ;\r\nValidating database \"chol23c_hwq_lhr\" before executing the command.\r\nPreparing database \"chol23c_hwq_lhr\" for Data Guard.\r\nInitialization parameter DB_RECOVERY_FILE_DEST_SIZE set to '200g'.\r\nInitialization parameter DB_RECOVERY_FILE_DEST set to '\/u03\/app\/oracle\/fast_recovery_area'.\r\nLOG_ARCHIVE_DEST_n initialization parameter already set for local archival.\r\nInitialization parameter LOG_ARCHIVE_DEST_1 set to 'location=use_db_recovery_file_dest valid_for=(all_logfiles, all_roles)'.\r\nInitialization parameter LOG_ARCHIVE_DEST_STATE_1 set to 'Enable'.\r\nSucceeded.\r\n<\/pre>\n<p>This new command greatly simplifies the preparation of a Data Guard configuration!<\/p>\n<p>Before 21c, you had to do everything by hand.<\/p>\n<p>&#8212;<\/p>\n<p>Ludo<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Oracle Data Guard 21c came with a new command: prepare database for data guard with db_unique_name is {db_unique_name} db_recovery_file_dest_size is &#8220;{size}&#8221; db_recovery_file_dest is &#8220;{dest}&#8221; ; This command prepares a database to become primary in a Data Guard configuration. It sets &hellip; <a href=\"https:\/\/www.ludovicocaldara.net\/dba\/prepare-database-for-data-guard\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[329,360],"tags":[363,292,362,364],"class_list":["post-2207","post","type-post","status-publish","format-standard","hentry","category-oracle-dg","category-oracle-database-23c","tag-automation","tag-data-guard","tag-db23c","tag-manageability"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts\/2207","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/comments?post=2207"}],"version-history":[{"count":3,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts\/2207\/revisions"}],"predecessor-version":[{"id":2226,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts\/2207\/revisions\/2226"}],"wp:attachment":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/media?parent=2207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/categories?post=2207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/tags?post=2207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}