From Fedora Project Wiki
Line 56: Line 56:
 
  $ createuser -P
 
  $ createuser -P
  
== configuration ==
+
== Configuration ==
  
 
The postgresql server is using two main configuration files  
 
The postgresql server is using two main configuration files  
Line 64: Line 64:
 
The default settings is usually restricted to localhost.   
 
The default settings is usually restricted to localhost.   
  
== tips and tricks ==
+
== Tips and tricks ==
  
 
For database management is comfortable to use graphical tools such as phpPgAdmin or pgadmin3
 
For database management is comfortable to use graphical tools such as phpPgAdmin or pgadmin3

Revision as of 18:03, 14 November 2013

The installation and initialization of the postgresql server is little bit different in compare to other packages. This document aims to summarize basic installation steps relevant to recent fedora release. In first place, you may consider to install newer version than is packaged for fedora see [1]. However, this is not recommended.

Installation

$ sudo yum install postgresql postgresql-server

The postgresql server is turned off and disabled by default. You can enable its start during the boot using following command:

$ sudo systemctl enable postgresql

You can start the postgresql server only when necessary as follows.

$ sudo systemctl start postgresql
Job for postgresql.service failed. See 'systemctl status postgresql.service' and 'journalctl -xn' for details.

The database needs to be populated by initial data after installation. The error log describes problem and its solution.

$ journalctl -xn
-- Logs begin at Mon 2013-11-04 14:38:33 CET, end at Thu 2013-11-14 11:45:56 CET. --
Nov 14 11:45:34 mlich-lenovo.usersys.redhat.com sudo[2054]: jmlich : TTY=pts/2 ; PWD=/home/jmlich ; USER=root ; COMMAND=/bin/systemctl status postgresql
Nov 14 11:45:37 mlich-lenovo.usersys.redhat.com sudo[2073]: jmlich : TTY=pts/2 ; PWD=/home/jmlich ; USER=root ; COMMAND=/bin/systemctl status postgresql
Nov 14 11:45:56 mlich-lenovo.usersys.redhat.com sudo[2105]: jmlich : TTY=pts/2 ; PWD=/home/jmlich ; USER=root ; COMMAND=/bin/systemctl start postgresql
Nov 14 11:45:56 mlich-lenovo.usersys.redhat.com systemd[1]: Starting PostgreSQL database server...
-- Subject: Unit postgresql.service has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit postgresql.service has begun starting up.
Nov 14 11:45:56 mlich-lenovo.usersys.redhat.com postgresql-check-db-dir[2108]: An old version of the database format was found.
Nov 14 11:45:56 mlich-lenovo.usersys.redhat.com postgresql-check-db-dir[2108]: Use "postgresql-setup upgrade" to upgrade to version 9.3.
Nov 14 11:45:56 mlich-lenovo.usersys.redhat.com postgresql-check-db-dir[2108]: See /usr/share/doc/postgresql/README.rpm-dist for more information.
Nov 14 11:45:56 mlich-lenovo.usersys.redhat.com systemd[1]: postgresql.service: control process exited, code=exited status=1
Nov 14 11:45:56 mlich-lenovo.usersys.redhat.com systemd[1]: Failed to start PostgreSQL database server.
-- Subject: Unit postgresql.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- Documentation: http://www.freedesktop.org/wiki/Software/systemd/catalog/be02cf6855d2428ba40df7e9d022f03d
-- 
-- Unit postgresql.service has failed.
-- 
-- The result is failed.

The database initialization could be done using following command. It creates the configuration files postgresql.conf and pg_hba.conf

$ sudo postgresql-setup initdb

Upgrade

As you can see from error message, it is not fresh installation, but ugprade.

$ sudo postgresql-setup upgrade

User and password

$ sudo su - postgres
$ createuser -P

Configuration

The postgresql server is using two main configuration files

  • /var/lib/pgsql/data/postgresql.conf
  • /var/lib/pgsql/data/pg_hba.conf

The default settings is usually restricted to localhost.

Tips and tricks

For database management is comfortable to use graphical tools such as phpPgAdmin or pgadmin3

$ sudo yum install phpPgAdmin
$ sudo yum install pgadmin3