Documente Academic
Documente Profesional
Documente Cultură
This demo is intended to act as a prepared demo for Oracle->Oracle Transactional Data
Management that can be used to show some of the more interesting capabilities of Oracle
GoldenGate.
It includes:
* 1-1 mapping,
* 1 table mapping to 2 tables using a FILTER.
* using @STREXT, @STRFIND, and @STRLEN to split a source column into 2 on target.
* calling a SQLEXEC SQL statement to look up a value from another table and insert it.
* calling a SQLEXEC stored procedure to calculate a sum value
* using @CASE to select a column value based on another
* Auditing table that uses INSERTALLRECORDS to track all operations against a table
* A stored procedure that will create a reasonable load to demo latency/performance.
This demo has been set up for a laptop environment running Windows and Oracle.
To keep it simple, use a single Oracle instance for the demo environment, and install the Oracle
GoldenGate software twice: once under a source directory and again under a target directory.
Prerequisites:
Oracle 9i, 10g or 11g has been installed. Full Oracle client software is installed
(GoldenGate needs access to the Oracle XDK libraries). **DO NOT USE INSTANT
CLIENT**; verify you can run a SQL*Plus session with both the source and target db users
and connect to the db; source and target users profiles are set up with correct Oracle
environment info; TNSNames is properly configured.
Oracle GoldenGate has already been installed in a source directory <C:\ogg_source> by an
OS user with permissions to read the Oracle redo logs (user must log in as Administrator on
Windows). The default db username/password used in these scripts is oggs/source.
GoldenGate has already been installed in a target directory <C:\ogg_target>. The default db
username/password used in theses scripts is oggt/target.
Minimal supplemental logging is enabled for the source database. The database is in
archive log mode.
Oracle db users (oggs and oggt) have been created on the source and target databases. For
the demo, give both users DBA privs to keep it simple. If you are wondering exactly which
privs are required, see the Oracle GoldenGate Install Guide for details.
Note: although GoldenGate supports it, this demo is not set up to use ASM.
4. Create the target tables and procedures by running the following from
OGGProject \ogg_target
sqlplus oggt/target < target_create.sql
You will get 8 Table created messages and one 1 row created message.
The target schema differs from the source in a number of ways.
* customers has been split into us_customers and non_us_customers. The correct table
will be populated by replicate by using a FILTER on the COUNTRY field.
* contactname in the customers table has been split into contactfirst and contactlast
and will be populated using @STR functions
* orders includes a new shippername field that will be populated by replicat using a
SQLEXEC lookup against the shippers table
* order_details includes a new total field that will be populated by replicat using a
stored proc
* products has the discontinued field changed to a varchar(8) that will be populated by
replicat using a CASE statement
* products_audit table that will have a row inserted for every operation on the
products table.
* a shippers table exists that is used by a SQLEXEC SQL to lookup shippername for
orders table.
EXTRACT added.
REPLICAT added.
TABLE OGGS.CUSTOMERS;
Retrieving definition for OGGS.CUSTOMERS
TABLE OGGS.ORDERS;
Retrieving definition for OGGS.ORDERS
TABLE OGGS.ORDER_DETAILS;
Retrieving definition for OGGS.ORDER_DETAILS
TABLE OGGS.PRODUCTS;
Retrieving definition for OGGS.PRODUCTS
TABLE OGGS.BIGINSERT_TABLE;
Retrieving definition for OGGS.BIGINSERT_TABLE
C:\ogg_source>
Run individual demo scripts to show features. Generally there is one script to make changes on the
source and a second to select the changed/added rows on the target. Scripts are run from sqlplus
from the OGGProject\ogg_source or OGGProject\ogg_target demo directories:
1. Customers - shows FILTER on country field splitting records between two tables on target.
Also shows string manipulation functions splitting a string column into 2 columns on the target.
On source: CMD> sqlplus oggs/source < insert_cust.sql
On target: CMD> sqlplus oggt/target < select_cust.sql
2. Orders - shows SQL lookup of shippername using shipvia column first via an insert and then an
update.
On source: CMD> sqlplus oggs/source < insert_orders.sql
On target: CMD> sqlplus oggt/target < select_orders.sql
On source: CMD> sqlplus oggs/source < update_orders.sql
On target: CMD> sqlplus oggt/target < select_orders.sql
3. Order_Details - shows total field being filled in by a stored procedure via an update.
On target: CMD> sqlplus oggt/target < select_order_det.sql
On source: CMD> sqlplus oggs/source < update_order_det.sql
On target: CMD> sqlplus oggt/target < select_order_det.sql
4. Products - shows @CASE() used to translate discontinued field from number to varchar (1 =
Yes, 0 = No, null = unknown)
On target: CMD> sqlplus oggt/target < select_prod.sql
On source: CMD> sqlplus oggs/source < update_prod.sql
On target: CMD> sqlplus oggt/target < select_prod.sql
5. Products_Audit - shows table that records all transactions while adding additional information
via functions and user tokens (HOSTNAME and USERID).
On target: CMD> sqlplus oggt/target < select_audit.sql /* show insert and update records
On source: CMD> sqlplus oggs/source < delete_prod.sql
On target: CMD> sqlplus oggt/target < select_audit.sql /* show delete records
6. Show report on replicate in order to show changed record reporting on each table and lag time
GGSCI> send ggs_rep, report
GGSCI> view report ggs_rep, details
/* inspect report */
Run the following on the source side to invoke the stored procedure
CMD> sqlplus oggs/source < biginsert.sql
Run the following on the target machine during and afterward to show operation rates
GGSCI> stats ggs_rep, reportrate sec
Operation rates were generally between 1000-1600 per sec
10
Note: these numbers are transaction processed since reset - so you should run ASAP after
running the biginsert.sql script to get the most accurate numbers. Sitting idle drops the ops/sec rate.
There is also a REPORTCOUNT EVERY 1 MINUTES, rate in the ggs_rep parameter file, that
will print the number of records processed and the rate in the ggs_rep report file. It only does this
while the replicat is actively processing records.
To view:
GGSCI> view report ggs_rep, details
Misc.
There are several utility sql scripts:
src_clean.sql
target_clean.sql
src_count.sql
target_count.sql
11