• No results found

Configuring Data Delivery to ActiveMQ Overview

In document D89113GC10_ag (Page 155-160)

Practices for Lesson 7: Overview Practices Overview

Practice 7-3: Configuring Data Delivery to ActiveMQ Overview

In this practice, you perform all necessary steps to configure the environment variables and the delivery Extract that will propagate all data changes to the JMS broker.

Assumptions

Practice 7-1 and 7-2 have been successfully completed.

Tasks

1. The GGSCI process that is running the Oracle GoldenGate Manager must have access to several Linux shared objects stored in subdirectories under the JDK. In addition, the manager process needs access to the JAVA_HOME directory location. The environment variables LD_LIBRARY_PATH and JAVA_HOME must be set before GGSCI is launched from the command line. Using the shell window you left open from Practice 7-2, change the directory to /u03/ogg/oggjms_trg and create a setenv.sh file. Define the

environment variables LD_LIBRARY_PATH and JAVA_HOME in that file, which will be sourced before invoking GGSCI:

[OS prompt]$ cd /u03/ogg/oggjms_trg [OS prompt]$ vi setenv.sh

LD_LIBRARY_PATH=/u01/app/oracle/product/12.1.0.2/db_1/lib:/usr/java/la test/jre/lib/amd64:/u03/ogg/oggjms_trg:/usr/java/latest/jre/lib/amd64/

server

export LD_LIBRARY_PATH JAVA_HOME=/usr/java/latest export JAVA_HOME

Note: The LD_LIBRARY_PATH line is one line, even if it is shown across multiple lines.

2. Save the setenv.sh file and exit the editor. Source the file using the dot command (.) and verify that the environment variables have been correctly set by echoing their values on the screen:

[OS prompt]$ . setenv.sh [OS prompt]$ echo $JAVA_HOME /usr/java/latest

[OS prompt ggs_trg]$ echo $LD_LIBRARY_PATH

/u01/app/oracle/product/12.1.0.2/db_1/lib:/usr/java/latest/jre/lib/amd 64:/u03/ogg/oggjms_trg:/usr/java/latest/jre/lib/amd64/server

Oracle University and Error : You are not a Valid Partner use only

3. You can now start GGSCI, which will inherit the environment variables that will allow the process to locate the shared objects required by the Oracle GoldenGate User Exit to work.

IMPORTANT: If the GGSCI Manager process is running, you must stop it and restart it so that it inherits the environment variables set by sourcing the setenv.sh file.

[OS prompt]$ ggsci

Oracle GoldenGate Command Interpreter Version 11.2.1.0.27 19591627

OGGCORE_11.2.1.0.0OGGBP_PLATFORMS_141006.1156

Linux, x64, 64bit (optimized), Generic on Oct 6 2014 13:09:44 Copyright (C) 1995, 2014, Oracle and/or its affiliates. All rights reserved.

GGSCI ([TRGHOST]) > info all

Program Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING

GGSCI ([TRGHOST]) > stop mgr

Manager process is required by other GGS processes.

Are you sure you want to stop it (y/n)? y Sending STOP request to MANAGER ...

Request processed.

Manager stopped.

GGSCI ([TRGHOST]) > start mgr Manager started.

GGSCI ([TRGHOST]) >

4. In the replication target environment, you must create the delivery Extract parameter file.

Unlike database-to-database replication, which requires Extract processes on the source and Replicat processes on the target, in this case the delivery of data changes that

occurred on the source is propagated to the JMS broker by using an Extract process, rather than a Replicat on the replication target.

GGSCI ([TRGHOST]) > Edit Param javaue EXTRACT javaue

setEnv ( GGS_USEREXIT_CONF = "./dirprm/javaue.properties" ) GetEnv (JAVA_HOME)

GetEnv (PATH)

GetEnv (LD_LIBRARY_PATH) GetEnv (LIBPATH)

CUserExit libggjava_ue.so CUSEREXIT PASSTHRU INCLUDEUPDATEBEFORES sourceDefs ./dirdef/jmsdef.def

getUpdateBefores

TABLE src_user.economic_entity;

TABLE src_user.gdp_by_year;

TABLE src_user.gdp_growth_by_year;

Oracle University and Error : You are not a Valid Partner use only

5. Save the parameter file and leave the GGSCI session open. Open a new shell window, change the directory to /u03/oggjms_trg/dirprm, and configure the

javaue.properties file.

[OS prompt ggs_trg]$ cd /u03/ogg/oggjms_trg/dirprm [OS prompt dirprm]$ vi javaue.properties

### javaue.properties (GoldenGate Java Extract properties file) gg.handlerlist=advjms

java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQI nitialContextFactory

java.naming.provider.url=tcp://localhost:61616 gg.handler.advjms.type=jms

gg.handler.advjms.destination=dynamicQueues/oggjmsQueue gg.handler.advjms.connectionFactory=ConnectionFactory gg.handler.advjms.format=xml

### native library config ###

goldengate.userexit.nochkpt=TRUE

The lines specifying java.naming.factory.initial and

javawriter.bootoptions are one line each even if, for formatting reasons, they are shown over multiple lines. It is extremely important to make sure that the lines are not broken up and no white spaces exist between keywords; otherwise, the delivery Extract process will not start. You can edit or display the javaue.properties file stored in /home/oracle/labs/Practice07/solutions to see what the properties file should look like.

Also, note the gg.handler.advjms.format parameter, which specifies that messages coming from the source database should be queued in XML format.

Oracle University and Error : You are not a Valid Partner use only

6. Leave the OS shell window open and resume the GGSCI session you left open, connected to the ggs_trg Oracle GoldenGate instance. Add the data delivery Extract process, making sure that the Extract process was created and registered correctly:

GGSCI ([TRGHOST]) > ADD extract javaue, extTrailSource ./dirdat/pu EXTRACT added.

GGSCI ([TRGHOST]) > Info All

Program Status Group Lag at Chkpt Time Since Chkpt

MANAGER RUNNING

EXTRACT STOPPED JAVAUE 00:00:00 00:00:33 7. Using the OS shell window you left open, change the directory to

/opt/apache-activemq-5.10.0/bin and launch ActiveMQ in Console mode. Do not close the shell because ActiveMQ takes over the shell, occasionally printing log messages to the screen:

[OS prompt]$ cd /opt/apache-activemq-5.10.0/bin [OS prompt bin]$ ./activemq console

INFO: Using default configuration

(you can configure options in one of these file: /etc/default/activemq /home/user01/.activemqrc)

INFO: Invoke the following command to create a configuration file ./activemq setup [ /etc/default/activemq | /home/oracle/.activemqrc ]

INFO: Using java '/usr/bin/java'

INFO: Starting in foreground, this is just for debugging purposes (stop process by pressing CTRL+C)

Java Runtime: Oracle Corporation 1.7.0_09 /usr/java/jdk1.7.0_75/jre Heap sizes: current=251264k free=247327k max=251264k

JVM args: Xms256M Xmx256M

Dorg.apache.activemq.UseDedicatedTaskRunner=true -Djava.util.logging.config.file=logging.properties

-Dcom.sun.management.jmxremote -Dactivemq.classpath=/opt/apache-activemq-5.10.0/conf; -Dactivemq.home=/opt/apache-activemq-5.10.0 -Dactivemq.base=/opt/apache-activemq-5.10.0

ACTIVEMQ_HOME: /opt/apache-activemq-5.10.0 ACTIVEMQ_BASE: /opt/apache-activemq-5.10.0 Loading message broker from: xbean:activemq.xml INFO | Refreshing

org.apache.activemq.xbean.XBeanBrokerFactory$1@bbf4061: startup date [Sat Oct 20 08:58:44 EST 2012]; root of context hierarchy

WARN | destroyApplicationContextOnStop parameter is deprecated, please use shutdown hooks instead

INFO | PListStore:/opt/apache-activemq-5.10.0/data/localhost/tmp_storage started INFO | Using Persistence Adapter:

KahaDBPersistenceAdapter[/opt/apache-activemq-5.10.0/data/kahadb]

INFO | ActiveMQ 5.10.0 JMS Message Broker (localhost) is starting INFO | For help or more information please see:

http://activemq.apache.org/

Oracle University and Error : You are not a Valid Partner use only

INFO | Listening for connections at: tcp://EDDDR53P1:61616 INFO | Connector openwire Started

INFO | ActiveMQ JMS Message Broker (localhost, ID:host01.example.com-33804-1350683930829-0:1) started

INFO | jetty-7.1.6.v20100715

INFO | ActiveMQ WebConsole initialized.

INFO | Initializing Spring FrameworkServlet 'dispatcher' INFO | ActiveMQ Console at http://0.0.0.0:8161/admin INFO | ActiveMQ Web Demos at http://0.0.0.0:8161/demo INFO | RESTful file access application at

http://0.0.0.0:8161/fileserver

INFO | Started [email protected]:8161

8. Resume the GGSCI session that is connected to the ggs_trg Oracle GoldenGate instance and start the javaue data delivery Extract process.

GGSCI ([Host]) > start ext javaue

Sending START request to MANAGER ...

EXTRACT JAVAUE starting

GGSCI ([Host]) > info all

Program Status Group Lag at Chkpt Time Since Chkpt

MANAGER RUNNING

EXTRACT RUNNING JAVAUE 00:00:00 00:00:04

9. The first time JAVAUE is started, it takes several seconds before the status changes to RUNNING. A Java virtual machine is instantiated and a connection is made to Apache ActiveMQ, creating the dynamic queue oggjmsQueue. If, after 30 seconds, the status of JAVAUE is either STOPPED or ABENDED, you should investigate what happened by using the VIEW REPORT JAVAUE command, which lists the causes of the failure. An environment variable pointing to a wrong disk location, or not having stopped and restarted the manager process after sourcing the setenv.sh file are usually the reasons why the delivery Extract fails to start.

This completes Practice 7-3. Continue with Practice 7-4.

Oracle University and Error : You are not a Valid Partner use only

Practice 7-4: Generating Data and Verifying Replication

In document D89113GC10_ag (Page 155-160)