4. dataCompJ 기능#
이 장은 dataCompJ의 비교(DIFF) 기능과 일치(SYNC) 기능을 보다 자세히 예제와 함께 설명한다.
- 비교 (DIFF) 기능
- 일치 (SYNC) 기능
비교(DIFF) 기능#
비교(DIFF) 기능은 Master DB와 Slave DB 간의 이기종 복제 작업에서 발생할 수 있는 불일치 레코드들을 식별하고 이들을 파일에 기록하여, 두 데이터베이스 시스템간의 불일치 레코드들을 확인한다.
설정 파일#
dataCompJ 설정파일의 <Options> - <Operation> 값을 "DIFF"로 지정한다.
<Connections>와 <Options>의 항목들은 모두 필수로 기입해야 하며, 대상 테이블에 대해 <TablePairs>에 기술해야 한다.
dataCompJ.xml#
<?xml version="1.0" encoding="UTF-8" ?>
<dataCompJ>
<Connections>
<MasterDB>
<JdbcUrl>jdbc:Altibase://192.168.1.94:21135/mydb</JdbcUrl>
<JdbcFilePath>./jdbc/Altibase710.jar</JdbcFilePath>
<UserId>sys</UserId>
<Password>manager</Password>
</MasterDB>
<SlaveDB>
<JdbcUrl>jdbc:oracle:thin:@//192.168.3.18:1521/xe</JdbcUrl>
<JdbcFilePath>./jdbc/ojdbc5.jar</JdbcFilePath>
<UserId>altibase</UserId>
<Password>altibase</Password>
</SlaveDB>
</Connections>
<Options>
<Operation>DIFF</Operation>
<FileEncoding>UTF-8</FileEncoding>
<Diff>
<DirPath>./diff/</DirPath>
</Diff>
<Sync>
<MOSO UPDATE_TO_SLAVE="true"/>
<MOSX INSERT_TO_SLAVE="true"/>
<MXSO DELETE_FROM_SLAVE="true"/>
</Sync>
<Log>
<DirPath>./</DirPath>
<TraceInconsistentRecord>false</TraceInconsistentRecord>
</Log>
<MaxThread>0</MaxThread>
</Options>
<TablePairs>
<TablePair>
<MasterTable>EX1</MasterTable>
</TablePair>
</TablePairs>
</dataCompJ>
실행 방법#
비교(DIFF)는 다음과 같이 실행한다.
$ dataCompJCli.sh -f dataCompJ.xml
실행 결과#
실행 결과로 수행 결과가 요약된 리포트 파일( dataCompJ_report.txt)과 수행 중 이벤트가 기록되는 로그 파일들(dataCompJ.log, dataCompJ_data.log)이 생성된다. 보다 상세한 설명은 출력 파일을 참고한다.
예제에 사용되는 테이블의 구조는 아래와 같다.
CREATE TABLE ex1 (C1 int primary key, C2 varchar(20), C3 CLOB, C4 int);
DIFF 수행#
$ dataCompJCli.sh -f dataCompJ.xml
----------------------------------------------------------
Data Comparison Utility for Java (dataCompJ)
Copyright 2000, ALTIBASE Corporation or its subsidiaries.
All Rights Reserved.
----------------------------------------------------------
* Build started at 2016-12-14 16:30:03.673
* Build finished at 2016-12-14 16:30:04.357 (Elapsed: 0:00:00.691)
* Run started at 2016-12-14 16:30:04.374
* Run finished at 2016-12-14 16:30:04.905 (Elapsed: 0:00:00.531)
----------------------------------------------------------
Refer to the following output files for details.
----------------------------------------------------------
- dataCompJ_report.txt: Report file to provide summarized execution result.
- dataCompJ.log: Log file to keep track of detailed program events during execution.
- dataCompJ_data.log: Log file to keep track of data events during diff/sync operation as well as different record.
리포트 파일 내용 확인#
$ cat dataCompJ_report.txt
==========================================================
Build
- Started : 2016-12-14 16:30:03.673
- Finished : 2016-12-14 16:30:04.357
- Elapsed : 0:00:00.691
--------------------------------------------------------
[ User input information ]
...
[ Problematic table(s): 0 ]
[ Candidate table(s) for data comparison: 1 ]
1: SYS.EX1 -> ALTIBASE.EX1
* SELECT SQL : SELECT C1,C2,C4 FROM SYS.EX1 ORDER BY C1 ASC
* Excluded columns :
* Where condition :
* N/A data type columns: C3(CLOB)
==========================================================
Run
- Started : 2016-12-14 17:19:42.731
- Finished : 2016-12-14 17:19:42.822
- Elapsed : 0:00:00.091
----------------------------------------------------------
1: SYS.EX1 -> ALTIBASE.EX1
Fetched record count from MASTER: 10
Fetched record count from SLAVE : 10
------------------------------------------------------
Type Records
------------------------------------------------------
MOSO Matched 7
MOSO Diff 2
MOSX Master only 1
MXSO Slave only 1
------------------------------------------------------
실행 데이터 파일#
비교(DIFF) 기능 선택하였을 때 TablePair 단위로 다음 4개의 CSV 형식의 데이터 파일들이 생성된다.
-
SchemaName.TableName_MASTER_diff.csv:
MOSO 불일치 발생 시 Master 테이블의 해당 레코드 값을 CSV 형태로 저장하는 파일. -
SchemaName.TableName_SLAVE_diff.csv:
MOSO 불일치 발생 시 Slave 테이블의 해당 레코드 값을 CSV 형태로 저장하는 파일. -
SchemaName.TableName_MASTER_only.csv:
MOSX 불일치 발생 시 Master 테이블에만 존재하는 레코드 값을 CSV 형태로 저장하는 파일. -
SchemaName.TableName_SLAVE_only.csv:
MXSO 불일치 발생 시 Slave 테이블에만 존재하는 레코드 값을 CSV 형태로 저장하는 파일.
SchemaName.TableName_MASTER_diff.csv 파일과 SchemaName.TableName_SLAVE_diff.csv 파일에는 MOSO 불일치 데이터가 같은 순서로 기록되기 때문에, DIFF 프로그램으로 두 개의 파일을 비교하면 MOSO 불일치가 발생한 부분을 직관적으로 비교할 수 있다.
예제#
예제에 사용되는 테이블의 구조는 아래와 같다.
CREATE TABLE ex1 (C1 int primary key, C2 varchar(20), C3 CLOB, C4 int); /* C3 CLOB dataCompJ에서 지원하지 않는 데이터 타입 */
CREATE TABLE ex2 (C1 int primary key, C2 varchar(20), C3 int);
DIFF 예제 1#
두 개의 테이블을 대상으로 스키마 이름을 생략 또는 명시하는 예제이다.
아래의 예제에서 EX1 테이블의 경우 <MasterTable>항목은 스키마 이름 없이 테이블 이름만 기술하고, <SlaveTable> 항목은 생략했다. 스키마 이름 없이 테이블 이름만 기술한 <MasterTable>은 <MasterDB>-<UserId>에 입력된 값을 스키마 이름으로 사용한다. 생략된 <SlaveTable>은 <MasterTable>과 같은 값으로 가정하여 처리된다.
EX1 테이블의 C3 컬럼은 dataCompJ가 지원하지 않는 데이터 타입인 CLOB으로 비교 대상에서 자동으로 제외되며, 리포트의 Candidate tables 항목에 이 내용이 기록된다.
EX2 테이블은 스키마 이름과 테이블 이름을 사용자가 명시적으로 입력하였고, 입력받은 스키마 이름과 테이블 이름을 기반으로 처리된다.
dataCompJ.xml#
<?xml version="1.0" encoding="UTF-8" ?>
<dataCompJ>
<Connections>
<MasterDB>
<JdbcUrl>jdbc:Altibase://192.168.1.94:21135/mydb</JdbcUrl>
...
<UserId>sys</UserId>
...
</MasterDB>
<SlaveDB>
<JdbcUrl>jdbc:oracle:thin:@//192.168.3.18:1521/xe</JdbcUrl>
...
<UserId>altibase</UserId>
...
</SlaveDB>
</Connections>
<Options>
<Operation>DIFF</Operation>
...
</Options>
<TablePairs>
<TablePair>
<MasterTable>EX1</MasterTable>
</TablePair>
<TablePair>
<MasterTable>SYS.EX2</MasterTable>
<SlaveTable>ALTIBASE.EX2</SlaveTable>
</TablePair>
</TablePairs>
</dataCompJ>
dataCompJ_report.txt#
===========================================================================
Build
- Started : 2016-12-14 17:06:53.021
- Finished : 2016-12-14 17:06:53.679
- Elapsed : 0:00:00.669
---------------------------------------------------------------------------
[ User input information ]
...
[ Problematic table(s): 0 ]
[ Candidate table(s) for data comparison: 2 ]
1: SYS.EX1 -> ALTIBASE.EX1
* SELECT SQL : SELECT C1,C2,C4 FROM SYS.EX1 ORDER BY C1 ASC
* Excluded columns :
* Where condition :
* N/A data type columns: C3(CLOB)
2: SYS.EX2 -> ALTIBASE.EX2
* SELECT SQL : SELECT C1,C2,C3 FROM SYS.EX2 ORDER BY C1 ASC
* Excluded columns :
* Where condition :
* N/A data type columns:
===========================================================================
Run
- Started : 2016-12-14 17:56:04.516
- Finished : 2016-12-14 17:56:04.593
- Elapsed : 0:00:00.076
---------------------------------------------------------------------------
1: SYS.EX1 -> ALTIBASE.EX1
Fetched record count from MASTER: 10
Fetched record count from SLAVE : 10
------------------------------------------------------
Type Records
------------------------------------------------------
MOSO Matched 7
MOSO Diff 2
MOSX Master only 1
MXSO Slave only 1
------------------------------------------------------
2: SYS.EX2 -> ALTIBASE.EX2
Fetched record count from MASTER: 10
Fetched record count from SLAVE : 10
------------------------------------------------------
Type Records
------------------------------------------------------
MOSO Matched 10
MOSO Diff 0
MOSX Master only 0
MXSO Slave only 0
------------------------------------------------------
DIFF 예제 2#
대상 테이블의 특정 컬럼을 사용자가 명시적으로 제외하고(Exclude), 특정 조건을 만족하는 레코드(Where)만을 대상으로 비교(Diff) 수행하는 예제이다. dataCompJ.xml에 EX1 테이블에 대해 주요 키가 아닌 컬럼들 중 C4 컬럼을 비교 대상에서 제외하고 C1 컬럼값이 5보다 큰 레코드만 비교 작업을 수행하도록 사용자가 명시적으로 입력한다.
dataCompJ.xml#
<?xml version="1.0" encoding="UTF-8" ?>
<dataCompJ>
...
<Options>
<Operation>DIFF</Operation>
...
</Options>
<TablePairs>
<TablePair>
<MasterTable>EX1</MasterTable>
<Exclude>C4</Exclude>
<Where>C1 > 5</Where>
</TablePair>
<TablePair>
<MasterTable>SYS.EX2</MasterTable>
<SlaveTable>ALTIBASE.EX2</SlaveTable>
</TablePair>
</TablePairs>
</dataCompJ>
dataCompJ_report.txt#
===========================================================================
Build
- Started : 2016-12-14 17:06:53.021
- Finished : 2016-12-14 17:06:53.679
- Elapsed : 0:00:00.669
---------------------------------------------------------------------------
[ User input information ]
...
[ Problematic table(s): 0 ]
[ Candidate table(s) for data comparison: 2 ]
1: SYS.EX1 -> ALTIBASE.EX1
* SELECT SQL : SELECT C1,C2 FROM SYS.EX1 WHERE C1 > 5 ORDER BY C1 ASC
* Excluded columns : C4
* Where condition : C1 > 5
* N/A data type columns: C3(CLOB)
2: SYS.EX2 -> ALTIBASE.EX2
* SELECT SQL : SELECT C1,C2,C3 FROM SYS.EX2 ORDER BY C1 ASC
* Excluded columns :
* Where condition :
* N/A data type columns:
===========================================================================
Run
- Started : 2016-12-14 17:57:09.895
- Finished : 2016-12-14 17:57:09.974
- Elapsed : 0:00:00.080
---------------------------------------------------------------------------
1: SYS.EX1 -> ALTIBASE.EX1
Fetched record count from MASTER: 5
Fetched record count from SLAVE : 5
------------------------------------------------------
Type Records
------------------------------------------------------
MOSO Matched 5
MOSO Diff 0
MOSX Master only 0
MXSO Slave only 0
------------------------------------------------------
2: SYS.EX2 -> ALTIBASE.EX2
Fetched record count from MASTER: 10
Fetched record count from SLAVE : 10
------------------------------------------------------
Type Records
------------------------------------------------------
MOSO Matched 10
MOSO Diff 0
MOSX Master only 0
MXSO Slave only 0
------------------------------------------------------
일치(SYNC) 기능#
일치(SYNC)기능은 Master DB와 Slave DB 간의 이기종 복제 작업에서 발생할 수 있는 불일치 레코드들을 식별하여 이를 Slave DB에 적용한다. 두 데이터베이스 시스템의 데이터 동기화(Synchronization)를 손쉽게 할 수 있다.
설정 파일#
dataCompJ 설정 파일의 <Options> - <Operation> 값을 "SYNC"로 지정한다.
<Connections>와 <Options> 항목들은 모두 필수로 기입해야 하며, 대상 테이블에 대해 <TablePairs>에 기술해야 한다.
dataCompJ.xml#
<?xml version="1.0" encoding="UTF-8" ?>
<dataCompJ>
<Connections>
<MasterDB>
<JdbcUrl>jdbc:Altibase://192.168.1.94:21135/mydb</JdbcUrl>
...
<UserId>sys</UserId>
...
</MasterDB>
<SlaveDB>
<JdbcUrl>jdbc:oracle:thin:@//192.168.3.18:1521/xe</JdbcUrl>
...
<UserId>altibase</UserId>
...
</SlaveDB>
</Connections>
<Options>
<Operation>SYNC</Operation>
...
</Options>
<TablePairs>
<TablePair>
<MasterTable>EX1</MasterTable>
</TablePair>
</TablePairs>
</dataCompJ>
실행 방법#
일치(SYNC) 기능은 다음과 같이 실행한다.
$ dataCompJCli.sh -f dataCompJ.xml
$ dataCompJCli.sh -f ./dataCompJ.xml
Data Comparison Utility for Java (dataCompJ)
Copyright 2000, ALTIBASE Corporation or its subsidiaries.
All Rights Reserved.
-----------------------------------------------------------------
* Build started at 2016-12-14 18:08:40.407
* Build finished at 2016-12-14 18:08:41.076 (Elapsed: 0:00:00.676)
* Run started at 2016-12-14 18:08:41.090
* Run finished at 2016-12-14 18:08:41.654 (Elapsed: 0:00:00.564)
---------------------------------------------------------------------------
Refer to the following output files for details.
---------------------------------------------------------------------------
- dataCompJ_report.txt: Report file to provide summarized execution result.
- dataCompJ.log: Log file to keep track of detailed program events during execution.
- dataCompJ_data.log: Log file to keep track of data events during diff/sync operation as well as different record
실행 결과#
실행 결과로 수행 결과가 요약된 리포트 파일(dataCompJ_report.txt)과 수행 중 이벤트가 기록되는 로그 파일들(dataCompJ.log, dataCompJ_data.log)이 생성된다. 보다 상세한 설명은 출력 파일을 참고한다.
dataCompJ_report.txt#
$ cat dataCompJ_report.txt
===========================================================================
Build
- Started : 2016-12-14 18:08:40.407
- Finished : 2016-12-14 18:08:41.076
- Elapsed : 0:00:00.676
---------------------------------------------------------------------------
[ User input information ]
...
[ Problematic table(s): 0 ]
[ Candidate table(s) for data comparison: 1 ]
1: SYS.EX1 -> ALTIBASE.EX1
* SELECT SQL : SELECT C1,C2,C4 FROM SYS.EX1 ORDER BY C1 ASC
* Excluded columns :
* Where condition :
* N/A data type columns: C3(CLOB)
===========================================================================
Run
- Started : 2016-12-14 18:08:41.090
- Finished : 2016-12-14 18:08:41.654
- Elapsed : 0:00:00.564
---------------------------------------------------------------------------
1: SYS.EX1 -> ALTIBASE.EX1
Fetched record count from MASTER: 10
Fetched record count from SLAVE : 10
------------------------------------------------------
Type Resolution Try Fail
------------------------------------------------------
MOSO UPDATE TO SLAVE 2 0
MOSX INSERT TO SLAVE 1 0
MXSO DELETE FROM SLAVE 1 0
------------------------------------------------------
모든 대상 테이블과 레코드들에 대해 SYNC가 정확히 수행된 경우, 동일한 대상 테이블에 대해 DIFF 기능을 재수행하면 모든 레코드가 동일하다는 비교 결과를 얻게 된다.
$ dataCompJCli.sh -f ./dataCompJ.xml
-----------------------------------------------------------------
Data Comparison Utility for Java (dataCompJ)
Copyright 2000, ALTIBASE Corporation or its subsidiaries.
All Rights Reserved.
-----------------------------------------------------------------
* Build started at 2016-12-14 18:11:54.924
* Build finished at 2016-12-14 18:11:55.561 (Elapsed: 0:00:00.645)
* Run started at 2016-12-14 18:11:55.580
* Run finished at 2016-12-14 18:11:56.190 (Elapsed: 0:00:00.610)
----------------------------------------------------------
Refer to the following output files for details.
----------------------------------------------------------
- dataCompJ_report.txt: Report file to provide summarized execution result.
- dataCompJ.log: Log file to keep track of detailed program events during execution.
- dataCompJ_data.log: Log file to keep track of data events during diff/sync operation as well as different record.
$ cat dataCompJ_report.txt
==========================================================
Build
- Started : 2016-12-14 18:11:54.924
- Finished : 2016-12-14 18:11:55.561
- Elapsed : 0:00:00.645
---------------------------------------------------------
[ User input information ]
...
[ Problematic table(s): 0 ]
[ Candidate table(s) for data comparison: 1 ]
1: SYS.EX1 -> ALTIBASE.EX1
* SELECT SQL : SELECT C1,C2,C4 FROM SYS.EX1 ORDER BY C1 ASC
* Excluded columns :
* Where condition :
* N/A data type columns: C3(CLOB)
==========================================================
Run
- Started : 2016-12-14 18:11:55.580
- Finished : 2016-12-14 18:11:56.190
- Elapsed : 0:00:00.610
---------------------------------------------------------------------------
1: SYS.EX1 -> ALTIBASE.EX1
Fetched record count from MASTER: 10
Fetched record count from SLAVE : 10
------------------------------------------------------
Type Records
------------------------------------------------------
MOSO Matched 10
MOSO Diff 0
MOSX Master only 0
MXSO Slave only 0
------------------------------------------------------