Step‑by‑Step Manual Setup of Oracle Data Guard on RH Linux
This guide walks through preparing the primary and standby Oracle 11g databases on RH Linux, configuring listeners, tnsnames, force logging, adding standby redo logs, editing parameter files, transferring files with RMAN, verifying roles, activating Active Data Guard, using snapshot standby, switching logs, and setting an archive‑log deletion policy.
1. Environment Preparation
Operating system: Red Hat Linux; CPU 2, RAM 4 GB, 40 GB disk. Database version 11.2.0.4. Primary SID: BEIJING (single instance). Standby SID: GUOAN (single instance).
2. Primary Database Preparation
Edit listener.ora to configure a static listener:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = BEIJING)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0.4)
(SID_NAME = BEIJING)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = bill02)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /u01/app/oracleEdit tnsnames.ora for the standby connection string:
GUOAN = (DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = bill01)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = GUOAN)
)
)Enable force logging: alter database force logging; Check archive mode; if not enabled, run: alter database archivelog; Verify shared server parameters are empty (optional).
Show current redo log groups: select group#, member from v$logfile; Add four standby redo logs (size 100 M each):
alter database add standby logfile '/u01/app/oracle/oradata/BEIJING/redo04.log' size 100M;
alter database add standby logfile '/u01/app/oracle/oradata/BEIJING/redo05.log' size 100M;
alter database add standby logfile '/u01/app/oracle/oradata/BEIJING/redo06.log' size 100M;
alter database add standby logfile '/u01/app/oracle/oradata/BEIJING/redo07.log' size 100M;Edit the initBEIJING.ora (pfile) with Data Guard parameters, e.g.:
DB_NAME=BEIJING
DB_UNIQUE_NAME=BEIJING
LOG_ARCHIVE_CONFIG='DG_CONFIG=(BEIJING,GUOAN)'
LOG_ARCHIVE_DEST_1='LOCATION=/home/oracle/flash' VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
LOG_ARCHIVE_DEST_2='SERVICE=GUOAN ASYNC' VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
LOG_ARCHIVE_MAX_PROCESSES=4
FAL_SERVER=GUOAN
DB_FILE_NAME_CONVERT='GUOAN','BEIJING'
LOG_FILE_NAME_CONVERT='GUOAN','BEIJING'
STANDBY_FILE_MANAGEMENT=AUTOCopy the edited parameter file and password file to the standby server:
scp initBEIJING.ora oracle@bill01:/u01/app/oracle/product/11.2.0.4/dbs/initGUOAN.ora scp orapwBEIJING oracle@bill01:/u01/app/oracle/product/11.2.0.4/dbs/orapwGUOANCreate an SPFILE from the PFILE and start the primary instance:
create spfile from pfile; startup;3. Standby Database Preparation
Edit tnsnames.ora on the standby to point to the primary:
BEIJING = (DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = bill02)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = BEIJING)
)
)Edit the standby initGUOAN.ora (pfile) by swapping DB names:
db_name='BEIJING' -- keep same as primary for connection
DB_UNIQUE_NAME=GUOAN
LOG_ARCHIVE_CONFIG='DG_CONFIG=(GUOAN,BEIJING)'
LOG_ARCHIVE_DEST_1='LOCATION=/home/oracle/flash' VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
LOG_ARCHIVE_DEST_2='SERVICE=BEIJING ASYNC' VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
... (other parameters similar to primary) ...Create an SPFILE and start the standby (ignore the initial ORA‑00205 error about missing control file):
create spfile from pfile;
startup4. Transfer Primary Files to Standby
Use RMAN to duplicate the primary database to the standby:
rman target / auxiliary sys/oracle@guoan
RMAN> duplicate target database for standby from active database;The RMAN script copies the password file, control files, and all datafiles, then mounts the standby database.
5. Verify Primary and Standby Status
On the standby (mounted):
SQL> select database_role, open_mode from v$database;
-- Result: PHYSICAL STANDBY MOUNTED
SQL> select status from v$instance;
-- Result: MOUNTEDOn the primary (open):
SQL> select database_role, open_mode from v$database;
-- Result: PRIMARY READ WRITE
SQL> select status from v$instance;
-- Result: OPEN6. Activate Active Data Guard (ADG)
Apply redo logs on the standby in the background and open it read‑only:
SQL> recover managed standby database using current logfile disconnect from session;
SQL> alter database open;
SQL> select database_role, open_mode from v$database;
-- Result: PHYSICAL STANDBY READ ONLY WITH APPLY7. Use Snapshot Standby
Convert the standby to a snapshot (read‑write) for testing, then revert:
SQL> alter database convert to snapshot standby;
-- Perform testing on the snapshot standby
SQL> alter database convert to physical standby;
SQL> alter database recover managed standby database disconnect;8. Switch Primary Logs and Verify Propagation
Force a log switch on the primary and check the latest sequence on both sides:
SQL> alter system archive log current;
SQL> select sequence#, first_time, next_time from v$archived_log order by sequence#;
-- Primary shows latest sequence 15
SQL> select sequence#, first_time, next_time from v$archived_log order by sequence#;
-- Standby also shows sequence 15, confirming real‑time apply9. Set Archive Log Deletion Policy
Configure RMAN so that archived logs are deleted on the primary after they have been applied on all standby databases:
RMAN> CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY;After the change, show all confirms the new policy.
10. Summary
Manually building Oracle Data Guard provides transparent, step‑by‑step control, making debugging easier and the process reversible; graphical tools hide these details. The guide covers the essential configuration, file transfer, role verification, ADG activation, snapshot usage, log switching, and log‑deletion policy.
ITPUB
Official ITPUB account sharing technical insights, community news, and exciting events.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
