Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
oracle_goldengate_generic_jdbc [2020/11/12 18:05] – andonovj | oracle_goldengate_generic_jdbc [2020/11/12 18:21] (current) – andonovj | ||
---|---|---|---|
Line 284: | Line 284: | ||
+ | Finally, we can check if the data is replicated on the MySQL | ||
+ | |||
+ | < | ||
+ | [oracle@edvmr1p0 oggtrg]$ mysql -uoracle -p | ||
+ | Enter password: | ||
+ | Welcome to the MySQL monitor. | ||
+ | Your MySQL connection id is 5 | ||
+ | Server version: 5.1.73 Source distribution | ||
+ | |||
+ | Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. | ||
+ | |||
+ | Oracle is a registered trademark of Oracle Corporation and/or its | ||
+ | affiliates. Other names may be trademarks of their respective | ||
+ | owners. | ||
+ | |||
+ | Type ' | ||
+ | |||
+ | mysql> show databases; | ||
+ | +--------------------+ | ||
+ | | Database | ||
+ | +--------------------+ | ||
+ | | information_schema | | ||
+ | | bigdata | ||
+ | | test | | ||
+ | +--------------------+ | ||
+ | 3 rows in set (0.00 sec) | ||
+ | |||
+ | mysql> use bigdata | ||
+ | Reading table information for completion of table and column names | ||
+ | You can turn off this feature to get a quicker startup with -A | ||
+ | |||
+ | Database changed | ||
+ | mysql> select count(*) from customer_prod; | ||
+ | +----------+ | ||
+ | | count(*) | | ||
+ | +----------+ | ||
+ | | 3000 | | ||
+ | +----------+ | ||
+ | 1 row in set (0.00 sec) | ||
+ | |||
+ | mysql> select customer_id, | ||
+ | +-------------+------------+-----------+--------------------------+ | ||
+ | | customer_id | first_name | last_name | city | | ||
+ | +-------------+------------+-----------+--------------------------+ | ||
+ | | 1001 | Alisa | Vega | Calle Blancos | ||
+ | | 1002 | Inga | Griffin | ||
+ | | 1003 | Sopoline | ||
+ | | 1004 | Maile | Beasley | ||
+ | | 1005 | Asher | Glenn | Curridabat | ||
+ | | 1006 | Rosalyn | ||
+ | | 1007 | September | ||
+ | | 1008 | Magee | Higgins | ||
+ | | 1009 | Pascale | ||
+ | | 1010 | Melodie | ||
+ | +-------------+------------+-----------+--------------------------+ | ||
+ | 10 rows in set (0.01 sec) | ||
+ | |||
+ | mysql> | ||
+ | </ | ||
+ | |||
+ | =====Replication with Different Table Structure===== | ||
+ | What if we want to replicate between two tables which have different structure: | ||
+ | |||
+ | |||
+ | < | ||
+ | --Source: | ||
+ | SQL> desc product_prod | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | --Destination: | ||
+ | mysql> describe product_prod; | ||
+ | +-------------+---------------+------+-----+---------+-------+ | ||
+ | | Field | Type | Null | Key | Default | Extra | | ||
+ | +-------------+---------------+------+-----+---------+-------+ | ||
+ | | product_id | ||
+ | | prod_code | ||
+ | | prod_name | ||
+ | | supplier_id | decimal(10, | ||
+ | +-------------+---------------+------+-----+---------+-------+ | ||
+ | 4 rows in set (0.00 sec) | ||
+ | </ | ||
+ | |||
+ | In our case the product_id and product_code on the source are different than the prod_name and prod_code on the destination, | ||
+ | |||
+ | |||
+ | < | ||
+ | SQL> insert into product_prod select * from product where product_id < 100; | ||
+ | |||
+ | 99 rows created. | ||
+ | |||
+ | SQL> commit; | ||
+ | |||
+ | Commit complete. | ||
+ | |||
+ | SQL> | ||
+ | </ | ||
+ | |||
+ | The Golden Gate Replication Replicat will ABEND: | ||
+ | |||
+ | < | ||
+ | GGSCI (edvmr1p0) 8> info all | ||
+ | |||
+ | Program | ||
+ | |||
+ | MANAGER | ||
+ | REPLICAT | ||
+ | |||
+ | |||
+ | GGSCI (edvmr1p0) 9> view report rjdbc | ||
+ | |||
+ | ------------------------------------------------------------------------ | ||
+ | : [/ | ||
+ | g:: | ||
+ | : [/ | ||
+ | 6d]] | ||
+ | : [/ | ||
+ | : [/ | ||
+ | : [/ | ||
+ | |||
+ | 2020-11-12 18: | ||
+ | </ | ||
+ | |||
+ | |||
+ | So in order to fix that we have to do 2 things: | ||
+ | |||
+ | * Fix the jdbc properties file, to allow mapping of column with different names | ||
+ | * Map these columns in the rjdbc parameter file | ||
+ | |||
+ | So let's do it: | ||
+ | |||
+ | ====Modify JDBC Properties File==== | ||
+ | Make sure to add the following parameters, to the existing configuration. | ||
+ | |||
+ | < | ||
+ | gg.mdp.type=jdbc | ||
+ | gg.mdp.ConnectionUrl=jdbc: | ||
+ | gg.mdp.DriverClassName=com.mysql.jdbc.Driver | ||
+ | gg.mdp.UserName=oracle | ||
+ | gg.mdp.Password=< | ||
+ | </ | ||
+ | |||
+ | ====Modify Replicat Param File==== | ||
+ | Now we can modify the RJDBC param file: | ||
+ | |||
+ | < | ||
+ | [oracle@edvmr1p0 dirprm]$ trg | ||
+ | [oracle@edvmr1p0 oggtrg]$ ggsci | ||
+ | |||
+ | Oracle GoldenGate Command Interpreter | ||
+ | Version 12.2.0.1.160823 OGGCORE_OGGADP.12.2.0.1.0_PLATFORMS_161019.1437 | ||
+ | Linux, x64, 64bit (optimized), | ||
+ | Operating system character set identified as UTF-8. | ||
+ | |||
+ | Copyright (C) 1995, 2016, Oracle and/or its affiliates. All rights reserved. | ||
+ | |||
+ | |||
+ | |||
+ | GGSCI (edvmr1p0) 1> edit param rjdbc | ||
+ | |||
+ | REPLICAT rjdbc | ||
+ | TARGETDB LIBFILE libggjava.so SET property=dirprm/ | ||
+ | REPORTCOUNT EVERY 1 MINUTES, RATE | ||
+ | GROUPTRANSOPS 1000 | ||
+ | MAP OGGSRC.CUSTOMER_PROD, | ||
+ | MAP OGGSRC.PRODUCT_PROD, | ||
+ | COLMAP(USEDEFAULTS, | ||
+ | |||
+ | :wq | ||
+ | </ | ||
+ | |||
+ | |||
+ | ====Verify the Replication==== | ||
+ | Now, we can start the RJDBC and verify if the rows were replicated: | ||
+ | |||
+ | < | ||
+ | GGSCI (edvmr1p0) 3> start rjdbc | ||
+ | |||
+ | Sending START request to MANAGER ... | ||
+ | REPLICAT RJDBC starting | ||
+ | |||
+ | |||
+ | GGSCI (edvmr1p0) 4> info all | ||
+ | |||
+ | Program | ||
+ | |||
+ | MANAGER | ||
+ | REPLICAT | ||
+ | |||
+ | |||
+ | GGSCI (edvmr1p0) 5> info all | ||
+ | |||
+ | Program | ||
+ | |||
+ | MANAGER | ||
+ | REPLICAT | ||
+ | |||
+ | GGSCI (edvmr1p0) 7> send rjdbc,stats | ||
+ | |||
+ | Sending STATS request to REPLICAT RJDBC ... | ||
+ | |||
+ | Start of Statistics at 2020-11-12 18:19:49. | ||
+ | |||
+ | Replicating from OGGSRC.PRODUCT_PROD to bigdata.product_prod: | ||
+ | |||
+ | *** Total statistics since 2020-11-12 18:19:41 *** | ||
+ | Total inserts | ||
+ | Total updates | ||
+ | Total deletes | ||
+ | Total discards | ||
+ | Total operations | ||
+ | </ | ||
+ | |||
+ | We see that 99 inserts were processed, we can check of course also the MySQL database: | ||
+ | |||
+ | < | ||
+ | mysql> select count(*) from product_prod; | ||
+ | +----------+ | ||
+ | | count(*) | | ||
+ | +----------+ | ||
+ | | 99 | | ||
+ | +----------+ | ||
+ | 1 row in set (0.00 sec) | ||
+ | |||
+ | mysql> | ||
+ | </ | ||