|
|
Forewords1. Introduction and goalsOur goal in this tutorial is to guide the reader among all the variations on a theme that exists within Streams and present the essential minimum needed at each level of difficulty. We will focus the most used features in Streams and leave to Oracle Documentation the case of niches. Specifically we will develop the following feature in Streams
We will setup replication on the famous demo user SCOTT/TIGER schema and replicate first the table 'EMP', then we will extend to MASTER-MASTER replication so that to discuss DML_HANDLER, more specifically focusing on conflict resolution and DML ERROR. handlers. After that we will replicate the whole schema up to mutli-master mode replication. Last we will show how to setup a monitoring queue on emp table in order to send selected info to an MQseries queue in order to illustrate a bit more of Advance Queuing capabilities. 1.1 naming conventionDuring this tutorial we will create various streams objects and following precise naming convention.
You may encounter the expression 'Source DB' or 'Target DB'. They stands respectively for 'DEV1' and 'DEV2'. These 'source' and 'target' are only a quick and easy means to figure out which site is concerned 1.2 It is all about 10gThe current tutorial is aimed to demonstrate much of what can be done using Oracle Streams. We will focus mainly on oracle streams version 10gR2 as of this time of writing it is by far the most used versions. We will possibly extent this tutorial later to the new features of Oracle 11g. 2. Presentation of the available packages.One of the difficulty when you start the study of the streams is
the sheer number of procedures. Many of these packages seems to do the same
thing. It is not really the case. They differs following the end-users. However,
the most basic operations may be reached through different ways and still achieve the
exact same result. This may give the impression of disorder and the
beginners will realize too late that he has used the wrong set of package later. 2.1. Which set of package is the good one for you?Since there are different ways to do the same thing, one may wonder which way is best one. For instance let's consider the setup procedure of the scott.emp table replication from DEV1 to DEV2. You can set up a capture process using the 2 following ways : Test case : 2 ways to achieve the same result 1st method :
Using DBMS_STREAMS_ADM
2nd method : Using DBMS_CAPTURE_ADM, DBMS_RULE_ADM, DBMS_PROPAGATION_ADM:
2.2 Difference of the two methods You can legitimately wonder what is the
difference? The answer is there is none! Both procedures creates a queue name
'cap_scott_emp_1_q' over a queue table 'cap_scott_emp_1_qt'. A capture process
'cap_scott_emp_1'
is created that will capture all dml changes (no ddl will be captured) for the
table 'scott.emp'. The dml will be propagated through the
propagation process ''prop_scott_dev1_2_dev2'. to the remote db 'DEV2' and will
feed the remote queue 'app_scott_emp_2'. As for the rule set and the rule which
are created in the second procedure, they are created by default with a system
generated name in the first procedure. For instance method 2 allows us to setup queues like that :
That's the way you declare a queue table to connect to MQseries. There are others possible queue payload type :
The queue_payload_type used by dbms_streams_adm in first method can only be of type 'SYS.ANYDATA'. So for now we will retain that DBMS_STREAMS_ADM is a simplified method to create replication of queue type ANYDATA, and we will focus on this unless we need to complicated things, which we will :p 3 . CDC and Synchronous captureCDC (Change data Capture is another API developed by the data warehouse team to capture change and replicate them elsewhere. It use the same technology stack than streams but with a different API. In my view it brings only confusion. Synchronous capture that appears in 11g is also another of these goodies API that a subset of the streams. Here you will only capture dml and ddl of a table and you are not supposed to apply any rules to transform the data How many specific API Oracle will invent to satisfy a simple case ? Sound like people at Oracle Corps have not understood well the difference between an alphabet and pictogram collection. Every one of those specific API which are not flexible just bring a bit more confusion. |