Turning Archiving On and Off
============================
This section describes the aspect of archiving and includes the
following topics:
- Setting the Initial Database Archiving Mode
- Enabling Automatic Archiving
* Enabling Automatic Archiving at Instance Startup
* Enabling Automatic Archiving After Instance Startup
- Changing the Database Archiving Mode
- Disabling Automatic Archiving
* Disabling Automatic Archiving at Instance Startup
* Disabling Automatic Archiving after Instance Startup
- Performing Manual Archiving
You set a database's initial archiving mode as part of database creation.
Usually, you can use the default of NOARCHIVELOG mode at database creation
because there is no need to archive the redo information generated at that time.
After creating the database, decide whether to change from the initial
archiving mode.
After a database has been created, you can switch the database's archiving mode
on demand. However, you should generally not switch the database between
archiving modes.
NOTE: If a database is automatically created during Oracle installation,
the initial archiving mode of the database is operating system specific.
See your operating system-specific Oracle documentation.
NOTE:
ARCHIVELOG mode is necessary for creating on-line backups and for certain
types of database recovery. Configuring the database to operate in
ARCHIVELOG mode allows the user to perform complete and point-in-time
recovery from media (disk) failures using off-line or on-line backups. If
ARCHIVELOG mode is disabled, the database can be restored from a backup in
case of failure, but it cannot be rolled forward from that to a point when
failure occured.
Setting the Initial Database Archiving Mode
===========================================
When you create the database, you set the initial archiving mode of the redo
log in the CREATE DATABASE statement. If you do not specify either ARCHIVELOG
or NOARCHIVELOG, NOARCHIVELOG is the default. To verify database mode, execute
following statement:
SVRMGR> Select * from V$DATABASE
NAME CREATED LOG_MODE CHECKPOINT ARCHIVE_CH
---- ----------------- ------------ ---------- ----------
ORCL 05/21/97 17:55:06 NOARCHIVELOG 172185 170808
Enabling Automatic Archiving at Instance Startup
================================================
To enable automatic archiving of filled groups each time an instance is started,
include the "LOG_ARCHIVE_START" parameter, set to TRUE, in the database's
parameter file:
LOG_ARCHIVE_START=TRUE
The new value takes effect the next time you start the database.
Enabling Automatic Archiving After Instance Startup
====================================================
To enable automatic archiving of filled online redo log groups without
shutting down the current instance, use the SQL command ALTER SYSTEM
with the ARCHIVE LOG START parameter;
The following statement enables archiving:
SVRMGRL> ALTER SYSTEM ARCHIVE LOG START;
When using this option, the instance does not have to be shut down
to enable automatic archiving.
However, if an instance is shutdown and restarted after automatic archiving
is enabled using this option, the instance is reinitialized using the
settings of the parameter file ("LOG_ARCHIVE_START"), which may or may not
enable automatic archiving.
Changing the Database Archiving Mode
====================================
There are "init.ora" parameters you need to modify in order
to properly handle your database being in archive log mode. They are:
LOG_ARCHIVE_START
LOG_ARCHIVE_DEST
LOG_ARCHIVE_FORMAT
LOG_ARCHIVE_START:
Enables automatic archiving of filled groups each time an instance is started.
Set this parameter to TRUE if you do NOT wish to have to MANUALLY archive your
redo log files when in ARCHIVELOG mode.
LOG_ARCHIVE_DEST:
This parameter specifies the directory where your archive logs will be placed.
LOG_ARCHIVE_FORMAT:
This parameter names the archive logs in this format. For example, if your
format is: arch%s.arc
Your log files will be called: arch1.arc, arch2.arc, arch3.arc
where the '1', '2', '3', etc is the sequence number.
To Prepare to Switch Database Archiving Mode
============================================
1. Shut down the database instance.
SVRMGRL> shutdown
An open database must be closed and dismounted and any associated
instances shut down before the database's archiving mode can be switched.
Archiving cannot be disabled if any datafiles need media recovery.
2. Backup the database.
This backup can be used with the archive logs that you will generate.
3. Perform any operating system specific steps (optional).
4. Start up a new instance and mount, but do not open the database.
SVRMGRL> startup mount
NOTE: If you are using the Oracle Parallel Server, you must mount the
database exclusively using one instance to switch the database's
archiving mode.
5. Switch the database's archiving mode.
SVRMGRL> alter database archivelog;
6. Open the database.
SVRMGRL> alter database open;
7. Verify your database is now in archivelog mode.
SVRMGRL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination for example: $ORACLE_HOME/dbs/arch
Oldest on-line log sequence 275
Next log sequence 277
Current log sequence 278
8. Archive all your redo logs at this point.
SVRMGRL> archive log all;
9. Ensure these newly created Archive log files are added to the backup
process.
See the Oracle7 Parallel Server Concepts & Administration guide for more
information about switching the archiving mode when using the Oracle Parallel
Server.
Disabling Automatic Archiving
=============================
You can disable automatic archiving of the online redo log groups at any time.
However, once automatic archiving is disabled, you must manually archive groups
of online redo log files in a timely fashion.
If a database is operated in ARCHIVELOG mode, automatic archiving is disabled,
and all groups of online redo log files are filled but not archived.
LGWR cannot reuse any inactive groups of online redo log groups to
continue writing redo log entries. Therefore, database operation is
temporarily suspended until the necessary archiving is performed.
To disable automatic archiving after instance startup, you must be connected
with administrator privileges and have the ALTER SYSTEM privilege.
Automatic archiving can be disabled at or after instance startup.
Disabling Automatic Archiving at Instance Startup
=================================================
To disable the automatic archiving of filled online redo log groups each time a
database instance is started, set the "LOG_ARCHIVE_START" parameter of a
database's parameter file to FALSE:
LOG_ARCHIVE_START=FALSE
The new value takes effect the next time the database is started.
And, archive log list; command executed from SVRMGRL will show:
Automatic archival Disabled
Disabling Automatic Archiving after Instance Startup
====================================================
To disable the automatic archiving of filled online redo log groups without
shutting down the current instance, use the SQL command ALTER SYSTEM
with the ARCHIVE LOG STOP parameter.
The following statement stops archiving:
SVRMGRL> ALTER SYSTEM ARCHIVE LOG STOP;
If ARCH is archiving a redo log group when you attempt to disable automatic
archiving, ARCH finishes archiving the current group, but does not
begin archiving the next filled online redo log group.
The instance does not have to be shut down to disable automatic archiving.
However, if an instance is shut down and restarted after automatic
archiving is disabled, the instance is reinitialized using the settings
of the parameter file ("LOG_ARCHIVE_START"), which may or may not
enable automatic archiving.
NOTE: If you choose to disable automatic archiving and have not
disabled archiving altogether, you are responsible to archive
all filled redo log groups or else database operation is
temporarily suspended (you will experience a database hang)
until the necessary archiving is performed.
Performing Manual Archiving
===========================
If a database is operating in ARCHIVELOG mode, inactive groups of filled online
redo log files must be archived. You can manually archive groups of
the online redo log whether or not automatic archiving is enabled.
If automatic archiving is not enabled, you must manually archive groups of
filled online redo log files in a timely fashion. If all online redo
log groups are filled but not archived, LGWR cannot reuse any inactive
groups of online redo log members to continue writing redo log entries.
Therefore, database operation is temporarily suspended until the necessary
archiving is performed. You can exercise this scenario by executing
alter system switch logfile; command when automatic archival is disabled.
Attempting to repeat that command with a last redo log group will show hang,
and it won�t be completed with �statement processed� message until archiving
is done.
If automatic archiving is enabled, but you want to rearchive an inactive group
of filled online redo log members to another location, you can use manual
archiving. (However, the instance can decide to reuse the redo log group before
you have finished manually archiving, thereby overwriting the files. If this
happens, Oracle will display an error message in the ALERT file.)
To manually archive a filled online redo log group, you must be connected with
administrator privileges.
Manually archive inactive groups of filled online redo log members using the
SQL command:
SVRMGRL> ALTER SYSTEM ARCHIVE LOG ALL;
archives all unarchived log files: