You are on page 1of 29

Data Guard

A Dataguard configuration consist of one production DB and upto 9 standby databases. The databases in the Dataguard
configuration are connected by Orcale Net. There are no restrictions on the database where databases are located,
provided they can communicate with each other.

Primary Database:
A dataguard configuration consist one production DB, also known as primary database that plays primary role. The
primary database can be either a single-instance oracle DB or an Oracle Real Application Cluster database.

Standby Database:
A standby database is a transactionally consistent copy of a primary database. A standby database is initially created
from backup copy of the primary database. Once created, Dataguard automatically maintains the standby database by
transfering the redo data from the primary database to the standby database and then applying the same to the standby
database. Standby database also can be single instance or RAC
-Physical Standby
-Logical Standby
Physical Standby:
It provides a physical identical copy of the primary database, with on-disk database structure that are identical to the
primary database on a block for block basis. The database schema including indexes are same, physical standby is kept
synchronized with the primary database by recovering the redo data received from the primary database.
Logical Standby:
It contains the same logical information as the production database although the physical organization and structure of
the data can be different. It is kept synchronized with the primary database by transforming the redologs received from
the primary database into SQL statements and then executing the same on the standby database. This allows users to
access logical standby database for queries and reporting puposes at any time. The logical standby database can be used
for data protection and reporting.

Dataguard services

Log Transport Services:


It controls the automated transfer of redo data within the dataguard configuration.
It transfers the redo data from the primary system to the standby system in the configuration.
Enforce the database protection modes.
Log Apply Services:
It applies the archived redo logs automatically on the standby database.
Automatic detection of missing redo logs on the standby system and automatic retrieval of missing redologs
from the primary database or another standby database.
For physical standby database, Dataguard uses redoapply technology which applies redodata on the standby
database using standard recovery techniques at Oracle DB server.
For logical standby, Dataguard uses SQL applytechnology which first transforms the received redo data into
SQL statements and then executes the generated SQL statements on the logical standby database.

Role Management Services:


An Oracle database operates in one or two roles, primary or standby. Role Management Service controls the changing
of database roles from primary to standby and vice versa. The service includes Switchover, Switchback and Failover.

Network Configuration:
The primary database is connected to standby database using Oracle net.

Dataguard Broker:
The dataguard broker is a distributed management framework that automates and centralizes the creation,
maintenance and monitoring Dataguard configurations.
Creating and enabling one or more Dataguard configurations including setting up log transport services and Log
apply services.
Adding new or existing standby databases to an existing Dataguard configuration.
Managing an entire Dataguard configuration from any system in the configuration.
Monitoring log apply rates, capturing diagnostic information and detecting problems quickly with centralized
monitoring, testing and performance tools.
It can be initiated with GUI or CLI.

Dataguard Protection Modes


Dataguard provides three different modes of protection,
Maximum protection
Maximum availability
Maximum Performance

Maximum Protection
This mode offers the highest level of data protection. Data is synchronously transfered to the standby database from
primary database and transactions are not committed unless the redo data is available on atleast one standby database
configured in the mode. If the last standby database configured in this mode becomes unavailable, processing stops on
the primary database. This mode guarantees no data loss.

Maximum availability
This modes is similar to the maximum protection mode, including the no data loss, however if the standby database
becomes unavailable (i.e. N/w failure), processing continues on the primary database, when the fault is corrected, the
standby database is resynchronized to primary database. If there is a need to failover before the standby database is
resynchronized, some data may be lost.

Maximum Performance
This mode offers slightly less data protection on the primary database but higher performance than maximum
availability mode. In this mode, as the primary database process transactions, redo data is synchronously shipped to the
standby database, the commit operation on the primary database does not wait for the standby database to acknowledge
receipt of redo data before completing write operations on the primary database. If any standby is unavailable,
processing continues on the primary database and there is a little effect on the performance.

Dataguard Services
Primary Database:
Log Writer Process(LGWR): collects redo information and updates the online redo logs, it can also create loca
archived redologs and transfer online redo to standby.
Archiver(ARCH): One or more archiver prosesses copies the online redo logs either locally or remotely for standby
database.
Fetch Archive Log: services requests for archive redo logs from FAL clients running on multiple standby databases.
Multiple FAL servers can be run on a primary database, one for each FAL request.
Standby Database:
Fetch Archive Log: pulls archive log files from the primary database, initiates transfer and archivelogs when it detects
a gap sequence.
Remote File Server: Receives the archived redo logs from primary database.
Archiver Process: Archives the standby redo logs applied by the managed recovery process.
Managed Recovery Process: Applies archived redo log information to the standby database.

Data guard Configuration by cold Backup


Implementation Notes:-
On Primary Database
1.Enable force Logging
2.Create password file
3.Enable Archiving
4.Set Primary Database Initialization Parameters
5.Configure the Listener
6.Create a control file for the standby Database
7. Backup the physical files and copy to the standby server.
8. Startup

On Standby Database
1.Copy the pfile, passwordfile of the primary database to the standby server.
2.Prepare the Initialization Parameters.
3.Setup the environment to support the Standby database on the standby node.
4.Configure the Listener.
5.Start the physical standby database and verify standby database is performing properlyperly

vinod is a primary database


vinodstd is a standby database
Primary Database Steps:

1.General View

SQL> select name from v$database;


NAME
----------
vinod

SQL> show parameter unique


NAME TYPE VALUE
----------- ----------- ------------
db_unique_name string vinod

2.Enable Force Logging


SQL> alter database force logging;

2.Create Password file


To check if a password file already exists, run the following command:
SQL> select * from v$pwfile_users;
If doen't exists create it by following command
> cd $ORACLE_HOME/dbs
> orapwd file=orapwvinod password=oracle

3.Enable Archiving
SQL>startup mount
SQL> alter database archivelog
SQL> alter database open;
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /oraarch/vinod
Oldest online log sequence 80
Next log sequence to archive 82
Current log sequence 82

4.Set Primary Database Initialization Parameter


vinod.__db_cache_size=134217728
vinod.__java_pool_size=29360128
vinod.__large_pool_size=4194304
vinod.__shared_pool_size=109051904
vinod.__streams_pool_size=0
*.audit_file_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/adump'
*.background_dump_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/oradata/vinod/control01.ctl','/oradata/vinod/control02.ctl','/oradata/vinod/control03.ctl'
*.core_dump_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='vinod'
db_unique_name='vinod'
log_archive_config='DG_CONFIG=(vinod,vinodstd)'
*.db_recovery_file_dest='/home/oracle/oracle/product/10.2.0/db_1/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=vinodXDB)'
*.job_queue_processes=10
*.log_archive_dest_1='LOCATION=/oraarch/vinod'
log_archive_dest_2='SERVICE=vinodstd'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
*.remote_login_passwordfile='EXCLUSIVE'
*.log_archive_format='%t_%s_%r.dbf'
log_archive_max_processes=30

fal_server=vinodstd
fal_client=vinod
standby_file_management=auto
*.open_cursors=300
*.pga_aggregate_target=94371840
*.processes=150
*.sga_target=283115520
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/udump'
Configure Listener.ora and tnsname.ora
Listener.ora
SID_LIST_VINOD =
(SID_LIST =
(SID_DESC =
(SID_NAME = vinod)
(GLOBAL_DBNAME = vinod)
(ORACLE_HOME = /home/oracle/oracle/product/10.2.0/db_1)
)
)

Vinod =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.11.168)(PORT = 1525))
)
)

Tnsnames.ora
vinod =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.11.168)(PORT = 1525))
)
(CONNECT_DATA =
(SERVICE_NAME = vinod)
)
)

vinodstd =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.11.138)(PORT = 1525))
)
(CONNECT_DATA =
(SERVICE_NAME = vinodstd)
)
)

Once the new parameters file is ready we create from it the spfile
SQL> shutdown immediate
SQL> startup nomount pfile='/home/oracle/oracle/product/10.2.0/db_1/dbs/initvinod.ora';
SQL> create spfile from pfile='/home/oracle/oracle/product/10.2.0/db_1/dbs/initvinod.ora';
SQL> shutdown immediate
SQL> startup

5. Create a control file for the standby database


SQL> startup mount
SQL> alter database create standby controlfile as '/oradata/vinod/controlstd01.ctl'
SQL> alter database open
SQL> shut immediate

6. Backup the primary database and transfer a copy to the standby node.
Copy all physical files and transfer the same to the standby database witch the same structure.
7. SQL> startup

Standby Database Steps:


1.Prepare Intialization parameter file for standby database
vinod.__db_cache_size=134217728
vinod.__java_pool_size=29360128
vinod.__large_pool_size=4194304
vinod.__shared_pool_size=109051904
vinod.__streams_pool_size=0
*.db_name='vinod'
db_unique_name='vinod'
*.audit_file_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/adump'
*.background_dump_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/bdump'
*.core_dump_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/cdump'
*.user_dump_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/udump'
*.compatible='10.2.0.1.0'
*.control_files='/oradata/vinodstd/oradata/controlstd01.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
#*.db_recovery_file_dest='/oradata/u01/app/oracle/flash_recovery_area'
#*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=vinodXDB)'
*.job_queue_processes=10
*.log_archive_dest_1='LOCATION=/oradata/vinodstd/arch'
*.log_archive_dest_2='SERVICE=vinod'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
log_archive_max_processes=30
*.log_archive_format='%t_%s_%r.dbf'
log_archive_config='DG_CONFIG=(vinod,vinodstd)'
standby_file_management=auto

fal_server=vinod
fal_client=vinodstd
*.open_cursors=300
*.pga_aggregate_target=94371840
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=283115520
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'

NOTE: If there is a need to copy the datafile, RLG in different path unlike the primary database, here is the initialization
parameter to be set.
db_file_name_convert='/oradata/vinod/data', '/oradata/vinodstd/data'
log_file_name_convert='/oradata/vinod/redo', '/oradata/vinodstd/redo'

Configure Listener.ora and tnsname.ora


On Standby Listener :
vi Listener.ora
SID_LIST_vinodstd =
(SID_LIST =
(SID_DESC =
(SID_NAME = vinod)
(GLOBAL_DBNAME = vinod)
(ORACLE_HOME = /home/oracle/oracle/product/10.2.0/db_1)
)
)

vinodstd =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.11.168)(PORT = 1525))
)
)

vi tnsnames.ora

vinod =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.11.168)(PORT = 1525))
)
(CONNECT_DATA =

(SERVICE_NAME = vinod)
)
)

vinodstd =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.11.138)(PORT = 1525))
)
(CONNECT_DATA =
(SERVICE_NAME = vinodstd)
)
)

Prepare Intialization parameter file for standby database


Start the Listener and check tnsping on both nodes and both services
> tnsping vinod

OK(10 msec)

> tnsping vinodstd

OK(10 msec)

2. Setup the environment variable to point the standby database


ORACLE_HOME=/oradata/u01/app/oracle
ORACLE_SID=vinodstd

3. Startup nomount the standby database and generate spfile


SQL> startup nomount pfile='/oradata/u01/app/oracle/dbs/initvinodstd.ora'
SQL> create spfile from pfile='/oradata/u01/app/oracle/dbs/initvinodstd.ora'
File crated
SQL> shutdown immediate

4. Startup mount the standby database and perform recovery

SQL> startup mount


SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
Database Altered

5. Check alert log file will show following operation taking place
..............
..............
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION

Verify the Physical


standby database
is perform
properly

On Primary
Database:
>archive log list
Database log mode
Archive Mode
Automatic archival Enabled
Archive destination /oraarch/vinod
Oldest online log sequence 13
Next log sequence to archive 15
Current log sequence 15

SQL> alter system switch logfile;


system altered
SQL> alter system switch logfile;
system altered
SQL> alter system switch logfile;
system altered

>archive log list


Database log mode Archive Mode
Automatic archival Enabled
Archive destination /oraarch/vinod
Oldest online log sequence 16
Next log sequence to archive 18
Current log sequence 18

On Standby Database:
>archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /oraarch/vinod
Oldest online log sequence 16
Next log sequence to archive 0
Current log sequence 18

SQL>select sequence#, archived, applied from v$archived_log;

SEQUENCE# ARC APP


---------- --- ---
8 YES YES
9 YES YES
10 YES YES
11 YES YES
12 YES YES
13 YES YES
14 YES YES
15 YES YES
16 YES YES
17 YES YES These are the logs archived from the primary database.
18 YES YES

Data guard Configuration by Hot Backup

Implementation Notes:-
On Primary Database
1.Enable force Logging
2.Create password file
3.Enable Archiving
4.Set Primary Database Initialization Parameters
5.Configure the Listener
6.Create a control file for the standby Database
7. Take Hot backup and copy the physical files to standby server.
8. Startup

On Standby Database
1.Copy the pfile, passwordfile of the primary database to the standby server.
2.Prepare the Initialization Parameters.
3.Setup the environment to support the Standby database on the standby node.
4.Configure the Listener.
5.Start the physical standby database and verify standby database is performing properly

vinod is a primary database


vinodstd is a standby database
Primary Database Steps:

1.General View

SQL> select name from v$database;


NAME
----------
vinod

SQL> show parameter unique


NAME TYPE VALUE
----------- ----------- ------------
db_unique_name string vinod

2.Enable Force Logging


SQL> alter database force logging;

2.Create Password file


To check if a password file already exists, run the following command:
SQL> select * from v$pwfile_users;
If doen't exists create it by following command
> cd $ORACLE_HOME/dbs
> orapwd file=orapwvinod password=oracle

3.Enable Archiving
SQL>startup mount
SQL> alter database archivelog
SQL> alter database open;
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /oraarch/vinod
Oldest online log sequence 80
Next log sequence to archive 82
Current log sequence 82

4.Set Primary Database Initialization Parameter


vinod.__db_cache_size=134217728
vinod.__java_pool_size=29360128
vinod.__large_pool_size=4194304
vinod.__shared_pool_size=109051904
vinod.__streams_pool_size=0
*.audit_file_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/adump'
*.background_dump_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/oradata/vinod/control01.ctl','/oradata/vinod/control02.ctl','/oradata/vinod/control03.ctl'
*.core_dump_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='vinod'
db_unique_name='vinod'
log_archive_config='DG_CONFIG=(vinod,vinodstd)'
*.db_recovery_file_dest='/home/oracle/oracle/product/10.2.0/db_1/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=vinodXDB)'
*.job_queue_processes=10
*.log_archive_dest_1='LOCATION=/oraarch/vinod'
log_archive_dest_2='SERVICE=vinodstd'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
*.remote_login_passwordfile='EXCLUSIVE'
*.log_archive_format='%t_%s_%r.dbf'
log_archive_max_processes=30

fal_server=vinodstd
fal_client=vinod
standby_file_management=auto
*.open_cursors=300
*.pga_aggregate_target=94371840
*.processes=150
*.sga_target=283115520
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/udump'

Configure Listener.ora and tnsname.ora


Listener.ora
SID_LIST_VINOD =
(SID_LIST =
(SID_DESC =
(SID_NAME = vinod)
(GLOBAL_DBNAME = vinod)
(ORACLE_HOME = /home/oracle/oracle/product/10.2.0/db_1)
)
)

Vinod =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.11.168)(PORT = 1525))
)
)
Tnsnames.ora
vinod =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.11.168)(PORT = 1525))
)
(CONNECT_DATA =
(SERVICE_NAME = vinod)
)
)

vinodstd =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.11.138)(PORT = 1525))
)
(CONNECT_DATA =
(SERVICE_NAME = vinodstd)
)
)

Once the new parameters file is ready we create from it the spfile
SQL> shutdown immediate
SQL> startup nomount pfile='/home/oracle/oracle/product/10.2.0/db_1/dbs/initvinod.ora';
SQL> create spfile from pfile='/home/oracle/oracle/product/10.2.0/db_1/dbs/initvinod.ora';
SQL> shutdown immediate
SQL> startup

5. Create a control file for the standby database


SQL> startup mount
SQL> alter database create standby controlfile as '/oradata/vinod/controlstd01.ctl'
SQL> alter database open

SQL> Alter database begin backup;

Backup the primary database and transfer a copy to the standby node.
Copy all physical files and transfer the same to the standby database witch the same structure.

7. SQL> Alter database end backup;

SQL> alter system switch logfile;


Copy the archivelog files to the standby server.

SQL> shut immediate


SQL> startup

Standby Database Steps:


1.Prepare Intialization parameter file for standby database
vinod.__db_cache_size=134217728
vinod.__java_pool_size=29360128
vinod.__large_pool_size=4194304
vinod.__shared_pool_size=109051904
vinod.__streams_pool_size=0
*.db_name='vinod'
db_unique_name='vinod'
*.audit_file_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/adump'
*.background_dump_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/bdump'
*.core_dump_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/cdump'
*.user_dump_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/udump'
*.compatible='10.2.0.1.0'
*.control_files='/oradata/vinodstd/oradata/controlstd01.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
#*.db_recovery_file_dest='/oradata/u01/app/oracle/flash_recovery_area'
#*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=vinodXDB)'
*.job_queue_processes=10
*.log_archive_dest_1='LOCATION=/oradata/vinodstd/arch'
*.log_archive_dest_2='SERVICE=vinod'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
log_archive_max_processes=30
*.log_archive_format='%t_%s_%r.dbf'
log_archive_config='DG_CONFIG=(vinod,vinodstd)'
standby_file_management=auto

fal_server=vinod
fal_client=vinodstd
*.open_cursors=300
*.pga_aggregate_target=94371840
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=283115520
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'

NOTE: If there is a need to copy the datafile, RLG in different path unlike the primary database, here is the initialization
parameter to be set.
db_file_name_convert='/oradata/vinod/data', '/oradata/vinodstd/data'
log_file_name_convert='/oradata/vinod/redo', '/oradata/vinodstd/redo'

Configure Listener.ora and tnsname.ora


On Standby Listener :
vi Listener.ora
SID_LIST_vinodstd =
(SID_LIST =
(SID_DESC =
(SID_NAME = vinod)
(GLOBAL_DBNAME = vinod)
(ORACLE_HOME = /home/oracle/oracle/product/10.2.0/db_1)
)
)

vinodstd =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.11.168)(PORT = 1525))
)
)

vi tnsnames.ora

vinod =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.11.168)(PORT = 1525))
)
(CONNECT_DATA =

(SERVICE_NAME = vinod)
)
)

vinodstd =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.11.138)(PORT = 1525))
)
(CONNECT_DATA =
(SERVICE_NAME = vinodstd)
)
)

Prepare Intialization parameter file for standby database


Start the Listener and check tnsping on both nodes and both services
> tnsping vinod

OK(10 msec)

> tnsping vinodstd

OK(10 msec)

2. Setup the environment variable to point the standby database


ORACLE_HOME=/oradata/u01/app/oracle
ORACLE_SID=vinodstd

4. Startup nomount the standby database and generate spfile

SQL> startup nomount pfile='/oradata/u01/app/oracle/dbs/initvinodstd.ora'


SQL> create spfile from pfile='/oradata/u01/app/oracle/dbs/initvinodstd.ora'
File crated
SQL> shutdown immediate

5. Startup mount the standby database and perform recovery

SQL> startup mount


SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
Database Altered
5. Check alert log file will show following operation taking place

Verify the Physical


standby database
is perform
properly

On Primary
Database:
>archive log list
Database log mode
Archive Mode
Automatic archival Enabled
Archive destination /oraarch/vinod
Oldest online log sequence 13
Next log sequence to archive 15
Current log sequence 15

SQL> alter system switch logfile;


system altered
SQL> alter system switch logfile;
system altered
SQL> alter system switch logfile;
system altered

>archive log list


Database log mode Archive Mode
Automatic archival Enabled
Archive destination /oraarch/vinod
Oldest online log sequence 16
Next log sequence to archive 18
Current log sequence 18
On Standby Database:
>archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /oraarch/vinod
Oldest online log sequence 16
Next log sequence to archive 0
Current log sequence 18

SQL>select sequence#, archived, applied from v$archived_log;

SEQUENCE# ARC APP


---------- --- ---
8 YES YES
9 YES YES
10 YES YES
11 YES YES
12 YES YES
13 YES YES
14 YES YES
15 YES YES
16 YES YES
17 YES YES These are the logs archived from the primary database.
18 YES YES

Data guard Configuration by RMAN Backup (Automatic)


Implementation Notes:-
On Primary Database
1.Enable force Logging
2.Create password file
3.Enable Archiving
4.Set Primary Database Initialization Parameters
5.Configure the Listener
6.Take the backup including standby Controlfile, database, archivelog using RMAN.
7.Copy the backup pieces to standby server.

On Standby Database
1.Copy the pfile, passwordfile to the standby server
2.Prepare the Initialization Parameters.
3.Setup the environment to support the Standby database on the standby node.
4.Configure the Listener.
5.Start the physical standby database and verify standby database is performing properly

vinod is a primary database


vinodstd is a standby database
Primary Database Steps:
1.General View

SQL> select name from v$database;


NAME
----------
vinod

SQL> show parameter unique


NAME TYPE VALUE
----------- ----------- ------------
db_unique_name string vinod

2.Enable Force Logging


SQL> alter database force logging;

2.Create Password file


To check if a password file already exists, run the following command:
SQL> select * from v$pwfile_users;
If doen't exists create it by following command
> cd $ORACLE_HOME/dbs
> orapwd file=orapwvinod password=oracle

3.Enable Archiving
SQL>startup mount
SQL> alter database archivelog
SQL> alter database open;
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /oraarch/vinod
Oldest online log sequence 80
Next log sequence to archive 82
Current log sequence 82

4.Set Primary Database Initialization Parameter


vi initvinod.ora
vinod.__db_cache_size=134217728
vinod.__java_pool_size=29360128
vinod.__large_pool_size=4194304
vinod.__shared_pool_size=109051904
vinod.__streams_pool_size=0
*.audit_file_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/adump'
*.background_dump_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/oradata/vinod/control01.ctl','/oradata/vinod/control02.ctl','/oradata/vinod/control03.ctl'
*.core_dump_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='vinod'
db_unique_name='vinod'
log_archive_config='DG_CONFIG=(vinod,vinodstd)'
*.db_recovery_file_dest='/home/oracle/oracle/product/10.2.0/db_1/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=vinodXDB)'
*.job_queue_processes=10
*.log_archive_dest_1='LOCATION=/oraarch/vinod'
log_archive_dest_2='SERVICE=vinodstd'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
*.remote_login_passwordfile='EXCLUSIVE'
*.log_archive_format='%t_%s_%r.dbf'
log_archive_max_processes=30

fal_server=vinodstd
fal_client=vinod
standby_file_management=auto
*.open_cursors=300
*.pga_aggregate_target=94371840
*.processes=150
*.sga_target=283115520
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/udump'

Configure Listener.ora and tnsname.ora


Listener.ora
SID_LIST_VINOD =
(SID_LIST =
(SID_DESC =
(SID_NAME = vinod)
(GLOBAL_DBNAME = vinod)
(ORACLE_HOME = /home/oracle/oracle/product/10.2.0/db_1)
)
)

Vinod =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.11.168)(PORT = 1525))
)
)

Tnsnames.ora
vinod =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.11.168)(PORT = 1525))
)
(CONNECT_DATA =
(SERVICE_NAME = vinod)
)
)

vinodstd =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.11.138)(PORT = 1525))
)
(CONNECT_DATA =
(SERVICE_NAME = vinodstd)
)
)

Once the new parameters file is ready we create from it the spfile
SQL> shutdown immediate
SQL> startup nomount pfile='/home/oracle/oracle/product/10.2.0/db_1/dbs/initvinod.ora';
SQL> create spfile from pfile='/home/oracle/oracle/product/10.2.0/db_1/dbs/initvinod.ora';
SQL> shutdown immediate
SQL> startup

5. Configure RMAN
RMAN> connect target sys/sys@vinod
RMAN> backup database include current controfile for standby
RMAN> backup archivelog all;
OR
RMAN> backup database include current controfile for standby plus archivelog;

6. Copy all the backup pieces to the standby server on the same location where as in primary server

Standby Database Steps:

Copy the pfile, passwordfile from the primary server to the standby server.

1.Prepare Initialization parameter file for standby database


vi initvinod.ora
vinod.__db_cache_size=134217728
vinod.__java_pool_size=29360128
vinod.__large_pool_size=4194304
vinod.__shared_pool_size=109051904
vinod.__streams_pool_size=0
*.db_name='vinod'
db_unique_name='vinod'
*.audit_file_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/adump'
*.background_dump_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/bdump'
*.core_dump_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/cdump'
*.user_dump_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/udump'
*.compatible='10.2.0.1.0'
*.control_files='/oradata/vinodstd/oradata/controlstd01.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
#*.db_recovery_file_dest='/oradata/u01/app/oracle/flash_recovery_area'
#*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=vinodXDB)'
*.job_queue_processes=10
*.log_archive_dest_1='LOCATION=/oradata/vinodstd/arch'
*.log_archive_dest_2='SERVICE=vinod'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
log_archive_max_processes=30
*.log_archive_format='%t_%s_%r.dbf'
log_archive_config='DG_CONFIG=(vinod,vinodstd)'
standby_file_management=auto

fal_server=vinod
fal_client=vinodstd
*.open_cursors=300
*.pga_aggregate_target=94371840
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=283115520
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'

NOTE: If there is a need to copy the datafile, RLG in different path unlike the primary database, here is the initialization
parameter to be set.
db_file_name_convert='/oradata/vinod/data', '/oradata/vinodstd/data'
log_file_name_convert='/oradata/vinod/redo', '/oradata/vinodstd/redo'

Configure Listener.ora and tnsname.ora


On Standby Listener :
vi Listener.ora
SID_LIST_vinodstd =
(SID_LIST =
(SID_DESC =
(SID_NAME = vinod)
(GLOBAL_DBNAME = vinod)
(ORACLE_HOME = /home/oracle/oracle/product/10.2.0/db_1)
)
)

vinodstd =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.11.168)(PORT = 1525))
)
)

vi tnsnames.ora

vinod =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.11.168)(PORT = 1525))
)
(CONNECT_DATA =

(SERVICE_NAME = vinod)
)
)

vinodstd =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.11.138)(PORT = 1525))
)
(CONNECT_DATA =
(SERVICE_NAME = vinodstd)
)
)

Prepare Intialization parameter file for standby database


Start the Listener and check tnsping on both nodes and both services
> tnsping vinod

OK(10 msec)

> tnsping vinodstd

OK(10 msec)

2. Setup the environment variable to point the standby database


ORACLE_HOME=/oradata/u01/app/oracle
ORACLE_SID=vinodstd

5. Startup nomount the standby database and generate spfile

SQL> startup nomount pfile='/oradata/u01/app/oracle/dbs/initvinodstd.ora'


SQL> create spfile from pfile='/oradata/u01/app/oracle/dbs/initvinodstd.ora'
File crated
SQL> shutdown immediate

6. Startup nomount the standby database and duplicate the target database.

SQL> startup nomount

Connect to RMAN
RMAN> connect target sys/sys@vinod
RMAN>connect auxiliary sys/sys@vinodstd
RMAN>duplicate target database for standby nofilenamecheck;

Verify whether the Physical standby database is performing properly

On Primary Database:
>archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /oraarch/vinod
Oldest online log sequence 13
Next log sequence to archive 15
Current log sequence 15

SQL> alter system switch logfile;


system altered
SQL> alter system switch logfile;
system altered
SQL> alter system switch logfile;
system altered

>archive log list


Database log mode Archive Mode
Automatic archival Enabled
Archive destination /oraarch/vinod
Oldest online log sequence 16
Next log sequence to archive 18
Current log sequence 18

On Standby Database:
>archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /oraarch/vinod
Oldest online log sequence 16
Next log sequence to archive 0
Current log sequence 18

SQL>select sequence#, archived, applied from v$archived_log;

SEQUENCE# ARC APP


---------- --- ---
8 YES YES
9 YES YES
10 YES YES
11 YES YES
12 YES YES
13 YES YES
14 YES YES
15 YES YES
16 YES YES
17 YES YES These are the logs archived from the primary database.
18 YES YES

Data guard Configuration by RMAN Backup (Manual)


Implementation Notes:-
On Primary Database
1.Enable force Logging
2.Create password file
3.Enable Archiving
4.Set Primary Database Initialization Parameters
5.Configure the Listener
6.Take the backup including standby Controlfile, database, archivelog using RMAN.
7.Copy the backup pieces to standby server.

On Standby Database
1.Copy the pfile, passwordfile to the standby server
2.Prepare the Initialization Parameters.
3.Setup the environment to support the Standby database on the standby node.
4.Configure the Listener.
5.Start the physical standby database and verify standby database is performing properly

vinod is a primary database


vinodstd is a standby database
Primary Database Steps:

1.General View

SQL> select name from v$database;


NAME
----------
vinod

SQL> show parameter unique


NAME TYPE VALUE
----------- ----------- ------------
db_unique_name string vinod

2.Enable Force Logging


SQL> alter database force logging;

2.Create Password file


To check if a password file already exists, run the following command:
SQL> select * from v$pwfile_users;
If doen't exists create it by following command
> cd $ORACLE_HOME/dbs
> orapwd file=orapwvinod password=oracle

3.Enable Archiving
SQL>startup mount
SQL> alter database archivelog
SQL> alter database open;
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /oraarch/vinod
Oldest online log sequence 80
Next log sequence to archive 82
Current log sequence 82

4.Set Primary Database Initialization Parameter


vi initvinod.ora
vinod.__db_cache_size=134217728
vinod.__java_pool_size=29360128
vinod.__large_pool_size=4194304
vinod.__shared_pool_size=109051904
vinod.__streams_pool_size=0
*.audit_file_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/adump'
*.background_dump_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/oradata/vinod/control01.ctl','/oradata/vinod/control02.ctl','/oradata/vinod/control03.ctl'
*.core_dump_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='vinod'
db_unique_name='vinod'
log_archive_config='DG_CONFIG=(vinod,vinodstd)'
*.db_recovery_file_dest='/home/oracle/oracle/product/10.2.0/db_1/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=vinodXDB)'
*.job_queue_processes=10
*.log_archive_dest_1='LOCATION=/oraarch/vinod'
log_archive_dest_2='SERVICE=vinodstd'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
*.remote_login_passwordfile='EXCLUSIVE'
*.log_archive_format='%t_%s_%r.dbf'
log_archive_max_processes=30

fal_server=vinodstd
fal_client=vinod
standby_file_management=auto
*.open_cursors=300
*.pga_aggregate_target=94371840
*.processes=150
*.sga_target=283115520
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/udump'

Configure Listener.ora and tnsname.ora


Listener.ora
SID_LIST_VINOD =
(SID_LIST =
(SID_DESC =
(SID_NAME = vinod)
(GLOBAL_DBNAME = vinod)
(ORACLE_HOME = /home/oracle/oracle/product/10.2.0/db_1)
)
)

Vinod =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.11.168)(PORT = 1525))
)
)

Tnsnames.ora
vinod =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.11.168)(PORT = 1525))
)
(CONNECT_DATA =
(SERVICE_NAME = vinod)
)
)

vinodstd =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.11.138)(PORT = 1525))
)
(CONNECT_DATA =
(SERVICE_NAME = vinodstd)
)
)

Once the new parameters file is ready we create from it the spfile
SQL> shutdown immediate
SQL> startup nomount pfile='/home/oracle/oracle/product/10.2.0/db_1/dbs/initvinod.ora';
SQL> create spfile from pfile='/home/oracle/oracle/product/10.2.0/db_1/dbs/initvinod.ora';
SQL> shutdown immediate
SQL> startup

6. Configure RMAN
RMAN> connect target sys/sys@vinod
RMAN> backup database include current controfile for standby
RMAN> backup archivelog all;
OR
RMAN> backup database include current controfile for standby plus archivelog;

7. Copy all the backup pieces to the standby server on the same location where as in primary server

Standby Database Steps:

Copy the pfile, passwordfile from the primary server to the standby server.

1.Prepare Initialization parameter file for standby database


vi initvinod.ora
vinod.__db_cache_size=134217728
vinod.__java_pool_size=29360128
vinod.__large_pool_size=4194304
vinod.__shared_pool_size=109051904
vinod.__streams_pool_size=0
*.db_name='vinod'
db_unique_name='vinod'
*.audit_file_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/adump'
*.background_dump_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/bdump'
*.core_dump_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/cdump'
*.user_dump_dest='/home/oracle/oracle/product/10.2.0/db_1/admin/vinod/udump'
*.compatible='10.2.0.1.0'
*.control_files='/oradata/vinodstd/oradata/controlstd01.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
#*.db_recovery_file_dest='/oradata/u01/app/oracle/flash_recovery_area'
#*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=vinodXDB)'
*.job_queue_processes=10
*.log_archive_dest_1='LOCATION=/oradata/vinodstd/arch'
*.log_archive_dest_2='SERVICE=vinod'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
log_archive_max_processes=30
*.log_archive_format='%t_%s_%r.dbf'
log_archive_config='DG_CONFIG=(vinod,vinodstd)'
standby_file_management=auto

fal_server=vinod
fal_client=vinodstd
*.open_cursors=300
*.pga_aggregate_target=94371840
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=283115520
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'

NOTE: If there is a need to copy the datafile, RLG in different path unlike the primary database, here is the initialization
parameter to be set.
db_file_name_convert='/oradata/vinod/data', '/oradata/vinodstd/data'
log_file_name_convert='/oradata/vinod/redo', '/oradata/vinodstd/redo'

Configure Listener.ora and tnsname.ora


On Standby Listener :
vi Listener.ora
SID_LIST_vinodstd =
(SID_LIST =
(SID_DESC =
(SID_NAME = vinod)
(GLOBAL_DBNAME = vinod)
(ORACLE_HOME = /home/oracle/oracle/product/10.2.0/db_1)
)
)

vinodstd =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.11.168)(PORT = 1525))
)
)

vi tnsnames.ora

vinod =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.11.168)(PORT = 1525))
)
(CONNECT_DATA =

(SERVICE_NAME = vinod)
)
)

vinodstd =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.11.138)(PORT = 1525))
)
(CONNECT_DATA =
(SERVICE_NAME = vinodstd)
)
)

Prepare Intialization parameter file for standby database


Start the Listener and check tnsping on both nodes and both services
> tnsping vinod

OK(10 msec)

> tnsping vinodstd

OK(10 msec)

2. Setup the environment variable to point the standby database


ORACLE_HOME=/oradata/u01/app/oracle
ORACLE_SID=vinodstd

6. Startup nomount the standby database and generate spfile

SQL> startup nomount pfile='/oradata/u01/app/oracle/dbs/initvinod.ora'


SQL> create spfile from pfile='/oradata/u01/app/oracle/dbs/initvinod.ora'
File crated
SQL> shutdown immediate

7. Startup nomount the standby database and duplicate the target database.

SQL> startup nomount

Connect to RMAN
RMAN> connect target sys/sys@vinod
SQL> Alter database mount standby database;
RMAN> Restore database;
RMAN>Recover database;
SQL> Alter database recover managed standby database disconnect;

Verify whether the Physical standby database is performing properly


On Primary Database:
>archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /oraarch/vinod
Oldest online log sequence 13
Next log sequence to archive 15
Current log sequence 15

SQL> alter system switch logfile;


system altered
SQL> alter system switch logfile;
system altered
SQL> alter system switch logfile;
system altered

>archive log list


Database log mode Archive Mode
Automatic archival Enabled
Archive destination /oraarch/vinod
Oldest online log sequence 16
Next log sequence to archive 18
Current log sequence 18

On Standby Database:
>archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /oraarch/vinod
Oldest online log sequence 16
Next log sequence to archive 0
Current log sequence 18

SQL>select sequence#, archived, applied from v$archived_log;

SEQUENCE# ARC APP


---------- --- ---
8 YES YES
9 YES YES
10 YES YES
11 YES YES
12 YES YES
13 YES YES
14 YES YES
15 YES YES
16 YES YES
17 YES YES These are the logs archived from the primary database.
18 YES YES

Database Switchover
Convert the primary database to the standby database
>select database_role from v$database;
primary

>select switchover_status from v$database;


sessions active

>alter database commit to switchover to standby;


OR
>alter database commit to switchover to standby with session shutdown;
>shut immediate
>startup nomount;
>alter database mount standby database;
>alter database recover manager standby database disconnect from session;
>alter system set LOG_ARCHIVE_DEST_STATE_2=defer;

Convert the standby database to the primary database


>select database_role from v$database;
physical standby

>alter database commit to switchover to primary;


OR
>alter database commit to switchover to primary with session shutdown;

>shut immediate
> startup

Now standby database has become primary database

Database Switchback is vice versa of Database Switchover.

You might also like