Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
oracle_goldengate_apache_kafka [2020/11/12 12:36] – created andonovj | oracle_goldengate_apache_kafka [2020/11/12 12:51] (current) – andonovj | ||
---|---|---|---|
Line 2: | Line 2: | ||
Before we do anything, we have to start Kafka first, so let's do it: | Before we do anything, we have to start Kafka first, so let's do it: | ||
+ | ====Start Kafka==== | ||
< | < | ||
[oracle@edvmr1p0 ~]$ kafka-server-start.sh $KAFKA_HOME/ | [oracle@edvmr1p0 ~]$ kafka-server-start.sh $KAFKA_HOME/ | ||
Line 29: | Line 30: | ||
</ | </ | ||
+ | ====Configure Kafka Properties File==== | ||
+ | < | ||
+ | [oracle@edvmr1p0 dirprm]$ cat ~/ | ||
+ | gg.handlerlist=kafka | ||
+ | gg.handler.kafka.type=kafka | ||
+ | gg.handler.kafka.KafkaProducerConfigFile=kafka_producer.properties | ||
+ | gg.handler.kafka.TopicName=oggbgtopic | ||
+ | gg.handler.kafka.format=json | ||
+ | gg.handler.kafka.BlockingSend=false | ||
+ | gg.handler.kafka.includeTokens=false | ||
+ | gg.handler.kafka.mode =tx | ||
+ | |||
+ | goldengate.userexit.timestamp=utc | ||
+ | goldengate.userexit.writers=javawriter | ||
+ | javawriter.stats.display=TRUE | ||
+ | javawriter.stats.full=TRUE | ||
+ | |||
+ | gg.log=log4j | ||
+ | gg.log.level=INFO | ||
+ | |||
+ | gg.report.time=30sec | ||
+ | gg.classpath=dirprm/:/ | ||
+ | jvm.bootoptions=-Xmx512m -Xms32m -Djava.class.path=ggjava/ | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | ====Configure Kafka Producer Properties file==== | ||
+ | < | ||
+ | bootstrap.servers=localhost: | ||
+ | acks=1 | ||
+ | compression.type=gzip | ||
+ | reconnect.backoff.ms=1000 | ||
+ | |||
+ | value.serializer=org.apache.kafka.common.serialization.ByteArraySerializer | ||
+ | key.serializer=org.apache.kafka.common.serialization.ByteArraySerializer | ||
+ | batch.size=102400 | ||
+ | linger.ms=10000 | ||
+ | |||
+ | max.request.size = 5024000 | ||
+ | send.buffer.bytes = 5024000 | ||
+ | </ | ||
+ | |||
+ | |||
+ | ====Configure Golden Gate(Replicat)==== | ||
+ | Again we have to configure the Golden Gate Replicat: | ||
+ | |||
+ | < | ||
+ | [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> info all | ||
+ | |||
+ | Program | ||
+ | |||
+ | MANAGER | ||
+ | |||
+ | |||
+ | GGSCI (edvmr1p0) 2> edit param rkafka | ||
+ | |||
+ | |||
+ | |||
+ | GGSCI (edvmr1p0) 3> view param rkafka | ||
+ | |||
+ | REPLICAT rkafka | ||
+ | TARGETDB LIBFILE libggjava.so SET property=dirprm/ | ||
+ | REPORTCOUNT EVERY 1 MINUTES, RATE | ||
+ | GROUPTRANSOPS 10000 | ||
+ | MAP OGGSRC.*, TARGET OGGTRG.*; | ||
+ | |||
+ | |||
+ | GGSCI (edvmr1p0) 4> add replicat rkafka, exttrail ./dirdat/kf | ||
+ | REPLICAT added. | ||
+ | |||
+ | |||
+ | GGSCI (edvmr1p0) 5> start rkafka | ||
+ | |||
+ | Sending START request to MANAGER ... | ||
+ | REPLICAT RKAFKA starting | ||
+ | |||
+ | |||
+ | GGSCI (edvmr1p0) 6> info all | ||
+ | |||
+ | Program | ||
+ | |||
+ | MANAGER | ||
+ | REPLICAT | ||
+ | |||
+ | |||
+ | GGSCI (edvmr1p0) 7> info all | ||
+ | |||
+ | Program | ||
+ | |||
+ | MANAGER | ||
+ | REPLICAT | ||
+ | |||
+ | |||
+ | GGSCI (edvmr1p0) 8> | ||
+ | |||
+ | </ | ||
+ | |||
+ | =====Test===== | ||
+ | To test the replication, | ||
+ | |||
+ | < | ||
+ | [oracle@edvmr1p0 oggsrc]$ sqlplus oggsrc/ | ||
+ | |||
+ | SQL*Plus: Release 12.1.0.2.0 Production on Thu Nov 12 12:46:13 2020 | ||
+ | |||
+ | Copyright (c) 1982, 2014, Oracle. | ||
+ | |||
+ | Last Successful login time: Thu Nov 12 2020 12:26:00 +00:00 | ||
+ | |||
+ | Connected to: | ||
+ | Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production | ||
+ | With the Partitioning, | ||
+ | |||
+ | SQL> insert into customer_prod select * from customer where customer_id < 101; | ||
+ | |||
+ | 100 rows created. | ||
+ | |||
+ | SQL> commit; | ||
+ | |||
+ | Commit complete. | ||
+ | |||
+ | SQL> | ||
+ | </ | ||
+ | |||
+ | Check if the data is replicated between: GG Extract -> GG Replicat | ||
+ | |||
+ | < | ||
+ | --Source: | ||
+ | GGSCI (edvmr1p0) 4> send priex,stats | ||
+ | |||
+ | Sending STATS request to EXTRACT PRIEX ... | ||
+ | |||
+ | Start of Statistics at 2020-11-12 12:46:37. | ||
+ | |||
+ | DDL replication statistics (for all trails): | ||
+ | |||
+ | *** Total statistics since extract started | ||
+ | Operations | ||
+ | |||
+ | Output to ./ | ||
+ | |||
+ | Extracting from OGGSRC.CUSTOMER_PROD to OGGSRC.CUSTOMER_PROD: | ||
+ | |||
+ | *** Total statistics since 2020-11-12 12:46:30 *** | ||
+ | Total inserts | ||
+ | Total updates | ||
+ | Total deletes | ||
+ | Total discards | ||
+ | Total operations | ||
+ | |||
+ | *** Daily statistics since 2020-11-12 12:46:30 *** | ||
+ | Total inserts | ||
+ | Total updates | ||
+ | Total deletes | ||
+ | Total discards | ||
+ | Total operations | ||
+ | |||
+ | *** Hourly statistics since 2020-11-12 12:46:30 *** | ||
+ | Total inserts | ||
+ | Total updates | ||
+ | Total deletes | ||
+ | Total discards | ||
+ | Total operations | ||
+ | |||
+ | *** Latest statistics since 2020-11-12 12:46:30 *** | ||
+ | Total inserts | ||
+ | Total updates | ||
+ | Total deletes | ||
+ | Total discards | ||
+ | Total operations | ||
+ | |||
+ | End of Statistics. | ||
+ | |||
+ | |||
+ | GGSCI (edvmr1p0) 5> | ||
+ | |||
+ | --Target | ||
+ | GGSCI (edvmr1p0) 8> send rkafka, | ||
+ | |||
+ | Sending STATS request to REPLICAT RKAFKA ... | ||
+ | |||
+ | Start of Statistics at 2020-11-12 12:46:47. | ||
+ | |||
+ | Replicating from OGGSRC.CUSTOMER_PROD to OGGTRG.CUSTOMER_PROD: | ||
+ | |||
+ | *** Total statistics since 2020-11-12 12:46:34 *** | ||
+ | Total inserts | ||
+ | Total updates | ||
+ | Total deletes | ||
+ | Total discards | ||
+ | Total operations | ||
+ | |||
+ | *** Daily statistics since 2020-11-12 12:46:34 *** | ||
+ | Total inserts | ||
+ | Total updates | ||
+ | Total deletes | ||
+ | Total discards | ||
+ | Total operations | ||
+ | |||
+ | *** Hourly statistics since 2020-11-12 12:46:34 *** | ||
+ | Total inserts | ||
+ | Total updates | ||
+ | Total deletes | ||
+ | Total discards | ||
+ | Total operations | ||
+ | |||
+ | *** Latest statistics since 2020-11-12 12:46:34 *** | ||
+ | Total inserts | ||
+ | Total updates | ||
+ | Total deletes | ||
+ | Total discards | ||
+ | Total operations | ||
+ | |||
+ | End of Statistics. | ||
+ | |||
+ | |||
+ | GGSCI (edvmr1p0) 9> | ||
+ | </ | ||
+ | |||
+ | Finally, we can consume the data on Kafka: | ||
+ | |||
+ | < | ||
+ | [oracle@edvmr1p0 ~]$ kafka-console-consumer.sh --bootstrap-server localhost: | ||
+ | {" | ||
+ | </ | ||
+ | |||
+ | So, we have configured replication: | ||
+ | Oracle RDBMS -> Golden Gate (Extract) -> Golden Gate (Replicat) -> Apache Kafka | ||
=====Appendix===== | =====Appendix===== |