Ing. Erick López Ch. M.R.I. Replicación Oracle. What is Replication Replication is the process of...

Post on 20-Jan-2016

219 views 0 download

Transcript of Ing. Erick López Ch. M.R.I. Replicación Oracle. What is Replication Replication is the process of...

Ing. Erick López Ch. M.R.I.

ReplicaciónReplicaciónOracle

What is Replication

Replication is the process of copying and maintaining schema objects in multiple databases that make up a distributed database system.

Replication can improve the performance and protect the availability of applications because alternate data access options exist.

Basic Replication

Data replicas provide read-only access to the table data that originates from a primary or “master” site.

Applications can query data from local data replicas to avoid network access regardless of network availability.

Applications throughout the system must access data at the primary site when updates are necessary.

Basic Replication

Advance Replication

Extend the capabilities of basic read-only replication by allowing applications to update table replicas throughout a replicated database system.

With advanced replication, data replicas anywhere in the system can provide both read and update access to a table’s data.

Participating Oracle database servers automatically work to converge the data of all table replicas, and ensure global transaction consistency and data integrity.

Advance Replication

Basic Replication Concepts

Support applications requiring read-only access to table data originating from a primary site.

Uses of Basic Replication.Read-Only Table Snapshots.Snapshot Refreshes.

Uses of Basic Replication

Basic replication is useful for information distribution.

Information Off-Loading

Information Transport

Read-Only Table Snapshots

A read-only table snapshot is a local copy of table data originating from one or moreremote master tables.

An application can query the data in a read-only table snapshot, but cannot insert, update, or delete rows in the snapshot.

Read-Only Table Snapshots

Read-Only Table Snapshots

A Snapshot’s Defining Query The logical data structure of table snapshots is defined by a query that references data in one or more remote master tables. A snapshot's defining query determines what data the snapshot will contain.

Should be such that each row in the snapshot corresponds directly to a row or a part of a row in a single master table.

Read-Only Table Snapshots

A Snapshot’s Defining Query The logical data structure of table snapshots is defined by a query that references data in one or more remote master tables. A snapshot's defining query determines what data the snapshot will contain.

Should be such that each row in the snapshot corresponds directly to a row or a part of a row in a single master table.

Read-Only Table Snapshots

Should not contain a distinct or aggregatefunction, a GROUP BY or CONNECT BY clause, join, restricted types ofsubqueries, or a set operation.

CREATE SNAPSHOT sales.customers AS SELECT * FROM sales.customers@hq.acme.com

Read-Only Table Snapshots

CREATE SNAPSHOT sales.orders AS SELECT * FROM

sales.orders@hq.acme.com oWHERE EXISTS( SELECT c_id FROM sales.customers@hq.acme.com cWHERE o.c_id = c.c_id AND zip = 19555);

SNAP$_snapshotname

Snapshot Refreshes

You must decide how and when to refresh each snapshot to make it a more current.

Analyze application characteristics and requirements to determine appropriate snapshot refresh intervals.

To refresh snapshots, Oracle supports different types of refreshes, “complete” and“fast” snapshot refresh groups, as well as “manual” and “automatic” refreshes.

Complete and Fast Refreshes

Complete Refreshes The server that manages the snapshot

executes the snapshot's defining query. The result set of the query replaces the

existing snapshot data to refresh the snapshot.

Oracle can perform a complete refresh for any snapshot.

Complete and Fast Refreshes

Fast Refreshes The server that manages the snapshot first

identifies the changes that occurred in the master since the most recent refresh of the snapshot and then applies them to the snapshot.

Fast refreshes are more efficient than complete refreshes when there are few changes to the master because participating servers and networks replicate less data.

Fast refreshes are available for snapshots only when the master table has a snapshot log.

Complete and Fast Refreshes

Complete Refreshes The server that manages the snapshot

executes the snapshot's defining query. The result set of the query replaces the

existing snapshot data to refresh the snapshot.

Oracle can perform a complete refresh for any snapshot.

Advanced Replication Concepts

Disconnected Environments Advanced replication is useful for the

deployment of transaction processing applications that operate using disconnected components.

Failover Site protect the availability of a mission

critical database.

Advanced Replication Concepts

Distributing Application Loads Transaction processing applications that

require multiple points of access to database information

Information Transport data warehouse or data mart.

Advanced Replication Configurations

Multimaster Replication Allows multiple sites, acting as equal

peers, to manage groups of replicated database objects.

Applications can update any replicated table at any site in a multimaster configuration.

Advanced Replication Configurations

Advanced Replication Configurations

Snapshot Sites and Updatable Snapshots Master sites in an advanced replication

system can consolidate information that applications update at remote snapshot sites.

Facility allows applications to insert, update, and delete table rows through updatable snapshots.

Advanced Replication Configurations

Advanced Replication Configurations

Updatable snapshots have the following properties: Updatable snapshots are always simple, fast-

refreshable table snapshots. Oracle propagates the changes made through an

updatable snapshot to the snapshot’s remote master table.

If necessary, the updates then cascade to all

other master sites. Oracle refreshes an updatable snapshot as part of

a refresh group identical to read-only snapshots.

Advanced Replication Configurations

Hybrid Configurations Multimaster replication and updatable

snapshots can be combined in hybrid or “mixed” configurations to meet different application requirements.

Can have any number of master sites and multiple snapshot sites for each master.

Advanced Replication Configurations

Advanced Replication Configurations

Differences between updatable snapshots and replicated masters: Replicated masters must contain data for the full

table being replicated, whereas snapshots can replicate subsets of master table data.

Multimaster replication allows you to replicate changes for each transaction as the changes occur.

If conflicts occur from changes made to multiple copies of the same data, master sites detect and resolve the conflicts.

Replication Conflicts

Uniqueness Conflicts A uniqueness conflict occurs when the

replication of a row attempts to violate entity integrity (a PRIMARY KEY or UNIQUE constraint).

Update Conflicts Occurs when the replication of an update to a

row conflicts with another update to the same row. Update conflicts occur when two different transactions originating from different sites update the same row at nearly the same time.

Replication Conflicts

Delete Conflicts Occurs when two transactions originate from

different sites, with one transaction deleting a row that the other transaction updates or deletes.

Using Basic ReplicationUsing Basic Replication

1. Design the basic replication environment. Decide which master tables you want to replicate using read-only table snapshots, and which databases require such snapshots.

2. At each snapshot site, create the schemas and database links necessary to support snapshots.

3. At the master site, create the snapshot logs necessary to support fast refreshes of all snapshots.

Using Basic ReplicationUsing Basic Replication

4. Create the snapshots at each snapshot site.

5. At each snapshot site, create the refresh groups that the snapshots will use to refresh, and assign each snapshot to a refresh group.

6. Grant privileges necessary for application users to access snapshots.

Step 2:

Create Snapshot Site Schemas and Create Snapshot Site Schemas and Database LinksDatabase Links

CONNECT system/manager@dbs2;CREATE USER scott IDENTIFIED BY tiger

QUOTA UNLIMITED ON data;GRANT CONNECT TO scott;CONNECT scott/tiger@dbs2;CREATE DATABASE LINK dbs1 CONNECT TO

scott IDENTIFIED BY tiger USING ‘dbs1’;

Step 3:

Create Necessary Master Site Create Necessary Master Site Snapshot LogsSnapshot Logs

CONNECT system/manager@dbs1;CREATE SNAPSHOT LOG ON scott.emp;CREATE SNAPSHOT LOG ON scott.dept;

Step 4:

Create SnapshotsCreate Snapshots

CONNECT system/manager@dbs2;CREATE SNAPSHOT scott.emp AS

SELECT * FROM scott.emp@dbs1.acme.com;

CREATE SNAPSHOT scott.dept AS SELECT * FROM scott.dept@dbs1.acme.com;

Step 5:

Create Snapshot Site Refresh GroupsCreate Snapshot Site Refresh Groups

CONNECT system/manager@dbs2;DBMS_REFRESH.MAKE(

name => ’scott.refgrp1’,list => ’scott.dept,scott.emp’,next_date => SYSDATE,interval => ’SYSDATE+1/24’);

(1/1440) COMMIT;

Step 6:

Grant Access to SnapshotsGrant Access to Snapshots

GRANT SELECT ON scott.emp TO ... ;