Setting up VARS on PostgreSQL
VARS can run on most database servers. Below is the documentation to setup VARS to run on PostgreSQL
Once the PostgreSQL database server is installed you can create and configure a VARS database as follows:
- Initialize a database: [ Note /var/local/pgsql/data is just an example path. You may change that to suit your needs.]
initdb -D /var/local/pgsql/data
- Modify /var/local/pgsql/data/postgresql.conf to allow TCP/IP connections from anyhost. Add the following line:
- Modify /var/local/pgsql/data/pg_hba.conf to allow connections from anyhost. Add the following line:
host VARS varsuser 0.0.0.0/0 password
- Start PostgreSQL:
postgres -D /var/local/pgsql/data
- Create the vars database with the following command:
- Create a varsuser account. The user account needs to have aleast read/write/modify privelages. [Remember the password you use!! You'll need that later]
createuser varsuser --password
Set up the VARS database on PostgreSQL
Once you've initialize a database, you will need to create the database tables that VARS needs. You can use your favorite database utility or you can use PostgreSQL's command line utility psql to run the table definitions below.
VARS will need to be modified to recognize your database.
- Find and download the JDBC driver for your version of postgreSQL from http://jdbc.postgresql.org/. (JDBC type 4 driver is best). Just download the driver and drop it into VARS_HOME/lib.
- Note the following information. The default port for PostgreSQL is 5432 unless you changed it in postgresql.conf. The host is the either the fully qualified name or the IP address of the computer running PostgreSQL. Either the name or the IP address wil work.
JDBC URL: jdbc:postgresql://HOST:PORT/DATABASE [varies with your computer]
USERNAME: ??? [probably will be 'varsuser' if you followed the directions above]
PASSWORD: ??? [From above]
DRIVER NAME: org.postgresql.Driver
- Make a temp directory somewhere to work in:
mkdir tempdir;cd tempdir
- Copy the vars-jpa-XXX.jar from VARS_HOME/lib into the tempdir.
cp $VARS_HOME/lib/vars-jpa-6.0.2.jar tempdir
- Unzip the vars-jpa jar. [JAR files are just zip files with a different extension].
cd tempdir; mkdir trashme; unzip vars-jpa-6.0.2.jar -d trashme
- Edit the following files:
Inside each of these files are lines that specify the jdbc-url, username, password, and driver name of the databases. Edit them as appropriate. If you've munged the VARS and VARS_KB tables into a single database [which is what these directions assume] then you'll only have one url to use everywhere, otherwise be mindful of which database you point at. For example, annotation-jdbc.properties and query-jdbc.properties should point at the VARS database. The knowedgebase-jdbc.properties file should point at the VARS_KB database.
persistence.xml has several XML blocks named 'persistence-unit' in it. The ones named 'vars-jpa-knowledgebase', and 'vars-jpa-misc' should point at VARS_KB. 'vars-jpa-annotation' should point at the VARS database. You don't care about the 'vars-jpa-test' persistence unit.
- Once you've made edits you need to jar everything back up.
# Assuming you're still in tempdir
jar -cvf vars-jpa-6.0.2-postgresql.jar -C trashme *
This will create a new jar named vars-jpa-6.0.2-postgresql.jar. Delete VARS_HOME/lib/vars-jpa-6.0.2.jar and replace it with your new jar (VARS will automatically pick up the changes when you start it