본문 바로가기
Open Sources/ETC

Datagenerator - dbMonster Installation Guide

by 화뉘 2013. 3. 5.

Installation
PreInstall
JRE or J2SDK, version 1.4.0 or higher,
JDBC driver for your database.
MySQL
dbMonster Download
DBMonster 최신 버전을 Download 한다.
http://sourceforge.net/projects/dbmonster/files/dbmonster-core/
압축을 푼다.

[root@i-10-24-5-10 ~]# tar zxf dbmonster-core-1.0.3.tar.gz

/bin/dbmonster 파일에 실행 권한을 부여한다.

[root@i-10-24-5-10 ~]# cd dbmonster-core-1.0.3/bin
[root@i-10-24-5-10 ~]# chmod 777 dbmonster

DBMonster_HOME 설정
.bash_profile에서 DBMONSTER_HOME을 설정한다.

[root@i-10-24-5-10 ~]# vi ~/.bash_profile
------------------------------------------------------------------
DBMonster_HOME=/root/dbmonster-core-1.0.3
export DBMoster_HOME
-----------------------------------------------------------------

CLASSPATH에 MySQL Connector와 dbMonster Core PATH를 설정한다.

[root@i-10-24-5-10 ~]# vi ~/.bash_profile
------------------------------------------------------------------
CLASSPATH=.:/root/dbmonster-core-1.0.3/mysql-connector-java-5.1.17-bin.jar:/root/dbmonster-core-1.0.3/dbmonster-core-1.0.3.jar
export CLASSPATH
-----------------------------------------------------------------
[root@i-10-24-5-10 ~]# source ~/.bash_profile

 

User Guide
 해당 Tool은 DB에 Data를 Insert 하기 위해 사용한다. 그러므로 DB에 Data를 Insert 하는 방법 위주로 Guide 한다.

Table 생성
설치된 MySQL에 DB와 Table을 생성한다.

mysql> create database TestDB;
mysql> use TestDB;
Database changed
mysql >
CREATE TABLE `TestTable` (
`id` mediumint(8) unsigned NOT NULL auto_increment,
`IN_CTN` varchar(100) default NULL,
`OUT_CTN` varchar(100) default NULL,
`IN_CELL` mediumint default NULL,
`OUT_CELL` mediumint default NULL,
`START_TIME` varchar(100) default NULL,
`CALL_TIME` mediumint default NULL,
`END_TIME` varchar(100) default NULL,
`CLOSE_TYPE` varchar(255) default NULL,
PRIMARY KEY (`id`)
) AUTO_INCREMENT=1;mysql> show tables;
+------------------+
| Tables_in_TestDB |
+------------------+
| TestTable |
+------------------+
1 row in set (0.00 sec)

dbmonster.properties 생성
dbmonster.properties 파일을 생성한 뒤 아래와 같이 DB 정보를 입력한다.

dbmonster.jdbc.driver=com.mysql.jdbc.Driver
dbmonster.jdbc.url=jdbc:mysql://localhost:3306/TestDB
dbmonster.jdbc.username=root
dbmonster.jdbc.password=

Schema 생성
기본 Schema.xml 파일를 생성한다.

[root@i-10-24-5-10 dbmonster-core-1.0.3]# ./bin/dbmonster -c dbmonster.properties --grab -o testTable-schema.xml
Setting DBMONSTER_HOME to: ./bin/..
Setting JAVA_HOME to: /usr/bin/
2012-10-23 21:53:06,093 INFO SchemaGrabber - Grabbing schema from database. 1 tables to grab.
2012-10-23 21:53:06,188 INFO SchemaGrabber - Grabbing table TestTable. 100% done.
2012-10-23 21:53:06,188 INFO SchemaGrabber - Grabbing schema from database complete.

위의 명령어 수행 시에 Schema.xml 파일이 생성되었는지 확인한다.

[root@i-10-24-5-10 dbmonster-core-1.0.3]# ls

 

Schema를 열어서 내용을 확인한다.

<?xml version="1.0"?>
<!DOCTYPE dbmonster-schema PUBLIC "-//kernelpanic.pl//DBMonster Database Schema DTD 1.1//EN" "http://dbmonster.kernelpanic.pl/dtd/dbmonster-schema-1.1.dtd">
<dbmonster-schema>
<name>Change me!</name>
<table name="TestTable" rows="1000">
<key databaseDefault="false">
<generator type="pl.kernelpanic.dbmonster.generator.MaxKeyGenerator">
<property name="columnName" value="id"/>
</generator>
</key>
<column name="IN_CTN" databaseDefault="false">
<generator type="pl.kernelpanic.dbmonster.generator.StringGenerator">
<property name="allowSpaces" value="true"/>
<property name="excludeChars" value=""/>
<property name="maxLength" value="100"/>
<property name="minLength" value="0"/>
<property name="nulls" value="10"/>
</generator>
</column>
<column name="OUT_CTN" databaseDefault="false">
<generator type="pl.kernelpanic.dbmonster.generator.StringGenerator">
<property name="allowSpaces" value="true"/>
<property name="excludeChars" value=""/>
<property name="maxLength" value="100"/>
<property name="minLength" value="0"/>
<property name="nulls" value="10"/>
</generator>
</column>
<column name="IN_CELL" databaseDefault="false">
<generator type="pl.kernelpanic.dbmonster.generator.NumberGenerator">
<property name="maxValue" value="127"/>
<property name="minValue" value="0"/>
<property name="nulls" value="10"/>
<property name="returnedType" value="integer"/>
<property name="scale" value="0"/>
</generator>
</column>
<column name="OUT_CELL" databaseDefault="false">
<generator type="pl.kernelpanic.dbmonster.generator.NumberGenerator">
<property name="maxValue" value="127"/>
<property name="minValue" value="0"/>
<property name="nulls" value="10"/>
<property name="returnedType" value="integer"/>
<property name="scale" value="0"/>
</generator>
</column>
<column name="START_TIME" databaseDefault="false">
<generator type="pl.kernelpanic.dbmonster.generator.StringGenerator">
<property name="allowSpaces" value="true"/>
<property name="excludeChars" value=""/>
<property name="maxLength" value="100"/>
<property name="minLength" value="0"/>
<property name="nulls" value="10"/>
</generator>
</column>
<column name="CALL_TIME" databaseDefault="false">
<generator type="pl.kernelpanic.dbmonster.generator.NumberGenerator">
<property name="maxValue" value="127"/>
<property name="minValue" value="0"/>
<property name="nulls" value="10"/>
<property name="returnedType" value="integer"/>
<property name="scale" value="0"/>
</generator>
</column>
<column name="END_TIME" databaseDefault="false">
<generator type="pl.kernelpanic.dbmonster.generator.StringGenerator">
<property name="allowSpaces" value="true"/>
<property name="excludeChars" value=""/>
<property name="maxLength" value="100"/>
<property name="minLength" value="0"/>
<property name="nulls" value="10"/>
</generator>
</column>
<column name="CLOSE_TYPE" databaseDefault="false">
<generator type="pl.kernelpanic.dbmonster.generator.StringGenerator">
<property name="allowSpaces" value="true"/>
<property name="excludeChars" value=""/>
<property name="maxLength" value="255"/>
<property name="minLength" value="0"/>
<property name="nulls" value="10"/>
</generator>
</column>
</table>

Schema.xml 파일을 원하는 형식에 맞게 수정한다.

<?xml version="1.0"?>
<!DOCTYPE dbmonster-schema PUBLIC "-//kernelpanic.pl//DBMonster Database Schema DTD 1.1//EN" "http://dbmonster.kernelpanic.pl/dtd/dbmonster-schema-1.1.dtd">
<dbmonster-schema>
<name>Change me!</name>
<table name="TestTable" rows="1000">
<key databaseDefault="false">
<generator type="pl.kernelpanic.dbmonster.generator.MaxKeyGenerator">
<property name="columnName" value="id"/>
</generator>
</key>
<column name="IN_CTN" databaseDefault="false">
<generator type="pl.kernelpanic.dbmonster.generator.NumberGenerator">
<property name="maxValue" value="01099999999"/>
<property name="minValue" value="01012340000"/>
<property name="nulls" value="0"/>
<property name="returnedType" value="long"/>
<property name="scale" value="0"/>
</generator>
</column>
<column name="OUT_CTN" databaseDefault="false">
<generator type="pl.kernelpanic.dbmonster.generator.NumberGenerator">
<property name="maxValue" value="01099999999"/>
<property name="minValue" value="01012340000"/>
<property name="nulls" value="0"/>
<property name="returnedType" value="long"/>
<property name="scale" value="0"/>
</generator>
</column>
<column name="IN_CELL" databaseDefault="false">
<generator type="pl.kernelpanic.dbmonster.generator.NumberGenerator">
<property name="maxValue" value="999"/>
<property name="minValue" value="0"/>
<property name="nulls" value="0"/>
<property name="returnedType" value="integer"/>
<property name="scale" value="0"/>
</generator>
</column>
<column name="OUT_CELL" databaseDefault="false">
<generator type="pl.kernelpanic.dbmonster.generator.NumberGenerator">
<property name="maxValue" value="999"/>
<property name="minValue" value="0"/>
<property name="nulls" value="0"/>
<property name="returnedType" value="integer"/>
<property name="scale" value="0"/>
</generator>
</column>
<column name="START_TIME" databaseDefault="false">
<generator type="pl.kernelpanic.dbmonster.generator.DateTimeGenerator">
<property name="startDate" value="2012-01-01 00:00:00"/>
<property name="endDate" value="2012-12-31 23:59:59"/>
<property name="returnedType" value="timestamp"/>
<property name="nulls" value="0"/>
</generator>
</column>
<column name="CALL_TIME" databaseDefault="false">
<generator type="pl.kernelpanic.dbmonster.generator.NumberGenerator">
<property name="maxValue" value="9999"/>
<property name="minValue" value="0"/>
<property name="nulls" value="10"/>
<property name="returnedType" value="long"/>
<property name="scale" value="0"/>
</generator>
</column>
<column name="END_TIME" databaseDefault="false">
<generator type="pl.kernelpanic.dbmonster.generator.DateTimeGenerator">
<property name="startDate" value="2012-01-01 00:00:00"/>
<property name="endDate" value="2012-12-31 23:59:59"/>
<property name="returnedType" value="timestamp"/>
</generator>
</column>
<column name="CLOSE_TYPE" databaseDefault="false">
<generator type="pl.kernelpanic.dbmonster.generator.NumberGenerator">
<property name="maxValue" value="5"/>
<property name="minValue" value="0"/>
<property name="nulls" value="0"/>
<property name="returnedType" value="short"/>
<property name="scale" value="0"/>
</generator>
</column>
</table>
</dbmonster-schema>

Data 생성
Schema.xml 파일을 생성했으면, DB에 Insert할 Data를 생성한다.

[root@i-10-24-5-10 dbmonster-core-1.0.3]# ./bin/dbmonster -s testTable-schema.xml -c dbmonster.properties
Setting DBMONSTER_HOME to: ./bin/..
Setting JAVA_HOME to: /usr/bin/
2012-10-23 22:23:28,343 INFO DBMonster - Let's feed this hungry database.
2012-10-23 22:23:28,606 INFO DBCPConnectionProvider - Today we are feeding: MySQL 5.0.95
2012-10-23 22:23:28,634 INFO Schema - Generating schema <Change me!>.
2012-10-23 22:23:28,635 INFO Table - Generating table <TestTable>.
2012-10-23 22:23:29,271 INFO Table - Generation of table <TestTable> finished.
2012-10-23 22:23:29,272 INFO Schema - Generation of schema <Change me!> finished.
2012-10-23 22:23:29,272 INFO DBMonster - Finished in 930 ms.

Data가 생성되었는지 확인한다.

 

mysql> use TestDB;
Database changed
mysql> select count(*) from TestTable;
+----------+
| count(*) |
+----------+
| 1000 |
+----------+
1 row in set (0.00 sec)
mysql> select * from TestTable limit 20;;
+----+------------+------------+---------+----------+-------------------------+-----------+-------------------------+------------+
| id | IN_CTN | OUT_CTN | IN_CELL | OUT_CELL | START_TIME | CALL_TIME | END_TIME | CLOSE_TYPE |
+----+------------+------------+---------+----------+-------------------------+-----------+-------------------------+------------+
| 1 | 1032489120 | 1034046740 | 430 | 216 | 2012-03-19 03:57:30.393 | 9627 | 2012-02-02 03:28:36.644 | 0 |
| 2 | 1037516179 | 1078507465 | 578 | 668 | 2012-06-02 22:45:50.174 | 9669 | 2012-08-30 07:20:05.945 | 2 |
| 3 | 1012356038 | 1062823205 | 458 | 23 | 2012-10-16 12:24:04.479 | 8628 | 2012-11-01 02:07:25.855 | 0 |
| 4 | 1030324472 | 1052732655 | 921 | 325 | 2012-05-31 00:40:01.723 | 5880 | 2012-11-20 00:46:27.297 | 3 |
| 5 | 1068699296 | 1099770375 | 201 | 622 | 2012-04-17 02:40:08.407 | 1457 | 2012-01-07 11:46:19.375 | 4 |
| 6 | 1018749880 | 1076889042 | 244 | 710 | 2012-07-18 01:50:30.371 | 7259 | 2012-02-23 11:17:29.787 | 3 |
| 7 | 1059011957 | 1055075881 | 152 | 495 | 2012-12-28 02:47:39.837 | 3624 | 2012-11-27 21:27:31.698 | 4 |
| 8 | 1077794156 | 1091257313 | 349 | 991 | 2012-11-09 23:24:31.201 | 1599 | 2012-04-24 14:15:10.451 | 0 |
| 9 | 1079262948 | 1081390626 | 381 | 61 | 2012-04-04 12:28:05.853 | 5535 | 2012-07-01 10:10:36.834 | 3 |
| 10 | 1048357662 | 1025266286 | 576 | 664 | 2012-01-27 19:24:35.718 | 1677 | 2012-05-27 08:17:17.236 | 0 |
| 11 | 1071593659 | 1098599432 | 817 | 718 | 2012-02-22 17:45:28.142 | NULL | 2012-03-16 18:16:02.364 | 1 |
| 12 | 1022310488 | 1041964996 | 50 | 764 | 2012-01-14 13:17:55.509 | 1907 | 2012-10-01 18:42:09.092 | 4 |
| 13 | 1098454407 | 1061970929 | 878 | 814 | 2012-12-28 16:38:22.205 | 2684 | 2012-11-20 11:24:21.24 | 3 |
| 14 | 1045018304 | 1098384794 | 439 | 361 | 2012-05-27 16:56:54.535 | 8469 | 2012-03-24 13:43:12.569 | 3 |
| 15 | 1048270201 | 1036236054 | 900 | 420 | 2012-11-11 18:48:44.671 | 1666 | 2012-11-20 05:43:02.53 | 2 |
| 16 | 1076683160 | 1071154066 | 299 | 936 | 2012-09-02 04:02:11.865 | 4151 | 2012-03-06 15:57:29.15 | 0 |
| 17 | 1044288754 | 1097387981 | 381 | 812 | 2012-03-03 10:55:24.94 | 9352 | 2012-10-23 06:23:03.044 | 0 |
| 18 | 1035749667 | 1026648098 | 271 | 597 | 2012-05-30 11:36:38.843 | 8085 | 2012-02-07 15:15:14.493 | 2 |
| 19 | 1082415375 | 1017146392 | 567 | 545 | 2012-09-15 10:45:06.257 | 6614 | 2012-08-11 07:15:03.63 | 2 |
| 20 | 1094317843 | 1061650357 | 13 | 182 | 2012-04-19 05:50:42.799 | 2315 | 2012-09-28 07:24:34.195 | 1 |
+----+------------+------------+---------+----------+-------------------------+-----------+-------------------------+------------+
20 rows in set (0.00 sec)


 
 

 

'Open Sources > ETC' 카테고리의 다른 글

SonarQube  (0) 2016.02.03
업무 관리 도구 - 트렐로(Trello)  (0) 2014.07.12
Datagenerator - dbMonster Data Type  (0) 2013.03.05
Datagenerator - generatedata.com  (0) 2013.03.05
Grinder  (0) 2013.03.05

댓글