Step by Step DR - Data Guard Document
Step by Step DR - Data Guard Document
===================================================================
Machine setup
------------We have two servers (physical or VMs) with Linux OS and Oracle installed on t
hem. In this case I ve used Oracle Linux 5.5
and Oracle Database 11.2.0.1.0.
- The primary server has a running database instance.
- The standby server has a software only installation.
1. Primary Server Setup
=======================
- Logging:
Check that the primary database is in archivelog mode.
--sql> SELECT log_mode FROM v$database;
--LOG_MODE
---------ARCHIVELOG
--If it is noarchivelog mode, switch is to archivelog mode using sql.
sql>
sql>
sql>
sql>
---
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
ALTER DATABASE ARCHIVELOG;
ALTER DATABASE OPEN;
ORCL_STBY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.153.130)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
--5. Backup Primary Database
-------------------------- For a backup-based duplicate, or a manual restore, take a backup of the pri
mary database.
$ rman target=/
-RMAN> BACKUP DATABASE format '/u01/backup/full_bkp_%D_%s_%u' PLUS ARCHIVELOG
format '/u01/backup/arch_bkp_%D_%s_%u';
--6. Create Standby Controlfile and PFILE
--------------------------------------- Create a controlfile for the standby database by issuing the following comm
and on the primary database.
sql> ALTER DATABASE CREATE STANDBY CONTROLFILE AS '/tmp/orcl_stby.ctl';
--sql> CREATE PFILE='/tmp/initorcl_stby.ora' FROM SPFILE;
--- Amend the PFILE making the entries relevant for the standby database. I m maki
ng a replica of the original server,
so in my case I only had to amend the following parameters.
*.db_unique_name='ORCL_STBY'
*.fal_server='ORCL'
*.log_archive_dest_2='SERVICE=ORCL ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_
ROLE) DB_UNIQUE_NAME=ORCL'
7. Standby Server Setup (Manual)
================================
- Create directories
Create the necessary directories on the standby server.
--$ mkdir -p /u01/app/oracle/oradata/orcl
$ mkdir -p /u01/app/oracle/fast_recovery_area/orcl
$ mkdir -p /u01/app/oracle/admin/orcl/adump
--- Copy the files from the primary to the standby server.
$ scp /tmp/orcl_stby.ctl [email protected]:/u01/app/oracle/oradata/orcl/
cntrlorcl.dbf
---
# Parameter file.
scp /tmp/initorcl_stby.ora [email protected]:/tmp/initorcl_stby.ora
--# Remote login password file.
scp $ORACLE_HOME/dbs/orapworcl [email protected]:$ORACLE_HOME/dbs
--# Transfer backup files
scp /u01/backup/* [email protected]:/u01/backup
--i) Start Listener
----------------- Make sure the listener is started on the standby server.
$ lsnrctl start
ii) Restore Backup
------------------ Create the SPFILE form the amended PFILE.
$ export ORACLE_SID=orcl
$ sqlplus / as sysdba
--sql> CREATE SPFILE FROM PFILE='/tmp/initorcl_stby.ora';
--- Restore the backup files.
$ rman target=/
RMAN> STARTUP MOUNT;
RMAN> RESTORE DATABASE;
8. Standby Server Setup (DUPLICATE)
----------------------------------- Create directories
Create the necessary directories on the standby server.
--$ mkdir -p /u01/app/oracle/oradata/orcl
$ mkdir -p /u01/app/oracle/fast_recovery_area/orcl
$ mkdir -p /u01/app/oracle/admin/orcl/adump
--- Copy the files from the primary to the standby server.
$ scp /tmp/orcl_stby.ctl [email protected]:/u01/app/oracle/oradata/orcl/
control01.ctl
--# Parameter file.
scp /tmp/initorcl_stby.ora [email protected]:/tmp/initorcl_stby.ora
--# Remote login password file.
scp $ORACLE_HOME/dbs/orapworcl [email protected]:$ORACLE_HOME/dbs
---
i) Start Listener
----------------- Make sure the listener is started on the standby server.
$ lsnrctl start
ii) Start instance
$ export ORACLE_SID=orcl
sql> sqlplus / as sysdba
sql> STARTUP NOMOUNT PFILE='/tmp/initorcl_stby.ora';
--ii) Duplicate database
Connect to RMAN, specifying a full connect string for both the TARGET and AUX
ILLARY instances. DO not attempt to use OS authentication.
$ rman TARGET sys/oracle@orcl AUXILIARY sys/oracle@orcl_stby
DUPLICATE TARGET DATABASE
FOR STANDBY
FROM ACTIVE DATABASE
DORECOVER
SPFILE
SET db_unique_name='ORCL_STBY' COMMENT 'Is standby'
SET LOG_ARCHIVE_DEST_2='SERVICE=ORCL ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMA
RY_ROLE) DB_UNIQUE_NAME=ORCL'
SET FAL_SERVER='ORCL' COMMENT 'Is primary'
NOFILENAMECHECK;
9. Add standby redolog files
---------------------------Add standby redolog files for switchover and real time apply.
sql> ALTER DATABASE ADD
y_redo01.log') SIZE 50M;
sql> ALTER DATABASE ADD
y_redo02.log') SIZE 50M;
sql> ALTER DATABASE ADD
y_redo03.log') SIZE 50M;
sql> ALTER DATABASE ADD
y_redo04.log') SIZE 50M;