How to Enable and Maintain Oracle 12c Archives - dummies

How to Enable and Maintain Oracle 12c Archives

By Chris Ruel, Michael Wessler

If you haven’t already done so, enabling your system to archive your Oracle 12c is a very simple process. However, keep these things in mind:

  • You have to shut down and restart the database.

  • You must have enough space to store your archive logs.

Before you turn on archiving, decide where to store the archive log files. Use the Fast Recovery Area for archiving.

How to enable the Fast Recovery Area in Oracle 12c

Follow along to enable the Fast Recovery Area:

  1. Open a command prompt to your operating system.

  2. Log in to SQL*Plus as SYSDBA:

    <sqlplus / as sysdba>
  3. Configure how much space you want to dedicate to your Fast Recovery Area:

    <alter system set db_recovery_file_dest_size = 100G;>

    This example dedicates 100GB. You should see this:

    System altered.
  4. Choose the destination:

    <alter system set db_recovery_file_dest=

    You should see this:

    System altered.

    Now Oracle automatically creates your archive logs under the Fast Recovery Area. The archive process creates a folder for your database and the subfolder for the date the archives were created. It organizes them very nicely.

If you want to see how much of your Fast Recovery Area is used, log in to SQL*Plus and query the view V$FLASH_RECOVERY_AREA_USAGE. It’s sort of a misnomer. Oracle still hasn’t changed the name of this view from FLASH to FAST even though they made the change in the documentation two versions ago.

After determining where you want to keep the archive logs, you can turn on archiving. These steps walk you through the process:

  1. Open a command prompt to your operating system.

  2. Log in to SQL*Plus as SYSDBA:

    <sqlplus / as sysdba>
  3. Shut down the database:

    <shutdown immediate>

    You see this:

    Database closed.
    Database dismounted.
    ORACLE instance shut down.
  4. Start the database in mount mode:

    <startup mount>

    You see something like this:

    ORACLE instance started.
    Total System Global Area 1336176640 bytes
    Fixed Size         2287480 bytes
    Variable Size      1258293384 bytes
    Database Buffers      67108864 bytes
    Redo Buffers        8486912 bytes
    Database mounted.
  5. Issue the command to enable archive mode:

    <alter database archivelog;>

    You should see this:

    Database altered.
  6. Open the database:

    <alter database open;>

    You should see this:

    Database altered.

    Now your database is in archive log mode, and archive log files should show up in your Fast Recovery Area.

If you’re impatient and want to see them now, type the following:

<alter system archive log current;>

You see this:

System altered.

If you navigate to your Fast Recovery Area, you should see one of your archive logs under a subdirectory with today’s date.

How to maintain the archives in Oracle 12c

Archive logs are a fundamental part of your backup and recovery strategy. However, they can take up a lot of space and need to be backed up. Luckily, backing up your archive logs is no more difficult than backing up anything else in your database. Furthermore, RMAN has some features to help you reclaim that space the archives occupy.

Make a backup of all your archive logs with this:

<backup archivelog all tag=archive_bak;>

This command backs up all the archive logs in your archive destination, which can be a tall order depending on how often you issue this command.

Back up your archive logs at least once per day. Keep your archive logs for up to 30 days.

Instead of backing up all archive logs every time, you might try backing up only the ones created since the last backup. To do so, type this:

<backup archivelog all not backed up tag=archive_bak;>

You could issue that command every day as part of your backup strategy. You could even do it several times a day just to be sure you get all of your archive logs backed up as often as possible. When the archive logs are backed up, you may not want them in the archive destination; they take up space after all.

Recovery Management (RMAN) offers a convenient command to clean up any successfully backed-up archives. If you want to back up all your archive logs and then delete the files that were backed up, type this:

<backup archivelog all delete input tag=archive_bak;>

We favor the “delete input” clause of the command as part of an archive log backup strategy:

  • It allows you to back up any archive logs that exist in your archive destination while at the same time freeing up space.

  • RMAN deletes the archive logs only if the backup was successful.

  • You don’t have to worry about coming up with a time formula that will back up the archives every so often. Because it deletes the ones it successfully backs up, you can specify “all” every time, ensuring that none are missed.

Run an archive log backup command every time you do any database backup. That way, you have everything you need to recover if there’s a failure.