[JBoss EAP] 데이터베이스별 JBoss Datasource 설정 예시
본문 바로가기
IT 이야기/JBoss EAP

[JBoss EAP] 데이터베이스별 JBoss Datasource 설정 예시

by 찬찬이 아빠 2019. 12. 23.
반응형

아래 예시는 일반적인 형태의 Datasource 설정이며 pool, validation, statement는 사용 환경에 맞게 값을 추가/삭제/변경 후 활용 권장합니다.

 

  1. JBoss EAP에 JDBC 모듈 추가 및 설정

아래 예제는 CUBRID JDBC 모듈을 기준으로 작성되었으며 타 사 제품의 경우 볼드체로 명기한 부분을 제조사에 맞게 수정하길 권장합니다.

 

 1) /JBOSS/jboss-eap-7.2/modules/system/layers/base/com/DATABASE명/main 디렉터리생성

1
# mkdir -p /JBOSS/jboss-eap-7.2/modules/system/layers/base/com/cubrid/main
cs

 

 2) 데이터베이스 제조사의 JDBC 모듈을 신규 생성한 디렉터리에 복사

1
# cp JDBC-cubrid.jar /JBOSS/jboss-eap-7.2/modules/system/layers/base/com/cubrid/main
cs

 

 3) module.xml 파일 생성

1
2
3
4
5
6
7
8
9
10
11
# vim /JBOSS/jboss-eap-7.2/modules/system/layers/base/cubrid/main/module.xml
 
<module xmlns="urn:jboss:module:1.1" name="com.cubrid">
     <resources>
          <resource-root path="JDBC-cubrid.jar" />
     </resources>
     <dependencies>
          <module name="javax.api" />
          <module name="javax.transaction.api" />
     </dependencies>
</module>
cs

※ JDBC 드라이버는 데이터베이스 제조사에 문의하여 설치되는 DB의 버전에 맞게 설치해야함

 

 

  2. 데이터베이스 별 설정 예시

 1) CUBRID Datasource 설정

   ① 단일

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<datasource jta="false" jndi-name="java:jboss/cubridDS" pool-name="cubrid" enabled="true" use-ccm="false">
     <connection-url>jdbc:cubrid:test-dbms1:33000:DB_NAME:::?charset=utf-8</connection-url>
          <driver-class>cubrid.jdbc.driver.CUBRIDDriver</driver-class>
          <driver>cubrid</driver>
          <pool>
               <min-pool-size>30</min-pool-size>
               <max-pool-size>100</max-pool-size>
               <prefill>true</prefill>
               <use-strict-min>true</use-strict-min>
          </pool>
          <security>
               <user-name>DB_USER_NAME</user-name>
               <password>DB_PASSWORD</password>
          </security>
          <validation>
             <check-valid-connection-sql>select 1</check-valid-connection-sql>
             <validate-on-match>true</validate-on-match>
             <background-validation>false</background-validation>
          </validation>
           <statement>
              <share-prepared-statements>false</share-prepared-statements>
           </statement
</datasource>
<drivers>
     <driver name="cubrid" module="com.cubrid">
          <driver-class>cubrid.jdbc.driver.CUBRIDDriver</driver-class>
      </driver>
</drivers>
cs

 

   ② 이중화(HA)

1
2
3
4
5
6
7
8
9
10
11
<datasource jta="false" jndi-name="java:jboss/cubridDS" pool-name="cubrid" enabled="true" use-ccm="false">
     <connection-url>jdbc:cubrid:test-dbms1:33000:DB_NAME:::?altHosts=test-dbms2:33000&amp;charset=utf-8</connection-url>
          <driver-class>cubrid.jdbc.driver.CUBRIDDriver</driver-class>
          <driver>cubrid</driver>
          <pool>
               <min-pool-size>30</min-pool-size>
               <max-pool-size>100</max-pool-size>
               <prefill>true</prefill>
               <use-strict-min>true</use-strict-min>
          </pool>
--- 이하 동일 ---
cs

 

 

 2) Maria Datasource 설정
   ① 단일

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<datasource jta="false" jndi-name="java:jboss/mysqlDS" pool-name="mysql" enabled="true" use-ccm="false">
     <connection-url>jdbc:mysql://test-dbms1:3306/DB_NAME</connection-url>
          <driver>mysql</driver>
          <pool>
               <min-pool-size>30</min-pool-size>
               <max-pool-size>100</max-pool-size>
               <prefill>true</prefill>
               <use-strict-min>true</use-strict-min>
          </pool>
          <security>
               <user-name>DB_USER_NAME</user-name>
               <password>DB_PASSWORD</password>
          </security>
--- 중간 생략 ---
</datasource>
<drivers>
     <driver name="mysql" module="com.mysql">
          <driver-class>com.mysql.jdbc.Driver</driver-class>
      </driver>
</drivers>
cs

 

   ② 이중화(HA)

1
2
3
4
5
6
7
8
9
10
<datasource jta="false" jndi-name="java:jboss/mysqlDS" pool-name="mysql" enabled="true" use-ccm="false">
     <connection-url>jdbc:mysql://test-dbms1:3306/DB_NAME,test-dbms2:3306</connection-url>
          <driver>mysql</driver>
          <pool>
               <min-pool-size>30</min-pool-size>
               <max-pool-size>100</max-pool-size>
               <prefill>true</prefill>
               <use-strict-min>true</use-strict-min>
          </pool>
--- 이하 동일 ---
cs

 

 

 3) PostgreSQL Datasource 설정

   ① 단일

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<datasource jta="false" jndi-name="java:jboss/postgreDS" pool-name="postgresql" enabled="true" use-java-context="true" use-ccm="false">
     <connection-url>jdbc:postgresql://test-dbms1:5432/DB_NAME</connection-url>
          <driver>postgresql</driver>
          <pool>
               <min-pool-size>30</min-pool-size>
               <max-pool-size>100</max-pool-size>
               <prefill>true</prefill>
               <use-strict-min>true</use-strict-min>
          </pool>
          <security>
               <user-name>DB_USER_NAME</user-name>
               <password>DB_PASSWORD</password>
          </security>
--- 중간 생략 ---
</datasource>
<drivers>
     <driver name="postgresql" module="com.postgresql">
          <driver-class>com.postgresql.jdbc.Driver</driver-class>
      </driver>
</drivers>
cs

 

   ② 이중화(HA)

1
2
3
4
5
6
7
8
9
10
<datasource jta="false" jndi-name="java:jboss/postgreDS" pool-name="postgreDS" enabled="true" use-java-context="true" use-ccm="false">
     <connection-url>jdbc:postgresql://test-dbms1:5432,test-dbms2:5432/DB_NAME?targetServerType=master</connection-url>
          <driver>postgreDS</driver>
          <pool>
               <min-pool-size>30</min-pool-size>
               <max-pool-size>100</max-pool-size>
               <prefill>true</prefill>
               <use-strict-min>true</use-strict-min>
          </pool>
--- 이하 동일 ---
cs

 

 

 4) Altibase Datasource 설정

   ① 단일

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<datasource jta="false" jndi-name="java:jboss/altibaseDS" pool-name="altibase" enabled="true" use-ccm="false">
     <connection-url>jdbc:Altibase://test-dbms1:20300/DB_NAME</connection-url>
          <driver>altibase</driver>
          <pool>
               <min-pool-size>30</min-pool-size>
               <max-pool-size>100</max-pool-size>
               <prefill>true</prefill>
               <use-strict-min>true</use-strict-min>
          </pool>
          <security>
               <user-name>DB_USER_NAME</user-name>
               <password>DB_PASSWORD</password>
          </security>
--- 중간 생략 ---
</datasource>
<drivers>
     <driver name="altibase" module="com.altibase">
          <driver-class>Altibase.jdbc.driver.AltibaseDriver</driver-class>
      </driver>
</drivers>
cs

 

   ② 이중화(HA)

1
2
3
4
5
6
7
8
9
10
<datasource jta="false" jndi-name="java:jboss/altibaseDS" pool-name="altibase" enabled="true" use-ccm="false">
     <connection-url>jdbc:Altibase://test-dbms1:16382/DB_NAME?AlternateServers=(test-dbms2:16383)&amp;ConnectionRetryCount=1&amp;ConnectionRetryDelay=1&amp;LoadBalance=off</connection-url>
          <driver>altibase</driver>
          <pool>
               <min-pool-size>30</min-pool-size>
               <max-pool-size>100</max-pool-size>
               <prefill>true</prefill>
               <use-strict-min>true</use-strict-min>
          </pool>
--- 이하 동일 ---
cs

 

 

 5) Oracle Datasource 설정

   ① 단일

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<datasource jta="false" jndi-name="java:jboss/oracleDS" pool-name="oracle" enabled="true" use-ccm="false">
     <connection-url>jdbc:oracle:thin:test-dbms1:1521:DB_NAME</connection-url>
          <driver>oracle</driver>
          <pool>
               <min-pool-size>30</min-pool-size>
               <max-pool-size>100</max-pool-size>
               <prefill>true</prefill>
               <use-strict-min>true</use-strict-min>
          </pool>
          <security>
               <user-name>DB_USER_NAME</user-name>
               <password>DB_PASSWORD</password>
          </security>
--- 중간 생략 ---
</datasource>
<drivers>
     <driver name="oracle" module="com.oracle">
          <driver-class>orcle.jdbc.OracleDriver</driver-class>
      </driver>
</drivers>
cs

 

   ② 이중화(HA)

1
2
3
4
5
6
7
8
9
10
<datasource jta="false" jndi-name="java:jboss/oracleDS" pool-name="oracle" enabled="true" use-ccm="false">
     <connection-url>jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=test-dbms1) (PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=test-dbms2) (PORT=1521))(CONNECT_DATA=(SERVICE_NAME=DB_NAME)))</connection-url>
          <driver>oracle</driver>
          <pool>
               <min-pool-size>30</min-pool-size>
               <max-pool-size>100</max-pool-size>
               <prefill>true</prefill>
               <use-strict-min>true</use-strict-min>
          </pool>
--- 이하 동일 ---
cs

 

 

 6) Tibero Datasource 설정

   ① 단일

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<datasource jta="false" jndi-name="java:jboss/tiberoDS" pool-name="tibero" enabled="true" use-ccm="false">
     <connection-url>jdbc:tibero:thin:@test-dbms1:8629:DB_NAME</connection-url>
          <driver>tibero</driver>
          <pool>
               <min-pool-size>30</min-pool-size>
               <max-pool-size>100</max-pool-size>
               <prefill>true</prefill>
               <use-strict-min>true</use-strict-min>
          </pool>
          <security>
               <user-name>DB_USER_NAME</user-name>
               <password>DB_PASSWORD</password>
          </security>
          <timeout>
             <idle-timeout-minutes>2</idle-timeout-minutes>
          </timeout>
          <statement>
             <prepared-statement-cache-size>20</prepared-statement-cache-size>
          </statement>
</datasource>
<drivers>
     <driver name="tiberoDS" module="com.tibero">
          <driver-class>com.tmax.jdbc.tbDriver</driver-class>
      </driver>
</drivers>
cs

 

   ② 이중화(HA)

1
2
3
4
5
6
7
8
9
10
<datasource jta="false" jndi-name="java:jboss/tiberoDS" pool-name="tibero" enabled="true" use-ccm="false">
     <connection-url>jdbc:tibero:thin:@(DESCRIPTION=(failover=on)(load_balance=on)(address_list=(host=test-dbms1)(port=8629))(address=(host=test-dbms2)(port=8629)))(database_name=DB_NAME))</connection-url>
          <driver>tibero</driver>
          <pool>
               <min-pool-size>30</min-pool-size>
               <max-pool-size>100</max-pool-size>
               <prefill>true</prefill>
               <use-strict-min>true</use-strict-min>
          </pool>
--- 이하 동일 ---
cs
반응형

댓글