본문 바로가기

TECH DOC

ORACLE Coherence 12c Hot Cache with OGG

ORACLE Coherence 12c Hot Cache with OGG

 

ORACLE Coherence 12c Hot Cache with OGG v1.0

 

 

1.    ENVIRONEMNTS

 

<공통>

x86 64 bit 시스템

 

<데이터 소스>

ORACLE ENTERPRISE EDITION

ORACLE GOLDENGATE

 

<데이터 타겟>

ORACLE GOLDENGATE APPLICATION ADAPTERS

ORACLE COHERENCE

JDK 1.8 이상

 

 

2.    SOFTWARES TO INSTALL

 

설치에 앞서 다음 소프트웨어가 필요하다.

 

l  ORACLE ENTERPRISE EDITION 11.2.0.3.8

l  ORACLE GOLDENGATE FOR ORACLE 11g ( 11.2.1.0.25 )

l  ORACLE GOLDENGATE APPLICATION ADAPTERS ( 11.2.1.0.4 )

l  ORACLE COHERENCE ( 12.1.0.0.0 )

l  jdk8-1.8.0-60

 

3.    OUTLINE OF INSTALLATION ORDER

 

A.     (SOURCE) ORACLE 설치,구성 (과정 생략)

B.     (SOURCE) ORACLE GOLDENGATE FOR ORACLE 설치구성

C.     (TARGET) jdk 1.8 설치

D.     (TARGET) ORACLE COHERENCE 설치구성

E.     (TARGET) ORACLE GOLDENGATE APPLICATION ADAPTERS 설치구성

F.     (TARGET) DEVELOP JPA

 

4.    ORACLE GOLDENGATE FOR ORACLE 설치구성 (SOURCE)

OS 환경 셋팅은 생략했다.

 

GGSCI > view param mgr

 

port 7809

PURGEOLDEXTRACTS ./dirdat/*, USECHECKPOINTS, MINKEEPhours 10

 

DOWNCRITICAL

DOWNREPORTMINUTES 30    

 

LAGREPORTMINUTES 5

LAGINFOMINUTES 10

LAGCRITICALMINUTES 60   

--AUTORESTART ER *, RETRIES 3, WAITMINUTES 1, RESETMINUTES 10

SYSLOG NONE

 

 

GGSCI > view param 01_EXT

 

extract 01_ext

userid ggsc, password xxxxxx

 

DBOPTIONS DECRYPTPASSWORD xxxxxx encryptkey default

 

exttrail ./dirdat/s1

EOFDELAYCSECS 30

FLUSHCSECS 30

FETCHOPTIONS NOUSESNAPSHOT

REPORTCOUNT EVERY 10 MINUTES, RATE

report at 23:59

reportrollover at 00:00

statoptions, reportfetch, reportdetail, resetreportstats

sqlexec "alter session set recyclebin=off"

THREADOPTIONS MAXCOMMITPROPAGATIONDELAY 60000 IOLATENCY 60000

TRANLOGOPTIONS EXCLUDEUSER GGSC, EXCLUDEUSERID 229

 

TRANLOGOPTIONS BUFSIZE 4194304

TRANLOGOPTIONS DBLOGREADER

TRANLOGOPTIONS DBLOGREADERBUFSIZE 4194304

 

getUpdateBefores

 

DDL INCLUDE MAPPED, OBJTYPE 'TABLE'

DDLOPTIONS REPORT

DDLERROR _SKIPDDL 2660306

TRANLOGOPTIONS RAWDEVICEOFFSET 0

TRANLOGOPTIONS LOGRETENTION DISABLED

BR BROFF

 

TABLE SYSTEM.TEST

 

 

GGSCI > view param 01_PUMP

 

EXTRACT 01_pump

PASSTHRU

RMTHOST xxx.xx.xxx.xxx , MGRPORT 7809

report at 23:59

reportrollover at 00:00

statoptions, reportfetch, reportdetail, resetreportstats

FLUSHCSECS 30

EOFDELAYCSECS 30

RMTTRAIL ./dirdat/t1

REPORTCOUNT EVERY 10 MINUTES, RATE

 

TABLE SYSTEM.TEST;

 

소스 측 OGG 셋팅은 extractor  getUpdateBefores 옵션을 넣는 것 외에 특이사항이 없다.

 

5.    JDK 1.8 설치 (TARGET)

사용하는 Coherence 버전에 따라 필요한 JDK 버전이 상이하다.

여기서는 1.8 을 설치하겠다.

 

# yum install jdk8

 

6.    ORACLE COHERENCE 설치 (TARGET)

 

코히런스 설치 파일은 executable jar 파일 하나이다.

여기서는 coherence user 에 설치를 진행했다.

 

코히런스에 셋팅한 프로파일은 다음과 같다.

 

 

# .bash_profile

 

# Get the aliases and functions

if [ -f ~/.bashrc ]; then

        . ~/.bashrc

fi

 

# User specific environment and startup programs

 

PATH=$PATH:$HOME/bin

 

export PATH

 

export ORACLE_HOME=/home/coherence/Oracle/Middleware/Oracle_Home

export JAVA_HOME=/usr/java/jdk-1.8.0

export COHERENCE_HOME=/home/coherence/Oracle/Middleware/Oracle_Home/coherence

export CLASSPATH=$CLASSPATH:/home/coherence/Oracle/Middleware/Oracle_Home/oracle_common/modules/oracle.toplink_12.1.3/eclipselink.jar:/home/coherence/Oracle/Middleware/Oracle_Home/oracle_common/modules/oracle.toplink_12.1.3/toplink-grid.jar:/home/ggt/systemtestJPA.jar

 

 

# java –jar fmw_12.2.1.0.0_coherence.jar

 

UI 가 사용 가능한 환경에서 인스톨러를 실행한다.

 

 

cd $COHERENCE_HOME/bin

 

다음 두 파일을 만든다.

 

# vi coherence-cache-config.xml

 

<proxy-scheme>

      <scheme-name>example-proxy</scheme-name>

      <service-name>TcpProxyService</service-name>

 

      <acceptor-config>

        <tcp-acceptor>

          <local-address>

            <address system-property="tangosol.coherence.extend.address">localhost</address>

            <port system-property="tangosol.coherence.extend.port">9099</port>

          </local-address>

        </tcp-acceptor>

      </acceptor-config>

 

      <autostart system-property="tangosol.coherence.extend.enabled">true</autostart>

    </proxy-scheme>

 

# vi extend-client-config.xml

 

<?xml version="1.0"?>

<cache-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.oracle.com/coherence/coherence-cache-config" xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-cache-config coherence-cache-config.xsd">

        <caching-scheme-mapping>

                <cache-mapping>

                        <cache-name>*</cache-name>

                        <scheme-name>remote</scheme-name>

                </cache-mapping>

        </caching-scheme-mapping>

        <caching-schemes>

                <remote-cache-scheme>

                        <scheme-name>remote</scheme-name>

                        <service-name>ExtendTcpCacheService</service-name>

                        <initiator-config>

                                <tcp-initiator>

                                        <remote-addresses>

                                                <socket-address>

                                                        <address>localhost</address>

                                                        <port>9099</port>

                                                </socket-address>

                                        </remote-addresses>

                                        <connect-timeout>10s</connect-timeout>

                                </tcp-initiator>

                                <outgoing-message-handler>

                                        <request-timeout>5s</request-timeout>

                                </outgoing-message-handler>

                        </initiator-config>

                </remote-cache-scheme>

        </caching-schemes>

</cache-config>

 

cd $COHERENCE_HOME/bin

cp cache-server.sh cache-server-extend.sh

 

# vi cache-server-extend.sh

 

#!/bin/sh

 

# This will start a cache server

 

# specify the Coherence installation directory

SCRIPT_PATH="${0}"

while [ -h "${SCRIPT_PATH}" ]; do

  LS=`ls -ld "${SCRIPT_PATH}"`

  LINK=`expr "${LS}" : '.*-> \(.*\)$'`

  if [ `expr "${LINK}" : '/.*'` > /dev/null ]; then

    SCRIPT_PATH="${LINK}"

  else

    SCRIPT_PATH="`dirname "${SCRIPT_PATH}"`/${LINK}"

  fi

done

 

CURRENT_DIR=`pwd`

cd `dirname ${SCRIPT_PATH}` > /dev/null

SCRIPT_PATH=`pwd`

COHERENCE_HOME=`dirname $SCRIPT_PATH`

cd ${CURRENT_DIR}

 

# specify the JVM heap size

MEMORY=1g

 

if [ ! -f ${COHERENCE_HOME}/bin/cache-server.sh ]; then

  echo "coherence.sh: must be run from the Coherence installation directory."

  exit

fi

 

if [ -f $JAVA_HOME/bin/java ]; then

  JAVAEXEC=$JAVA_HOME/bin/java

else

  JAVAEXEC=java

fi

 

if [ "$1" = "-jmx" ]; then

    JMXPROPERTIES="-Dtangosol.coherence.management=all -Dtangosol.coherence.management.remote=true -Dtangsol.coherence.cacheconfig=coherence-cache-config.xml"  

    shift

fi

 

JAVA_OPTS="-Xms$MEMORY -Xmx$MEMORY $JMXPROPERTIES"

 

$JAVAEXEC -server -showversion $JAVA_OPTS -cp "$COHERENCE_HOME/lib/coherence.jar:/home/coherence/Oracle/Middleware/Oracle_Home/oracle_common/modules/oracle.toplink_12.1.3/eclipselink.jar:/home/coherence/Oracle/Middleware/Oracle_Home/oracle_common/modules/oracle.toplink_12.1.3/toplink-grid.jar:/home/ggt/systemtestJPA.jar" com.tangosol.net.DefaultCacheServer $1

 

<COHERENCE 기동>

 

cd $COHERENCE_HOME/bin

 

sh cache-server-extend.sh

 

 

1.    ORACLE GOLDENGATE APPLICATION ADAPTERS ( TARGET )

 

.bash_profile

 

# .bash_profile

 

# Get the aliases and functions

if [ -f ~/.bashrc ]; then

        . ~/.bashrc

fi

 

# User specific environment and startup programs

 

PATH=$PATH:$HOME/bin:./:/home/ggt

 

export PATH

 

export LD_LIBRARY_PATH=/home/ggt/lib

 

stty erase

 

export PS1='[\u@\h \W]\$'

 

export COHERENCE_HOME=/oracle/product/11.2.0.3/coherence

export JAVA_HOME=/usr/java/jdk-1.8.0

export ORACLE_HOME=/oracle/product/11.2.0.3

export ORACLE_BASE=/oracle

export ORACLE_SID=MAT

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/java/jdk-1.8.0/jre/lib/amd64/server:/usr/java/jdk-1.8.0/jre/lib/amd64:/home/coherence/Oracle/Middleware/Oracle_Home/coherence/lib:$GG_HOME

export ANT_HOME=

export GG_HOME=/home/ggt

export CGGA_DEMO_HOME=/home/ggt/cgga

 

exportCLASSPATH=$CLASSPATH:/home/ggt/systemtestJPA.jar:/home/coherence/Oracle/Middleware/Oracle_Home/oracle_common/modules/oracle.toplink_12.1.3/eclipselink.jar:/home/coherence/Oracle/Middleware/Oracle_Home/oracle_common/modules/oracle.toplink_12.1.3/toplink-grid.jar

 

 

GGSCI > view param mgr

 

 

port 7809

PURGEOLDEXTRACTS /home/ggt/dirdat/* , USECHECKPOINTS, MINKEEPHOURS 12

 

DOWNCRITICAL

DOWNREPORTMINUTES 30   

LAGREPORTMINUTES 5

LAGINFOMINUTES 10

LAGCRITICALMINUTES 60   

SYSLOG NONE

 

 

 

GGSCI > view param hcjavaue

 

extract hcjavaue

 

setEnv (GGS_USEREXIT_CONF="/home/ggt/dirprm/hcjavaue.properties")

GetEnv (JAVA_HOME)

 

GetEnv (PATH)

 

GetEnv (LD_LIBRARY_PATH)

 

CUserExit /home/ggt/libggjava_ue.so CUSEREXIT PASSTHRU INCLUDEUPDATEBEFORES

sourceDefs /home/ggt/dirdef/test.def

getUpdateBefores

NoTcpSourceTimer

 

TABLE SYSTEM.TEST;

 

cd ~/dirprm

 

# vi hcjavaue.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.brokentrail=true

goldengate.log.logname=cuserexit

 

goldengate.log.level=DEBUG

 

goldengate.log.tofile=true

 

# ====================================================================

# Native JNI library properties

# ====================================================================

goldengate.userexit.nochkpt=true

goldengate.userexit.writers=jvm

 

# ======================================

 

jvm.bootoptions=-Xmx32M -Xms32M -classpath=/home/ggt/systemtestJPA.jar -Dtoplink.goldengate.persistence-unit=CoherenceHotCache -Dlog4j.configuration=/home/ggt/ggjava/resources/classes/debug-log4j.properties -Dtangosol.coherence.cacheconfig=/home/ggt/client-extend-config.xml -Dlog4j.debug=true -Djava.class.path=/home/ggt/dirprm:/home/ggt/ojdbc6.jar:/home/ggt/ggjava/ggjava.jar:/home/coherence/Oracle/Middleware/Oracle_Home/coherence/lib/coherence.jar:/home/ggt/systemtestJPA.jar:/home/coherence/Oracle/Middleware/Oracle_Home/oracle_common/modules/javax.persistence_2.0.0.0_2-0.jar:/home/coherence/Oracle/Middleware/Oracle_Home/oracle_common/modules/oracle.toplink_12.1.3/eclipselink.jar:/home/coherence/Oracle/Middleware/Oracle_Home/oracle_common/modules/oracle.toplink_12.1.3/toplink-grid.jar

 

2.    DEVELOP JPA

 

JPA 프로젝트를 시작하고 다음을 생성한다.

(최종 버전은 jar 가 된다. GetSystemTest  test 용도의 main 함수를 포함한다.)

 

src > mypojos.GetSystemTest.java ( 테스트용도 )

 

package mypojos;

 

import javax.persistence.EntityManager;

import javax.persistence.EntityManagerFactory;

import javax.persistence.Persistence;

import javax.persistence.Query;

 

public class GetSystemTest {

 

        private static EntityManagerFactory emf;

        private static EntityManager em;

 

        public static void main(String[] args) throws IllegalArgumentException {

               try {

                       emf = Persistence.createEntityManagerFactory("CoherenceHotCache");

                       em = emf.createEntityManager();

 

                       Query q1 = em.createNamedQuery("cnt");

                       System.out

                                      .println("Number of system.test :" + q1.getSingleResult());

               } catch (IllegalArgumentException e) {

                       System.out.println(e.getMessage());

               }

        }

 

}

 

 

 

src > mypojos.SystemTest.java

 

package mypojos;

 

import java.io.Serializable;

import javax.persistence.*;

 

@Entity

@Table(name = "Test")

@NamedQuery(name="cnt", query="select count(c) from SystemTest c")

 

public class SystemTest implements Serializable {

 

        private static final long serialVersionUID = 1L;

 

        @Id

        private int Id;

 

        public SystemTest() {

        }

 

        public int getId() {

               return this.Id;

        }

 

        public void setId(int Id) {

               this.Id = Id;

        }

 

}

 

 

 

META-INF > orm.xml

 

<?xml version="1.0" encoding="UTF-8"?>

<entity-mappings version="2.0" xmlns="http://java.sun.com/xml/ns/persistence/orm"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd">

        <package>mypojos</package>

        <entity class = "SystemTest" name = "SystemTest">

               <table name="TEST"></table>

                       <attributes>

                              <id name = "Id"></id>

                       </attributes>

        </entity>

</entity-mappings>

 

 

 

META-INF > persistence.xml

 

<?xml version="1.0" encoding="UTF-8"?>

<persistence version="2.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_2_0.xsd">

               <persistence-unit name="CoherenceHotCache" transaction-type="RESOURCE_LOCAL">

               <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

               <class>mypojos.SystemTest</class>

               <properties>

                       <property name="javax.persistence.jdbc.driver"value="oracle.jdbc.OracleDriver"/>

                       <property name="javax.persistence.jdbc.url"value="jdbc:oracle:thin:@xxx.xx.xxx.xxx:1521:xxx2"/>

                       <property name="javax.persistence.jdbc.user"value="system"/>

                       <property name="javax.persistence.jdbc.password"value="xxx"/>

               </properties>

        </persistence-unit>

</persistence>