Personal tools

HPCLab:Specific PostgreSQL configuration

From hpcwiki

Revision as of 20:49, 21 April 2018 by Hfrancot (Talk | contribs)

Jump to: navigation, search

PostgreSQL 9.4

  • Main guide: http://www.sfentona.net/?p=2756
    • Update: CentOS version is now pgdg-centos94-9.4-3.noarch.rpm (correct the download)
  • The initdb process (create the pgdata structure in the file system) yielded:
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    ./postgres -D /media/hpclab-data/pgdata
or
   ./pg_ctl -D /media/hpclab-data/pgdata -l logfile start


Complete "raw" guide

Step 1) Install the yum Repo for PostgresSQL 9.4

yum -y localinstall http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-1.noarch.rpm

Step 2) Download the RPMS and install the database engine

yum -y install   postgresql94-contrib  postgresql94-server

Step 3) Create the directories from where the database will be running from. In this case it will be from /home/postgres

mkdir /home/postgres; chown -R postgres:postgres /home/postgres

Step 4) Initialize the database.

cd  /usr/pgsql-9.4/bin/; ./initdb -D /home/postgres

Step 5) Alter the default location from where your database will be running from.

vim /var/lib/pgsql/.bash_profile

#Alter the PGDATA as follows. See sample below
#PGDATA=/var/lib/pgsql/9.4/data
PGDATA=/home/postgres
export PGDATA

6) Configure systemd to start the database on boot-up

vi /usr/lib/systemd/system/postgresql-9.4.service
  1. Note: avoid inserting whitespace in these Environment= lines, or you may
  2. break postgresql-setup.
  3. Location of database directory
  4. Environment=PGDATA=/var/lib/pgsql/9.4/data/

Environment=PGDATA=/home/postgres/

Run as superuser

systemctl daemon-reload
systemctl enable  postgresql-9.4.service
systemctl start  postgresql-9.4.service