DB – Archive log mode


Versao Portuguesa





This post comes out from the practice to learn and preparation the subjects for OCP - Oracle Certified Professional . In simple words, Oracle works with logs, all DMS/DDL are written in log file, know as redo logs, the written happens in circular way. So the files are redo file contents will be replaced, with the transactions. In order to keep that info, Oracle allows to archive the contents.

It has a few reasons to archive the redo log, for now let focus on one, teh need of recover the database. I mean some thing happened and is need to put the database back. The traditional method is done in two steps.

1) Restore - restore data files and control files
2) Recover - Apply logs, in this case the archive logs .. and eventually redo log

Let's see how to do that, but for now a note, the database should be in mount state and in a consistent manner, eg after a "shutdown immediate".





SQL> select startup_time from  v$instance;
STARTUP_Time
---------
19-DEC-12

SQL> select dbid,name,log_mode,flashback_on from  v$database;

      DBID        NAME       LOG_MODE          FLASHBACK_ON
----------          ---------      ------------               ------------------
1272537938 ORCL        NOARCHIVELOG   NO

SQL>  archive log list;
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     6
Current log sequence           8

SQL>  alter system  switch logfile;
System altered.

SQL>  archive log list;
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     8
Current log sequence           10

SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup mount;
ORACLE instance started.

Total System Global Area  577511424 bytes
Fixed Size                  1338000 bytes
Variable Size             364905840 bytes
Database Buffers          205520896 bytes
Redo Buffers                5746688 bytes
Database mounted.

SQL> alter database archivelog;
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     10
Next log sequence to archive   12
Current log sequence           12

SQL> alter database open;
Database altered.

SQL> select dbid,name,log_mode,flashback_on from  v$database;

      DBID         NAME                              LOG_MODE     FLASHBACK_ON
----------           ------------------------------ ------------          ------------------
1272537938  ORCL                                ARCHIVELOG   NO






Thank you for reading, hope this post was helpful.
Rogerio


Comments