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

📄 ch08.htm

📁 Teach yourself Oracle8 in 21 day
💻 HTM
📖 第 1 页 / 共 4 页
字号:
you should make sure that you will not try to reuse that log file before the operation
is complete. There are several ways to make sure that the archiving process happens
quickly:

<UL>
	<LI>Archive to disk. You can archive to disk and then copy those archive log files
	to tape later. This will prevent the archiving process from waiting for a tape drive
	or other, slower medium to complete.
	<P>
	<LI>Use multiple log files. By having more than two redo log files, you can simultaneously
	archive two or more log files while a third is being used for logging.
</UL>

<P>Archiving is very important to maintain recoverability in the database. Archiving
and backups are covered in more detail on Day 16.
<H3><FONT COLOR="#000077"><B>Adding Redo Log Files and Groups</B></FONT></H3>
<P>As with many of the functions that you have seen in this book, there are several
ways to add to the redo log. Most of these utilities have the option of using either
a graphical or a command-line utility.
<H4><FONT COLOR="#000077"><B>Using the Enterprise Manager</B></FONT></H4>
<P>If you choose, you can add log files to the redo log via the Enterprise Manager.
To do so, drill down into the database that you want to modify using the Navigator
pane and right-click the Redo Log Groups icon. You will see the Create option. Select
the Create option and you will see the Create Redo Log Group screen (see Figure 8.1).
From here you fill in the size of the new redo log file that you want to create,
specify a name under the New Members label, and click Add to add the redo log member.
After you have clicked Add, that member will appear in the Current Members list,
as shown in Figure 8.2.


<BLOCKQUOTE>
	<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>In this example I have closed all
	panes except for the Navigator pane. 
<HR>


</BLOCKQUOTE>

<P>After you have entered all the filenames for the redo log group members, click
OK to create the log group. To add a member to an already existing group, right-click
on the Redo Log Group icon. This will bring up the Create Redo Log Member screen,
as shown in Figure 8.3.</P>
<P><A NAME="01"></A><A HREF="01.htm"><B>Figure 8.1.</B></A></P>
<P><I>The Create Redo Log Group screen.</I></P>
<P><A NAME="02"></A><A HREF="02.htm"><B>Figure 8.2.</B></A></P>
<P><I>The name of the new member of the redo log group appears in the Current Members
list after you add it.</I></P>
<P><A NAME="03"></A><A HREF="03.htm"><B>Figure 8.3.</B></A></P>
<P><I>The Create Redo Log Member screen.</I></P>
<P>Here you type the name of the redo log group member and click OK to create that
member. To create a redo log group member with the same characteristics as an existing
redo log group member, right-click the redo log group member that you want to duplicate
and select the Create Like option. You will then see the Create Log Group Member
screen, as shown in Figure 8.4. Simply type the new log group member's name and click
the OK button to create the redo log group member.</P>
<P><A NAME="04"></A><A HREF="04.htm"><B>Figure 8.4.</B></A></P>
<P><I>You can base a new log group member on an existing member after clicking Create
Like.</I></P>
<P>The options for the redo log group creation is somewhat limited in the Enterprise
Manager. It is not possible to add redo log group members and groups from the Storage
Manager.
<H4><FONT COLOR="#000077"><B>Using the </B>ALTER DATABASE<B> Command</B></FONT></H4>
<P>Log files or log file groups can be added or modified with the <TT>ALTER DATABASE</TT>
command, as shown on Day 6. I prefer the command-line utilities because they can
be scripted, and as such are a permanent record that can be used over and over again.
An example of how to use the <TT>ALTER DATABASE </TT>command to add a log file is
shown here:</P>
<PRE><FONT COLOR="#0066FF">ALTER DATABASE database
ADD LOGFILE ( `log3a', `log3b' ) SIZE 10M;
</FONT></PRE>
<P>To add a new log file to an already existing group, you can use this command:</P>
<PRE><FONT COLOR="#0066FF">ALTER DATABASE database
ADD LOGFILE MEMBER `log3c' TO GROUP 3;
</FONT></PRE>
<P>If you don't know the group name, you can use the same command and specify the
other members of the log file group, as in</P>
<PRE><FONT COLOR="#0066FF">ALTER DATABASE database
ADD LOGFILE MEMBER `log3c' TO GROUP ( `log3a', `log3b');
</FONT></PRE>
<P>As I have said before, by using a SQL script and the <TT>ALTER DATABASE</TT> command,
you can preserve a permanent record of the change and then use the file as a template
for other, similar operations.
<H3><FONT COLOR="#000077"><B>Modifying Redo Log Files and Groups</B></FONT></H3>
<P>As with many functions you have seen in this book, there are several ways to add
to the redo log. Most of these utilities have an option of using either a graphical
or a command-line utility.
<H4><FONT COLOR="#000077"><B>Using the Enterprise Manager</B></FONT></H4>
<P>To modify a redo log group member, right-click that member via the Enterprise
Manager's Navigator pane and choose the Quick Edit option. From here you will see
the Quick Edit Redo Log Member screen, as shown in Figure 8.5. In this screen you
can change the name of the redo log group member, thus causing the <TT>ALTER DATABASE
RENAME FILE</TT> command to be run. As you can see here, the options for modifying
the redo log via the Enterprise Manager are very limited. I prefer to use the <TT>ALTER
DATABASE</TT> command because of its flexibility and options.</P>
<P><A NAME="05"></A><A HREF="05.htm"><B>Figure 8.5.</B></A></P>
<P><I>The Quick Edit Redo Log Member screen.</I></P>
<P>
<H4><FONT COLOR="#000077"><B>Using the </B>ALTER DATABASE<B> Command</B></FONT></H4>
<P>You can modify log files or log file groups with the <TT>ALTER DATABASE</TT> command,
as shown earlier today and on Day 6. Again, I really prefer the command-line utilities
because they can be scripted, and as such are a permanent record that can be used
over and over again. For example, a redo log file can be renamed with the command</P>
<PRE><FONT COLOR="#0066FF">ALTER DATABASE database
RENAME LOGFILE `log1' TO `log2';
</FONT></PRE>
<P>Or you can delete a rollback segment with this command:</P>
<PRE><FONT COLOR="#0066FF">ALTER DATABASE database
DROP LOGFILE `log1';
</FONT></PRE>
<P>You can drop an entire log file group with the following command:</P>
<PRE><FONT COLOR="#0066FF">ALTER DATABASE database
DROP LOGFILE GROUP 3;
</FONT></PRE>
<P>If you don't know the number of the log file group, you can drop it by specifying
the names of the log file group members:</P>
<PRE><FONT COLOR="#0066FF">ALTER DATABASE database
DROP LOGFILE GROUP (`log3a', `log3b');
</FONT></PRE>
<P>If necessary, you can drop just a log file group member with this syntax:</P>
<PRE><FONT COLOR="#0066FF">ALTER DATABASE database
DROP LOGFILE GROUP MEMBER `log3b';
</FONT></PRE>
<H3><FONT COLOR="#000077"><B>Characteristics of the Log Files</B></FONT></H3>
<P>The redo log files are one of the few files in the Oracle database that are always
written to in a sequential manner. Because redo records are only read during recovery,
they are write-only files during normal operations.</P>
<P>Because of the sequential nature of the redo log files, by isolating these files
onto separate disk volumes you can take advantage of the fact that sequential I/O
is much faster than random I/O. Keep in mind that the archival operation reads from
the redo log file, so if you have two redo log files on the same disk volume, the
archive process in conjunction with the redo log operation will cause random I/O.


<BLOCKQUOTE>
	<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>I use the term <I>disk volume</I>
	to refer to either a disk drive or set of disk drives in a RAID array. 
<HR>


</BLOCKQUOTE>

<P>In most cases, the performance of the redo log operation is not usually a problem.
If you are running in a high transaction rate environment, you might need to separate
each redo log file on its own disk volume.


<BLOCKQUOTE>
	<P>
<HR>
<FONT COLOR="#000077"><B>TIP:</B></FONT><B> </B>The redo log files should be protected,
	either by using log file groups or with a RAID array. When using a RAID array (either
	hardware or software), use RAID-1 for the redo log files. RAID-1 offers the most
	protection and the fastest write performance. 
<HR>


</BLOCKQUOTE>

<P>The performance of the archive log volume is not as important as that of the redo
log volume, but it is still fairly important. It is necessary that the archival operation
be completed before you need to reuse the redo log file.</P>
<P>In many cases, archival information can be kept on another system and restored
when necessary. If you are doing this, or are keeping your archive log files on tape,
you might want to archive to disk first and then copy to tape or to the network so
you can restore the data more quickly. If you are copying your data to a backup system,
you can use RAID-5, which is slower but less costly. In any case, by archiving to
a temporary area first, you free up the redo log file in the fastest possible time.
This is covered in more detail on Day 16.
<H2><FONT COLOR="#000077"><B>Control Files</B></FONT></H2>
<P>Control files are used to keep information critical to the operation of the RDBMS.
The control file (or files) resides on the operating system file system. These files
are used in the startup of the instance to identify where the datafiles and redo
log files are in the system. The loss of a control file can be devastating to the
operation of the RDBMS. It is always a good idea to have multiple control files on
different disk volumes so that a failure does not cause the loss of all the control
files. You can add an additional control file after the database has been created
by following these steps:

<DL>
	<DD><B>1. </B>Shut down the Oracle instance.
	<P><B>2.</B> Copy the control file to another location on another disk volume.</P>
	<P><B>3.</B> Edit the parameter file to include the new file name in the <TT>CONTROL_FILES</TT>
	parameter.</P>
	<P><B>4.</B> Restart the Oracle instance.
</DL>

<P>The control file can also be created using the <TT>CREATE CONTROLFILE</TT> command.
This creation of the control file should be done only in extreme situations, such
as when you need to rename a database or reproduce a control file because all control
files are damaged and you don't have backups.</P>
<P>The best way to save and protect your control files is to use the <TT>ALTER DATABASE
</TT>database<TT> BACKUP CONTROLFILE</TT> command. The options to the <TT>ALTER DATABASE
</TT>database<TT> BACKUP CONTROLFILE</TT> command are as follows:

<UL>
	<LI><TT>TO `</TT>filename<TT>'</TT>--Creates a new control file with the name specified
	as filename. If the file already exists, the optional <TT>REUSE</TT> qualifier must
	be used.
	<P>
	<LI><TT>TO TRACE</TT>--This optional parameter writes SQL to a trace file that can
	be used to re-create the control files. Optionally you can specify the qualifiers
	<TT>RESETLOGS</TT> or <TT>NORESETLOGS</TT>, which will add additional SQL to open
	the database with these options. The SQL statements are complete enough to start
	the database, re-create the control files, and recover and open the database appropriately.
</UL>



<BLOCKQUOTE>
	<P>
<HR>
<FONT COLOR="#000077"><B>TIP:</B></FONT><B> </B>Any time you make changes to the
	structure of the database by adding datafiles, redo log files, and so on, run the
	command <TT>ALTER DATABASE </TT>database<TT> BACKUP CONTROLFILE TO TRACE</TT>. By
	doing this you will have a method of re-creating the control files if necessary.
	This will save you a lot of work if you have to recover the entire system. 
<HR>


</BLOCKQUOTE>

<P>The control files are an important part of your system, although they rarely require
any maintenance. As long as you do a backup after you make any major changes, you
should be in pretty good shape.
<H2><FONT COLOR="#000077"><B>Rollback Segments</B></FONT></H2>

⌨️ 快捷键说明

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