📄 ch18.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>Teach Yourself Oracle 8 In 21 Days -- Ch 18 -- Administering Oracle Replication</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="../ch17/ch17.htm"><IMG SRC="../buttonart/previous.gif" WIDTH="128" HEIGHT="28"
ALIGN="BOTTOM" ALT="Previous chapter" BORDER="0"></A><A HREF="../ch19/ch19.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 18 -<BR>
Administering Oracle Replication</FONT></H1>
</CENTER>
<P>Today's lesson completes the three-day section on maximizing uptime and securing
your data. On Day 16, "Understanding Effective Backup Techniques," you
learned how to back up your database; on Day 17, "Recovering the Database,"
you learned how to restore that data in the event of a system failure. Today you
will learn how to use other techniques to maximize uptime and minimize recovery time.</P>
<P>Not all replication is used for maximizing uptime. It is convenient, however,
to include all the benefits and uses of replication in this lesson. Replication can
be used for many different purposes, such as read-only copies in satellite locations
and multiple access points.</P>
<P>Today you will learn about replication and other methods for reducing downtime,
such as the backup database and Oracle failover.
<H2><FONT COLOR="#000077"><B>What Is Replication?</B></FONT></H2>
<P><FONT COLOR="#000077"><B>New Term:</B></FONT><B> </B><I>Replication</I> is the
facility that allows you to copy database data to multiple local and remote systems.
This data can be accessed and modified in certain instances. In many cases, systems
are designed so that the remote data is read-only and updates are processed on the
master system. There are various options available.</P>
<P>A replicated database might consist of the entire database or of certain tables
or tablespaces. This is completely up to you. With Oracle replication, you can configure
a number of options to provide whatever features you want.
<H3><FONT COLOR="#000077"><B>Replication Options</B></FONT></H3>
<P>Oracle provides several replication options; the most basic of these is the <I>read-only
table snapshot</I>. This basic method of replication allows you to copy a table to
a remote site as a read-only table. Any updates to the table must be made on the
master database. This method is described as a "snapshot" because it is
a picture of the database at a certain point in time. Unlike other replication options,
the read-only table snapshot refreshes the remote copy only on a periodic basis,
which you control.</P>
<P>Another option for replication is Oracle <I>advanced replication</I>. With advanced
replication it is possible for all replicated objects to be updated. Advanced replication
is much more complex than the read-only table snapshot because conflict resolution
must be programmed. The advanced replication option can be quite powerful, but it
is more difficult to maintain.
<H4><FONT COLOR="#000077"><B>Read-Only Table Snapshots</B></FONT></H4>
<P>Read-only table snapshots are used when a read-only copy is all that is needed.
You might think this method is quite limiting, but in reality it is very useful.
Indeed, there are quite a few applications where the read-only table snapshot is
sufficient, and even desirable:
<UL>
<LI>Retail--Retail stores typically maintain a master price list at a central location
and download new prices on a regular basis. It does not make sense for each store
to change its own prices. Of course, you would want to maintain the inventory database
locally.
<P>
<LI>Lookup tables--Lookup tables are also very good applications for read-only snapshots
because they are not usually updated and you might want their data to be controlled
by a central site.
<P>
<LI>Data analysis--OLTP data can be periodically replicated to another system for
analysis. This replicated system might be performing DSS tasks to analyze sales data
and so on.
<P>
<LI>Manufacturing--Component parts lists can be maintained at a central database
and each assembly line gets a read-only copy of that data. If a part replacement
is necessary, this should be done globally.
</UL>
<P>Telemarketing--A list of clients should be maintained at a central location and
downloaded periodically to each sales office. It is desirable for all offices to
have the same client list.</P>
<P>These are just a few examples of places where a read-only replicated table is
quite sufficient for the satellite location. With this type of replication, the data
on the local or master database is periodically updated to the replicated sites,
as shown in Figure 18.1.</P>
<P><A NAME="01"></A><A HREF="01.htm"><B>Figure 18.1.</B></A><B></B></P>
<P><I>Read-only snapshots.</I></P>
<P>This snapshot can be an entire table or a selected view of that table. In this
manner you can keep information in the master table that is not propagated to the
replicated sites, such as item costs or sales figures. With replication you have
many options for what data you want to replicate and when you want to replicate it.</P>
<P>In some cases you must update the data on each replicated site. This is where
the advanced replication option is necessary.
<H4><FONT COLOR="#000077"><B>Advanced (Symmetric) Replication</B></FONT></H4>
<P><FONT COLOR="#000077"><B>New Term:</B></FONT><B> </B>The Oracle <I>advanced replication</I>
option, sometimes known as <I>symmetric replication</I> or <I>updateable snapshots</I>,
allows each of the replicated databases to be updated. The updates are typically
batched and periodically sent to the other replicated objects. You can, however,
configure Oracle to propagate updates immediately. This is known as <I>synchronous
data propagation</I> or <I>realtime data replication</I>.</P>
<P>The updateable snapshot method is usually sufficient, but with certain applications
it is necessary to use realtime data replication.</P>
<P>With the advanced replication option, the system is sometimes described as having
multiple masters. These masters can each have read-only table snapshots if desired.
An advanced replication system is shown in Figure 18.2.</P>
<P><A NAME="02"></A><A HREF="02.htm"><B>Figure 18.2.</B></A><B></B></P>
<P><I>An advanced replication system.</I></P>
<P>With the advanced replication option, you can have multiple sites throughout the
country, and each can be used as an independent database. Each of these databases
can be updated independently and on a regular basis--and can even be deferred to
off hours.
<H3><FONT COLOR="#000077"><B>How Does Replication Work?</B></FONT></H3>
<P>Replication is quite straightforward. The data to be replicated is defined by
a defining query, which determines the data that is to be replicated. After the query
is defined, the data is selected from the master and copied to the replicated site.</P>
<P>The defining query is set up so that each row in the replicated table corresponds
to one row or part of one row in the master table. The defining query cannot contain
an aggregate function or <TT>GROUP BY</TT> clause.</P>
<P><FONT COLOR="#000077"><B>New Term:</B></FONT><B> </B>After the defining query
is set up, it will be executed on a regular basis and its result will be propagated
to the replicate systems. This propagation of fresh replicated data is called the
<I>snapshot refresh</I>. The snapshot refresh can operate in a couple different modes:
<UL>
<LI>Complete refresh--In this mode the master executes the snapshot's defining query
and the result replaces the entire snapshot on the replicated system.
</UL>
<UL>
<LI>Fast refresh--In this mode the master determines what changes have been made
to the master and applies these changes to the snapshot. If only a few changes have
occurred since the last snapshot, this method is much more efficient.
</UL>
<P><FONT COLOR="#000077"><B>New Term:</B></FONT><B> </B>If multiple tables are involved
in the snapshot, you can use a <I>snapshot group</I>. When you define a snapshot
group, several different tables can be linked together so that there is transaction
consistency within the snapshot (that is, the tables are in sync).</P>
<P>The snapshot refresh can occur manually or automatically, depending on how you
configure the master and the replicated site. With an automatic refresh, no operator
intervention is required. The snapshots are automatically refreshed on a regular
time interval. With manual refresh, the operator determines when the refresh should
occur and manually initiates the refresh. If changes to the tables are rare, manual
refresh might work for you.
<H3><FONT COLOR="#000077"><B>Configuring Replication</B></FONT></H3>
<P>Replication can be configured through Replication Manager or manually via SQL
commands. What method you use is up to you.
<H4><FONT COLOR="#000077"><B>Configuring Using Replication Manager</B></FONT></H4>
<P>To configure replication using Replication Manager, you should first make sure
the database was created with the advanced replication option. This option is available
through the Oracle Database Assistant installation process.
<BLOCKQUOTE>
<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>If your database was not built with
the advanced replication option, you must run the administrative SQL script <TT>\orant\rdbms80\admin\
catrep.sql</TT> to install the replication packages.
<HR>
</BLOCKQUOTE>
<P>Replication Manager can be invoked from the Enterprise Manager toolbar or from
the Oracle Replication Manager program group. After you invoke Replication Manager,
you will see the main screen (shown in Figure 18.3).</P>
<P><A NAME="03"></A><A HREF="03.htm"><B>Figure 18.3.</B></A><B></B></P>
<P><I>Oracle Replication Manager.</I></P>
<P>If you have never run Replication Manager, you might find yourself in the Setup
wizard. From here you can create the master and snapshot sites. If you click the
Cancel button, you will see that no database connections are set up, so no information
can be displayed.</P>
<P>If you had specified advanced replication when you were building the database
from the Database Assistant, this would already be set up for you. To invoke the
Setup wizard, click Create (see Figure 18.4).</P>
<P><A NAME="04"></A><A HREF="04.htm"><B>Figure 18.4.</B></A><B></B></P>
<P><I>Create the database connection.</I></P>
<P>After you click Create, the Create DB Connection dialog (shown in Figure 18.5)
prompts you to supply information to connect to a database.</P>
<P><A NAME="05"></A><A HREF="05.htm"><B>Figure 18.5.</B></A><B></B></P>
<P><I>The Create DB Connection dialog.</I></P>
<P>You will also be prompted to set up a propagator. To do so, highlight the database
connection from the Replication Manager main screen (<TT>system@dogs</TT> in this
case) and pull down the Edit menu to select properties. To select a propagator, click
the Propagator tab (see Figure 18.6). You can choose any of the users you have defined;
<TT>DBSNMP</TT> is a good choice.</P>
<P><A NAME="06"></A><A HREF="06.htm"><B>Figure 18.6.</B></A><B></B></P>
<P><I>The Edit DB Connection dialog.</I></P>
<P>The next step is to invoke the Setup wizard. Do so by selecting File | Setup Wizard.
From here you will be led through a series of screens that will help you configure
a replicated system. The first is the Master or Snapshot Site Setup screen, shown
in Figure 18.7.</P>
<P><A NAME="07"></A><A HREF="07.htm"><B>Figure 18.7.</B></A><B></B></P>
<P><I>The Master or Snapshot Site Setup screen of the Setup wizard.</I></P>
<P>Here you can specify whether you are setting up a database as a master site or
as a snapshot site. Both require initial setup. <B></B></P>
<P><FONT COLOR="#000077"><B>Configuring the Master Site</B> </FONT></P>
<P>Configuring the master site involves setting up a replication account and privileges
as well as setting up scheduling for the snapshots. To do so, perform these steps:
<DL>
<DD><B>1. </B>First you'll see the Select Master Sites screen, shown in Figure 18.8.
Here you set up the database that will serve as the master.
</DL>
<P><A NAME="08"></A><A HREF="08.htm"><B>Figure 18.8.</B></A><B></B></P>
<P><I>The Select Master Sites screen of the Setup wizard.</I></P>
<DL>
<DD><B>2. </B>Clicking the New button invokes the New Master Site screen, shown in
Figure 18.9. Enter the database connection name and the <TT>SYSTEM</TT> password
on this screen.
</DL>
<P><A NAME="09"></A><A HREF="09.htm"><B>Figure 18.9.</B></A><B></B></P>
<P><I>The New Master Site screen of the Setup wizard.</I></P>
<DL>
<DD><B>3.</B> After you select the master site, you will be prompted for the default
administrator and the propagator/receiver, as shown in Figure 18.10. I prefer to
use the default settings in this case.
</DL>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -