The PREPARE DATABASE FOR DATA GUARD command

This slide explains how to configure a database for Data Guard using a single command.

The PREPARE DATABASE FOR DATA GUARD command configures a database and sets it up to be used as a primary database in a Data Guard broker configuration.

Command Parameters

db_unique_name: The value for the DB_UNIQUE_NAME initialization parameter. If the initialization parameter has been set to a different value, the existing value is replaced with the value specified by db_unique_name. If this parameter is not specified, the DB_UNIQUE_NAME parameter is set to the value of the DBNAME parameter.

directory-location: The directory name for the DB_RECOVERY_FILE_DEST initialization parameter, which represents the fast recovery area location. The specified directory must be accessible by all instances of a RAC database. This parameter can be omitted if a local archive destination is set. However, if the DB_RECOVERY_FILE_DEST initialization parameter has not been set and no local archive destination has been set, specifying this parameter is mandatory. If directory_location is specified, a log_archive_dest_n initialization parameter is set to the value USE_DB_RECOVERY_FILE_DEST. This is done whether or not there is a local archive destination already set.

size: A size value for the DB_RECOVERY_FILE_DEST initialization parameter. This parameter is mandatory if DB_RECOVERY_FILE_DEST is specified.

broker-config-file-1-location: A file location that is used to set the DG_BROKER_CONFIG_FILE1 initialization parameter. The file location specified must be accessible by all instances of a RAC database. This is an optional command parameter.

broker-config-file-2-location: A file location that is used to set the DG_BROKER_CONFIG_FILE2 initialization parameter. The file location specified must be accessible by all instances of a RAC database. This is an optional command parameter.

The PREPARE DATABASE FOR DATA GUARD command sets the following initialization parameters, as per the values recommended for the Maximum Availability Architecture (MAA):

  • DB_FILES=1024
  • LOG_BUFFER=256M
  • DB_BLOCK_CHECKSUM=TYPICAL

    If this value is already set to FULL, the value is left unchanged.

  • DB_BLOCK_CHECKSUM=TYPICAL

    If this value is already set to FULL, the value is left unchanged.

  • DB_LOST_WRITE_PROTECT=TYPICAL

    If this value is already set to FULL, the value is left unchanged.

  • DB_FLASHBACK_RETENTION_TARGET=120

    If this parameter is already set to a non-default value, it is left unchanged.

  • PARALLEL_THREADS_PER_CPU=1
  • DG_BROKER_START=TRUE

This command enables archivelog mode, enables force logging, enables Flashback Database, and sets the RMAN archive log deletion policy to SHIPPED TO ALL STANDBY. If standby redo logs do not exist in the primary database, they are added. If the logs exist and are misconfigured, they are deleted and re-created.

Command Example

The following example prepares a database with the name boston for use as a primary database. The recovery destination is $ORACLE_BASE_HOME/dbs.

DGMGRL> PREPARE DATABASE FOR DATA GUARD

WITH DB_UNIQUE_NAME IS boston

DB_RECOVERY_FILE_DEST IS "$ORACLE_BASE_HOME/dbs/"

DB_RECOVERY_FILE_DEST_SIZE is "400G"

DG_BROKER_CONFIG_FILE1 IS "$ORACLE_HOME/dbs/file1.dat"

DG_BROKER_CONFIG_FILE2 IS "$ORACLE_HOME/dbs/file2.dat";

Preparing database "boston" for Data Guard.

Creating server parameter file (SPFILE) from initialization parameter memory values.

Database must be restarted after creating the server parameter (SPFILE).

Shutting down database "boston".

Database closed.

Database dismounted.

ORACLE instance shut down. Starting database "boston" to mounted mode.

ORACLE instance started.

Database mounted. Server parameter file (SPFILE) is "ORACLE_BASE_HOME/dbs/spboston.ora".

Initialization parameter DB_UNIQUE_NAME set to 'boston'.

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 "boston".

Database dismounted.

ORACLE instance shut down.

Starting database "boston" to mounted mode.

ORACLE instance started.

Database mounted.

Initialization parameter DB_FLASHBACK_RETENTION_TARGET set to 120.

Initialization parameter DB_BLOCK_CHECKSUM set to 'TYPICAL'.

Initialization parameter DB_LOST_WRITE_PROTECT set to 'TYPICAL'.

Initialization parameter PARALLEL_THREADS_PER_CPU set to 1.

Removing RMAN archivelog deletion policy 1.

Removing RMAN archivelog deletion policy 2.

RMAN configuration archivelog deletion policy set to SHIPPED TO ALL STANDBY.

Initialization parameter DB_RECOVERY_FILE_DEST_SIZE set to '400G'.

Initialization parameter DB_RECOVERY_FILE_DEST set to 'ORACLE_BASE_HOME/ dbs/'. Initialization parameter DG_BROKER_START set to FALSE.

Initialization parameter DG_BROKER_CONFIG_FILE1 set to 'ORACLE_HOME/dbs/ file1.dat'.

Initialization parameter DG_BROKER_CONFIG_FILE2 set to 'ORACLE_HOME/dbs/ file2.dat'.

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'.

Initialization parameter STANDBY_FILE_MANAGEMENT set to 'MANUAL'.

Standby log group 4 will be dropped because it was not configured correctly.

Standby log group 3 will be dropped because it was not configured correctly.

Adding standby log group size 26214400 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.

Related Topics