Lab-02-Backup and Recovery Configuration
Lab-02-Backup and Recovery Configuration
Overview
In these practices, you learn how to configure your database to enable recovery from various
losses. You verify the control file configuration, the fast recovery area (FRA), redo log groups,
ARCHIVELOG mode, and redundant archive log destinations.
How to configure your database for recovery:
Ensure redundancy of control files. If a control file is damaged or lost, recovery is
easier if you have another copy.
Review the fast recovery area configuration.
Ensure that there are at least two redo log members in each group. If a redo log
member is damaged or lost, recovery is easier when you have an additional member in
Overview
In this practice, you verify that the control file is multiplexed.
A control file is a small binary file that describes the structure of the database. It must be
available for writing by the Oracle server whenever the database is mounted or opened. Without
this file, the database cannot be mounted, and recovery or re-creation of the control file is
required. Your database should have a minimum of two control files on different storage devices
to minimize the impact of a loss of one control file. The loss of a single control file causes the
instance to fail because all control files must be available at all times. However, recovery can be
a simple matter of copying one of the other control files. The loss of all control files is slightly
more difficult to recover from, but is not usually catastrophic.
Tasks
1. Open a terminal window and start SQL*Plus and connect to the CDB root as the SYS user
with the SYSDBA privilege.
$ sqlplus / AS SYSDBA
...
SQL>
2. Find out how many control files exist in the database. The query returns the names of two
control files (control01.ctl and control02.ctl), which verifies that the control files
are multiplexed.
SQL> SELECT name FROM v$controlfile;
NAME
----------------------------------------------------------------
/u01/app/oracle/oradata/ORCLCDB/control01.ctl
/u01/app/oracle/fast_recovery_area/ORCLCDB/control02.ctl
SQL>
When the CDB was created, DBCA created two control files. When you use the CREATE
DATABASE command in SQL*Plus to create a database, you configure the
CONTROL_FILES parameter to generate two control files and set their names.
NAME TYPE
---------------------------------------------------- -------
VALUE
--------------------------------------------------------
control_files string
/u01/app/oracle/oradata/ORCLCDB/control01.ctl,
/u01/app/oracle/fast_recovery_area/ORCLCDB/control02.ctl
SQL>
File created.
SQL>
5. Shut down the database instance in IMMEDIATE mode.
SQL> SHUTDOWN IMMEDIATE
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
6. Exit SQL*Plus.
SQL> EXIT
7. Create a directory for the new control file.
$ mkdir -p /u01/app/oracle/controlfiles_dir/ORCLCDB
$
8. Before you edit your PFILE, make a backup of it.
$ cp $ORACLE_HOME/dbs/initorclcdb.ora
$ORACLE_HOME/dbs/backup_initorclcdb.ora
$
9. Copy one of the control files to the directory you created in a previous step
(/u01/app/oracle/controlfiles_dir/ORCLCDB) and name the file
control03.ctl.
$ cp /u01/app/oracle/oradata/ORCLCDB/control01.ctl
/u01/app/oracle/controlfiles_dir/ORCLCDB/control03.ctl
$
SQL>
12. Start the database instance.
SQL> STARTUP
ORACLE instance started.
…
Database opened.
SQL>
13. View the CONTROL_FILES parameter again.
SQL> SHOW PARAMETER control_files
NAME TYPE
------------------------------------ -----------
VALUE
------------------------------
control_files string
/u01/app/oracle/oradata/ORCLCDB/control01.ctl,
/u01/app/oracle/fast_recovery_area/ORCLCDB/control02.ctl
SQL>
Question: Why does the CONTROL_FILES parameter still show only two control files?
Answer: By default, the database instance starts up with the SPFILE. If an SPFILE does
not exist, then the instance starts up with a PFILE. In this case, both an SPFILE and PFILE
are present, so the SPFILE takes precedence. You configured the PFILE, not the SPFILE.
The SPFILE still contains only two references.
SQL>
b. Create the SPFILE.
SQL> CREATE SPFILE FROM PFILE;
File created.
SQL>
16. Start the database instance.
SQL> STARTUP
ORACLE instance started.
…
Database mounted.
Database opened.
SQL>
17. View the CONTROL_FILES parameter again. The third control file is now included in the list,
which indicates that the SPFILE is configured properly. The results below are formatted for
easier viewing.
SQL> SHOW PARAMETER control_files
SQL> exit
...
$
19. Run the cleanup02-01.sh script to clean up the environment.
$ /home/oracle/labs/admin/cleanup02-01.sh
...
SQL>
System altered.
Overview
In this practice, you review the fast recovery area (FRA) configuration and change its size to 12
GB.
Time Estimate
It should take approximately 5 minutes to complete this practice.
Tasks
1. Evaluate the space needed for the FRA. The amount of disk space to allocate for the FRA
depends on the size and activity levels of your database. As a general rule, the larger the
NAME TYPE
------------------------------------ -----------
VALUE
------------------------------
db_recovery_file_dest string
/u01/app/oracle/fast_recovery_area
db_recovery_file_dest_size big integer
14970M
SQL>
Question: Is the fast recovery area enabled?
Answer: Yes. The DB_RECOVERY_FILE_DEST and DB_RECOVERY_FILE_DEST_SIZE
parameters values are not null, indicating that the fast recovery area is enabled.
Question: What changes can you make to the fast recovery area?
Answer: You can change the location and size of the fast recovery area.
Question: Does changing the size of the fast recovery area require the database to be
restarted?
System altered.
SQL>
Note: If the archived redo log file destination fills up or cannot be written to, the database
will halt. You would then need to remove archived redo log files from the archived redo log
file destination so that the database could resume operations. This activity is covered in one
Overview
Ensure that there are at least two redo log members in each group. If you are using file system
storage, then each member should be distributed on separate disks or controllers so that no
single equipment failure impacts an entire log group. The loss of an entire current log group is
one of the most serious media failures because it can result in data loss. The loss of a single
member of a multi-member log group does not affect database operation (other than causing an
alert to be published in the alert log). One set of members should be stored in the FRA.
Time Estimate
It should take approximately 20 minutes to complete this practice.
SQL>
Question: Why is it recommended to have three groups when two would be sufficient?
Answer: The Oracle Database server treats the online redo log groups as a circular buffer
in which to store transaction information, filling one group and then moving on to the next.
After all groups have been written to, the Oracle Database server begins overwriting
information in the first log group. If the database is configured in ARCHIVELOG mode, the
LGWR cannot overwrite data in the first log group if it has not been archived.
Question: Can multiplexing redo logs impact database performance?
Answer: Multiplexing redo logs may heavily influence database performance because a
commit cannot complete until the transaction information has been written to the logs by
LGWR. You must place your redo log files on your fastest disks served by your fastest
controllers. If possible, do not place any other database files on the same disks as your
redo log files. Because only one group is written to at a given time, there is no performance
impact in having members from several groups on the same disk.
2. Add another member to each redo log group. Name each member redonnb.log, where
nn represents the group number.
Database altered.
Database altered.
Database altered.
SQL>
3. Verify that the redo log files are now multiplexed. The query result shows that each group
has two members, and therefore, the redo log files are multiplexed. Observe the INVALID
status of the newly added redo log members. This status is expected because the new
members have not yet been written to by LGWR. When a log switch occurs and the group
containing the new member becomes CURRENT, the new member's status will change to
null.
SQL> SELECT group#, status, member FROM v$logfile ORDER BY 1, 3;
1
/u01/app/oracle/oradata/ORCLCDB/redo01.log
2 INVALID
/u01/app/oracle/fast_recovery_area/ORCLCDB/redo02b.log
2
/u01/app/oracle/oradata/ORCLCDB/redo02.log
3 INVALID
/u01/app/oracle/fast_recovery_area/ORCLCDB/redo03b.log
6 rows selected.
SQL>
4. Switch the log files and observe the changes.
a. Find out which log group is the current log group. In this example, the query result
shows that group 1 is the current group. Your current group may be different.
SQL> SELECT group#, members, status FROM v$log;
System altered.
System altered.
System altered.
SQL>
GROUP# STATUS
------ -------
MEMBER
----------------------------------------------------------------
1
/u01/app/oracle/fast_recovery_area/ORCLCDB/redo01b.log
2
/u01/app/oracle/fast_recovery_area/ORCLCDB/redo02b.log
2
/u01/app/oracle/oradata/ORCLCDB/redo02.log
3
/u01/app/oracle/fast_recovery_area/ORCLCDB/redo03b.log
3
/u01/app/oracle/oradata/ORCLCDB/redo03.log
6 rows selected.
SQL>
d. Query the V$LOG view again to learn which log group is now the current group. In this
example, the results show that the LGWR is writing to group 1. Your group may be
different. Your statuses may be different too. An INACTIVE status means the log group
is no longer needed for database instance recovery.
SQL> SELECT group#, members, status FROM v$log;
System altered.
SQL>
f. Query the V$LOG view again. The current group has changed to group 2, and the
former current group's status is now ACTIVE. Your current group may be different. An
ACTIVE status means that the log group is active, but it’s not the current log group. It is
needed for crash recovery. It may be in use for block recovery.
SQL> SELECT group#, members, status FROM v$log;
System altered.
SQL>
h. Query the V$LOG view again. The current group has changed again to group 3, and the
status of both the other groups is now ACTIVE. Your current group may be different.
SQL> SELECT group#, members, status FROM v$log;
SQL>
Question: Can the LGWR background process write to only one member of the CURRENT
group in case the other members are missing or damaged?
Answer: Yes, it can. As long as there is one member left in the CURRENT group, LGWR
can work.
GROUP# STATUS
---------- ----------------
1 ACTIVE
2 ACTIVE
3 CURRENT
SQL>
Database altered.
System altered.
SQL>
c. Drop the member in the next group and then perform a log switch.
SQL> ALTER DATABASE DROP LOGFILE MEMBER
'/u01/app/oracle/fast_recovery_area/ORCLCDB/redo03b.log';
Database altered.
System altered.
SQL>
Database altered.
System altered.
SQL>
e. Verify that each group now has only one member.
SQL>
f. Exit from SQL*Plus.
SQL> exit
…
$
g. Remove the physical files from the operating system.
$ rm /u01/app/oracle/fast_recovery_area/ORCLCDB/redo*.log
$
h. Verify that the redo log files have been removed.
$ ls /u01/app/oracle/fast_recovery_area/ORCLCDB
archivelog control02.ctl onlinelog
$
Overview
In this practice, you configure your database for ARCHIVELOG mode so that redo logs are
archived.
Time Estimate
It should take approximately 10 minutes to complete this practice.
Tasks
1. Run the setup02-04.sh script to prepare the environment for this practice.
SQL>
Database altered.
...
$
2. Log in to SQL*Plus as the SYS user with the SYSDBA privilege.
$ sqlplus / AS SYSDBA
…
SQL>
3. Issue the ARCHIVE LOG LIST command to determine whether the database is in
ARCHIVELOG mode.
SQL> archive log list
Database log mode No Archive Mode
Automatic archival Disabled
Database altered.
SQL>
d. Verify that the database is now in ARCHIVELOG mode.
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 25
Next log sequence to archive 27
Current log sequence 27
SQL>
Database altered.
SQL>