Skip to content
Jens Reimann edited this page Dec 30, 2015 · 12 revisions

Note: This is outdated! Recent releases of Package Drone do not use any SQL database anymore.

Install PostgreSQL

Internally, JPA using Eclipse Link, and Gemini JPA is used. This requires the use of the OSGi DataSourceFactory specification, which is included in the newest version of the PostgreSQL JDBC driver.

To learn more how to install PostgreSQL, have a look at the PostgreSQL wiki. This guide assumes that PostgreSQL is installed as is on a standard Linux installation.

Note: Although older versions, before 9.2, also work, they do have problems handling BLOBs. There is is recommended to run Package Drone at least with PostgreSQL 9.3

PostgreSQL config files

To enable the JDBC driver access to the PostgreSQL server, access via TCP has to be allowed. This can be restricted by user and host (network).

Two files have to be edited to allow it to work: postgresql.conf and pg_hba.conf. Unfortunately the location is different depending on the distribution:

  • Debian and Derivates (Ubuntu): /etc/postgresql/[version]/main/*.conf
  • other Distributions: /var/lib/pgsql/data/*.conf

For this description we will enable access of the "pd" user for the whole network. This might not be a good idea depending on your security requirements.

postgresql.conf

Under the heading "CONNECTIONS AND AUTHENTICATION" uncomment the line which reads:

# listen_addresses = 'localhost'

and change it that way (if package drone is running on the same server):

listen_addresses = 'localhost'

otherwise:

listen_address = '*'

pg_hba.conf

Here we have to add an additional line, which should look like this:

host    pd             pd             0.0.0.0/0           md5

This will allow a user "pd" to access the database "pd" from anywhere on the network.

Now we have to restart the postgres server, this again depends on the distribution you are using. Either

sudo /etc/init.d/postgresql restart

or

sudo systemctl stop postgresql
sudo systemctl start postgresql

should probably work.

Creating the user and the database

Create the user

Switch to the postgres user:

sudo su - postgres

Now start the client and connect to the default database:

psql

Create the user:

CREATE USER pd WITH PASSWORD '<choose a database password>';

Create the database, owned by the user above:

CREATE DATABASE pd OWNER pd;

To check if this really works, leave the client:

\q

And test the connection:

psql -h localhost -U pd

This should lead to a password prompt, and after successful login it should look like this:

Password for user pd: 
psql (9.3.6)
SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)
Type "help" for help.

pd=>

Congratulations, your database is ready to be utilized!

Please continue with the Setup