⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch17.htm

📁 Teach yourself Oracle8 in 21 day
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>

<HEAD>

	<TITLE>Teach Yourself Oracle 8 In 21 Days -- Ch 17 -- Recovering the Database</TITLE>
</HEAD>

<BODY TEXT="#000000" BGCOLOR="#FFFFFF">

<CENTER>
<H1><IMG SRC="../buttonart/sams.gif" WIDTH="171" HEIGHT="66" ALIGN="BOTTOM" BORDER="0"><BR>
<FONT COLOR="#000077">Teach Yourself Oracle 8 In 21 Days</FONT></H1>
</CENTER>
<CENTER>
<P><A HREF="../ch16/ch16.htm"><IMG SRC="../buttonart/previous.gif" WIDTH="128" HEIGHT="28"
ALIGN="BOTTOM" ALT="Previous chapter" BORDER="0"></A><A HREF="../ch18/ch18.htm"><IMG
SRC="../buttonart/next.gif" WIDTH="128" HEIGHT="28" ALIGN="BOTTOM" ALT="Next chapter"
BORDER="0"></A><A HREF="../index.htm"><IMG SRC="../buttonart/contents.gif" WIDTH="128"
HEIGHT="28" ALIGN="BOTTOM" ALT="Contents" BORDER="0"></A> 
<HR>

</CENTER>
<CENTER>
<H1><FONT COLOR="#000077">- Day 17 -<BR>
Recovering the Database</FONT></H1>
</CENTER>
<P>Yesterday you learned how to back up your database; today you will learn how to
recover your database in the event of an emergency. Several types of failures can
necessitate a recovery:

<UL>
	<LI>An instance failure necessitates an instance recovery. As long as no permanent
	hardware failures have occurred, the instance recovery will be automatic and complete.
	Enabling parallel recovery improves performance.
	<P>
	<LI>A hardware failure that results in the loss of a datafile necessitates a media
	recovery. This involves both recovering the lost data and performing an instance
	recovery (if necessary). This process will be explained in the section titled &quot;Media
	Recovery.&quot;
	<P>
	<LI>A user error that results in the loss of data might necessitate a point-in-time
	recovery, which allows you to recover up to a certain point before the failure occurred.
	This can be very useful, but very problematic. The point-in-time recovery is detailed
	in the section titled &quot;The Point-in-Time Recovery.&quot;
</UL>

<P>No matter what type of recovery is required, the important task of recovery should
be performed as quickly as possible. If a failure requiring recovery occurs, many
users will have little to do until the recovery is complete. But even though the
recovery operation must be completed quickly, you should not rush. Any mistakes during
the recovery will only delay the resumption of normal operations.
<H3><FONT COLOR="#000077"><B>Recovery Versus Restoration</B></FONT></H3>
<P>Today you will learn about recovery and restoration operations. These two concepts
might sometimes be thought of as the same, but they are actually quite different:

<UL>
	<LI><I>Recovery</I> is the act of bringing the database back to where it was an instant
	before the failure, and refers to the process whereby Oracle rolls forward committed
	transactions and rolls back noncommitted transactions. Recovery is automatic.
	<P>
	<LI><I>Restoration</I> is the act of replacing a datafile with a backup copy. You
	can restore a database only if it is not running in <TT>ARCHIVELOG</TT> mode and
	has overwritten redo log files. Restoration is a manual operation requiring operator
	intervention (either by hand or via the graphical administration tools).
</UL>

<H2><FONT COLOR="#000077"><B>Recovering Your Database</B></FONT></H2>
<P>Despite how reliable hardware has become, there are still occasions when the system
might fail (perhaps because of a component failure or a power failure). If the failure
causes no data loss, Oracle can recover itself; this is referred to as an <I>instance
recovery</I>. If data has been lost, data must be restored from a previous backup
and recovered; this is referred to as <I>media recovery</I>. If some event, such
as an accidental deletion of a table, has occurred, a <I>point-in-time</I> <I>recovery</I>
must be performed to avoid recovering the table-drop statement and repeating the
mistake.
<H3><FONT COLOR="#000077"><B>Instance Recovery</B></FONT></H3>
<P><FONT COLOR="#000077"><B>New Term:</B></FONT><B> </B>When an instance failure
occurs, the Oracle recovery process can completely recover the database upon instance
startup. All transactions that were committed at the time of the failure will be
recovered, or <I>rolled forward</I>, and all transactions that were in process (also
known as <I>in-flight transactions</I>) will be <I>rolled back</I>.


<BLOCKQUOTE>
	<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>Instance recovery can be quite time
	consuming. How much time instance recovery takes depends on the number of dirty buffers
	in the SGA. The number of dirty buffers depends on how much time has passed since
	the last checkpoint and the number of data modifications. 
<HR>


</BLOCKQUOTE>

<P>The instance-recovery process is automatic. When the instance is started, the
startup process examines the datafiles and redo log files to determine whether the
instance was properly shut down. At this point, the redo log is read and the affected
transactions are rolled forward or back. If the checkpoint launched by the last log
switch was completed, the transactions in fewer than one log file will require recovery.


<BLOCKQUOTE>
	<P>
<HR>
<FONT COLOR="#000077"><B>TIP:</B></FONT><B> </B>If you tune the checkpoint interval
	and recovery parallelism, you can shorten the recovery time. 
<HR>


</BLOCKQUOTE>

<P>Users cannot access the database during the recovery process; only after the instance
recovery is complete can users access the database. For this reason, recovery time
should be kept to a minimum. Using the parallel-recovery feature of the Parallel
Query option can help you reduce the time it takes for instance recovery to be completed.
As you will see on Day 19, &quot;Advanced Oracle Options,&quot; the number of processes
or threads that perform the instance recovery can be tuned. If you tune the number
of recovery processes to run best with your system, you can optimize the recovery
interval.
<H3><FONT COLOR="#000077"><B>Media Recovery</B></FONT></H3>
<P>In the event of a media failure (if, for example, a datafile is damaged), data
recovery is necessary. If a datafile is damaged, you must restore it from backup
before recovery can occur. The Oracle recovery process then applies archive log files
and redo log files to restore the damaged datafile to its prior-to-failure state.
This process might require the use of all archive log files created since the backup
to recover the restored datafile, which can be quite time consuming.


<BLOCKQUOTE>
	<P>
<HR>
<FONT COLOR="#000077"><B>TIP:</B></FONT><B> </B>If you schedule frequent backups,
	you can shorten restoration and recovery time. Recovery time depends both on how
	much time has passed and how much data has been modified since the last backup. 
<HR>


</BLOCKQUOTE>

<P>By placing the latest backup files as well as any archive log files created since
the last backup online, you can shorten the time it takes to start the recovery process.
If you have a plan and have everything ready to go, things will run more smoothly.</P>
<P>In order to assist the recovery process, Oracle8 provides several different methods
for database recovery:

<UL>
	<LI>Backup Manager
	<P>
	<LI>OS facilities
	<P>
	<LI>The Import utility
	<P>
	<LI>The NT Recovery utility
</UL>

<P>Each of these utilities can perform an effective backup; personal preference and
your system needs dictate which one you use.
<H4><FONT COLOR="#000077"><B>Backup Manager</B></FONT></H4>
<P>As with the database-backup procedure, you can perform a recovery using Enterprise
Manager's Backup Manager utility. To do so, follow these steps:

<DL>
	<DD><B>1. </B>After you invoke Backup Manager, you can start the recovery process
	by selecting Recover | Restore Wizard.
	<P><B>2. </B>The Restore wizard leads you through a series of screens that are similar
	to those of the Backup wizard. The first screen, shown in Figure 17.1, allows you
	to choose what type of restore you want to perform. Note that I have selected the
	Tablespaces radio button. After you decide what type of restore you want to perform,
	click Next.
</DL>

<P><A NAME="01"></A><A HREF="01.htm"><B>Figure 17.1.</B></A></P>
<P><I>Screen one of the Restore wizard.</I></P>


<BLOCKQUOTE>
	<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>The available options in this case
	are Tablespaces and Datafiles. Because the instance is up and running in this example,
	the database recovery option is not available. If the instance was down, Database
	would be an option. 
<HR>


</BLOCKQUOTE>


<DL>
	<DD><B>3.</B> Because I chose the Tablespaces option, the Tablespaces screen (shown
	in Figure 17.2) appears. From here you select what tablespaces you want restored;
	you can choose as many or as few tablespaces as you want. Note that I have chosen
	to restore the <TT>DOGS</TT> tablespace. After you select a tablespace, click Next.
</DL>

<P><A NAME="02"></A><A HREF="02.htm"><B>Figure 17.2.</B></A></P>
<P><I>The Tablespaces screen of the Restore wizard.</I></P>

<DL>
	<DD><B>4. </B>After you select the tablespace(s) you want recovered, the Restore
	wizard determines which datafiles will be restored. The Rename screen, shown in Figure
	17.3, allows you to change the name of the datafile to be used in the restore. This
	is valuable because the volume that contains that datafile might not be available
	due to a hardware failure. If you want, you can change the name of the datafile.
	When you finish, click Next.
</DL>

<P><A NAME="03"></A><A HREF="03.htm"><B>Figure 17.3.</B></A></P>
<P><I>The Rename screen of the Restore wizard.</I></P>

<DL>
	<DD><B>5. </B>The Channels screen, shown in Figure 17.4, allows you to select the
	channel(s) to be used during the recovery process. Depending on how many backup files
	and datafiles you are working with, a larger number of channels can improve performance
	by adding some parallelism. It might occasionally be necessary to change the channel
	from the one used in the backup operation. After you determine what channel to use,
	click Next.
</DL>

<P><A NAME="04"></A><A HREF="04.htm"><B>Figure 17.4.</B></A></P>
<P><I>The Channels screen of the Restore wizard.</I></P>

<DL>
	<DD><B>6.</B> Finally, the Restore wizard presents the Summary screen, shown in Figure
	17.5. If all is correct, start the restoration process by clicking OK.
</DL>

<P><A NAME="05"></A><A HREF="05.htm"><B>Figure 17.5.</B></A></P>
<P><I>The Summary screen of the Restore wizard.</I></P>
<P>If you want to change the type of restore operation from an online to an offline
restore, you can change the state of the instance from the main screen of the Backup
Manager utility. To shut down the database, simply select the Shutdown radio button
and click Apply (see Figure 17.6).</P>
<P>After you select the Shutdown option, you are asked what type of shutdown you
want to perform. Your options are

<UL>
	<LI>Normal--If you select the Normal option, the shutdown process waits for all users
	to disconnect and then continues. During this time, no new connections are allowed.
	<P>
	<LI>Immediate--If you select the Immediate option, all idle connections are disconnected,
	current transactions are rolled back, and the instance is shut down.
	<P>
	<LI>Abort--If you select the Abort option, the Oracle instance is immediately terminated.
	A shutdown with Abort causes media recovery to be necessary.
</UL>

<P><A NAME="06"></A><A HREF="06.htm"><B>Figure 17.6.</B></A></P>
<P><I>Change the state of the database from the main screen of Backup Manager.</I></P>

<UL>
	<LI>Transactional--If you select the Transactional option, currently running transactions
	are allowed to complete. As soon as a transaction has finished or aborted, the connection
	is terminated. During this time, no new connections are allowed.
</UL>

<P>I recommend that you always use the Immediate or Normal option. The Abort option
should be used only in the case of an emergency.</P>
<P>As you have seen, it is easy to back up and restore a database using Backup Manager.
Nonetheless, it is still important to test the recovery process periodically to make
sure it is working correctly.
<H4><FONT COLOR="#000077"><B>OS Facilities</B></FONT></H4>
<P>The method for restoring a datafile using OS facilities is as simple as the method
used for creating the backup using OS facilities:

<DL>
	<DD><B>1. </B>With the tablespace offline, copy the datafile from the backup to the
	original datafile.
	<P><B>2.</B> After you bring the tablespace back online (via the <TT>ALTER TABLESPACE</TT>
	command or the restarting of the Oracle instance), Oracle will realize that the datafile
	has been replaced and prompt you to apply the archived log files.
</DL>

<P>Tablespace and datafile recovery can be performed only if the RDBMS is running
in <TT>ARCHIVELOG</TT> mode. Otherwise, you must restore the entire database from
the last full, offline backup. No roll forward or rollback occurs.
<H4><FONT COLOR="#000077"><B>The Import Utility</B></FONT></H4>
<P>You can use the Import utility to restore the database if and only if the Export
utility was used to create the backup. For more information about the Import and
Export utilities, see Day 9, &quot;Managing Data.&quot;
<H4><FONT COLOR="#000077"><B>The NT Recovery Utility</B></FONT></H4>
<P>NT Recovery Manager is very similar to NT Backup Manager. NT Recovery Manager,
provided with your Oracle for Windows NT software, is not part of Enterprise Manager.
Because of this, NT Recovery Manager can recover only a local database--it cannot
provide recovery over a network. To recover a local database with NT Recovery Manager,
perform these steps:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -