10.21.2010

Q: How to Enable Archive Log?

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 is simple, set the parameter LOG_ARCHIVE_DEST then connect to your database in mounted but closed mode (startup mount) and alter the database.

oracle@saturn:~$ echo $ORACLE_SID
DBTARGET

Connect as sysdba:
SQL> select LOG_MODE from v$database;
LOG_MODE
---------------------
NOARCHIVELOG

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 612368384 bytes
Fixed Size 2074664 bytes
Variable Size 180357080 bytes
Database Buffers 423624704 bytes
Redo Buffers 6311936 bytes
Database mounted.

SQL> alter database archivelog;
Database altered.

SQL> alter database open;
Database altered.

SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 5
Next log sequence to archive 7
Current log sequence 7
SQL> conn tnahar
Enter password:
Connected.

SQL> select LOG_MODE from v$database;

LOG_MODE
------------------------
ARCHIVELOG

SQL> show parameter log_archive_dest

NAME TYPE VALUE
------------------------------------ ----------------- ------------------------------
log_archive_dest string
log_archive_dest_1 string
log_archive_dest_10 string
log_archive_dest_2 string
log_archive_dest_3 string
log_archive_dest_4 string
log_archive_dest_5 string
log_archive_dest_6 string
log_archive_dest_7 string
log_archive_dest_8 string
log_archive_dest_9 string

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_state_1 string enable
log_archive_dest_state_10 string enable
log_archive_dest_state_2 string enable
log_archive_dest_state_3 string enable
log_archive_dest_state_4 string enable
log_archive_dest_state_5 string enable
log_archive_dest_state_6 string enable
log_archive_dest_state_7 string enable
log_archive_dest_state_8 string enable
log_archive_dest_state_9 string enable



SQL> alter system set log_archive_dest_1='location=/dump/DBTARGET_ARCHIVELOG/';

SQL> archive log list;Database log mode Archive Mode
Automatic archival Enabled
Archive destination /dump/DBTARGET_ARCHIVELOG/
Oldest online log sequence 5
Next log sequence to archive 7
Current log sequence 7

SQL>exit
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;SQL> startup mountSQL> alter database noarchivelog; 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.