Objective
In this part, we will create:
PRIMARY
PRODDB / RAC
|
|
Oracle Net
|
v
RMAN DUPLICATE
|
v
+---------------------+
| PHYSICAL STANDBY |
| |
| DB_NAME=PRODDB |
| DB_UNIQUE_NAME= |
| PRODDB_DR |
+---------------------+
|
ASM
+DATA / +RECO
The key technology is:
RMAN DUPLICATE ... FOR STANDBY
We will start with the Active Database Duplicate method, then discuss the backup-based method.
1. The Architecture
For this masterclass, let’s use:
PRIMARY -------------------------------- DB_NAME PRODDB DB_UNIQUE_NAME PRODDB Role PRIMARY RAC 2 nodes prod-rac01 prod-rac02
Standby:
STANDBY -------------------------------- DB_NAME PRODDB DB_UNIQUE_NAME PRODDB_DR Role PHYSICAL STANDBY RAC 2 nodes dr-rac01 dr-rac02
ASM:
+DATA +RECO
2. Very Important: DB_NAME vs DB_UNIQUE_NAME
This is one of the first things you must get right.
Primary:
DB_NAME = PRODDB DB_UNIQUE_NAME = PRODDB
Standby:
DB_NAME = PRODDB DB_UNIQUE_NAME = PRODDB_DR
So:
DB_NAME
|
+--------+--------+
| |
PRODDB PRODDB
PRIMARY STANDBY
DB_UNIQUE_NAME
|
+--------+--------+
| |
PRODDB PRODDB_DR
The physical standby has the same DB_NAME, but a different DB_UNIQUE_NAME.
3. Before RMAN — Primary Check
Connect to the primary:
sqlplus / as sysdba
Run:
SELECT name,
db_unique_name,
database_role,
open_mode,
log_mode,
force_logging
FROM v$database;
Expected:
NAME DB_UNIQUE_NAME DATABASE_ROLE OPEN_MODE LOG_MODE FORCE_LOGGING -------- -------------- ------------- ---------- ---------- ------------- PRODDB PRODDB PRIMARY READ WRITE ARCHIVELOG YES
If you don’t have:
ARCHIVELOG
and:
FORCE_LOGGING = YES
stop and correct Part 2 first.
4. Check the RAC Threads
Because our primary is RAC:
SELECT thread#,
instance,
status,
enabled
FROM v$thread
ORDER BY thread#;
Example:
THREAD# INSTANCE STATUS ENABLED ------- -------- ------ ------- 1 PROD1 OPEN PUBLIC 2 PROD2 OPEN PUBLIC
This is important because later we’ll need standby redo logs for each thread.
5. Check Primary Redo Logs
SELECT thread#,
group#,
bytes/1024/1024 AS size_mb,
members,
status
FROM gv$log
ORDER BY thread#, group#;
Example:
THREAD# GROUP# SIZE_MB MEMBERS STATUS ------- ------ ------- ------- -------- 1 1 4096 2 CURRENT 1 2 4096 2 INACTIVE 1 3 4096 2 INACTIVE 2 4 4096 2 CURRENT 2 5 4096 2 INACTIVE 2 6 4096 2 INACTIVE
We will use this information in Part 5.
6. Check the Primary Archive Configuration
SELECT dest_id,
status,
target,
destination,
db_unique_name,
valid_role,
error
FROM v$archive_dest
WHERE status <> 'INACTIVE'
ORDER BY dest_id;
At this point, if the standby isn’t ready yet, you may keep the Data Guard destination disabled:
ALTER SYSTEM SET log_archive_dest_state_2=DEFER SCOPE=BOTH SID='*';
This avoids repeatedly generating transport errors while we’re building the standby.
Later:
ALTER SYSTEM SET log_archive_dest_state_2=ENABLE SCOPE=BOTH SID='*';
7. Standby: Verify ASM
On the standby:
sqlplus / as sysasm
Run:
SELECT name,
state,
type,
total_mb,
free_mb,
usable_file_mb
FROM v$asm_diskgroup
ORDER BY name;
Expected:
NAME STATE TYPE TOTAL_MB FREE_MB ------ -------- ------- ---------- -------- DATA MOUNTED NORMAL ... RECO MOUNTED NORMAL ...
8. Standby: Start the Instance NOMOUNT
On the standby:
export ORACLE_SID=PRODDB export ORACLE_HOME=/u01/app/oracle/product/19.0.0/dbhome_1 export PATH=$ORACLE_HOME/bin:$PATH
Then:
sqlplus / as sysdba
Start:
STARTUP NOMOUNT;
If successful:
ORACLE instance started.
You should not expect the database to be mounted.
Check:
SELECT status FROM v$instance;
Expected:
STATUS ------------ STARTED
9. Why NOMOUNT?
RMAN needs an Oracle instance running on the auxiliary server.
At this stage:
Instance | +-- Memory +-- Background processes +-- SPFILE/PFILE | X No control file No datafiles
That’s exactly what we want.
RMAN will create the database structure.
10. Standby Initialization Parameters
A minimal PFILE might look like:
db_name='PRODDB' db_unique_name='PRODDB_DR' remote_login_passwordfile='EXCLUSIVE' standby_file_management='AUTO' db_create_file_dest='+DATA' db_recovery_file_dest='+RECO' db_recovery_file_dest_size='2T'
You can create:
$ORACLE_HOME/dbs/initPRODDB.ora
with these parameters.
The exact sizing and parameters should match your environment.
11. Start Using the PFILE
If you created the PFILE:
STARTUP NOMOUNT PFILE='$ORACLE_HOME/dbs/initPRODDB.ora';
Verify:
SHOW PARAMETER db_name; SHOW PARAMETER db_unique_name;
Expected:
db_name -------- PRODDB db_unique_name -------------- PRODDB_DR
12. Oracle Net — The Critical Test
Before RMAN, test the connection from the primary:
tnsping PRODDB_DR
Then:
sqlplus sys@PRODDB_DR as sysdba
From standby:
tnsping PRODDB
Then:
sqlplus sys@PRODDB as sysdba
If either direction fails, don’t proceed.
13. RMAN Target/Auxiliary Connection
From the standby server:
rman target sys@PRODDB auxiliary sys@PRODDB_DR
You should get something similar to:
connected to target database: PRODDB connected to auxiliary database: PRODDB
Notice that both connections may display:
PRODDB
because DB_NAME is the same.
The distinction is:
TARGET
DB_UNIQUE_NAME = PRODDB
AUXILIARY
DB_UNIQUE_NAME = PRODDB_DR
14. Verify RMAN
Inside RMAN:
SHOW ALL;
Then:
LIST BACKUP SUMMARY;
We are simply verifying that RMAN can communicate with the primary.
Exit:
EXIT;
15. Active Database Duplicate
Now we reach the main command.
DUPLICATE TARGET DATABASE FOR STANDBY FROM ACTIVE DATABASE DORECOVER;
This tells RMAN:
Use primary as source
|
v
Copy database over Oracle Net
|
v
Create physical standby
|
v
Recover standby
16. But We Need the SPFILE
In production, we generally want RMAN to create the standby SPFILE as part of the duplicate.
For example:
DUPLICATE TARGET DATABASE FOR STANDBY FROM ACTIVE DATABASE DORECOVER SPFILE SET db_unique_name='PRODDB_DR' SET standby_file_management='AUTO' SET log_archive_config='DG_CONFIG=(PRODDB,PRODDB_DR)' SET db_create_file_dest='+DATA' SET db_recovery_file_dest='+RECO';
This is a much more complete example.
17. Important Correction for RAC
If the primary is RAC, don’t blindly configure:
cluster_database=FALSE
or:
cluster_database=TRUE
without considering the standby build stage.
A common strategy is:
Create standby
↓
Build database
↓
Configure Grid/RAC
↓
Register database with srvctl
↓
Enable RAC instances
We’ll handle the RAC conversion/configuration carefully.
18. File Naming with ASM
Because our standby uses ASM and OMF:
+DATA +RECO
we want Oracle/RMAN to create files there.
The SPFILE can specify:
db_create_file_dest='+DATA'
and:
db_recovery_file_dest='+RECO'
This avoids unnecessarily complicated:
DB_FILE_NAME_CONVERT
configuration.
19. Should We Use NOFILENAMECHECK?
For separate standby storage, you may see:
NOFILENAMECHECK
in many examples.
For example:
DUPLICATE TARGET DATABASE FOR STANDBY FROM ACTIVE DATABASE DORECOVER NOFILENAMECHECK;
But don’t add it automatically.
The purpose is to tell RMAN not to reject identical file names.
If the primary and standby accidentally share the same underlying storage, that can be dangerous.
With ASM, the storage isolation architecture must be understood first.
20. RMAN Progress
During the duplicate, you’ll see RMAN performing operations similar to:
Starting Duplicate Db
then:
contents of Memory Script:
{
backup as copy ...
}
and:
channel ORA_AUX_DISK_1 channel ORA_AUX_DISK_2
You may also see:
Starting backup at ...
and:
Finished backup at ...
This can take hours for a multi-terabyte database.
21. Monitor RMAN From Another Session
Don’t sit staring at the RMAN screen.
From another session:
sqlplus / as sysdba
Check:
SELECT sid,
serial#,
opname,
sofar,
totalwork,
ROUND(sofar/NULLIF(totalwork,0)*100,2) pct_complete
FROM v$session_longops
WHERE opname LIKE '%RMAN%'
AND totalwork > 0
AND sofar < totalwork
ORDER BY start_time;
This can provide useful progress information.
22. Monitor Sessions
You can also check:
SELECT sid,
serial#,
program,
module,
status
FROM v$session
WHERE program LIKE '%rman%'
OR module LIKE '%RMAN%';
This helps identify active RMAN work.
23. Monitor ASM
While the duplicate is running:
SELECT name,
total_mb,
free_mb,
usable_file_mb
FROM v$asm_diskgroup;
You should see:
FREE_MB
decreasing as the database is copied.
Don’t allow the ASM disk group to run out of space during the duplicate.
24. Monitor Network
At OS level:
sar -n DEV 1 10
or:
iostat -xz 1
and, if available:
iftop
or:
nload
The objective is to understand whether the bottleneck is:
CPU Network Source storage Target storage RMAN channels
25. Active Duplicate Performance
The overall speed is approximately constrained by the slowest component:
Primary read
↓
RMAN processing
↓
Network
↓
RMAN receive
↓
Standby ASM write
If:
Primary storage = 2 GB/s Network = 10 Gb/s ≈ 1.25 GB/s Standby storage = 800 MB/s
your effective throughput will be closer to the weakest relevant stage.
26. Compression
RMAN network compression can sometimes help when:
Network is the bottleneck + CPU has capacity
For example, depending on your Oracle licensing/configuration and environment:
CONFIGURE COMPRESSION ALGORITHM 'BASIC';
But don’t assume compression always improves performance.
If:
CPU = saturated Network = very fast
compression can make the duplicate slower.
27. Encryption
If Oracle Net encryption is already configured—as we discussed earlier in your Oracle security series—you must account for the CPU cost of encryption during large RMAN transfers.
The architecture becomes:
Primary | | RMAN | Encryption v Network | | Decryption v Standby
For multi-terabyte duplication, measure the impact.
28. RMAN Channels
For a larger database, you may use multiple channels.
Example:
RUN {
ALLOCATE CHANNEL c1 DEVICE TYPE DISK;
ALLOCATE CHANNEL c2 DEVICE TYPE DISK;
ALLOCATE CHANNEL c3 DEVICE TYPE DISK;
ALLOCATE CHANNEL c4 DEVICE TYPE DISK;
DUPLICATE TARGET DATABASE
FOR STANDBY
FROM ACTIVE DATABASE
DORECOVER;
RELEASE CHANNEL c1;
RELEASE CHANNEL c2;
RELEASE CHANNEL c3;
RELEASE CHANNEL c4;
}
Don’t automatically use 32 or 64 channels.
Start with a controlled number and benchmark.
29. After RMAN Completes
Check:
SELECT name,
db_unique_name,
database_role,
open_mode
FROM v$database;
Expected:
NAME DB_UNIQUE_NAME DATABASE_ROLE -------- -------------- ---------------- PRODDB PRODDB_DR PHYSICAL STANDBY
The standby will normally be mounted.
30. Check Datafiles
SELECT file#,
name,
status,
enabled
FROM v$datafile
ORDER BY file#;
You should see the complete set of datafiles.
Also:
SELECT COUNT(*) AS datafiles FROM v$datafile;
Compare with primary:
SELECT COUNT(*) AS datafiles FROM v$datafile;
The counts should make sense for your environment.
31. Check Tempfiles
SELECT file#,
name,
bytes/1024/1024/1024 size_gb
FROM v$tempfile;
Remember that tempfile handling differs from permanent datafiles in Data Guard.
Don’t assume the standby’s tempfile configuration must be identical in every detail.
32. Check Control Files
SHOW PARAMETER control_files;
For ASM you might see:
+DATA/PRODDB_DR/CONTROLFILE/current.... +RECO/PRODDB_DR/CONTROLFILE/current....
This gives us redundancy across disk groups.
33. Check SPFILE
SHOW PARAMETER spfile;
You may see:
+DATA/PRODDB_DR/PARAMETERFILE/spfile....
This confirms that the standby configuration is using the expected SPFILE.
34. Check Standby Role
This is the most important validation:
SELECT database_role,
open_mode,
protection_mode,
protection_level
FROM v$database;
Expected:
DATABASE_ROLE PHYSICAL STANDBY OPEN_MODE MOUNTED
Don’t expect:
READ WRITE
at this stage.
35. Why MOUNTED?
A physical standby is typically mounted while redo apply is running:
PRIMARY | | Redo v STANDBY | | MOUNT v Recovery processes | v Datafiles
Later, if Active Data Guard is licensed and configured, you can open it:
READ ONLY
while applying redo.
36. Start Redo Apply
For a traditional SQL-managed configuration:
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
For real-time apply, once standby redo logs are configured:
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
However, for the Masterclass, we’ll deliberately postpone the final real-time apply configuration until Part 5, where we properly create and validate the standby redo logs.
37. Verify Recovery Process
On 19c:
SELECT name,
role,
action,
thread#,
sequence#
FROM v$dataguard_process
ORDER BY name;
This is preferable to relying exclusively on older monitoring queries.
You can also inspect:
SELECT process,
status,
thread#,
sequence#
FROM v$managed_standby;
depending on the exact monitoring scenario.
38. Check Transport
On primary:
SELECT dest_id,
status,
target,
destination,
db_unique_name,
error
FROM v$archive_dest
WHERE target='STANDBY';
You want:
STATUS = VALID ERROR = NULL
39. Generate Test Redo
On primary:
ALTER SYSTEM SWITCH LOGFILE;
For RAC, perform controlled testing per instance/thread where appropriate.
Then:
SELECT thread#,
sequence#,
first_time
FROM v$log_history
ORDER BY first_time DESC
FETCH FIRST 10 ROWS ONLY;
40. Check Standby Reception
On standby:
SELECT thread#,
sequence#,
applied,
first_time
FROM v$archived_log
ORDER BY first_time DESC
FETCH FIRST 20 ROWS ONLY;
You should see redo arriving.
But remember:
RECEIVED
doesn’t necessarily mean:
APPLIED
Those are two different stages.
41. Measure Transport and Apply Lag
Run on standby:
SELECT name,
value,
unit
FROM v$dataguard_stats
WHERE name IN (
'transport lag',
'apply lag',
'apply finish time'
);
Example:
NAME VALUE ---------------- ---------------- transport lag +00 00:00:00 apply lag +00 00:00:02
This is our first real Data Guard health measurement.
42. Backup-Based Duplicate
Active duplicate isn’t the only method.
The alternative:
PRIMARY | | RMAN BACKUP v BACKUP STORAGE | | Transfer v STANDBY | | RMAN RESTORE v PHYSICAL STANDBY
This is often attractive for very large databases.
43. Why Use Backup-Based Creation?
Imagine:
Database = 30 TB
and the primary-to-DR link is:
1 Gbps
An active duplicate could take a very long time.
Instead:
Primary | | High-speed local backup v Backup infrastructure | | Physical transfer v DR
may be much faster.
44. Backup-Based Workflow
On primary:
BACKUP DATABASE PLUS ARCHIVELOG;
Then transfer the backup pieces to the standby.
On standby:
CATALOG START WITH '/backup/proddb/';
Then:
RESTORE DATABASE;
followed by recovery and Data Guard configuration.
The exact commands depend on your backup architecture.
45. Active vs Backup-Based
| Feature | Active Duplicate | Backup-Based |
|---|---|---|
| Backup staging | Not required | Required |
| Network from primary | High | Lower during restore |
| Build simplicity | High | Medium |
| Large DB | Can be challenging | Often attractive |
| Existing backup infra | Less important | Very useful |
| Primary impact | Potentially higher | Can be controlled |
| DR over slow WAN | Less attractive | Often better |
There isn’t one universal winner.
46. Expert Design Decision
Ask:
How large is the database? How much redo is generated? What is the WAN bandwidth? What is the latency? What is the backup infrastructure? How much production impact is acceptable? What is the RTO?
Then choose the build method.
47. RMAN Duplicate Failure — First Diagnostic Step
If RMAN fails, don’t immediately rerun the whole operation.
First examine:
RMAN output alert.log listener.log ASM alerts network connectivity
On the standby:
tail -100 $ORACLE_BASE/diag/rdbms/proddb_dr/PRODDB/trace/alert_PRODDB.log
The actual diagnostic path depends on your ORACLE_BASE and DB_UNIQUE_NAME.
48. Check Alert Log
A very useful command:
adrci
Then:
show alert -tail 100
During a Data Guard build, the alert log can reveal:
ORA- errors ASM errors control file issues redo issues authentication failures
49. Common Error: ORA-12514
Example:
ORA-12514: TNS:listener does not currently know of service requested
Check:
lsnrctl status
Then verify:
SERVICE_NAME GLOBAL_DBNAME SID ORACLE_HOME
The service name in your tnsnames.ora must correspond to something the listener can actually resolve.
50. Common Error: ORA-01017
ORA-01017: invalid username/password
Check:
SYS password Password file REMOTE_LOGIN_PASSWORDFILE Oracle Net connection
For Data Guard, password-file consistency is fundamental.
51. Common Error: ORA-19504
If you see:
ORA-19504: failed to create file
investigate:
ASM disk group Storage capacity Permissions OMF configuration File naming
Check:
SELECT name,
free_mb,
usable_file_mb
FROM v$asm_diskgroup;
52. Common Error: ORA-19809
If FRA is full:
ORA-19809: limit exceeded for recovery files
Check:
SELECT name,
space_limit,
space_used,
space_reclaimable
FROM v$recovery_file_dest;
Increase the FRA or clean up according to your backup/recovery policy.
Don’t simply delete files manually from the FRA.
53. Verify the Database Identity
After duplication:
SELECT
name,
dbid,
db_unique_name,
database_role,
open_mode
FROM v$database;
The DBID should correspond to the primary because the physical standby is a physical copy of the same database.
You should see:
NAME DB_UNIQUE_NAME DATABASE_ROLE -------- -------------- ------------------- PRODDB PRODDB_DR PHYSICAL STANDBY
54. The Important Mental Model
At the end of Part 4, understand this:
RMAN | +--- connects to PRIMARY | +--- connects to AUXILIARY | +--- creates standby control file | +--- transfers database blocks | +--- creates standby datafiles | +--- configures standby | +--- performs recovery | v PHYSICAL STANDBY
RMAN creates the database.
Data Guard subsequently keeps it synchronized.
Those are related but distinct responsibilities.
55. Part 4 Final Checklist
Before declaring the standby build successful:
✓ RMAN target connection works ✓ RMAN auxiliary connection works ✓ Standby starts NOMOUNT ✓ DB_NAME matches primary ✓ DB_UNIQUE_NAME is unique ✓ ASM +DATA available ✓ ASM +RECO available ✓ RMAN DUPLICATE completes ✓ Control files created ✓ Datafiles created ✓ SPFILE created ✓ DATABASE_ROLE = PHYSICAL STANDBY ✓ Standby mounted ✓ Redo transport works ✓ Redo reception verified ✓ Redo apply started ✓ Transport lag checked ✓ Apply lag checked


