Académique Documents
Professionnel Documents
Culture Documents
1
Gestion de la base de données distribuée
Concepts de bases de données distribuées
Les concepts liés aux bases de données distribuées incluent :
2
Gestion de la base de données distribuée
Un système de base de données distribué permet aux applications
d'accéder aux données de bases de données distantes.
3
Gestion de la base de données distribuée
Les bases de données distribuées utilisent une architecture client /
serveur pour traiter les requêtes.
4
Gestion de la base de données distribuée
5
Gestion de la base de données distribuée
Note :
Une application peut simultanément accéder ou modifier les
données de plusieurs bases de données dans un seul environnement
distribué.
Exemple:
une seule requête à partir d'un client de Manufacturing sur la base
de données locale mfg peut récupérer les données jointes de la
Table produits sur la base de données locale et la table dept sur la
base de données hq distante.
6
Gestion de la base de données distribuée
Vous pouvez également créer des synonymes pour les objets distants
dans le système distribué afin que les utilisateurs peuvent y accéder
avec la même syntaxe que les objets locaux.
Exemple:
si vous êtes connecté à la base de données mfg mais vous voulez
accéder aux données sur la base de données hq, créant Un
synonyme sur mfg pour la table dept distante vous permet d'émettre
cette requête:
7
Gestion de la base de données distribuée
Bases de données distribuées VS traitement distribué
Les termes base de données distribuée et traitement distribué sont
étroitement liés, mais ont des significations distinctes.
Distributed database
Un ensemble de bases de données dans un système distribué qui
peut apparaître aux applications en tant que source de données
unique.
Distributed processing
Les opérations qui se produisent lorsqu'une application distribue ses
tâches entre différents ordinateurs dans un réseau.
8
Gestion de la base de données distribuée
9
Gestion de la base de données distribuée
Replication : Le terme réplication fait référence à l'opération de
copie et de maintenance des objets de base de données dans
plusieurs bases de données appartenant à un système distribué.
10
Gestion de la base de données distribuée
Client/Server Database Architecture
Le serveur de base de données est le logiciel Oracle gérant une base
de données
11
Gestion de la base de données distribuée
12
Gestion de la base de données distribuée
Database Links
Remarques:
Un lien de base de données est un pointeur qui définit un chemin à
un sens unique d‘un serveur de bdd Oracle vers un autre serveur de
bdd
13
Gestion de la base de données distribuée
Cette figure montre un example d’un utilisateur scott qui accède à la table emp qui se
trouve au niveau de la bdd distante de nom global hq.example.com:
14
Gestion de la base de données distribuée
Type de liens
Fixed user link Les utilisateurs se connectent le nom utilisateur et mot de passe
referencé dans le link.
15
Gestion de la base de données distribuée
Lien de bdd partagé (Shared Database Links)
Intégration de bdd
Permettre à un utilisateur d’ acceder aux autres objets distant
d’un autre utilisateur
16
Gestion de la base de données distribuée
Lien de bdd partagé (Next) (Shared Database Links)
17
Gestion de la base de données distribuée
Liens partagés VS Liens de Base de Données Standard
18
Gestion de la base de données distribuée
Nom Global De la base de données dans les liens de bdd
Chaque bdd dans une bdd distribuée est identifiée par son nom
global de bdd
19
Gestion de la base de données distribuée
Nom Global De la base de données dans les liens de bdd (Next)
Exemple:
20
Gestion de la base de données distribuée
Nom Global De la base de données dans les liens de bdd (Next)
21
Gestion de la base de données distribuée
Nom Global De la base de données dans les liens de bdd (Next)
22
Gestion de la base de données distribuée
Syntaxe pour créer un lin de bdd
Après la création du lien de bdd, on peut l’utiliser dans des requêtes
SQL pour accéder aux tables, vue et objet PL/SQL dans l’autre bdd
en ajoutant @dblink aux nom de: tables, vues et objets PL/SQL
Prérequis:
Pour créer un lien de bdd privé, il faut avoir le privilège système
CREATE DATABASE LINK
Pour créer un lien de bdd public, il faut avoir le privilège système
CREATE PUBLIC DATABASE LINK
Il faut avroir le privilège système CREATE SESSION au niveau de la
bdd distante
Oracle Net doit être installé au niveau des bases de données local
et distante
23
Gestion de la base de données distribuée
Syntax
dblink_authentication
AUTHENTICATED BY user IDENTIFIED BY password
24
Gestion de la base de données distribuée
Semantics
PUBLIC :
If you omit this clause, then the database link is private and is
available only to you.
25
Gestion de la base de données distribuée
PUBLIC (Next)
If you omit both of those clauses, then the database link connects
to the remote database as the locally connected user.
26
Gestion de la base de données distribuée
SHARED
Specify SHARED to create a database link that can be shared by
multiple sessions using a single network connection from the source
database to the target database.
Dblink :
Specify the complete or partial name of the database link.
If you specify only the database name, then Oracle Database
implicitly appends the database domain of the local database.
27
Gestion de la base de données distribuée
Restriction on Creating Database Links
CONNECT TO Clause
The CONNECT TO clause lets you specify the user and
credentials, if any, to be used to connect to the remote database
28
Gestion de la base de données distribuée
CURRENT_USER Clause
Specify CURRENT_USER to create a current user database link.
The current user must be a global user with a valid account on
the remote database.
If you omit this clause, then the database link uses the user
name and password of each user who is connected to the
database.
29
Gestion de la base de données distribuée
dblink_authentication
You can specify this clause only if you are creating a shared
database link—that is, you have specified the SHARED clause.
30
Gestion de la base de données distribuée
USING 'connect string‘
Specify the service name of a remote database.
31
Gestion de la base de données distribuée
Remarques:
Les liens de bdd sont utiliser entre bdd Oracle
Pour acceder à une bdd distante non oracle on utilise Oracle
Heterogeneous Services.
32
Gestion de la base de données distribuée
Transaction distante
Une transaction distante contient une ou plusieurs instructions
distantes, toutes faisant référence à nœud distant unique.
Example:
UPDATE scott.dept@sales.us.americas.example_auto.com
SET loc = 'NEW YORK'
WHERE deptno = 10;
UPDATE scott.emp@sales.us.americas.example_auto.com
SET deptno = 11
WHERE deptno = 10;
COMMIT;
33
Gestion de la base de données distribuée
Distributed Transactions
Une transaction distribuée est une transaction qui comprend une ou
plusieurs instructions qui, individuellement ou en groupe, m-à-j les
données sur deux ou plusieurs nœuds distincts d'un dans une bdd
distribuée.
Exemple:
UPDATE scott.dept@sales.us.americas.example_auto.com
SET loc = 'NEW YORK‘
WHERE deptno = 10;
UPDATE scott.emp
SET deptno = 11
WHERE deptno = 10;
COMMIT;
34
Gestion de la base de données distribuée
Mécanisme de validation en deux phases
Le mécanisme de validation en deux phases de la base de données
garantit que tous les serveurs de base de données participant à une
transaction distribuée
soit ils valident tous la transaction
soit ils annulent tous la transaction
35
Gestion de la base de données distribuée
What Are Distributed Transactions?
A distributed transaction includes one or more statements that,
individually or as a group, update data on two or more distinct nodes
of a distributed database.
36
Gestion de la base de données distribuée
Example:
UPDATE scott.dept@hq.us.example.com
SET loc = 'REDWOOD SHORES'
WHERE deptno = 10;
UPDATE scott.emp
SET deptno = 11
WHERE deptno = 10;
UPDATE scott.bldg@maint.us.example.com
SET room = 1225
WHERE room = 1163;
COMMIT;
37
Gestion de la base de données distribuée
There are two types of permissible operations in distributed
transactions: DML and DDL transactions, and transaction control
statement.
38
Gestion de la base de données distribuée
Transaction Control Statements
Some transaction control statements are supported in distributed
transactions. The following are the supported transaction control
statements:
COMMIT
ROLLBACK
SAVEPOINT
39
Gestion de la base de données distribuée
Session Trees for Distributed Transactions
A session tree is a hierarchical model that describes the relationships
among sessions and their roles.
40
Gestion de la base de données distribuée
About Session Trees for Distributed Transactions
41
Gestion de la base de données distribuée
All nodes participating in the session tree of a distributed transaction
assume one or more of the following roles:
Role Description
42
Gestion de la base de données distribuée
The role a node plays in a distributed transaction is determined by:
Whether the transaction is local or remote
The commit point strength of the node
Whether all requested data is available at a node, or whether
other nodes need to be referenced to complete the transaction
Whether the node is read-only
43
Gestion de la base de données distribuée
Local Coordinators
A local coordinator is responsible for coordinating the transaction
among the nodes it communicates directly with by:
44
Gestion de la base de données distribuée
Global Coordinator
The node where the distributed transaction originates is called the
global coordinator
The global
coordinator performs the following operations during a distributed
transaction:
45
Gestion de la base de données distribuée
Sends all of the distributed transaction SQL statements, remote
procedure calls, and so forth to the directly referenced nodes,
thus forming the session tree
Instructs the commit point site to initiate the global commit of the
transaction if all nodes prepare successfully
46
Gestion de la base de données distribuée
Commit Point Site
The system administrator always designates one node to be the
commit point site.
The node selected as commit point site should be the node that
stores the most critical data.
47
Gestion de la base de données distribuée
48
Gestion de la base de données distribuée
The commit point site is distinct from all other nodes involved in a
distributed transaction in these ways:
The commit point site commits before the other nodes involved in
the transaction. In effect, the outcome of a distributed transaction
at the commit point site determines whether the transaction at all
nodes is committed or rolled back: the other nodes follow the
lead of the commit point site. The global coordinator ensures that
all nodes complete the transaction in the same manner as the
commit point site.
49
Gestion de la base de données distribuée
How a Distributed Transaction Commits
A distributed transaction is considered committed after all non-
commit-point sites are prepared, and the transaction has been
actually committed at the commit point site.
The redo log at the commit point site is updated as soon as the
distributed transaction is committed at this node.
Note:
In the same way, a distributed transaction is considered not
committed if the commit has not been logged at the commit point
site.
50
Gestion de la base de données distribuée
Commit Point Strength (COMMIT_POINT_STRENGTH parameter)
Every database server must be assigned a commit point strength.
Note:
Specifically, the commit point strength determines whether a given
node is the commit point site in the distributed transaction and thus
commits before all of the other nodes.
51
Gestion de la base de données distribuée
how the database determines the commit point site
The commit point site, which is determined at the beginning of the
prepare phase, is selected only from the nodes participating in the
transaction. The following sequence of events occurs:
52
Gestion de la base de données distribuée
how the database determines the commit point site (Next)
Either the node with the highest commit point strength directly
referenced in the transaction or one of its servers with a higher
commit point strength becomes the commit point site.
After the final commit point site has been determined, the global
coordinator sends prepare responses to all nodes participating in
the transaction
Example:
53
Gestion de la base de données distribuée
54
Gestion de la base de données distribuée
The following conditions apply when determining the commit point
site:
55
Gestion de la base de données distribuée
Two-Phase Commit Mechanism
In a distributed database environment, the database must
coordinate the committing or rolling back of the changes in a
distributed transaction as a self-contained unit.
The commit mechanism has the following distinct phases, which the
database performs automatically whenever a user commits a
distributed transaction:
56
Gestion de la base de données distribuée
Two-Phase Commit Mechanism (Next)
Phase Description
Prepare phase The initiating node, called the global coordinator, asks
participating nodes other than the commit point site to
promise to commit or roll back the transaction, even if there
is a failure. If any node cannot prepare, the transaction is
rolled back.
Commit phase If all participants respond to the coordinator that they are
prepared, then the coordinator asks the commit point site to
commit. After it commits, the coordinator asks all other
nodes to commit the transaction.
Forget phase The global coordinator forgets about the transaction.
57
Gestion de la base de données distribuée
Prepare Phase
58
Gestion de la base de données distribuée
About Prepare Phase
In this phase, the database does not actually commit or roll back the
transaction.
59
Gestion de la base de données distribuée
Types of Responses in the Prepare Phase
When a node is told to prepare, it can respond in the different ways.
Response Meaning
Prepared Data on the node has been modified by a statement in the
distributed transaction, and the node has successfully prepared.
Read-only No data on the node has been, or can be, modified (only queried),
so no preparation is necessary.
Abort The node cannot successfully prepare.
60
Gestion de la base de données distribuée
Steps in the Prepare Phase
The prepare phase in the two-phase commit process includes
specific steps
The node requests that its descendants, that is, the nodes
subsequently referenced, prepare to commit.
Le nœud demande que ses descendants, c'est-à-dire les nœuds par la
suite référencé, préparez-vous à vous engager.
61
Gestion de la base de données distribuée
Steps in the Prepare Phase (Next)
62
Gestion de la base de données distribuée
Steps in the Prepare Phase (Next)
63
Gestion de la base de données distribuée
Steps in the Prepare Phase (Next)
The node guarantees that locks held for the transaction are able to
survive a failure.
Le noeud garantit que les verrous détenus pour la transaction
peuvent survivre à un échec.
64
Gestion de la base de données distribuée
Note:
These actions guarantee that the node can subsequently commit or
roll back the transaction on the node. The prepared nodes then wait
until a COMMIT or ROLLBACK request is received from the global
coordinator.
Commit Phase
The second phase in committing a distributed transaction is the
commit phase. Before this phase occurs, all nodes other than the
commit point site referenced in the distributed transaction have
guaranteed that they are prepared, that is, they have the necessary
resources to commit the transaction.
65
Gestion de la base de données distribuée
Commit (Next)
Steps in the Commit Phase
The commit phase in the two-phase commit process includes
specific steps. The commit phase consists of the following steps:
66
Gestion de la base de données distribuée
Commit (Next)
7. At each node, the database records an additional redo entry in the
local redo log, indicating that the transaction has committed.
8. The participating nodes notify the global coordinator that they
have committed.
Note:
When the commit phase is complete, the data on all nodes of the
distributed system is consistent.
67
Gestion de la base de données distribuée
Guaranteeing Global Database Consistency
Each committed transaction has an associated system change
number (SCN) to uniquely identify the changes made by the SQL
statements within that transaction.
68
Gestion de la base de données distribuée
Guaranteeing Global Database Consistency
69
Gestion de la base de données distribuée
Note:
Among other benefits, the coordination of SCNs among the nodes of
a distributed system ensures global read-consistency at both the
statement and transaction level.
During the prepare phase, the database determines the highest SCN
at all nodes involved in the transaction. The transaction then
commits with the high SCN at the commit point site. The commit
SCN is then sent to all prepared nodes with the commit decision.
70
Gestion de la base de données distribuée
Forget Phase
After the participating nodes notify the commit point site that they
have committed, the commit point site can forget about the
transaction.
1. After receiving notice from the global coordinator that all nodes
have committed, the commit point site erases (effacer) status
information about this transaction.
2. The commit point site informs the global coordinator that it has
erased the status information.
72
Gestion de la base de données distribuée
Automatic Resolution of In-Doubt Transactions
Assume that there are two nodes, local and remote, in the following
scenarios.
The local node is the commit point site. User scott connects to local
and executes and commits a distributed transaction that updates
local and remote.
73
Gestion de la base de données distribuée
Failure During the Prepare Phase
74
Gestion de la base de données distribuée
Failure During the Prepare Phase
76
Gestion de la base de données distribuée
Failure During the Commit Phase (Next)
The global coordinator, which in this case is also the commit point
site, requests all databases other than the commit point site to
promise to commit or roll back when told to do so.
The commit point site commits the transaction locally, then sends a
commit message to remote asking it to commit.
77
Gestion de la base de données distribuée
The remote database receives the commit message, but cannot
respond because of a network failure.
78