From Fedora Project Wiki
(Upgrade)
Line 1: Line 1:
 
The installation and initialization of the postgresql server is little bit different in compare to other packages and other linux distros. 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 [http://yum.postgresql.org/]. However, this is not recommended.  
 
The installation and initialization of the postgresql server is little bit different in compare to other packages and other linux distros. 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 [http://yum.postgresql.org/]. However, this is not recommended.  
 +
 +
TODO: check https://help.ubuntu.com/community/PostgreSQL, check correctness of proposed approach
  
 
== Installation ==
 
== Installation ==

Revision as of 10:42, 5 December 2013

The installation and initialization of the postgresql server is little bit different in compare to other packages and other linux distros. 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.

TODO: check https://help.ubuntu.com/community/PostgreSQL, check correctness of proposed approach

Installation

$ sudo yum install postgresql-server postgresql-contrib

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 in my example, it is not fresh installation, but ugprade.

$ sudo postgresql-setup upgrade

You may need to switch postgresql to trust mode before update. Modify pg_hba.conf

local   all             all                                     trust
host    all             all             127.0.0.1/32            trust
host    all             all             ::1/128                 trust

The data are located at

  • /var/lib/pgsql/data
  • /var/lib/pgsql/data-old

User and password

$ sudo su - postgres
$ psql 
psql (9.2.6)
Type "help" for help.
postgres=# \password postgres
$ sudo su - postgres
$ createuser -P

Create Database

$ sudo su - postgres
$ createdb -O myuser mydb 

Configuration

The postgresql server is using two main configuration files

  • /var/lib/pgsql/data/postgresql.conf
listen_addresses = 'localhost'
#listen_addresses = '*'
  • /var/lib/pgsql/data/pg_hba.conf
host    all         all         0.0.0.0          0.0.0.0      md5
host    all         all         ::1/128                       md5
local   all         all                                       md5

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