DBA Hub

📋Steps in this guide1/2

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.

oracle 21cconfigurationintermediate
by OracleDba
14 views
1

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 and initialization parameters. Enable archivelog mode and force logging. Add some standby logs. Enable flashback database. Set the initialization parameter and enable the broker. In Oracle 21c these steps can be performed using the command.

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
alter system set db_recovery_file_dest_size=400g;
alter system set db_recovery_file_dest='/u01/app/oracle/fast_recovery_area';

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

alter database force logging;

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;

alter database flashback on;

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

PREPARE DATABASE FOR DATA GUARD

We make a bequeath connection to the database and issue the command to see the syntax. Here is an example of the command used during my Vagrant 21c Data Guard build . The environment variables translate as follows. Here is an example of the output it creates. We can see the common setup tasks are performed, but it also sets some additional initialization parameters. There are some other things to consider. - If the SPFILE doesn't exist for a single instance, one is created. - It sets the RMAN archive log deletion policy to SHIPPED TO ALL STANDBY. - Not only does it add missing standby logs, but if some are misconfigured, it will drop and reconfigure them. For more information see: Hope this helps. Regards Tim...

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
$ 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>

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

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

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>

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

Comments (0)

Please to add comments

No comments yet. Be the first to comment!