The Oracle GoldenGate Adapter for Coherence

Overview

    Purpose

    This Oracle-By-Example (OBE) tutorial covers installing, configuring, and running the Oracle GoldenGate Adapter for Oracle Coherence.

    Time to Complete

    Approximately 2 to 2.5 hours.

    Introduction

    The Oracle GoldenGate Adapter for Coherence provides a mechanism to synchronize changes made directly to an Oracle database with a Coherence cache. Such synchronization is two-way: all changes made to data residing in the Coherence cache are checkpointed to the Oracle database, and all changes made to the Oracle database are propagated to the Coherence cache. 

    Scenario

    On one computer three major software components cooperate to keep a cache synchronized across two different subsystems (the database realm and the cache realm.) The three software components are:

    1. The Oracle RDBMS
    2. The Oracle GoldenGate Adapter for Coherence
    3. Oracle Coherence

    The Java Adapter for Oracle Goldengate represents the bridge between the Oracle GoldenGate software, written in C/C++, and the Java world (Oracle Coherence and potentially Oracle WebLogic Server.) The Oracle GoldenGate Adapter for Coherence needs Oracle GoldenGate Application Adapters for JMS and Flat File.

    In this OBE, you set up a lab environment where all cooperating software components run together on the same computer and are installed under the oracle user. Such an arrangement greatly simplifies the setup work to achieve an operational environment in the shortest possible time, but it is not advisable to emulate this configuration in production environments.

    IMPORTANT! This OBE is meant to be a proof of concept. The Oracle RDBMS, Oracle GoldenGate, and Oracle Coherence run all on a single computer. Moreover, all software is installed by the oracle user and Oracle GoldenGate is installed in the home directory. In production environments, best practices dictate different configurations. Oracle GoldenGate, for example, should not be installed in the home directory, but in shared directories (such as /opt.)

    Alternative Configuration

    This OBE can also be run on a different operating system (i.e. Microsoft Windows or Linux 32bit) , where the Oracle RDBMS, Oracle GoldenGate and Oracle Coherence are installed in the same computer. If you are not using Linux x86_64, you must find the appropriate software for your configuration on the Oracle eDelivery Web site (edelivery.oracle.com )

    The following is a list of hardware and software requirements:

    Hardware
    • One Linux host (alternatively, one Linux virtual machine) -  This example uses Oracle Linux OL 6.4, 64-bit. Other versions of the Oracle GoldenGate software exist for Windows, and 32-bit Linux.
    Software
    • Oracle GoldenGate on Oracle, Linux-64 ( Oracle Software Delivery Cloud ), version 11.2.1.0.2, part number V34339-01. This is the part number for 64-bit Linux.
    • Oracle GoldenGate Application Adapters 11.1.1.0.0 for JMS and Flat File Media Pack ( Oracle Software Delivery Cloud ), version 11.1.1.0.1, part number V22250-01. This is the part number for 64-bit Linux.
    • Oracle Coherence 12c ( Oracle Software Delivery Cloud ), version 12.1.2.0.0, part number V38519-01.
    • Oracle 11gR2 Database installed on the host used for this OBE.
    • Apache Ant release 1.8. The environment variable ANT_HOME should point to the directory where Apache Ant is installed. In addition, the $PATH environment variable should contain an entry for ${ANT_HOME}/bin.
    • OracleGoldenGate Adapter for Coherence files, which are needed by this OBE.  They can be downloaded here.


    • This OBE has also been tested with GoldenGate version 11.2.1.0.2 with GoldenGate Adapter version 11.2.1.0.1.
      When possible it is always preferable to use the same Major and Minor versions (for example, 11.2.1).

    Prerequisites

    The Oracle RDBMS has been installed in "standard" directory locations. ORACLE_HOME points to /u01/app/oracle/product/11.2.0/dbhome_1.

    Before starting this tutorial, you should:

    • Have root access to the Linux software.
    • Have web access to download the software and documentation.
    • Have an instance of the Oracle RDBMS up and running on the Linux host. IMPORTANT! This OBE covers installing Oracle GoldenGate, the Java Adapter for GoldenGate and Oracle Coherence, but assumes the Oracle RDBMS is installed and an Oracle RDBMS instance created and running on the host computer.
      In addition, it assumes that Apache Ant is properly installed.
    • Have the Oracle Java JDK 1.7 installed on the host computer.
      This OBE assumes the JDK 1.7 is properly installed and does not cover how to download, unpack and install the Java JDK.

    Typographic Conventions

    Text color and font in the directions and in the screens should be interpreted as follows:

    Some_Command
    You type this as a command or a value. Example:
    Enter ./ggsci to start the command line interpreter.
    Some_Prompt
    The system responds with this as a prompt or reply. Example:
    After the welcome splash banner, you can enter commands at the GGSCI (host01) 1> prompt.
    Some_Button
    Click this on-screen button. Example:
    After selecting the version you want, click Continue to start the download.
    Some_Variable
    A variable that you substitute with a real value. Example:
    Enter your userid/password at the prompt.
    Some_Filename
    A filename, path, or folder/directory. Example:
    Edit the hosts file in the /etc directory.
    Some_Code
    A keyword or code element. Example:
    Change the parameter HandleCollisions to NoHandleCollisions after the initial load.

1. Installing the Software

    The installation of the software is simply fetching the zip files from the web and unzipping them. To install the Oracle GoldenGate software, perform the following steps:

    1.1 Accessing Oracle GoldenGate Documentation

      Access the documentation library.

      Using a web browser, go to http://www.oracle.com/technetwork/middleware/goldengate/documentation/index.html. You have the option to either read the documents online, or to download the library to your local workstation as either PDF or HTML format.

      Click View Library.

      Click Oracle Installation and Setup Guide. Read the Installation Guide for Oracle.

      You have successfully accessed Oracle GoldenGate documentation as a prerequisite for installing the software.

    1.2 Installing Oracle GoldenGate on Linux

      Copy the software from Oracle Software Delivery Cloud.

      Using a web browser, go to https://edelivery.oracle.com and click Sign In. On the Terms and Conditions page, select Yes for both agreements, and click Continue.

      On the Media Pack Search page, select Product Pack = Oracle Fusion Middleware, and Platform = Linux x86-64.

      Click Go.

      Select Oracle GoldenGate on Oracle v11.2.1 Media Pack for Linux x86-64.

      Click Continue.

      Make sure you are looking at part number V34339-01 for "Oracle GoldenGate V11.2.1.0.3 for Oracle 11g on Linux x86-64."

      Click Download.

      Click the Back browser button.

      Select Oracle GoldenGate Application Adapters 11.1.1.0.0 for JMS and Flat File Media Pack.

      Select Oracle GoldenGate V11.1.1.0.0 For Java on Linux 64-bit for OGG v11.1.1.0.0.

      Make sure you are looking at part number V22250-01

      Click Download.

      Download Oracle Coherence 12c release 12.1.2.0.0 from https://edelivery.oracle.com.

      Select Oracle Fusion Middleware 12c Media Pack

      Make sure you are looking at part number V38519-01. Click Download.

      Unpack the Oracle GoldenGate for Oracle software in its directory.

      Create the installation directories to receive the Oracle GoldenGate software.

      Host01 - Linux
      [oracle@host01 ~]$ cd ~ 
      [oracle@host01 ~]$ mkdir goldengate-v11.2.1.0.3 
      [oracle@host01 ~]$ cd goldengate-v11.2.1.0.3 
      [oracle@host01 goldengate-v11.2.1.0.3]$                                                         
      

      Copy the downloaded zip from wherever you downloaded it to ~oracle/goldengate-v11.2.1.0.3.

      . Unzip it and untar (extract) it. Be mindful of the trailing dot in the copy command.

      Host01 - Linux
      [oracle@host01 goldengate-v11.2.1.0.3]$ cp /stage/V34339-01.zip . 
      [oracle@host01 goldengate-v11.2.1.0.3]$ unzip V34339-01.zip  
      Archive:  V34339-01.zip
        inflating: fbo_ggs_Linux_x64_ora11g_64bit.tar
        inflating: Oracle_GoldenGate_11.2.1.0.3_README.doc
        inflating: Oracle GoldenGate_11.2.1.0.3_README.txt
        inflating: OGG_WinUnix_Rel_Notes_11.2.1.0.3.pdf
      [oracle@host01 goldengate-v11.2.1.0.3]$ tar -xvpf fbo_ggs_Linux_x64_ora11g_64bit.tar 
      UserExitExamples/
      UserExitExamples/ExitDemo_more_recs/
      UserExitExamples/ExitDemo_more_recs/Makefile_more_recs.HPUX
      
       ... many lines omitted for clarity ... 
      
      ulg.sql
      usrdecs.h
      zlib.txt
      [oracle@host01 goldengate-v11.2.1.0.3]$                                                         
      

      Start the GoldenGate Software Command Interface (GGSCI). Create the default empty subdirectories.


      IMPORTANT! GGSCI for Oracle will not start if the LD_LIBRARY_PATH environment variable is either undefined or if it does not point to the ${ORACLE_HOME}/lib directory. You will properly set up the environment setting the various environment variables in the .bashrc file.You can temporarily set the LD_LIBRARY_PATH variable by issuing the shell command:

      export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${ORACLE_HOME}/lib
      just before invoking ggsci

      Make sure LD_LIBRARY_PATH is correctly set before launching GGSCI.

      Host01 - Linux
      [oracle@host01 goldengate-v11.2.1.0.3]$ ./ggsci 
      
      Oracle GoldenGate Command Interpreter for Oracle
      Version 11.2.1.0.3 14400833 OGGCORE_11.2.1.0.3_PLATFORMS_120823.1258_FBO
      Linux, x64, 64bit (optimized), Oracle 11g on Aug 23 2012 20:20:21
      
      Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
      
      GGSCI (host01) 1> Create Subdirs 
      
      Creating subdirectories under current directory /home/user01/oracle/ggs_src
      
      Parameter files            /home/user01/oracle/ggs_src/dirprm: already exists
      Report files               /home/user01/oracle/ggs_src/dirrpt: created
      Checkpoint files           /home/user01/oracle/ggs_src/dirchk: created
      Process status files       /home/user01/oracle/ggs_src/dirpcs: created
      SQL script files           /home/user01/oracle/ggs_src/dirsql: created
      Database definitions files /home/user01/oracle/ggs_src/dirdef: created
      Extract data files         /home/user01/oracle/ggs_src/dirdat: created
      Temporary files            /home/user01/oracle/ggs_src/dirtmp: created
      Stdout files               /home/user01/oracle/ggs_src/dirout: created
      
      GGSCI (host01) 2> Exit 
      [oracle@host01 goldengate-v11.2.1.0.3]$                                                           
      

      If a directory already exists, the installation leaves the contents of that directory alone.

      The adapters cannot be directly installed into an existing GoldenGate install. Additionally, only portions of the adapter install are relevant to HotCache.

      Unpackaging the GoldenGate adapter into the previously installed GoldenGate directory will overwrite certain common files with non-database specific versions, causing problems with later steps. The adapter must merged into the GoldenGate  install in two two steps, as shown below.

      1. Unpackage the adapter TAR into a temporary location:
        $ cd /tmp
        $ mkdir ggadapter
        $ cd ggadapter
        $ tar –xvf path.to.installer.tar.file/ ggs_Adapters_Linux_x64.tar
      2. Copy select files to GoldenGate proper.
        cp –r ggjava path.to.installer.goldengate/.
        cp libgg_java_ue.so path.to.installer.goldengate/
        .

      For example:
      Host01 - Linux
      [oracle@host01 goldengate-v11.2.1.0.3]$ cd /stage/
      [oracle@host01 stage ]$ unzip V22250-01.zip Archive: V22250-01.zip inflating: ggs_JavaAdapter_Linux_x64_v11_1_1_0_0_007.tar inflating: README.txt inflating: OGG_Java_Rel_Notes_11.1.1.0.0_007.pdf extracting: ggs_Linux_x64_Generic_64bit_v11_1_1_0_0_078.zip [oracle@host01 stage]$ tar -xvpf ggs_JavaAdapter_Linux_x64_v11_1_1_0_0_007.tar gendef ggjava/ ggjava/resources/ ggjava/resources/lib/ ggjava/resources/lib/gguserexitapi-11.1.1.0.0.006.jar ... many lines omitted for clarity ... sample-dirprm/javaue.prm sample-dirprm/capture.prm sample-dirprm/mgr.prm [oracle@host01 stage]$ cp –r ggjava /home/oracle/goldengate-v11.2.1.0.3/.
      [oracle@host01 stage]$ cp libgg_java_ue.so /home/oracle/goldengate-v11.2.1.0.3/.
      [oracle@host01 stage]$ cd /home/oracle/goldengate-v11.2.1.0.3/
      [oracle@host01 goldengate-v11.2.1.0.3]$  

      You have successfully installed  both Oracle GoldenGate and Oracle Coherence GoldenGate Java Adapter on the source Oracle GoldenGate instance.

    1.3 Installing Oracle Coherence on the Linux host (Host01)

      Logged in as the oracle user, change directory to the default directory (cd ~.) Unzip the downloaded V38519-01.zip file from wherever it was downloaded, extracting its content to the default directory.

      Host01 - Linux
      [oracle@host01 goldengate-v11.2.1.0.3]$ cd ~ 
      [oracle@host01 ~]$ unzip /stage/V38519-01.zip                                                     
      Archive:  /stage/V38519-01.zip
        inflating: coherence_121200.jar  
      [oracle@host01 ~]$                                                         
      

      Launch the Coherence installer using java -jar

      Host01 - Linux
      [oracle@host01 ~]$ java -jar coherence_121200.jar 
      Extracting files....
      Starting Oracle Universal Installer
      
      Checking if CPU speed is above 300 MHz.   Actual 2494.334 MHz    Passed
      Checking monitor: must be configured to display at least 256 colors.   Actual 16777216    Passed
      Checking swap space: must be greater than 512 MB.   Actual 4063228 MB    Passed
      Checking if this platform requires a 64-bit JVM.   Actual 64    Passed (64-bit not required)
      Checking temp space: must be greater than 300 MB.   Actual 19283 MB    Passed
      
      
      Preparing to launch the Oracle Universal Installer from /tmp/OraInstall2013-08-25_03-35-31PM
      Log: /u01/app/oraInventory/logs/install2013-08-25_03-35-31PM.log                                  
      


      If the Oracle Coherence quick installer is used rather then the full installer, pre-create the install directory and specify an Oracle home. For example:

      $ mkdir /u01/app/coherence
      $ java -jar coherence fmw_12.1.3.0.0_coherence_quick.jar ORACL_HOME=/u01/app/coherence


      The Oracle Coherence installer starts.

      Click Next .

      The default Oracle Home proposed by the installer should be /home/oracle/Oracle/MiddleWare/Oracle_Home. If that is the case, accept the default and click Next. If the proposed directory for Oracle Home is not /home/oracle/Oracle/MiddleWare/Oracle_Home, change it to be /home/oracle/Oracle/MiddleWare/Oracle_Home, then click Next.

      Choose a typical Coherence installation (the default) and click Next.

      The Installation Summary form appears, showing the options chosen for the installation. Click Install.

      The Installation Progress form appears, showing the the various installation steps. When the progress bar reaches 100% click Next.

      The Installation Complete form appears, showing the the Oracle Home and the log directories, plus the various features of Coherence which have been installed. Click Finish to exit the installer.

      You have successfully installed Oracle Coherence 12c.

2. Extracting and installing the OBE scripts

    Download the cgga.zip file if you didn't do it already.

    Extract the content of cgga.zip in the default directory of the oracle user (/home/oracle)

    2.1 Creating the Directory for the OBE files

      Make sure you are positioned in the default directory of the oracle user (/home/oracle.) If necessery issue the command cd ~ while logged in as oracle.
      Host01 - Linux
      [oracle@host01 ~]$ cd ~ 
      [oracle@host01 ~]$ unzip /stage/cgga.zip                                 
      Archive:  /stage/cgga.zip
        inflating: cgga/cs-cap.ggsci       
        inflating: cgga/cs-cgga.ggsci      
        inflating: cgga/cs-stop.ggsci      
         creating: cgga/dirprm/
       ... many lines omitted for clarity ... 
        inflating: cgga/workspace/CacheStoreDemo/build.xml  
        inflating: cgga/workspace/CacheStoreDemo/.project  
        inflating: cgga/workspace/CacheStoreDemo/setup.sql  
        inflating: cgga/workspace/CacheStoreDemo/cs-coherence-cache-config.xml
      

      In this example the file cgga.zip was saved in the /stage directory. If you downloaded it in a different directory, replace /stage with the directory in which you saved cgga.zip.

      Unzipping the cgga.zip file creates the directory cgga under the oracle user default directory (/home/oracle/cgga.)

    2.2 Modifying .bashrc to add the required environment variables

      For this OBE to work, several environment variables must be set. In particular:

      Variable Purpose
      ORACLE_BASE Root directory for all Oracle RDBMS files
      ORACLE_HOME Below the ORACLE_BASE directory, the files for each database
      ORACLE_SID Oracle System Id which uniquely identifies a particular RDBMS instance
      LD_LIBRARY_PATH Location where all shared objects are stored
      ANT_HOME Points to the directory where Apache Ant is installed
      JAVA_HOME Points to the directory where Oracle Java JDK is installed
      CGGA_DEMO_HOME Points to the directory where the files needed by this OBE are installed
      GG_HOME Points to the directory where Oracle GoldenGate is installed
      PATH Environmental variable that tells the shell which directories to search for executable files in response to commands issued by a user. For this OBE to work, the shell must be able to locate the Ant executable and the Oracle GoldenGate executable

      Edit the file /home/oracle/.bashrc (Note the dot before the file name.) In the Unix/Linux OS, a file named with a dot prefix is a hidden file. Use either vi or gedit to edit the .bashrc file.

      Host01 - Linux
      [oracle@host01 ~] vi .bashrc 
      # .bashrc
      ... # non relevant content removed
      
      export ANT_HOME=/u01/app/apache-ant-1.9.4
      export JAVA_HOME=/usr/java/jdk1.7.0_21
      
      ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1 export ORACLE_SID=oggcoh
      export LD_LIBRARY_PATH=$JAVA_HOME/jre/lib/amd64/server:$ORACLE_HOME/lib:$GG_HOME:$LD_LIBRARY_PATH export CGGA_DEMO_HOME=$HOME/cgga export GG_HOME=$HOME/goldengate-v11.2.1.0.3 export PATH=$JAVA_HOME/bin:$ANT_HOME/bin:$GG_HOME:$PATH

      Either source the .bashrc file (source .bashrc) or exit and restart a new shell to make sure that the new environment variables are read by the bash shell.

      Confirm that key environment variables point to their correct directories and such.

      Host01 - Linux
      [oracle@host01 ~]$ echo ANT_HOME                                                                  
      /opt/ant
      [oracle@host01 ~]$  echo $JAVA_HOME
      /usr/java/jdk1.7.0_21
      [oracle@host01 ~] $ echo $GG_HOME
      /home/oracle/goldengate-v11.2.1.0.3
      [oracle@host01 ~]$ echo $ CGGA_DEMO_HOME
      /home/oracle/cgga
      [oracle@host01 ~] $



    2.3 Modifying the cs-cgga.properties file to adapt it to your environment

      The file cs-cgga.properties, located under /home/oracle/cgga/dirprm, is the crucial file which instructs the Oracle GoldenGate Java adapter on various elements of the Java subsystem, such as files and directory locations of the various components (TopLink and Coherence libraries/jar file, OBE classes, etc.) Edit the file and make sure that all elements included in the javawriter.bootoptions variable exist and are readable.

      Host01 - Linux
      [oracle@host01 ~]$ vi cgga/dirprm/cs-cgga.properties 
      # ====================================================================
      # List of active event handlers. handlers not in the list are ignored.
      # ====================================================================
      gg.handlerlist=cache
      
      # ====================================================================
      # Coherence cache updater
      # ====================================================================
      gg.handler.cache.type=oracle.toplink.goldengate.CoherenceAdapter
      
      # print plain text output (custom velocity template)
      gg.handler.txtfile1.type=singlefile
      gg.handler.txtfile1.format=text
      gg.handler.txtfile1.mode=op
      gg.handler.txtfile1.file=./dirout/csdemo-output.txt
      
      
      # ====================================================================
      # Native JNI library properties
      # ====================================================================
      goldengate.userexit.nochkpt=true
      goldengate.userexit.writers=javawriter
      goldengate.log.logname=./dirout/csdemo-userexit-jcoh
      
      # ======================================
      javawriter.bootoptions=-Djava.class.path=./dirprm:/u01/app/oracle/product/11.2.0/dbhome_1/jdbc/lib/ojdbc6.jar:
      ./ggjava/ggjava.jar:/home/oracle/Oracle/Middleware/Oracle_Home/coherence/lib/coherence.jar:
      /home/oracle/Oracle/Middleware/Oracle_Home/oracle_common/modules/javax.persistence_2.0.0.0_2-0.jar:
      /home/oracle/Oracle/Middleware/Oracle_Home/oracle_common/modules/oracle.toplink_12.1.2/eclipselink.jar:
      /home/oracle/Oracle/Middleware/Oracle_Home/oracle_common/modules/oracle.toplink_12.1.2/toplink-grid.jar:
      /home/oracle/cgga/workspace/CacheStoreDemo/bin -Xmx32M -Xms32M -Dtoplink.goldengate.persistence-unit=employee
      -Dlog4j.configuration=debug-log4j.properties -Dtangosol.coherence.distributed.localstorage=false
      -Dtangosol.coherence.cacheconfig=/home/oracle/cgga/workspace/CacheStoreDemo/cs-coherence-cache-config.xml
      -Dtangosol.coherence.localhost=127.0.0.1 -Dtangosol.coherence.ttl=0 -Dtangosol.coherence.clusterport=4617
      [oracle@host01 dirprm]$ ls /u01/app/oracle/product/11.2.0/dbhome_1/jdbc/lib/ojdbc6.jar /u01/app/oracle/product/11.2.0/dbhome_1/jdbc/lib/ojdbc6.jar

      IMPORTANT! The last entry (which begins with javawriter.bootoptions=) in the cs-cgga.properties file is only one long line, even if it is shown, for clarity, across several rows.

      The javawriter.bootoptions property can be thought of as having portions or sections per product area, some of which are:

      Product
      Values added
      Database
      /u01/app/oracle/product/11.2.0/dbhome_1/jdbc/lib/ojdbc6.jar
      Coherence Proper
      /home/oracle/Oracle/Middleware/Oracle_Home/coherence/lib/coherence.jar
      Coherence cache configuration and runtime
      -Dtangosol.coherence.distributed.localstorage=false
      -Dtangosol.coherence.cacheconfig=/home/oracle/cgga/workspace/CacheStoreDemo/cs-coherence-cache-config.xml
      -Dtangosol.coherence.localhost=127.0.0.1
      -Dtangosol.coherence.ttl=0
      -Dtangosol.coherence.clusterport=4617
      Coherence Toplink and JPA
      /home/oracle/Oracle/Middleware/Oracle_Home/oracle_common/modules/javax.persistence_2.0.0.0_2-0.jar
      /home/oracle/Oracle/Middleware/Oracle_Home/oracle_common/modules/oracle.toplink_12.1.2/eclipselink.jar
      /home/oracle/Oracle/Middleware/Oracle_Home/oracle_common/modules/oracle.toplink_12.1.2/toplink-grid.jar
      Toplink JPA
      -Dtoplink.goldengate.persistence-unit=employee
      GoldenGate Adapter
      ./ggjava/ggjava.jar
      ./dirprm
      JVM and log4j
      -Xmx32M -Xms32M  
      -Dlog4j.configuration=debug-log4j.properties


      It is crucial that no new line characters or spaces appear at the end of the logical rows otherwise the Java adapter will not work.

      Save the file and exit the editor. To verify that all elements appearing in the javawriter.bootoptions variable exist and are accessible, display the content of the cs-cgga.properties file to the screen (using the cat command)and then highlight with the mouse each component of the variable and use the ls command to make sure that it exists on the file system.

      Host01 - Linux
      [oracle@host01 ~]$ cd ~/cgga/dirprm
      [oracle@host01 dirprm]$ ls /u01/app/oracle/product/11.2.0/dbhome_1/jdbc/lib/ojdbc6.jar
      /u01/app/oracle/product/11.2.0/dbhome_1/jdbc/lib/ojdbc6.jar
      [oracle@host01 dirprm]$ ls /home/oracle/Oracle/Middleware/Oracle_Home/coherence/lib/coherence.jar
      /home/oracle/Oracle/Middleware/Oracle_Home/coherence/lib/coherence.jar
      [oracle@host01 dirprm]$ ls /home/oracle/Oracle/Middleware/Oracle_Home/oracle_common/modules/javax.persistence_2.0.0.0_2-0.jar
      /home/oracle/Oracle/Middleware/Oracle_Home/oracle_common/modules/javax.persistence_2.0.0.0_2-0.jar
      [oracle@host01 dirprm]$ ls /home/oracle/Oracle/Middleware/Oracle_Home/oracle_common/modules/oracle.toplink_12.1.2/eclipselink.jar
      /home/oracle/Oracle/Middleware/Oracle_Home/oracle_common/modules/oracle.toplink_12.1.2/eclipselink.jar
      [oracle@host01 dirprm]$ ls /home/oracle/Oracle/Middleware/Oracle_Home/oracle_common/modules/oracle.toplink_12.1.2/toplink-grid.jar
      /home/oracle/Oracle/Middleware/Oracle_Home/oracle_common/modules/oracle.toplink_12.1.2/toplink-grid.jar
      [oracle@host01 dirprm]$ ls /home/oracle/cgga/workspace/CacheStoreDemo/bin
      cachestore  META-INF
      [oracle@host01 dirprm]$

    2.4 Modifying the jdbc.properties file to adapt it to your environment

      The file jdbc.properties, located under /home/oracle/cgga/workspace/CacheStoreDemo, contains the JDBC parameters used to connect to the Oracle RDBMS.

      Change directory to /home/oracle/cgga/workspace/CacheStoreDemo and edit the jdbc.properties file. Make sure that all JDBC parameters are correctly set and correspond to a valid Oracle system user for your RDBMS. Varify the listener port and the Oracle System Id for your instance.

      Host01 - Linux
      [oracle@host01 ~]$ cd ~/cgga/workspace/CacheStoreDemo
      [oracle@host01 CacheStoreDemo]$ vi jdbc.properties
      #*************************************
      #Specify JDBC Connection Details here*
      #*************************************
      
      # Database User
      db.user=system
      
      # DB Password
      db.password=oracle
      
      # The database host
      db.host=localhost
      
      # The database SID
      db.sid=oggcoh
      
      # The database listener port
      db.port=1521
      
      jdbc.url=jdbc:oracle:thin:@${db.host}:${db.port}:${db.sid}                          
      jdbc.driver=oracle.jdbc.OracleDriver
      

      Save the file and exit the editor.

    2.5 Modifying the persistence.xml file to adapt it to your environment

      The file persistence.xml, located under /home/oracle/cgga/workspace/CacheStoreDemo/bin/META-INF, contains properties used to connect to the Oracle RDBMS.These properties are not modified by any script and may need to be changed to match your environment.

      Change directory to /home/oracle/cgga/workspace/CacheStoreDemo/bin/META-INF and edit the persistence.xml file. Make sure that all properties are correctly set and correspond to a valid values for your environment.  Pay particular attention to the jdbc.url, jdbc.user and jdbc.password properties.

      Host01 - Linux
      [oracle@host01 ~]$ cd ~/cgga/workspace/CacheStoreDem/bin/META-INF
      [oracle@host01 META-INF]$ vi persistence.xml
      #*************************************
      
      <?xml version="1.0" encoding="UTF-8"?> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"> <persistence-unit name="employee" transaction-type="RESOURCE_LOCAL"> <class>cachestore.model.Employee</class> <properties> <!-- Default Login using Oracle for EclipseLink's internal connection pool --> <property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver" /> <property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@localhost:1521:oggcoh" /> <property name="javax.persistence.jdbc.user" value="csdemo" /> <property name="javax.persistence.jdbc.password" value="csdemo" /> <!-- Minimal connections in internal pool --> . . .
      </properties> </persistence-unit> </persistence>.

      Save the file and exit the editor.

3. Configuring the Environment

    The configuration of the environment is done through the Ant utility. 

    3.1 Using Ant to copy files to their respective directories

      Change directory to /home/oracle/cgga/workspace/CacheStoreDemo and invoke Ant with init as its target. The *.ggsci will be copied into $GG_HOME (the install directory for Oracle GoldenGate) and the *.prm files and the *.properties file will be copied in the dirprm directory under $GG_HOME.

      Host01 - Linux
      [oracle@host01 ~]$ cd ~/cgga/workspace/CacheStoreDemo/ 
      [oracle@host01 CacheStoreDemo]$ ant init
      Buildfile: /home/oracle/cgga/workspace/CacheStoreDemo/build.xml
      
      define:
      
      init:
           [copy] Copying 3 files to /home/oracle/goldengate-v11.2.1.0.3
           [copy] Copying 4 files to /home/oracle/goldengate-v11.2.1.0.3/dirprm
       BUILD SUCCESSFUL Total time: 0 seconds [oracle@host01 CacheStoreDemo]$

    3.2 Using Ant to create Oracle database users and objects

      While still located in the /home/oracle/cgga/workspace/CacheStoreDemo directory, invoke Ant again, this time using createusers as its target. Ant will use the values found in jdbc.properties for the DBA user (system) and for its password (oracle). However, Ant will allow you to confirm their values by typing Enter. You can override the values found in jdbc.properties by typing an alternative user and password instead of Enter

      Host01 - Linux
      [oracle@host01 CacheStoreDemo] ant createusers
      Buildfile: /home/oracle/cgga/workspace/CacheStoreDemo/build.xml
      
      define:
      
      init:
      
      createusers:
          [input] Please enter the dba user [system]: [system]
      
          [input] Please enter the dba password [oracle] [oracle]
      
            [sql] Executing commands
            [sql] 12 of 12 SQL statements executed successfully
      
      BUILD SUCCESSFUL
      Total time: 7 seconds
      [oracle@host01 CacheStoreDemo]$                                                  
      

      The Ant createusers target creates two database users, CSDEMO, with password csdemo and NOTCSDEMO, with password notcsdemo. In addition, a few privileges are granted to those users.

    3.3 Additional Database provisioning

      Much of the provisioning of the database is handled by the ant scripts in the prior section.  Correctly setting logging is key to the success of the HotCache adapter. 


      In particular implementations will need to:

      • Enable Forced logging
      • Enable Schema level logging
      • Enable table level logging.

      See Chapter 5 of the Oracle GoldenGate for Oracle Databases Installation and Setup Guide for more details and a complete list of possibly logging related options.


      Note that is you using Oracle Database 11.2.0.4, 12.1.0.2 or later you need only issue a single command.
      Specifically:
      $ sqlplus system/password - suitably privileged account
      SQLplus > ALTER SYSTEM SET ENABLE_GOLDENGATE_REPLICATION = TRUE SCOPE=BOTH;
      SQLplus > ...

      This only needs to be done once, and in a RAC environment, will take effect on all instances. It can be done without bouncing the database instance, and you’ll want to use SCOPE=BOTH or update the init.ora file to ensure that when the database is bounced, the setting remains in effect.

      If this parameter is not set and/or missing privileges (exec DBMS_GOLDENGATE_AUTH.GRANT_ADMIN_PRIVILEGE ( '<appropriate user>' ); ), you may see error, ORA-26947 or ORA-26945 when attempting to use any of the GoldenGate functionality.


      For prior versions:
      1. Enabled forced logging:
        $ sqlplus system/password - suitably privileged account
        SQLplus > ALTER DATABASE FORCE LOGGING;
        SQLplus > ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
        SQLplus >ALTER SYSTEM SWITCH LOGFILE;
        SQLplus > . . .

      2. Enable Schema level logging
        $ cd Golden Gate Install directory
        $ ./ggsci
        GGSCI> DBLogin UserID <login>, Password <pswd>
        GGSCI> add SCHEMATRANSDATA <schema.1>
        GGSCI> Add SCHEMATRANSDATA <schema.2>
        . . .

      3. Enable Table level logging
        $ cd Golden Gate Install directory
        $ ./ggsci
        GGSCI> DBLogin UserID <login>, Password <pswd>
        GGSCI> Add TranData <OWNER>.<TABLE1>
        GGSCI> Add TranData <OWNER>.<TABLE2>
        . . .





4. The Oracle GoldenGate Adapter for Coherence in Action

    You can now reap the fruits of the hard work done so far. Change directory to ~/cgga/workspace/CacheStoreDemo/scripts. The shell file cs-demo-start.sh can be used to launch the demo application which shows the Oracle GoldenGate Adapter for Coherence in action.

    4.1 Launch the CacheStoreDemo application 

      Host01 - Linux
      [oracle@host01 CacheStoreDemo]$ cd scripts 
      [oracle@host01 scripts]$ pwd 
      /home/oracle/cgga/workspace/CacheStoreDemo/scripts
      [oracle@host01 scripts]$ ./cs-demo-start.sh                                     
      

      After you invoke the shell script which starts the demo application, the following actions are performed:

    • An EMPLOYEE table is created in the csdemo user schema.
    • A GoldenGate extract process "cs-cap"(ture) is created to monitor changes to all tables in the csdemo schema and produce a trail file.
    • A GoldenGate extract process "cs-cgga" is created to monitor the trail file produced by the cs-cap extract.

    The following windows are opened:

    • "CacheStore Demo-CacheServer Console" -- the CacheServer that will be updated with database changes
    • "CacheStore Demo-Extract Console" -- the console output of the cs-cap process.
    • "CacheStore Demo-CGGA Console "-- the console of the Coherence GoldenGate Adapter processing events consumed by the cs-cgga extract process.
    • "CacheStore Demo-Employee Cache Monitor" -- an Swing application that supports the creation, modification, and deletion of Employee objects in Coherence cache backed by a CacheStore.
    • "CacheStore Demo-Cache Monitor" -- the console of "CacheStore Demo-Employee Cache Monitor" Swing application.
    • "CacheStore Demo-Third Party SQLplus" -- a terminal running SQLplus logged into the database with the notcsdemo user id

      Note that it can take up to 15-20 seconds for the application to start. The last window to appear is the "CacheStore Demo Employee-Cache Monitor", which is the GUI screen which allows for getting and putting objects into the Coherence cache. When this window appears on screen you can start interacting wiht the application. Confirm all windows exist before moving on. 



    4.2 Confirm applications started 

      Confirm that Golden Gate has started by starting ggsci and issuing the info all command.
      In the  terminal window used to start the scripts or in a new terminal window:

      Host01 - Linux
      [oracle@host01 ~] cd $GG_HOME                                                     
      [oracle@host01 goldengate-v11.2.1.0.3] ggsci Oracle GoldenGate Command Interpreter for Oracle Version 11.2.1.0.3 14400833 OGGCORE_11.2.1.0.3_PLATFORMS_120823.1258_FBO Linux, x64, 64bit (optimized), Oracle 11g on Aug 23 2012 20:20:21 Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved. GGSCI (host01) 1> info all

      Program Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING EXTRACT RUNNING CS-CAP 00:00:00 00:00:10 EXTRACT RUNNING CS-CGGA 00:00:00 00:00:04 GGSCI (host01) 2> exit
      [oracle@host01 ~]

      Note the three running processes Manager and the two extracts.

      In the CacheStoreDemo-Cache Monitor window examine the Coherence default cache server output

      Near the bottom you should see, when all startup is complete a log message resembling:
      [java] 2014-08-29:... Oracle Coherence GE 12.1.2.0.0. . .
      Member 3 joined Service TopLinkGridJPA...


      The demostration has now successfully started.

5. Adding, modifying and Removing data to/from the Coherence Cache

    Now that the infrastructure is in place and the GUI Coherence monitor application is running, you can start adding, modifying and removing data. The sqlplus session is also available, beside the Java GUI. You can add an EMPLOYEE entry either using the Java GUI Coherence monitor application or directly using SQL statement in sqlplus. The end result will be the Coherence refreshed both ways. The Java GUI Coherence monitor has registered its interest in being notified whenever the Coherence cache is modified, and displays the Event Log to the text area placed in the "CacheStore Demo Employee-Cache Monitor" window. This feedback mechanism is useful to verify that SQL statements entered straight in sqlplus are actually modifying the Coherence cache.

    5.1 Adding an Employee entry using the Java GUI application

      Using the "CacheStore Demo Employee-Cache Monitor" window insert a new Employee entry with ID = 1, first name = 'John' and surname = 'Doe' then click on the "Put" button. The Event Log should immediately report the new entry stored in the Coherence cache.

      Verify that the new entry has been checkpointed to the Oracle Employee table by selecting everything (the asterisk sign) from the Employee table. Enter the SQL select statement "select * from csdemo.employee;" in sqlplus.The Employee data should display in the sqlplus window.

    5.2 Adding an Employee entry using sqlplus

      Add employee Jane Roe, with Id 2, using SQL directly in the sqlplus window. Enetr the SQL statement "insert into csdemo.employee values (2,'Jane','Roe');" and then commit the transaction by entering "commit;"

      Almost immediately, the Event Log text area in the "CacheStore Demo Employee-Cache Monitor" window should display the new entry, confirming that the Coherence cache has been updated via the Oracle GoldenGate Adapter.

      To further verify that the Coherence cache has been updated, select the "CacheStore Demo Employee-Cache Monitor" window and enter the Employee Id 2 in the ID field, then click the "Get" button. The remaining fields in the form (Firstname and Lastname) should be populated with the Jane Roe entry.

    5.3 Modifying an Employee entry in the cache using sqlplus

      Using sqlplus update the first name of employee number 1 from John to William. Enter the SQL statement "update csdemo.employee set firstname = 'William' where id = 1;" and then commit the transaction by entering "commit;"

      Almost instantaneously, the Event Log text area in the "CacheStore Demo Employee-Cache Monitor" window should display the UPDATE event.

    5.4 Removing an Employee entry in the cache using the Java GUI application

      Using the "CacheStore Demo Employee-Cache Monitor" window enter the number one (1) into the ID field and click the "Remove" button.

      The Event Log text area in the "CacheStore Demo Employee-Cache Monitor" window should display the DELETED event.

    5.5 Removing an Employee entry in the cache using sqlplus

      Using sqlplus delete the entry for the Employee whose last name is 'Roe'. Enter the SQL statement "delete from csdemo.employee where lastname = 'Roe';" and then commit the transaction by entering "commit;"

      Almost instantaneously, the Event Log text area in the "CacheStore Demo Employee-Cache Monitor" window should display the DELETED event.

      All entries have now been deleted from the Coherence cache and the Oracle RDBMS table. To verify that, using sqlplus, select all rows from the Employee table. sqlplus should display the message "no rows selected" to signal that the Employee table is empty.

Summary

    The Oracle GoldenGate Adapter for Coherence can do far more than was demonstrated in this simple exercise.

    In this tutorial, you have learned how to:

    • Install and configure Oracle GoldenGate
    • Install and configure Oracle Coherence
    • Install and configure the Oracle GoldenGate Java adapter
    • Configure and start Extract, Data Pump, and data delivery Extract processes in a heterogeneous environment, comprising the Oracle RDBMS, Oracle GoldenGate and Oracle Coherence
    • Generate sample data and test the proper synchronization between the Coherence cache and the Oracle RDBMS table

    Resources

    Credits

To help navigate this Oracle by Example, note the following:

Hiding Header Buttons:
Click the Title to hide the buttons in the header. To show the buttons again, simply click the Title again.
Topic List Button:
A list of all the topics. Click one of the topics to navigate to that section.
Expand/Collapse All Topics:
To show/hide all the detail for all the sections. By default, all topics are collapsed.
Show/Hide All Images:
To show/hide all the screenshots. By default, all images are displayed.
Print:
To print the content. The content currently displayed or hidden will be printed.

To navigate to a particular section in this tutorial, select the topic from the list.