TCache 동기화

본 장에서는 TCache 동기화하는 Multi Domain Invalidation 및 Multi Node Invalidation에 대해서 설명한다.

1. 개요

TCache가 적용되어 있는 데이터베이스의 데이터를 변경하는 경우 TCache의 데이터와 데이터베이스 Table 간의 동기화가 필요하다. TCache를 사용하는 데이터에 대한 update, delete를 수행할 때 프로그램에서 INVALIDATE를 수행해야만 한다.

데이터베이스에 직접 접근하여 수행하는 경우는 다음 명령을 이용하여 강제로 INVALIDATE를 수행하여야 한다. 이 경우 Cache Object가 모두 삭제되므로 주의한다.

pfmtcacheadmin –i [CacheName]

아래 그림은 TCache의 동기화 과정을 보여준다.

figure 5 1
동기화

여러 개의 Node에서 TCache 동기화 방법도 각각의 Node에대해 Invalidate를 수행한다. TPFMAGENT라는 Tmax 서버를 이용하며 자세한 설정 부분은 Multi Domain InvalidationMulti Node Invalidation(COUSIN)을 참조한다.

2. Multi Domain Invalidation

Multi Domain Invalidation는 각 Node 간 tpacall이 가능하도록 Domain Gateway 설정이 가능한 환경에서 설정한다. Invalidate Flow적인 측면은 동기화와 동일하다. 기술적인 상세한 내용은 Tmax 안내서를 참고한다.

Tmax 서버 설정(Node1)
###############################################################
#                                                             #
#         Sample Configuration File for Tmax System           #
#         =========================================           #
#                                                             #
#     Copyright(c) 2015 TmaxSoft Inc. All rights reserved     #
#                                                             #
###############################################################


*DOMAIN
tmax1           SHMKEY =79000, MINCLH=1, MAXCLH=3,
                TPORTNO=9999, BLOCKTIME=30

*NODE
fw2test         TMAXDIR = "/home/tmax/tmax",
                APPDIR  = "/home/tmax/tmax/appbin",
                PATHDIR = "/home/tmax/tmax/path",
                TLOGDIR = "/home/tmax/tmax/log/tlog",
                ULOGDIR = "/home/tmax/tmax/log/ulog",
                SLOGDIR = "/home/tmax/tmax/log/slog"

*SVRGROUP
NFRGRP01        NODENAME = "fw2test"

*SERVER
#######  TCache Domain SERVER######
TPFMAGENT       SVGNAME = NFRGRP01

#### TCache alias name ####
TCACHEFR02      SVGNAME = NFRGRP01, MIN=1, MAX=5, TARGET = TPFMAGENT,
                CLOPT = "-r -l -x SPFMAGENT:SPFMAGENT02 -o $(SVR)_$(CYEAR)$(CMONTH)$(CDAY).log -e $(SVR)_$(CYEAR)$(CMONTH)$(CDAY).log"

*SERVICE
##### TCache Service ####
SPFMAGENT       SVRNAME = TPFMAGENT,   SVCTIME=30
SPFMAGENT02     SVRNAME = TCACHEFR02
SPFMAGENT01     SVRNAME = TGW02
# TCache Config의 SPFMAGENT|2(SPFMAGENT01, SPFMAGENT02)와 Match됨.
# 내부적으로 Local은 SPFMAGENT02가 Call되며, Remote는 SPFMAGENT01가 Call되어 Invalidate를 하게 됨.
# 자세한 설명은 기술적인 설명은 Tmax 안내서를 참조바람.

##### TCache Gateway ####
*GATEWAY
TGW02           NODENAME = fw2test, GWTYPE=TMAXNONTX, PORTNO=9302,
                RGWADDR = "192.168.1.51", RGWPORTNO=9301, RESTART=Y,
                MAXRSTART=128, CLOPT="-i", CPC=8
TCache 환경설정(Node1)
# the configuration file of TCACHE

SHMKEY=0x70005        # the key of shared memory
IPCPERM=0777          # permission of the shared memory
SIZE_LOCAL=1024       # L1 cache size in kilo-bytes
LIB_PTHREAD=libpthread.so   # the pthread library file name

INVALIDATE_TYPE=1     # Invalidate type 0:multi-node 1:multi-domain
# INVALIDATE_TYPE : INVALIDATE_TYPE이 1일때 Domain Gateway방식을 사용한다는 의미

AGENT_SVC=SPFMAGENT|2 # multi-node sync. svc SPFMAGENT|2 = SPFMAGENT01, SPFMAGENT02
# AGENT_SVC : 2개의 Node가 있을때 SPFMAGENT|2와 같이 설정하며 SPFMAGENT01, SPFMAGENT02를 tpacall하게 된다.

# cache for PFM_SVC
CACHE_NAME=PFM_SVC
SIZE_MEM=65536      # the total cache memory size in kilo-bytes
SIZE_HASH=1024      # the number of hash key (MAX=65536)
SIZE_KEY=30         # the number of digits of the index column
SIZE_REC=2048       # the size of a single record in bytes
INV_TIMEOUT=10      # invalidation timeout in sec
.
.
.
Tmax 서버 설정(Node2)
###############################################################
#                                                             #
#         Sample Configuration File for Tmax System           #
#         =========================================           #
#                                                             #
#     Copyright(c) 2015 TmaxSoft Inc. All rights reserved     #
#                                                             #
###############################################################


*DOMAIN
tmax1           SHMKEY =78898, MINCLH=1, MAXCLH=3,
                TPORTNO=9030, BLOCKTIME=30

*NODE
tmaxh6          TMAXDIR = "/data5/tmax/tmax",
                APPDIR  = "/data5/tmax/tmax/appbin",
                PATHDIR = "/data5/tmax/tmax/path",
                TLOGDIR = "/data5/tmax/tmax/log/tlog",
                ULOGDIR = "/data5/tmax/tmax/log/ulog",
                SLOGDIR = "/data5/tmax/tmax/log/slog"

*SVRGROUP
NFRGRP02        NODENAME = "tmaxh6"

*SERVER
#######  TCache Domain SERVER######
TPFMAGENT       SVGNAME = NFRGRP02

#### TCache alias name ####
TCACHEFR01      SVGNAME = NFRGRP02, MIN=1, MAX=5, TARGET = TPFMAGENT,
                CLOPT = "-r -l -x SPFMAGENT:SPFMAGENT01 -o
                $(SVR)_$(CYEAR)$(CMONTH)$(CDAY).log -e $(SVR)_$(CYEAR)$(CMONTH)$(CDAY).log"

*SERVICE
##### TCache Service ####
SPFMAGENT       SVRNAME = TPFMAGENT,   SVCTIME=30
SPFMAGENT01     SVRNAME = TCACHEFR01
SPFMAGENT02     SVRNAME = TGW01
# TCache Config의 SPFMAGENT|2(SPFMAGENT01, SPFMAGENT02)와 Match됨.
# 내부적으로 Local은 SPFMAGENT01가 Call되며, Remote는 SPFMAGENT02가 Call되어 Invalidate를 하게 됨.
# 자세한 설명은 기술적인 설명은 Tmax 안내서를 참조바람.

##### TCache Gateway ####
*GATEWAY
TGW01           NODENAME = tmaxh6, GWTYPE=TMAXNONTX, PORTNO=9301,
                RGWADDR = "192.168.32.86", RGWPORTNO=9302, RESTART=Y,
                MAXRSTART=128, CLOPT="-i", CPC=8
TCache 환경설정(Node2)
# the configuration file of TCACHE

SHMKEY=0x78016      # the key of shared memory
IPCPERM=0777        # permission of the shared memory
SIZE_LOCAL=1024     # L1 cache size in kilo-bytes
LIB_PTHREAD=libpthread.so   # the pthread library file name
INVALIDATE_TYPE=1     # Invalidate type 0:multi-node 1:multi-domain
# INVALIDATE_TYPE : INVALIDATE_TYPE이 1일때 Domain Gateway방식을 사용한다는 의미
AGENT_SVC=SPFMAGENT|2 # multi-node sync. svc SPFMAGENT|2 = SPFMAGENT01, SPFMAGENT02)
# AGENT_SVC : 2개의 Node가 있을때 SPFMAGENT|2와 같이 설정하며 SPFMAGENT01, SPFMAGENT02를 tpacall하게 된다.

# cache for PFM_SVC
CACHE_NAME=PFM_SVC
SIZE_MEM=1024       # the total cache memory size in kilo-bytes
SIZE_HASH=1024      # the number of hash key (MAX=65536)
SIZE_KEY=30         # the number of digits of the index column
SIZE_REC=1024       # the size of a single record in bytes
INV_TIMEOUT=10      # invalidation timeout in sec
.
.
.

3. Multi Node Invalidation(COUSIN)

Multi Domain Invalidation은 DomainGateway 설정이 불가능한 환경에서 설정한다. 해당 Node에서 call할 대상을 Tmax 환경설정 파일에 설정하여 tpgetsvglist을 가져와 각각의 Node에 tpacallsvg로 Invalidate할 서버를 tpacall하게 된다. Invalidate Flow적인 측면은 동기화와 동일하다. 기술적인 상세한 내용은 Tmax 안내서를 참고한다.

Tmax 서버 설정(Node1, Node2 동일)
################################################################################
# DOMAIN SECTION                                                               #
################################################################################
*DOMAIN

SHPDOM05        SHMKEY             = 97990,
                TPORTNO            = 8890,
                MAXUSER            = 3000,
                MINCLH             = 1,
                MAXCLH             = 2,
                RACPORT            = 9493,
                BLOCKTIME          = 1800,
                MAXSVR             = 2500,
                MAXSPR             = 6500,
                MAXSVC             = 20000,
                MAXSACALL          = 1024,
                MAXCACALL          = 1024,
                MAXSVG             = 100,
                MAXTOTALSVG        = 600,
                MAXGW              = 1024,
                MAXCPC             = 400,
                MAXCOUSIN          = 60,
                MAXCOUSINSVG       = 120,
                GWCHKINT           = 30,
                GWCONNECT_TIMEOUT  = 30,
                NCLHCHKTIME        = 180,
                NLIVEINQ           = 30,
                IPCPERM            = 0664,
                MAXNODE            = 4

################################################################################
# NODE SECTION                                                                 #
################################################################################
*NODE
BCS01           HOSTNAME = "tmaxi4",
                TMAXDIR  = "/data2/tmax/tmax",
                APPDIR   = "/data2/tmax/tmax/appbin"

BCS02           HOSTNAME = "tmaxi7",
                TMAXDIR  = "/data2/tmax/package/tmax",
                APPDIR   = "/data2/tmax/tmax/appbin"

################################################################################
# Server Group SECTION                                                         #
################################################################################
*SVRGROUP

OPFMGRP11       NODENAME = "BCS01"
OPFMGRP21       NODENAME = "BCS02"

OPFMGRP31       NODENAME = "BCS01", COUSIN = "OPFMGRP32", LOAD = 0
OPFMGRP32       NODENAME = "BCS02", LOAD = 0

################################################################################
# SERVER SECTION                                                               #
################################################################################
*SERVER
# TCache Multi Node ..
TPFMAGENT       SVGNAME = OPFMGRP31, MIN = 1, MAX = 1,
                CLOPT="-o $(SVR)_$(CYEAR)$(CMONTH)$(CDAY).log -e $(SVR)_$(CYEAR)$(CMONTH)$(CDAY).log"

*SERVICE

SPFMAGENT       SVRNAME=TPFMAGENT

# -------------------------------------------------------- #
# Non Framework ...
# -------------------------------------------------------- #
TCache 환경설정(Node1)
# the configuration file of TCACHE

SHMKEY=0x70099      # the key of shared memory
IPCPERM=0777        # permission of the shared memory
SIZE_LOCAL=1024     # L1 cache size in kilo-bytes
LIB_PTHREAD=libpthread.so   # the pthread library file name
INVALIDATE_TYPE=0           # multi-node invalidate type.
# INVALIDATE_TYPE : INVALIDATE_TYPE이 0일때 Cousin방식을 사용한다는 의미.
AGENT_SVC = SPFMAGENT # multi-node sync. svc
# AGENT_SVC : SPFMAGENT 서버를 tpacall함.

# cache for PFM_SVC
CACHE_NAME=PFM_SVC
SIZE_MEM=65536      # the total cache memory size in kilo-bytes
SIZE_HASH=1024      # the number of hash key (MAX=65536)
SIZE_KEY=30         # the number of digits of the index column
SIZE_REC=2048       # the size of a single record in bytes
INV_TIMEOUT=10      # invalidation timeout in sec
.
.
.
TCache 환경설정(Node2)
# the configuration file of TCACHE

SHMKEY=0x70999      # the key of shared memory
IPCPERM=0777        # permission of the shared memory
SIZE_LOCAL=1024     # L1 cache size in kilo-bytes
LIB_PTHREAD=libpthread.so   # the pthread library file name
INVALIDATE_TYPE=0           # multi-node invalidate type.
# INVALIDATE_TYPE : INVALIDATE_TYPE이 0일때 Cousin방식을 사용한다는 의미.
AGENT_SVC = SPFMAGENT # multi-node sync. svc
# AGENT_SVC : SPFMAGENT 서버를 tpacall함.

# cache for PFM_SVC
CACHE_NAME=PFM_SVC
SIZE_MEM=65536      # the total cache memory size in kilo-bytes
SIZE_HASH=1024      # the number of hash key (MAX=65536)
SIZE_KEY=30         # the number of digits of the index column
SIZE_REC=2048       # the size of a single record in bytes
INV_TIMEOUT=10      # invalidation timeout in sec
.
.
.