Parallel recovery significantly reduces recovery time and minimizes database downtime in situations where recovery cannot be performed while the database is open. During serial recovery, changes that were generated by several concurrent processes are applied sequentially to the datafile. Therefore, if there are a large number of changes to apply, media recovery can take longer than the time it took to initially generate these changes. However, parallel recovery applies these changes simultaneously from a redo log file to different datafiles, thus saving time.
Steps of Parallel Recovery
Parallel recovery can be performed either manually or automatically. To manually perform a parallel recovery, you simply start several Server
Manager sessions and issue the RECOVER DATAFILE <datafile_name> command on different datafiles in each session.
This method is not efficient because each session has to read the entire redo log file. Therefore, automatic parallel recovery is the preferred procedure. In the rest of the course, whenever parallel recovery is mentioned, it will refer to automatic parallel recovery as shown in the parallel-records below.
Specifying Parallel Recovery
There are two ways to specify parallel recovery:
Set the RECOVERY_PARALLELISM parameter in the parameter file for your database and restart the database with this parameter file;
Specify the PARALLEL recover-parallel-clause in the
RECOVER DATABASE
command.
Syntax for RECOVER command with PARALLEL clause
The syntax in the example below shows the code for the RECOVER command with the PARALLEL clause.
The value of DEGREE specifies the number of recovery processes Oracle will create to apply the redo information to the datafiles. This value overrides the value set in the RECOVERY_PARALLELISM parameter.
If you use the NOPARALLEL clause in the RECOVER command, you are specifying that the recovery is a serial process. This clause again overrides the value for the RECOVERY_PARALLELISM parameter.
The RECOVERY_PARALLELISM parameter determines the default number of recovery processes per session if there is no PARALLEL clause specified in the RECOVER
command. For most media recovery situations, Oracle recommends you set the parameter for one or two recovery processes for each disk containing datafiles. When you set the value for the RECOVERY_PARALLELISM parameter in the
initSID.ora file, pay attention to the following guidelines:
The value must be greater than 1
The value cannot be greater than the value of another initialization parameter PARALLEL_MAX_SERVERS (which specifies the number of parallel server processes for an instance)
You can also start a parallel recovery by specifying the PARALLEL clause in the RECOVER command like this:
Question: How would I execute the command 'RECOVER DATABASE PARALLEL (DEGREE 2);' in SQL*Plus?
The SQL*Plus command-line interface provides an environment to execute SQL commands and PL/SQL code. To execute the RECOVER DATABASE PARALLEL (DEGREE 2); command, which is intended to initiate parallel media recovery in Oracle Database, you need to follow these steps:
Start SQL*Plus: The SQLPlus tool is typically invoked from the command line. On most systems, you can start SQLPlus by typing sqlplus and hitting enter.
Connect to the Database: After starting SQL*Plus, you need to connect to the database as a user with the necessary privileges. This is usually the SYS user, and the connection is made as SYSDBA. The command to connect will look something like this:
CONNECT SYS as SYSDBA
After typing this command, you'll be prompted to enter the SYS user password.
Execute the RECOVER Command: Once you're connected to the database with the proper privileges, you can issue the RECOVER DATABASE PARALLEL (DEGREE 2); command. This will start the database recovery process using two parallel threads, which can significantly speed up the recovery process for large databases.
RECOVER DATABASE PARALLEL (DEGREE 2);
Monitor the Recovery Process: Depending on the size and state of your database, the recovery process may take some time. You can monitor the recovery progress in the alert log and through the V$RECOVERY_STATUS dynamic performance view.
Remember, before you execute any significant operation like a database recovery, ensure that you have a complete and recent backup of your database. The RECOVER DATABASE command should only be run in situations where you've confirmed that media recovery is necessary, such as when a datafile has been damaged or deleted. The parallel recovery option should be used judiciously based on the system's resource availability, as it can be resource-intensive.
Lastly, while SQL*Plus is a common tool for managing Oracle Databases, consider using Oracle Enterprise Manager (EM) for complex recovery operations, as it offers a more user-friendly interface.
The value specified in the PARALLEL clause above overrides the value of the RECOVERY_PARALLELISM parameter.
The next lesson demonstrates how to reconstruct a lost or corrupted control file.