What is Oracle's ArchiveLog mode
Oracle writes to online rebuild log files (redo log online) in a cyclic manner, Oracle saves all the transactions that are being performed in these redo log files online. It starts writing to the first redo log file online, when it fills it passes to the second, and so on until the last redo log file online, when it fills the last one it initiates a process in the background called LGWR (Log Writer) to overwrite The contents of the first redo log file online and start over. When Oracle runs in ARCHIVELOG mode the background process called ARCH makes a copy of each redo log file online once the LGWR process finishes writing to it, it saves that copy to the offline rebuild files (redo log Offline) to disk:
Before proceeding, we can see whether or not the Archive mode is active with the command SQL> ARCHIVE LOG LIST from SqlPlus.
Define the path where the copy of the Redo Logs will be created
We have to define the path in the parameter log_archive_dest_1 as follows from SqlPlus with the user sys:
SQL> ALTER SYSTEM SET log_archive_dest_1='LOCATION=/U/oradata/PRUEBA/archive' SCOPE=SPFILE;
Format the name of the files to back up
For this we use the parameter log_archive_format as shown below from SqlPlus with the user sys:
SQL> ALTER SYSTEM SET log_archive_format='PRUEBA_%s.arc' SCOPE=SPFILE
Where TEST is the name of the database,% s is the log sequence number and arc is the extension that indicates that it is an archive (archived)
To enable ArchiveLog mode (as a DBA user)
- You need to shut down the SQL database> SHUTDOWN IMMEDIATE ;
- After that it is mounted under SQL> STARTUP MOUNT ;
- We execute the following SQL command> ALTER DATABASE ARCHIVELOG ;
- Finally we open the SQL database> ALTER DATABASE OPEN ;
Note: If we want to deactivate the ArchiveLog mode we do the same steps as above but only change step 3 by the SQL> ALTER DATABASE NOARCHIVELOG;