Changes between Initial Version and Version 1 of Sensors/Grimm/settingUpPostgresDB


Ignore:
Timestamp:
Oct 7, 2014 4:27:42 PM (5 years ago)
Author:
knpa
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Sensors/Grimm/settingUpPostgresDB

    v1 v1  
     1----------------------------------
     2installing and setting up a new db
     3----------------------------------
     4You will need sudo on that machine.
     5
     6- install postgres:
     7sudo yum install postgresql
     8sudo yum install postgresql-server
     9
     10postgres 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/
     11
     12- make a directory for posgres data:
     13mkdir -p /usr/local/pgsql/data
     14
     15- Create a database cluster (file structure)
     16initdb -D /usr/local/pgsql/data
     17
     18- Initialise the server (I think I only need to do the second of these things)
     19postmaster -D /usr/local/pgsql/data >logfile 2>&1 &
     20postgres -D /usr/local/pgsql/data &
     21
     22- create database:
     23createdb <db_name>
     24
     25- To restart the server (after shutting down for example)
     26su - postgres
     27pg_ctl start -D /usr/local/pgsql/data       
     28-----------------------------------
     29
     30Configuring
     31
     32The config files will be inside the database cluster directory you created above (so /usr/local/pgsql/data/ in the example).
     33
     34There are two main config files, both in the above dir.
     35
     36pg_hba.conf (the client authentication configuration file)
     37postgresql.conf (all sorts of things)
     38
     39You need to explicity allow for external hosts to connect to the database:
     40
     41pg_hba.conf:
     42# IPv4 local connections:
     43host    all             all             192.171.161.1/24         trust
     44
     45postgresql.conf
     46listen_addresses = '*'
     47
     48pg_ctl is a utility for monitoring and controlling a posgreSQL server
     49Check server status:
     50pg_ctl status -D /usr/local/pgsql/data       
     51pg_ctl: server is running (PID: 29763)