Running JBoss AS and PostgreSQL in different host (server)(MIGRATED)


In order to cope with extra load, sometimes one server may not be enough due to the large number of users or transactions.  To run application server and database server separately, follow the steps below:



1. Install & Setup JBoss Application Server

Please refer to the following instruction to setup JBoss Application Server.


2. Install & Setup PostgreSQL Database

If your linux distribution has PostgreSQL database installed by default, you can skip this step, otherwise, you can download PostgreSQL database and install according to the step here.


3. Configure Database Server permissions

After the database is initialized for the first time with the following command /etc/init.d/postgresql start , you can edit the following file to allow remote host (application server) to access the database. The instruction to open up database access to remote host is available at /var/lib/pgsql/data/pg_hba.conf, as the format may differ for different versions of PostgreSQL database, it is important to refer to the configuration instructions carefully. The sample configurations below is applicable to PostgreSQL version 8.1:


# IPv4-style local connections:

host    all         all     trust

host    wsemp       jboss     trust


Please take note that is the I.P. address of the application server.

As database connections can only be established with a username and password, this database user has to be a linux user, we can use the following commands to create a linux user, and subsequently PostgreSQL user based on this linux user. So, login as root, and execute the following commands:


[root@dragon data]# useradd wavelet

[root@dragon data]# passwd wavelet

Changing password for user wavelet.

New UNIX password:

BAD PASSWORD: it is based on a dictionary word

Retype new UNIX password:

passwd: all authentication tokens updated successfully.

[root@dragon data]# createuser wavelet

Shall the new role be a superuser? (y/n) y


[root@dragon data]#



4. Configure JBoss data source

The very first step is to ensure the JBoss Application server has the correct versions of JDBC drivers... As of the time of writing this document, Wavelet software is using JDK1.4.2, hence, we should use JDBC3 PostgreSQL database drivers. Please ensure all other invalid versions of PostgreSQL JDBC3 drivers are removed from the following directory /usr/java/jboss/server/default/lib . You can download the correct versions of the PostgreSQL JDBC driver from the following URL.


The next step is to configure the data source XML file,  /usr/java/jboss/server/default/deploy/postgres-ds.xml.


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

<!-- ===================================================================== -->

<!--                                                                       -->

<!--  JBoss Server Configuration                                           -->

<!--                                                                       -->

<!-- ===================================================================== -->

<!-- $Id: postgres-ds.xml,v 1.1 2002/07/22 22:57:24 d_jencks Exp $ -->

<!-- ==================================================================== -->

<!--  Datasource config for Postgres                                      -->

<!-- ==================================================================== -->











Please note that is the I.P. address of the DATABASE server. "wsemp" is the database name of the Wavelet EMP. "wavelet" and "thepasswd" is the database username and password created in the APPLICATION server earlier.