PostgreSQL

Prequisites

  • You have PostgreSQL installed on your system

If you do not have this prerequisite, the easiest way on Windows is to use Cygwinas it has a binary package for PostgreSQL already built. If you are on Unix, you get to build from source.

Steps

These steps take you from creating the intial database file repository to running the server. They should take approximately 15 minutes to complete.

Start the server

Create a new database file repository named irv with the initdb command:

initdb irv

Start PostgreSQL against this new repository:

postmaster -D irv -i

The -D tells PostgreSQL to use the irv file repository and -i tells PostgreSQL to listen for JDBC connections.

This command should not return as it the actual PostgreSQL process. If you have problems or stop following these instructions, you may use CTRL-C to stop the PostgreSQL process.

Create the IRV database

Once the server is running against the new irv file repository, an irv database needs to be created within this repository.

createdb irv

Install PL/pgSQL

Once the database is created, you must install PL/pgSQL for stored procedures to work.

createlang -d irv plpgsql

Create the IRV users

The IRV system uses two users to access the database. These need to be created manually.

First, start a PostgreSQL terminal session:

psql irv

Now execute the following commands, using your own password is you desire, keeping the single ticks around the passwords:


CREATE USER irv_admin WITH PASSWORD 'polaris';
CREATE USER irv_user WITH PASSWORD 'polaris';

Update security

The default security on PostgreSQL is rather lax. This step modifies this and also lets the irv_admin/irv_user users in if they are from the CMU network.

Within the irv file repository created in the first step, edit the pg_hba.conf file.

Change the two existing lines:


local   all       all                                                  trust
host    all       all               127.0.0.1         255.255.255.255  trust 

To:


local   all       irv_admin                                                  md5
host    all       irv_admin               127.0.0.1         255.255.255.255  md5 

This will ensure local access is restricted to users who know the irv_admin username and password.

Next, add the following three lines:


host    all       irv_admin         128.2.0.0         255.255.0.0       md5 
host    irv       irv_user          127.0.0.1         255.255.255.255   md5 
host    irv       irv_user          128.2.0.0         255.255.0.0       md5 

This will allow irv_admin and irv_user to connect both locally and from anywhere in the CMU network.

Once these changes are made, restart PostgreSQL (use CTRL-C to kill the current process and re-run the postmaster command).

Create the tables and permissions

This step is automated by the IRV BuildSystem. Make to check the Configurationto ensure your build environment is talking to the correct database.

Once you have verified this, from the IRV root directory, run:

ant db.create

Conclusion

That's it, the database is now configured to allow irv_admin/irv_user to connect to it and has the correct table structure for the IRV application to run against it.