Installing and setting up a new db

You will need sudo on that machine.

  • install postgres:

sudo yum install postgresql
sudo yum install postgresql-server

postgres tends to install its files under the username postgres. You should therefore create and use this user for the steps below. Specifically you need access to /var/run/postgresql/

  • make a directory for posgres data:

mkdir -p /usr/local/pgsql/data

  • Create a database cluster (file structure)

initdb -D /usr/local/pgsql/data

  • Initialise the server (I think I only need to do the second of these things)

postmaster -D /usr/local/pgsql/data >logfile 2>&1 &
postgres -D /usr/local/pgsql/data &

  • create database:

createdb <db_name>

  • To restart the server (after shutting down for example)

su - postgres
pg_ctl start -D /usr/local/pgsql/data

Configuring

The config files will be inside the database cluster directory you created above (so /usr/local/pgsql/data/ in the example).

There are two main config files, both in the above dir.

pg_hba.conf (the client authentication configuration file)
postgresql.conf (all sorts of things)

You need to explicity allow for external hosts to connect to the database:

pg_hba.conf:
# IPv4 local connections:
host all all 192.171.161.1/24 trust

postgresql.conf
listen_addresses = '*'

pg_ctl is a utility for monitoring and controlling a posgreSQL server
Check server status:
pg_ctl status -D /usr/local/pgsql/data
pg_ctl: server is running (PID: 29763)

Last modified 10 years ago Last modified on Oct 8, 2014, 11:59:01 AM