Thursday, April 17, 2008

Enabling ARCHIVELOG Mode

OVERVIEW

Most of the High Availability features of Oracle require you to enable ARCHIVELOG mode for your database.When you enable this mode redo logs will be archived instead of overwritten. The archivelogs are stored in a seperate place usually can backed up regularly by your standard filesystem backup system. Archive logs are utilized by RMAN, Data Guard, Flashback and many others.

If you are going to enable archivelog mode on a production database, I recommend shutting down the database and take a cold backup (Keeping a "final noarchivelog mode backup" which is to be a good and excepted practice).


Enabling Archive Mode

Enabling archive mode is simple, set the parameter LOG_ARCHIVE_DEST then connect to your database in mounted but closed mode (startup mount) and alter the database.

Lets start by checking the current archive mode of your DB.

SQL> SELECT LOG_MODE FROM SYS.V$DATABASE;

LOG_MODE
------------
NOARCHIVELOG

So we're in NOARCHIVELOG mode and we need to change.

SQL> CONN / AS SYSDBA;
SQL>ALTER SYSTEM set LOG_ARCHIVE_DEST = "c:\oracle\admin\test\archive"
scope = both;
System altered.

SQL> Archive Log List;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination c:\oracle\admin\test\archive
Oldest online log sequence 161
Next log sequence to archive 163
Current log sequence 163

You can specify as many as 10 diffrent archive log destinations by using the paramters log_archive_dest_1 through log_archive_dest_10. Remember, if you run out of space in your archive log destination the database will shut down/Hang!

SQL> shutdown immediate;
ORACLE instance shutdown.
SQL> startup mount
ORACLE instance started.

Total System Global Area 184549376 bytes
Fixed Size 1300928 bytes
Variable Size 157820480 bytes
Database Buffers 25165824 bytes
Redo Buffers 262144 bytes
Database mounted.

SQL> alter database archivelog;
Database altered.

SQL> alter database open;
Database altered.

There are several system views that can provide you with information reguarding archives, such as:

V$DATABASE : Identifies whether the database is in ARCHIVELOG or NOARCHIVELOG mode and whether MANUAL (archiving mode) has been specified.
V$ARCHIVED_LOG: Displays historical archived log information from the control file. If you use a recovery catalog, the RC_ARCHIVED_LOG view contains similar information.
V$ARCHIVE_DEST: Describes the current instance, all archive destinations, and the current value, mode, and status of these destinations.
V$ARCHIVE_PROCESSES: Displays information about the state of the various archive processes for an instance.
V$BACKUP_REDOLOG:Contains information about any backups of archived logs. If you use a recovery catalog, the RC_BACKUP_REDOLOG contains similar information.
V$LOG:Displays all redo log groups for the database and indicates which need to be archived.
V$LOG_HISTORY:Contains log history information such as which logs have been archived and the SCN range for each archived log.
Disable ARCHIVELOG Mode

Disabling archive mode is simple, connect to your database in mounted but closed mode (startup mount) and alter the database.

SQL> shutdown immediate;
ORACLE instance shutdown.
SQL> startup mount
ORACLE instance started.

Total System Global Area 184549376 bytes
Fixed Size 1300928 bytes
Variable Size 157820480 bytes
Database Buffers 25165824 bytes
Redo Buffers 262144 bytes
Database mounted.

SQL>
alter database noarchivelog;
Database altered.
SQL> alter database open; Database altered.





Post a Comment