8i | 9i | 10g | 11g | 12c | 13c | 18c | 19c | 21c | 23c | Misc | PL/SQL | SQL | RAC | WebLogic | Linux

Home » Articles » 21c » Here

Data Guard : The PREPARE DATABASE FOR DATA GUARD Command in Oracle Database 21c

The PREPARE DATABASE FOR DATA GUARD command simplifies the setup of the primary database when configuring Data Guard in Oracle database 21c.

Related articles

Introduction

There are a number of steps necessary to prepare a primary database before configuring Data Guard. For a simple single instance primary database they might look like this.

Set the DB_RECOVERY_FILE_DEST_SIZE and DB_RECOVERY_FILE_DEST initialization parameters.

alter system set db_recovery_file_dest_size=400g;
alter system set db_recovery_file_dest='/u01/app/oracle/fast_recovery_area';

Enable archivelog mode and force logging.

shutdown immediate;
startup mount;
alter database archivelog;
alter database open;

alter database force logging;

Add some standby logs.

alter database add standby logfile thread 1 group 10 size 50m;
alter database add standby logfile thread 1 group 11 size 50m;
alter database add standby logfile thread 1 group 12 size 50m;
alter database add standby logfile thread 1 group 13 size 50m;

Enable flashback database.

alter database flashback on;

Set the STANDBY_FILE_MANAGEMENT initialization parameter and enable the broker.

alter system set standby_file_management=auto;
alter system set dg_broker_start=true;

In Oracle 21c these steps can be performed using the PREPARE DATABASE FOR DATA GUARD command.

PREPARE DATABASE FOR DATA GUARD

We make a bequeath connection to the database and issue the HELP PREPARE command to see the syntax.

$ dgmgrl /
DGMGRL for Linux: Release 21.0.0.0.0 - Production on Sun Feb 6 13:11:59 2022
Version 21.3.0.0.0

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

Welcome to DGMGRL, type "help" for information.
Connected to "cdb1"
Connected as SYSDG.
DGMGRL> help prepare

Prepare a primary database for a Data Guard environment.

Syntax:

  PREPARE DATABASE FOR DATA GUARD
    [WITH [DB_UNIQUE_NAME IS ]
          [DB_RECOVERY_FILE_DEST IS ]
          [DB_RECOVERY_FILE_DEST_SIZE IS ]
          [BROKER_CONFIG_FILE_1 IS ]
          [BROKER_CONFIG_FILE_2 IS ]];


DGMGRL>

Here is an example of the command used during my Vagrant 21c Data Guard build.

dgmgrl / <<EOF
prepare database for data guard
  with db_unique_name is ${NODE1_DB_UNIQUE_NAME}
  db_recovery_file_dest is "${ORACLE_BASE}/fast_recovery_area"
  db_recovery_file_dest_size is 20g;
exit;
EOF

The environment variables translate as follows.

dgmgrl / <<EOF
prepare database for data guard
	with db_unique_name is cdb1
	db_recovery_file_dest is '/u01/app/oracle/fast_recovery_area'
	db_recovery_file_dest_size is 20G;
exit;
EOF

Here is an example of the output it creates.

DGMGRL for Linux: Release 21.0.0.0.0 - Production on Sun Feb 6 14:03:10 2022
Version 21.3.0.0.0

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

Welcome to DGMGRL, type "help" for information.
Connected to "cdb1"
Connected as SYSDG.
DGMGRL> > > > Preparing database "cdb1" for Data Guard.
Initialization parameter DB_FILES set to 1024.
Initialization parameter LOG_BUFFER set to 268435456.
Primary database must be restarted after setting static initialization parameters.
Primary database must be restarted to enable archivelog mode.
Shutting down database "cdb1".
Database closed.
Database dismounted.
ORACLE instance shut down.
Starting database "cdb1" to mounted mode.
ORACLE instance started.
Database mounted.
Initialization parameter DB_FLASHBACK_RETENTION_TARGET set to 120.
Initialization parameter DB_LOST_WRITE_PROTECT set to 'TYPICAL'.
RMAN configuration archivelog deletion policy set to SHIPPED TO ALL STANDBY.
Initialization parameter DB_RECOVERY_FILE_DEST_SIZE set to '20g'.
Initialization parameter DB_RECOVERY_FILE_DEST set to '/u01/app/oracle/fast_recovery_area'.
LOG_ARCHIVE_DEST_n initialization parameter already set for local archival.
Initialization parameter LOG_ARCHIVE_DEST_2 set to 'location=use_db_recovery_file_dest valid_for=(all_logfiles, all_roles)'.
Initialization parameter LOG_ARCHIVE_DEST_STATE_2 set to 'Enable'.
Adding standby log group size 52428800 and assigning it to thread 1.
Adding standby log group size 52428800 and assigning it to thread 1.
Adding standby log group size 52428800 and assigning it to thread 1.
Initialization parameter STANDBY_FILE_MANAGEMENT set to 'AUTO'.
Initialization parameter DG_BROKER_START set to TRUE.
Database set to FORCE LOGGING.
Database set to ARCHIVELOG.
Database set to FLASHBACK ON.
Database opened.
DGMGRL>

We can see the common setup tasks are performed, but it also sets some additional initialization parameters.

DB_FILES=1024
LOG_BUFFER=256M
DB_BLOCK_CHECKSUM=TYPICAL          # Unchanged if FULL
DB_LOST_WRITE_PROTECT=TYPICAL      # Unchanged if FULL
DB_FLASHBACK_RETENTION_TARGET=120  # Unchanged if non-default
PARALLEL_THREADS_PER_CPU=1
DG_BROKER_START=TRUE

There are some other things to consider.

For more information see:

Hope this helps. Regards Tim...

Back to the Top.