Oracle by Example brandingConfigure Recovery Settings

section 0Before You Begin

This 15-minute tutorial shows you how to configure the Fast Recovery Area, set the database in ARCHIVELOG mode, and enable Flashback Database.

Select the Oracle Database release:

Background

Oracle Recovery Manager (RMAN), a command-line tool, is the method preferred by Oracle for efficiently backing up and recovering your Oracle database. The files protected by the backup and recovery facilities built into RMAN include data files, control files, server parameter files, and archived redo log files. With these files you can reconstruct your database.

What Do You Need?

  • Oracle Database 18c19c

section 1Configure the Fast Recovery Area

  1. Open a terminal window. Execute the oraenv utility to set the environment variables for the orcl database.
    $ . oraenv
    ORACLE_SID = [oracle] ? orcl
    The Oracle base has been set to /scratch/u01/app/oracle
  2. Invoke SQL*Plus and log in as the SYSTEM user.
    $ sqlplus system
    
    SQL*Plus: Release 18.0.0.0.0 - Production on Thu Mar 28 03:04:00 2019
    Version 18.3.0.0.0
    
    Copyright (c) 1982, 2018, Oracle.  All rights reserved.
    
    Enter password: 
    Last Successful login time: Thu Mar 28 2019 02:54:20 -07:00
    
    Connected to:
    Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
    Version 18.3.0.0.0
    
    SQL>  SQL*Plus: Release 19.0.0.0.0 - Production on Mon Jul 15 01:08:39 2019
    Version 19.3.0.0.0
    
    Copyright (c) 1982, 2019, Oracle.  All rights reserved.
    
    
    Connected to:
    Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
    Version 19.3.0.0.0
    
    SQL> 
    
  3. Use the following SQL*Plus command to view the settings for all initialization parameters containing "recovery" in the name.
    QL> show parameter recovery
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    db_recovery_file_dest                string      /scratch/u01/app/oracle/recove
                                                     ry_area
    db_recovery_file_dest_size           big integer 12918M
    recovery_parallelism                 integer     0
    remote_recovery_file_dest            string
    
  4. Note that the size of your Fast Recovery Area may differ from what is shown in this example. The location of the Fast Recovery Area is set by the DB_RECOVERY_FILE_DEST initialization parameter. Oracle recommends that the Fast Recovery Area be located on a separate storage device from the database files.
  5. Set the Fast Recovery Area size to 10GB by executing the following command.
    SQL> alter system set db_recovery_file_dest_size=10G;
    
    System altered.
    SQL> show parameter recovery
    
                                                                                                                                                                                                         
    NAME                                 TYPE        VALUE                                                                                                                                               
    ------------------------------------ ----------- ------------------------------                                                                                                                                
    db_recovery_file_dest                string      /scratch/u01/app/oracle/recove                                                                                                                                
                                                     ry_area                                                                                                                                                       
    db_recovery_file_dest_size           big integer 10G                                                                                                                                                           
    recovery_parallelism                 integer     0                                                                                                                                                             
    remote_recovery_file_dest            string     
  6. You can also execute this command in RMAN.

section 2Enable Archiving of Redo Log Files

  1. Open a terminal window. Invoke SQL*Plus and connect as the SYSDBA user.
    $ . oraenv
    ORACLE_SID = [oracle] ? orcl
    The Oracle base has been set to /scratch/u01/app/oracle
    $ sqlplus / as sysdba
    
    SQL*Plus: Release 18.0.0.0.0 - Production on Thu Mar 28 03:04:00 2019
    Version 18.3.0.0.0
    
    Copyright (c) 1982, 2018, Oracle.  All rights reserved.
    
    Enter password: 
    Last Successful login time: Thu Mar 28 2019 02:54:20 -07:00
    
    Connected to:
    Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
    Version 18.3.0.0.0
    
    SQL>  SQL*Plus: Release 19.0.0.0.0 - Production on Mon Jul 15 01:08:39 2019
    Version 19.3.0.0.0
    
    Copyright (c) 1982, 2019, Oracle.  All rights reserved.
    
    
    Connected to:
    Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
    Version 19.3.0.0.0
    
    SQL> 
    
  2. Execute the following command to determine whether your database is in ARCHIVELOG mode.
    SQL> archive log list
    Database log mode              No Archive Mode
    Automatic archival             Disabled
    Archive destination            USE_DB_RECOVERY_FILE_DEST
    Oldest online log sequence     41
    Current log sequence           43
    SQL> 
    
  3. Switch to the RMAN terminal and execute the following command to shut down the database instance.
    RMAN> shutdown immediate
    
    using target database control file instead of recovery catalog
    database closed
    database dismounted
    Oracle instance shut down.
  4. Execute the following command to start the instance and mount the database.
    RMAN> startup mount
    
    connected to target database (not started)
    Oracle instance started
    database mounted
    
    Total System Global Area    3355443200 bytes
    
    Fixed Size                     8791392 bytes
    Variable Size               1862273696 bytes
    Database Buffers            1476395008 bytes
    Redo Buffers                   7983104 bytes
  5. Execute the following command to create a backup before you change the ARCHIVELOG mode.
    RMAN> backup database;
    Click output.txt to view the output.
  6. Execute the following command to put the database in ARCHIVELOG mode.
    RMAN> alter database archivelog;
    
    Statement processed
  7. Execute the following command to open the database.
    RMAN> alter database open;
    
    Statement processed
  8. Return to your SQL*Plus session (You might need to re-connect to sqlplus / as sysdba). Verify if the database is in ARCHIVELOG mode.
    SQL> connect / as sysdba
    Connected.
    SQL> archive log list;
    Database log mode              Archive Mode
    Automatic archival             Enabled
    Archive destination            USE_DB_RECOVERY_FILE_DEST
    Oldest online log sequence     41
    Next log sequence to archive   43
    Current log sequence           43
    SQL> 
    
  9. Exit SQL*Plus.
  10. Return to your RMAN session. Back up the database by executing the following command.
    RMAN> backup database plus archivelog;
    Click output.txt to view the output.

section 3Enabling Flashback Database

  1. Invoke RMAN and connect to the target database as the SYSBACKUP user.
    $ rman target sysbackup
    Recovery Manager: Release 18.0.0.0.0 - Production on Thu Mar 28 21:54:00 2019
    Version 18.3.0.0.0
    
    Copyright (c) 1982, 2018, Oracle and/or its affiliates.  All rights reserved.
    
    target database Password: enter password
    connected to target database: ORCL (DBID=1530541453)
    
    RMAN> Recovery Manager: Release 19.0.0.0.0 - Production on Thu May 28 21:54:00 2019
    Version 19.3.0.0.0
    
    Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.
    
    target database Password: enter password
    connected to target database: ORCL (DBID=1530541453)
    
    RMAN> 
    
  2. Optionally, specify the length of the desired flashback window (in minutes) by setting the DB_FLASHBACK_RETENTION_TARGET initialization parameter. The default value for this parameter is 1440 minutes, which is one day. This example sets the flashback window to 3 days:
    RMAN> alter system set db_flashback_retention_target=4320;
    
    using target database control file instead of recovery catalog
    Statement processed
  3. Enable Flashback Database by executing the following command.
    RMAN> alter database flashback on;
    
    Statement processed