Sei sulla pagina 1di 27

Join Us at our Data Integration

Developer Day

Hands on Lab Manual


Introduction to Oracle GoldenGate
Hands-on Lab



http://www.oracle.com/technetwork

I want to improve
the performance of
my application...

Can I copy Java


code to an HTML
Extension?

Heres where you


can find the
latest release.

I coded it
this way...
Is the app
customizable?

How does
restricted task
reassignment
work?

The best way to migrate


Oracle E-Business
Application Suite Tier
servers to Linux is...

Just watch the


live webcast on
virtualization.

Where can I find


technical articles on
logging in Java ME?

OracleTechnology Network.
Its code for sharing expertise.
Come to the best place to collaborate with other
IT professionals.
OracleTechnology Network is the worlds largest community
of developers, administrators, and architects using industrystandard technologies with Oracle products. Sign up for a free
membership and youll have access to:

Discussion forums and hands-on labs


Free downloadable software and sample code
Product documentation
Member-contributed content

Take advantage of our global network of knowledge.

JOINTODAY

Go to:oracle.com/technetwork

Copyright 2010, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners. 10039688

Developer Day Hands-on Lab, Workbook for Introduction to Oracle GoldenGate, version 11.1.1

Copyright 1995, 2010 Oracle and\or its affiliates. All rights reserved.
This software and related documentation are provided under a license agreement containing restrictions on use and
disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or
allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit,
perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or
decompilation of this software, unless required by law for interoperability, is prohibited.
The information contained herein is subject to change without notice and is not warranted to be error-free. If you find
any errors, please report them to us in writing.
If this software or related documentation is delivered to the U.S. Government or anyone licensing it on behalf of the
U.S. Government, the following notice is applicable:
U.S. GOVERNMENT RIGHTS Programs, software, databases, and related documentation and technical data
delivered to U.S. Government customers are "commercial computer software" or "commercial technical data" pursuant
to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, the use,
duplication, disclosure, modification, and adaptation shall be subject to the restrictions and license terms set forth in
the applicable Government contract, and, to the extent applicable by the terms of the Government contract, the
additional rights set forth in FAR 52.227-19, Commercial Computer Software License (December 2007). Oracle USA,
Inc., 500 Oracle Parkway, Redwood City, CA 94065.
This software is developed for general use in a variety of information management applications. It is not developed or
intended for use in any inherently dangerous applications, including applications which may create a risk of personal
injury. If you use this software in dangerous applications, then you shall be responsible to take all appropriate failsafe, backup, redundancy, and other measures to ensure the safe use of this software. Oracle Corporation and its
affiliates disclaim any liability for any damages caused by use of this software in dangerous applications.
Oracle is a registered trademark of Oracle Corporation and\or its affiliates. Other names may be trademarks of their
respective owners.
This software and documentation may provide access to or information on content, products, and services from third
parties. Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind
with respect to third-party content, products, and services. Oracle Corporation and its affiliates will not be responsible
for any loss, costs, or damages incurred due to your access to or use of third-party content, products, or services.

Contents

1 Oracle to Oracle, One-Way Data Replication........................................ 4

1.0 Reset the lab Environment.................................................................5


1.1 Create the Databases .......................................................................6
1.2 Start the GoldenGate Manager ............................................................7
1.3 Get the Database to Log Keys .............................................................9
1.4 Add the GoldenGate Components....................................................... 10
1.4.1 Tasks to Instantiate the Target Database ........................................ 10
1.4.2 Change Data Capture and Associated GoldenGate Trail ....................... 12
1.4.3 Extract Data Pump and Associated GoldenGate Trail .......................... 13
1.4.4 Replicat Checkpoint Table and Change Data Apply............................. 14
1.5 Generate Data and Start GoldenGate Processes...................................... 15
1.6 Validate the Results....................................................................... 24

1 Oracle to Oracle, One-Way Data Replication


In this exercise, we shall configure GoldenGate to perform real-time transactional
replication to a hot-site database.


Trail

To accomplish this task, we shall perform the following steps:

1. Create the sample source/target tables referenced in this workbook.


2. Start the GoldenGate Manager process on the source and target GoldenGate servers
(in this workshop, they are the same).
3. Configure an Extract that reads Oracle Redo.
4. Create the processes that will be used to instantiate the target database.
a. Extract Task on this source side; this reads directly from each table.
b. Replicat Task on the target side; this performs all insert operations.
c. Start the Extract Task; this will automatically start the Replicat Task.
Note: There are multiple methods for performing target database instantiation,
which are used in most production implementations and beyond the scope of
this workshop.
5. Create the Extract Data Pump to transmit captured data real-time to GoldenGate
Trails on the target server.
6. When the Extract Task stops, create and start Replicat in overlap mode.
7. Start Replicat in real-time data apply mode.

1.0 Reset the lab Environment


Before we begin this lab exercise, we recommend that you clean up the environment to
remove any residuals left over from previous configurations setup in this lab. The step is
not required if this is the first workshop conducted using the supplied environment.
You must first make a terminal connection to the system by clicking the menu items for
Applications Accessories Terminal.

To reset the lab environment, execute the cleanup_goldengate.sh script from the.
/Oracle_GoldenGate directory:

cd /Oracle_GoldenGate
cleanup_goldengate.sh

1.1 Create the Databases


To create the source and target databases:
1. Change directories into the /Oracle_GoldenGate/dirsql directory located within the
GoldenGate installation location.
cd /Oracle_GoldenGate/dirsql
2. To create the source database, execute the following command:
sqlplus east/Oracle @source_database.sql
3. To create the target database, execute the following command:
sqlplus west/Oracle @target_database.sql
4. Execute the following command on the source database only.
sqlplus east/Oracle @seed_database.sql

1.2 Start the GoldenGate Manager


The GoldenGate Manager process has been configured to automatically start when the
Linux environment is started, therefore it should be already running. Verify it is running
by starting the GoldenGate command interface, ggsci, and issuing the INFO MANAGER
command.
1. Go back to the From the GoldenGate installation directory
shell> cd ..
2. Start the ggsci command interface.
shell> ./ggsci
3. Enter the command
GGSCI> info manager
a. The response should be similar to the one below.

If it is not running, then start the manager with the following command:
GGSCI> start manager
Review the Manager run-time parameters by entering the GGSCI command
GGSCI> view param mgr

Press the space bar to display the next page.

1.3 Get the Database to Log Keys


Before we can start capturing real-time data; the Oracle database must be set to log the
primary key values whenever it logs a changed row, so they are available to GoldenGate
in Redo. By default, the database only logs column values that change and the row_id.
This is required so GoldenGate can locate the correct row on the target for update and
delete operations.
This task is accomplished by turning on supplemental logging for the table via the
GGSCI command ADD TRANDATA. For this workshop, we created a script.
In GGSCI, issue the command:
GGSCI> obey ./dirprm/add_trandata.oby

1.4 Add the GoldenGate Components


Add the GoldenGate components by executing the GGSCI command
GGSCI> obey ./dirprm/setup_goldengate.oby
This script executes multiple GGSCI ADD statements to configure both the source and
target environments. The following sections describe the individual steps that were just
executed.

1.4.1 Tasks to Instantiate the Target Database


The first part of the script creates an Extract and Replicat Task Group that will be used to
instantiate the target database. A Task is a special process that once started, reads from
each source table row by row. This data is transmitted to the Replicat on the target that
inserts each row of data into the empty database tables.
The Task will automatically shutdown once all rows are read, transmitted, and inserted.

Review the Extract Task runtime parameters. Issue the GGSCI command
GGSCI> view param eload
Press the space bar to display the next page. (Comments are denoted by two dashes).

10

Review the Replicat Task runtime parameters. Issue the GGSCI command
GGSCI> view param rload
Press the space bar to display the next page.

11

1.4.2 Change Data Capture and Associated GoldenGate Trail


The script then creates the EMASTR Extract, which reads change data from Redo. Every
Extract, except an Extract Task, must have an associated GoldenGate Trail; which is a
disk file used to queue GoldenGate records. A Local Extract Trail is considered local to
the Extract that writes to it.

Review the change data capture runtime settings by executing the GGSCI command
GGSCI> view param emastr

Press the space bar to display the next page.


12

1.4.3ExtractDataPumpandAssociatedGoldenGateTrail
Next, the Extract Data Pump and associated Remote GoldenGate Trail are created. A
Remote GoldenGate trail is one where the Extract (typically a Data Pump) transmits data
over a network (LAN or WAN) to a target file location.

Review the Data Pump runtime configuration by executing the GGSCI command
GGSCI> view param pmastr

Press the space bar to display the next page.


13

1.4.4 Replicat Checkpoint Table and Change Data Apply


Since we are using the same server for both the source and target GoldenGate
environments, the script then creates the Replicat Checkpoint Table and Replicat Change
Data Apply Group.

ADD CHECKPOINTTABLE is used to create a checkpoint table in the target database.


Replicat uses the table to maintain a checkpoint into the trail for recovery purposes. A
checkpoint table is optional; checkpoints are also maintained in a file on disk. The use of
a checkpoint table causes check pointing to be part of the Replicat transaction. This
system allows Replicat to recover better in certain circumstances than when checkpoint
files were used alone.
The checkpoint table name is defined in a user created file named GLOBALS in the
GoldenGate installation location. GGSCI reads this file upon startup, and any options
defined are used as global runtime options for the duration of the GGSCI session.
Next, the Replicat Group is created. Replicat will read from the designated GoldenGate
Trail, convert the queue data into SQL DML statements, and execute those statements on
the target tables. To review the Replicat runtime settings issue the GGSCI command
GGSCI> view param rmastr
Press the space bar to page down in the display.

14

Press the space bar to page down in the display.


1.5 Generate Data and Start GoldenGate Processes
Now that all of the GoldenGate components have been configured, we can start the data
generation process, begin real time data capture, and instantiate the target.
The data generation script, /Oracle_GoldenGate/dirsql/trans_generator.sql simulates a
real-time banking system. For the accounts created when we ran the seed script, random
transactions are executed; point of sale debit card transactions, ATM deposits, ATM
withdrawals, deposits with branch tellers, and withdrawals at branch tellers.
Start another Terminal Session, change your directory to the dirsql, and run the
transaction generator:
Applications

Accessories

Terminal

cd /Oracle_GoldenGate/dirsql
sqlplus east/Oracle @trans_generator.sql

Note: It is recommended you leave this window open throughout the entire workshop.

15

Start real-time data capture, by issuing the following GGSCI commands:


GGSCI> start emastr
GGSCI> start pmastr
GGSCI> status emastr
GGSCI> status pmastr
The Extract should be in the RUNNING state. Depending on the system, it may take a
few seconds to start. Wait until the status changes to RUNNING.

16

Begin the target database instantiation by issuing the GGSCI commands


GGSCI> start eload
GGSCI> status *, task

Continue checking the Task status until both ELOAD and RLOAD go into the
STOPPED state.

17

To validate instantiation results, review the Extract Task report file by issuing the GGSCI
command
GGSCI> view report eload
Press the space bar to page down in the display. Take note of the record counts reported
for each table.

18

Execute the same command for rload, the Replicat Task. The report counts for the two
Tasks must match.
If the Extract and Replicat Task counts match, start overlap data replication processing by
executing the following GGSCI commands:
GGSCI> start rmastr
To see the status and current checkpoint of the real-time capture and apply processes,
execute the following GGSCI command:
GGSCI> info er *

19

This overlap period is the time during which both the Extract reading redo and the
Extract Task reading directly from the source tables were both running. During this
period transactions written to redo could have also been captured by the Extract Task and
written to the target during the instantiation process. We must take this into consideration
and have GoldenGate handle any duplicate or missing records.
This is accomplished by two special Replicat runtime parameters,
HANDLECOLLISIONS and END RUNTIME.
When HANDLECOLLISIONS is active, Replicat performs the following special
operations:
1. Duplicate inserts.
a.If Replicat attempts to write a row into the target that already exists, the target
row is over-written.
2. Missing updates or deletes
a.If Replicat attempts to update or delete a row that is missing, the data is thrown
out.
END RUNTIME sets Replicat to perform a normal shutdown when a record in the
Extract Trail is encountered with commit timestamp equal to, or after the process start
time.

20

Issue the GGSCI command


GGSCI> status rmastr
Note: Depending on the system load, this process may take some time. Wait until the
process is STOPPED.

When Replicat goes into the STOPPED state, view the report file via the command
GGSCI> view report rmastr
Press the space bar to page down in the display.

21

Take note of the transaction counts for each table reported at the end of the file. Duplicate
rows are reported as insert collisions.

Before restarting Replicat, HANDLECOLLISIONS and END RUNTIME must be


deactivated. These two runtime parameters must never be set in a production
environment processing real-time transactions.
To start the Windows Notepad Editor, issue the GGSCI command
GGSCI> edit param rmastr
Place two dashes at the beginning of the line where each of these parameters is located to
comment them.

22

Save and close the file; then restart Replicat via the GGSCI command
GGSCI> start rmastr
Wait for the trans_generator script, which was executed in step 1.5, to complete.

23

1.6 Validate the Results


Execute the GGSCI command
GGSCI> lag emastr

Repeat the command until the response is At EOF, no more records to process.
Start a sqlplus session for the east schema
sqlplus east/Oracle
Note the row counts for the following tables:
select count(*) from ACCOUNT;
select count(*) from ACCOUNT_TRANS;
select count(*) from TELLER_TRANS;
select count(*) from BRANCH_ATM;

24

Issue the GGSCI command


GGSCI> lag rmastr

Repeat the command until the response is At EOF, no more records to process.
Start a sqlplus session for the west schema at a Windows Command prompt by executing
the command
sqlplus west/Oracle
Note the row counts for the following tables:
select count(*) from ACCOUNT;
select count(*) from ACCOUNT_TRANS;
select count(*) from TELLER_TRANS;
select count(*) from BRANCH_ATM;

25

If the row counts match those returned for the source tables; congratulations, you have
successfully completed this section of the workshop.

26

Potrebbero piacerti anche