Oracle DBA Tips Corner |
|
Activating the Standby Database - (Oracle 8i)
by Jeff Hunter, Sr. Database Administrator
Contents
Introduction
The Standby Database feature of Oracle (Oracle7 and higher) allows the DBA
to maintain a duplicate, or standby, copy of a database at a remote
site to provide continued primary database availability in the event of
failure. The standby database is created with a special copy of the control
file from the primary database. The standby database is kept in close synchronization
with the primary database by applying the primary database's archived log files
to the standby database. It is therefore necessary to operate the primary
database in Archivelog Mode to avail the benefit of a standby database.
A standby database is generally used where high availability of data is required.
A standby database is one way of quickly providing access to data if the primary
database fails and recovery will take longer than the desired time.
Activating the Standby Database - (Immediate Method)
Activating the Standby Database - (Graceful Switchover Method)
The main advantage of a graceful switchover is that it avoids the resetlogs
operation. This option is implicitly done by the ALTER DATABASE ACTIVATE STANDBY
DATABASE command. By avoiding the resetlogs operation, the source database can
resume its role as the standby database almost immediately with no data loss. Another feature to
a graceful switchover is that it does not invalidate previous backups.
The prerequisites of initiating graceful switchovers are the following:
Graceful Switchover steps
Now, rename and transfer the "create controlfile script" to
the standby server:
All articles, scripts and material located at the Internet address of http://www.idevelopment.info is the copyright of Jeffrey M. Hunter
and is protected under copyright laws of the United States. This document may not be hosted on any other site without my express,
prior, written permission. Application to host any of the material elsewhere can be made by contacting me at jhunter@idevelopment.info.
I have made every effort and taken great care in making sure that the material included on my web site is technically accurate,
but I disclaim any and all responsibility for any loss, damage or destruction of data or any other property which may arise from
relying on it. I will in no case be liable for any monetary damages arising from such loss, damage or destruction.
This article provides notes and instructions on how to activate
a standby database to become the primary database in a standby
database configuration. Note that this article was written
for release Oracle7 through 8i. For instructions on how
to activate a standby database in Oracle9i, please refer to
the "Role Transitions" section in the appropriate article for your Data Guard configuration:
In the event of a disaster on the primary machine, you need to make
the standby database active as soon as possible. In this example, it is assumed that the
primary database server is not available and that the standby
database needs to be activated as the primary database immediately.
The standby database will need to be activated in its current state - no
other redo from the primary database will be applied as it is assumed to
be down
The steps involved are:
SQL> recover managed standby database cancel;
Media recovery complete.
SQL> shutdown immediate
SQL> connect / as sysdba
Connected to an idle instance.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 252777660 bytes
Fixed Size 451772 bytes
Variable Size 218103808 bytes
Database Buffers 33554432 bytes
Redo Buffers 667648 bytes
SQL> alter database mount standby database;
Database altered.
SQL> recover standby database until cancel;
SQL> alter database activate standby database;
Database altered.
This process can take several minutes to complete, depending
on the speed of the server.
SQL> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.
--------------------------------------
SQL> startup open
ORACLE instance started.
Total System Global Area 252777660 bytes
Fixed Size 451772 bytes
Variable Size 218103808 bytes
Database Buffers 33554432 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.
Note that you cannot copy online redo logs from the primary to the standby in
a failover scenario.
The standby bit in the controlfile is now set, so you can never go back -
the standby is now your primary database. Since the redo log sequence
was reset when the standby was opened, it is a good idea to take a full
backup at this point.
The following section will go into detail about how to build a graceful
switchover when activating the standby database. This method is an alternative
to the one discussed above:
"Activating the Standby Database - (Immediate Method)". The major opposition to
the "Activating the Standby Database - (Immediate Method)" is that it performs a "resetlogs" operation
implicitly when opening the database.
A senior DBA or system administrator with a thorough understanding of Oracle
standby database implementation and Oracle recovery mechanisms should only
attempt this option on a production database.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup restrict
ORACLE instance started.
Total System Global Area 252777660 bytes
Fixed Size 451772 bytes
Variable Size 218103808 bytes
Database Buffers 33554432 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.
SQL> alter system archive log current;
System altered.
SQL> alter database backup controlfile to trace noresetlogs;
Database altered.
The trace file that contains the script needs to be modified with the
appropriate datafile and log file path names. The new create
controlfile script needs to be shipped to the standby site.
% cd ~oracle/admin/ORA817/udump
% mv ora920_ora_16864.trc create_controlfile.sql
% rcp create_controlfile.sql linux4:
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
If the primary site crashed and is not accessible, these steps
will still work if the online redo logs are still intact and accessible.
SQL> recover managed standby database cancel;
Media recovery complete.
SQL> shutdown immediate
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux Error: 2: No such file or directory
% rcp /u03/app/oradata/ORA817/redo_g0*.log linux4:/u03/app/oradata/ORA817/
% rcp /u04/app/oradata/ORA817/redo_g0*.log linux4:/u04/app/oradata/ORA817/
% rcp /u05/app/oradata/ORA817/redo_g0*.log linux4:/u05/app/oradata/ORA817/
% rm /u03/app/oradata/ORA817/control01.ctl
% rm /u04/app/oradata/ORA817/control02.ctl
% rm /u05/app/oradata/ORA817/control03.ctl
SQL> connect / as sysdba
Connected to an idle instance.
SQL> @create_controlfile.sql
ORACLE instance started.
Total System Global Area 252777660 bytes
Fixed Size 451772 bytes
Variable Size 218103808 bytes
Database Buffers 33554432 bytes
Redo Buffers 667648 bytes
Control file created.
SQL> recover database
Media recovery complete.
Recover command only recovers online data files.
SQL> alter system archive log all;
System altered.
SQL> alter database open;
Database altered.
SQL> alter tablespace temp add tempfile
2 '/u06/app/oradata/ORA817/temp01.dbf' size 524288000
3 reuse autoextend on next 524288000 maxsize 1500M;
Tablespace altered.
Thursday, 21-Jun-2007 16:32:56 EDT
Page Count: 30012