Oracle Data Guard 19c Masterclass – Part 2 : Preparing the Primary Database for Data Guard

In Part 1, we established the architecture and the three fundamental Data Guard operations:

REDO GENERATION
      ↓
REDO TRANSPORT
      ↓
REDO APPLY

Now we prepare the Oracle 19c primary database properly.

The objective is to reach a state where the primary is ready to create and maintain a physical standby.

1. Production Scenario

We’ll use this architecture throughout the series:

                    APPLICATION
                         |
                         v
              +---------------------+
              |     PRIMARY RAC     |
              |                     |
              |  RAC1      RAC2     |
              |  T1        T2       |
              +----------+----------+
                         |
                    REDO TRANSPORT
                         |
                         v
              +---------------------+
              |   PHYSICAL STANDBY  |
              |                     |
              |     DR RAC          |
              +---------------------+

For this part, we’re working only on:

PRIMARY

2. Pre-Check: Database Role

First confirm that you’re actually working on the primary.

SELECT name,
       db_unique_name,
       database_role,
       open_mode,
       log_mode,
       protection_mode,
       protection_level
FROM v$database;

Expected:

NAME     DB_UNIQUE_NAME  DATABASE_ROLE  OPEN_MODE   LOG_MODE
-------- -------------- --------------  ----------  ----------
PRODDB   PRODDB          PRIMARY        READ WRITE  ARCHIVELOG

If the database isn’t already in ARCHIVELOG, we’ll address that shortly.

3. Check RAC

For RAC:

SELECT inst_id,
       instance_number,
       instance_name,
       host_name,
       status
FROM gv$instance
ORDER BY inst_id;

Example:

INST_ID INSTANCE_NAME HOST_NAME       STATUS
------- ------------- --------------- --------
1       PROD1         prod-rac01      OPEN
2       PROD2         prod-rac02      OPEN

Then:

SELECT thread#,
       instance,
       status,
       enabled
FROM v$thread
ORDER BY thread#;

Example:

THREAD# INSTANCE STATUS ENABLED
------- -------- ------ -------
1       PROD1    OPEN   PUBLIC
2       PROD2    OPEN   PUBLIC

These threads become important when the standby receives redo.

4. ARCHIVELOG Is Mandatory

A physical standby relies on redo.

Therefore:

ARCHIVELOG

must be enabled.

Check:

ARCHIVE LOG LIST;

or:

SELECT log_mode
FROM v$database;

You want:

ARCHIVELOG

5. If ARCHIVELOG Is Disabled

If this is an existing production database:

NOARCHIVELOG

you need a maintenance operation to enable it.

Typical procedure:

SHUTDOWN IMMEDIATE;

Then:

STARTUP MOUNT;

Enable:

ALTER DATABASE ARCHIVELOG;

Open:

ALTER DATABASE OPEN;

For RAC, the operational procedure needs additional care because all instances must be handled appropriately.

Do not blindly execute the single-instance sequence on a production RAC system.

6. Verify ARCHIVELOG Again

SELECT name,
       log_mode
FROM v$database;

Expected:

NAME     LOG_MODE
-------- ----------
PRODDB   ARCHIVELOG

Then:

ARCHIVE LOG LIST;

You should see information such as:

Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            ...
Oldest online log sequence     ...
Next log sequence to archive   ...
Current log sequence           ...

7. FORCE LOGGING

This is one of the most important Data Guard preparation steps.

Check:

SELECT force_logging
FROM v$database;

You want:

FORCE_LOGGING
------------
YES

8. Why FORCE LOGGING?

Normally Oracle generates redo for database changes.

But certain operations can be performed with reduced or minimal logging.

For Data Guard, that can create a serious problem.

Imagine:

PRIMARY
   |
   | Some operation generates insufficient redo
   |
   X
   |
STANDBY

The standby may not be able to reproduce the primary’s changes correctly.

FORCE LOGGING ensures database operations generate redo even when an operation would otherwise use minimal logging.

9. Enable FORCE LOGGING

If appropriate for your production environment:

ALTER DATABASE FORCE LOGGING;

Then verify:

SELECT force_logging
FROM v$database;

Expected:

YES

10. FORCE LOGGING Is Not Free

This is important from a performance perspective.

Force logging can increase:

Redo generation
+
I/O
+
Potential primary workload

Therefore don’t simply enable it without understanding your workload.

But for a Data Guard production architecture, it is generally an important protection mechanism.

11. Check Supplemental Logging

For a physical standby, supplemental logging requirements differ from those of logical replication technologies.

Still, you should understand what is configured:

SELECT supplemental_log_data_min,
       supplemental_log_data_pk,
       supplemental_log_data_ui,
       supplemental_log_data_fk,
       supplemental_log_data_all
FROM v$database;

For our physical standby implementation, don’t confuse this with the requirements of a logical standby or GoldenGate.

This distinction matters at expert level.

12. DB_UNIQUE_NAME

Check:

SHOW PARAMETER db_unique_name;

Example:

NAME             TYPE       VALUE
---------------- ---------- --------
db_unique_name   string     PRODDB

Our target architecture:

Primary:
PRODDB

Standby:
PRODDB_DR

Both share:

DB_NAME = PRODDB

but have unique:

DB_UNIQUE_NAME

13. LOG_ARCHIVE_CONFIG

This parameter tells Oracle which databases participate in the Data Guard configuration.

Example:

ALTER SYSTEM SET LOG_ARCHIVE_CONFIG=
'DG_CONFIG=(PRODDB,PRODDB_DR)'
SCOPE=BOTH SID='*';

In RAC:

SID='*'

is important because you want the parameter consistently configured across instances.

Verify:

SHOW PARAMETER log_archive_config;

14. Why SID='*' in RAC?

Suppose:

RAC1
RAC2

If you configure only one instance:

RAC1 → correct
RAC2 → different

you can end up with inconsistent Data Guard behavior.

For cluster-wide parameters, use:

SCOPE=BOTH SID='*'

when appropriate.

This is a recurring RAC administration principle.

15. Configure LOG_ARCHIVE_DEST_2

This is where we define the standby destination.

A simplified example:

ALTER SYSTEM SET LOG_ARCHIVE_DEST_2=
' SERVICE=PRODDB_DR
  ASYNC
  VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
  DB_UNIQUE_NAME=PRODDB_DR'
SCOPE=BOTH SID='*';

Notice the important components:

SERVICE=
ASYNC
VALID_FOR=
DB_UNIQUE_NAME=

We’ll dissect each one.

16. SERVICE

SERVICE=PRODDB_DR

This normally references an Oracle Net service name configured in:

tnsnames.ora

Example:

PRODDB_DR =
  (DESCRIPTION =
    (ADDRESS =
      (PROTOCOL = TCP)
      (HOST = dr-scan.example.com)
      (PORT = 1521)
    )
    (CONNECT_DATA =
      (SERVICE_NAME = PRODDB)
    )
  )

The exact service architecture depends on whether the standby is single-instance or RAC.

17. Why Use a Service?

Instead of hardcoding every network detail into the database parameter, Oracle uses:

SERVICE
   ↓
Oracle Net
   ↓
Listener
   ↓
Standby database

This makes the architecture easier to maintain.

18. ASYNC

Our example uses:

ASYNC

meaning asynchronous redo transport.

We’ll later build separate labs for:

ASYNC
SYNC
AFFIRM
NOAFFIRM

and protection modes.

For now, we’re building a practical baseline.

19. VALID_FOR

This clause is extremely important:

VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)

It tells Oracle when this archive destination should be used.

In this case:

ONLINE_LOGFILES
+
PRIMARY_ROLE

means the destination is intended for online redo logs while the database is in the primary role.

This becomes particularly useful when designing configurations that must continue working correctly after role transitions.

20. DB_UNIQUE_NAME

The destination:

DB_UNIQUE_NAME=PRODDB_DR

must match the standby’s actual:

SHOW PARAMETER db_unique_name;

If the names don’t match, you’ll have configuration problems.

21. Check LOG_ARCHIVE_DEST_2

SELECT dest_id,
       status,
       target,
       destination,
       db_unique_name,
       valid_role,
       valid_type,
       error
FROM v$archive_dest
WHERE dest_id = 2;

Example:

DEST_ID STATUS TARGET   DB_UNIQUE_NAME
------- ------ -------- --------------
2       VALID  STANDBY  PRODDB_DR

22. LOG_ARCHIVE_DEST_STATE_2

Make sure the destination is enabled:

SHOW PARAMETER log_archive_dest_state_2;

Expected:

log_archive_dest_state_2 = ENABLE

If needed:

ALTER SYSTEM SET
log_archive_dest_state_2=ENABLE
SCOPE=BOTH SID='*';

23. Important: Don’t Enable It Too Early

This is an operational point.

If:

PRODDB_DR

doesn’t exist yet, enabling a destination that points to it may generate errors.

During a real implementation, you can stage the configuration carefully and enable transport once the standby listener/service and database are ready.

The exact order matters.

24. Password File

Data Guard uses Oracle Net authentication between primary and standby.

Therefore the password file is important.

Check:

SHOW PARAMETER remote_login_passwordfile;

Typical configuration:

EXCLUSIVE

For RAC:

password file

must be available consistently to the instances according to the cluster/storage architecture.

With ASM-managed password files, the file may reside in ASM rather than the local filesystem.

25. Why Password File Matters

Imagine:

PRIMARY
   |
   | SYS authentication
   |
   v
STANDBY

If the authentication configuration is incorrect, Data Guard transport or administrative operations can fail.

You may encounter errors related to:

ORA-01031
ORA-16191

among others, depending on the exact failure.

26. Oracle Net Connectivity

Before Data Guard configuration, test connectivity.

From the primary:

tnsping PRODDB_DR

Then:

sqlplus sys@PRODDB_DR as sysdba

Do not just test:

ping

A successful ICMP ping proves almost nothing about Oracle Net connectivity.

27. Test the Listener

From the primary:

tnsping PRODDB_DR

If available:

lsnrctl status

on the standby server.

For RAC environments, use the appropriate SCAN/listener/service architecture rather than relying on a single node address.

28. Test SYSDBA Connectivity

A real Data Guard pre-check should verify:

sqlplus sys@PRODDB_DR as sysdba

If this fails, stop here.

Don’t start building the standby until the Oracle Net and authentication path is understood.

29. FAL Parameters

You will frequently encounter:

FAL_SERVER
FAL_CLIENT

Historically, these parameters have been used to help a standby resolve archive gaps.

However, modern 19c Data Guard configurations—especially when managed with Broker—should not blindly copy old configuration recipes.

We’ll discuss archive gap resolution in detail later.

For now, understand the concept:

Standby
   |
   | "I'm missing redo"
   |
   v
Primary / FAL source

30. STANDBY_FILE_MANAGEMENT

This parameter is extremely useful.

Check:

SHOW PARAMETER standby_file_management;

Recommended for many physical standby configurations:

AUTO

Configure:

ALTER SYSTEM SET standby_file_management='AUTO' SCOPE=BOTH SID='*';

31. Why AUTO?

Suppose you create a new datafile on the primary:

ALTER TABLESPACE USERS ADD DATAFILE '+DATA' SIZE 10G;

With appropriate standby configuration:

PRIMARY
   |
   | Redo
   v
STANDBY
   |
   +---- New datafile created automatically

This dramatically simplifies administration.

Without it, you may have to manually create corresponding files on the standby.

32. Important Caveat

STANDBY_FILE_MANAGEMENT=AUTO does not mean:

“Everything is automatically handled.”

You still need to understand:

  • ASM
  • file naming
  • OMF
  • storage capacity
  • filesystem paths
  • role transitions
  • unusual file operations

Automation is useful only when the underlying architecture is correct.

33. DB_FILE_NAME_CONVERT

Historically, administrators often configured:

DB_FILE_NAME_CONVERT

when primary and standby datafile paths differ.

For example:

PRIMARY:
/u02/oradata/PRODDB/

STANDBY:
/u03/oradata/PRODDB/

Then:

DB_FILE_NAME_CONVERT

maps one path to another.

However, with modern Oracle environments using ASM/OMF and appropriate storage architecture, you may not need this parameter.

Don’t configure it automatically just because an old tutorial says so.

34. LOG_FILE_NAME_CONVERT

The same principle applies to:

LOG_FILE_NAME_CONVERT

It can map redo log paths between primary and standby.

But with ASM and modern storage architectures, it is often unnecessary.

The expert question isn’t:

“What parameters did the old Data Guard tutorial configure?”

It is:

“Does my storage architecture require these parameters?”

35. OMF + ASM

For our Masterclass architecture, we’ll favor:

ASM
+
OMF

because it simplifies storage management.

For example:

+DATA
+RECO

instead of manually maintaining:

/u01/oradata/PRODDB/
/u02/oradata/PRODDB/

This is especially useful in RAC/Data Guard environments.

36. Check OMF

SHOW PARAMETER db_create_file_dest;

Example:

db_create_file_dest = +DATA

Also:

SHOW PARAMETER db_recovery_file_dest;

Example:

db_recovery_file_dest = +RECO

37. FRA Configuration

Check:

SELECT name,
       space_limit,
       space_used,
       space_reclaimable
FROM v$recovery_file_dest;

The standby also needs adequate space for:

Archived redo
Flashback logs
Backups
Other recovery-related files

Don’t size the standby FRA based only on the current primary FRA usage.

38. Redo Generation Baseline

Before creating a standby, measure how much redo the primary generates.

For example:

SELECT thread#,
       TRUNC(first_time) day,
       ROUND(SUM(blocks * block_size) / 1024 / 1024 / 1024, 2) redo_gb
FROM v$archived_log
WHERE first_time >= SYSDATE - 7
GROUP BY thread#, TRUNC(first_time)
ORDER BY day, thread#;

This gives you a rough picture of daily redo volume.

39. Why Measure Redo?

Suppose:

Database size = 15 TB

but:

Redo generation = 1 TB/day

Your network and standby storage must handle the redo workload.

For example:

1 TB/day
≈ 11.9 MB/s average

But averages can be misleading.

You may have:

Normal:
10 MB/s

Peak:
150 MB/s

The standby architecture must survive the peaks.

40. Measure Peak Redo

A useful starting query:

SELECT TRUNC(first_time, 'HH24') hour,
       ROUND(
         SUM(blocks * block_size) / 1024 / 1024 / 1024,
         2
       ) redo_gb
FROM v$archived_log
WHERE first_time >= SYSDATE - 24/24
GROUP BY TRUNC(first_time, 'HH24')
ORDER BY hour;

This helps identify high-redo periods.

41. Check Redo Log Configuration

For RAC:

SELECT thread#,
       group#,
       bytes/1024/1024 AS size_mb,
       members,
       status
FROM gv$log
ORDER BY thread#, group#;

You want reasonably sized redo logs.

Tiny redo logs can cause:

Frequent log switches
+
More archive operations
+
More Data Guard transport events

42. Check Log Switch Frequency

SELECT thread#,
       TRUNC(first_time) day,
       COUNT(*) log_switches
FROM gv$log_history
WHERE first_time >= SYSDATE - 7
GROUP BY thread#, TRUNC(first_time)
ORDER BY day, thread#;

If you have thousands of switches per day, investigate redo sizing.

43. Check Current Archive Destinations

Before adding Data Guard:

SELECT dest_id,
       status,
       target,
       destination,
       db_unique_name,
       error
FROM v$archive_dest
WHERE status <> 'INACTIVE'
ORDER BY dest_id;

You may already have:

DEST 2 → FRA
DEST 3 → Backup
DEST 4 → Existing standby

Never assume LOG_ARCHIVE_DEST_2 is free.

44. Existing Data Guard Configuration

Before creating a new standby, check:

SELECT dest_id,
       status,
       target,
       destination,
       db_unique_name
FROM v$archive_dest
WHERE target = 'STANDBY';

You may discover that a standby already exists.

45. Check Data Guard Parameters

A useful pre-check:

SELECT name,
       value
FROM v$parameter
WHERE name IN (
    'db_name',
    'db_unique_name',
    'log_archive_config',
    'log_archive_dest_1',
    'log_archive_dest_2',
    'log_archive_dest_state_1',
    'log_archive_dest_state_2',
    'standby_file_management',
    'remote_login_passwordfile'
)
ORDER BY name;

Save this output.

It becomes your baseline.

46. RAC Configuration Rule

For a RAC primary:

SID='*'

is frequently important for cluster-wide parameters.

For example:

ALTER SYSTEM SET
log_archive_config='DG_CONFIG=(PRODDB,PRODDB_DR)'
SCOPE=BOTH SID='*';

Don’t configure one RAC instance and assume the other instance inherited the setting.

Always verify:

SELECT inst_id,
       name,
       value
FROM gv$parameter
WHERE name = 'log_archive_config';

47. Verify Across RAC

For example:

SELECT inst_id,
       value
FROM gv$parameter
WHERE name = 'standby_file_management';

You want:

INST_ID VALUE
------- ------
1       AUTO
2       AUTO

If you get:

1       AUTO
2       MANUAL

you have a configuration inconsistency.

48. Pre-Check: Database Size

SELECT ROUND(SUM(bytes)/1024/1024/1024,2) AS database_size_gb
FROM dba_data_files;

Also:

SELECT ROUND(SUM(bytes)/1024/1024/1024,2) AS temp_size_gb
FROM dba_temp_files;

And:

SELECT tablespace_name,
       ROUND(SUM(bytes)/1024/1024/1024,2) size_gb
FROM dba_data_files
GROUP BY tablespace_name
ORDER BY size_gb DESC;

This information will be used when sizing the standby.

49. Don’t Forget LOBs

If your database contains large LOB segments:

SELECT owner,
       segment_name,
       segment_type,
       ROUND(bytes/1024/1024/1024,2) size_gb
FROM dba_segments
WHERE segment_type LIKE 'LOB%'
ORDER BY bytes DESC
FETCH FIRST 20 ROWS ONLY;

This isn’t directly a Data Guard parameter issue, but it helps you understand:

Storage requirement
+
Backup duration
+
Recovery duration
+
Standby build time

50. Check ASM Capacity

On an ASM environment:

SELECT name,
       total_mb,
       free_mb,
       usable_file_mb
FROM v$asm_diskgroup
ORDER BY name;

Example:

NAME    TOTAL_MB   FREE_MB   USABLE_FILE_MB
------- ---------- --------- ---------------
DATA    1000000    250000    245000
RECO    500000     180000    175000

The standby needs sufficient capacity for the database and recovery workload.

51. Primary Pre-Implementation Checklist

Before proceeding to standby creation, we should have:

✓ ARCHIVELOG enabled
✓ FORCE LOGGING enabled
✓ DB_UNIQUE_NAME defined
✓ LOG_ARCHIVE_CONFIG planned
✓ LOG_ARCHIVE_DEST_n planned
✓ Oracle Net connectivity planned
✓ Password file available
✓ STANDBY_FILE_MANAGEMENT planned
✓ ASM capacity checked
✓ Database size measured
✓ Redo generation measured
✓ RAC threads identified
✓ Redo logs analyzed
✓ FRA analyzed

52. Practical Configuration Example

Assume:

Primary:
DB_NAME       = PRODDB
DB_UNIQUE_NAME = PRODDB

Standby:
DB_NAME       = PRODDB
DB_UNIQUE_NAME = PRODDB_DR

Primary SCAN:
prod-scan.example.com

Standby SCAN:
prod-dr-scan.example.com

On primary:

ALTER DATABASE FORCE LOGGING;

Then:

ALTER SYSTEM SET
log_archive_config='DG_CONFIG=(PRODDB,PRODDB_DR)'
SCOPE=BOTH SID='*';

Then a planned destination:

ALTER SYSTEM SET
log_archive_dest_2=
'SERVICE=PRODDB_DR
 ASYNC
 VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
 DB_UNIQUE_NAME=PRODDB_DR'
SCOPE=BOTH SID='*';

And:

ALTER SYSTEM SET
standby_file_management='AUTO'
SCOPE=BOTH SID='*';

Do not execute the LOG_ARCHIVE_DEST_2 example until the standby service and Oracle Net connectivity are ready.

53. Verify Everything

SELECT name,
       db_unique_name,
       database_role,
       open_mode,
       log_mode,
       force_logging,
       protection_mode,
       protection_level
FROM v$database;

Then:

SELECT inst_id,
       name,
       value
FROM gv$parameter
WHERE name IN (
    'db_unique_name',
    'log_archive_config',
    'standby_file_management',
    'remote_login_passwordfile'
)
ORDER BY name, inst_id;

Then:

SELECT dest_id,
       status,
       target,
       destination,
       db_unique_name,
       error
FROM v$archive_dest
WHERE status <> 'INACTIVE';

54. What We Have Achieved

At this point, the primary should conceptually look like:

              PRIMARY RAC
                   |
          +--------+--------+
          |                 |
        RAC1              RAC2
       THREAD 1          THREAD 2
          |                 |
          +--------+--------+
                   |
             FORCE LOGGING
                   |
              ARCHIVELOG
                   |
             REDO TRANSPORT
                   |
                   v
              PRODDB_DR

The primary is now prepared to participate in Data Guard.

55. Expert-Level Scenario

Imagine you configure:

LOG_ARCHIVE_CONFIG =
DG_CONFIG=(PRODDB,PRODDB_DR)

on RAC1 only.

RAC2 still has the old value.

What happens?

Potentially inconsistent Data Guard behavior between RAC instances.

The correct approach is to verify cluster-wide configuration:

SELECT inst_id,
       value
FROM gv$parameter
WHERE name = 'log_archive_config';

The important lesson:

In RAC, configuration consistency is part of Data Guard reliability.

56. Another Expert Scenario

You have:

FORCE_LOGGING = NO

but Data Guard is already configured.

Should you immediately enable:

ALTER DATABASE FORCE LOGGING;

You should first consider:

  • Current workload
  • Minimal logging operations
  • Redo generation
  • Storage throughput
  • Business RPO
  • Standby requirements

Then implement during an appropriate change window if required.

The expert doesn’t blindly execute commands; the expert understands the operational consequence.

57. Part 2 Summary

We have now prepared the primary side conceptually.

The most important parameters to remember are:

DB_UNIQUE_NAME
LOG_ARCHIVE_CONFIG
LOG_ARCHIVE_DEST_n
LOG_ARCHIVE_DEST_STATE_n
STANDBY_FILE_MANAGEMENT
REMOTE_LOGIN_PASSWORDFILE

And the two critical database properties:

ARCHIVELOG
FORCE LOGGING
Bookmark the permalink.
Loading Facebook Comments ...

Leave a Reply