This document provides instructions for installing PostgreSQL database server on Red Hat Enterprise Linux and Fedora Core systems. It discusses obtaining and installing the RPM packages, which packages to install for different purposes, and package file locations. Initializing and starting the PostgreSQL server is also covered.
This document provides instructions for installing PostgreSQL database server on Red Hat Enterprise Linux and Fedora Core systems. It discusses obtaining and installing the RPM packages, which packages to install for different purposes, and package file locations. Initializing and starting the PostgreSQL server is also covered.
This document provides instructions for installing PostgreSQL database server on Red Hat Enterprise Linux and Fedora Core systems. It discusses obtaining and installing the RPM packages, which packages to install for different purposes, and package file locations. Initializing and starting the PostgreSQL server is also covered.
Last Update: Mon Sep 03, 2007 Written by Devrim GNDZ !GDG "!M Maintainer# devrim$!ost%reS&L'or% and Lamar ()en !GDG "!M Maintainer# *o)en$pari'ed+ ,** -ontrib+tions are )e*-ome' !*ease .ee* .ree to drop +s e/mai* abo+t yo+r -omments'# This article will talk about the details of installing PostgreSQL Database Server on Red Hat Enterprise Linux !edora "ore# RP$s are read%&to&install binar% files for 'an% Linux distributions# Please note that this article is written for (#) and above* so so'e infor'ation 'a% not fit %our version# +eneral infor'ation PostgreSQL +lobal Develop'ent +roup ,P+D+- builds RP$s for various Linux distributions# .t the ti'e of this writing* we have RP$s and SRP$s for the following platfor's / 0 Red Hat Enterprise Linux 1* 2 and 3 !edora "ore 4*5*( 6n Pg!oundr%* there is a pro7ect for building RP$s0 http://pgfoundry.org/projects/pgsqlrpms !urther'ore* there are &hackers* &general and &announce 'ailing lists# .ll discussions are open to ever%one# 6btaining the RP$s The RP$s are available on PostgreSQL !TP site and all of its 'irrors# !or %our convenience* %ou 'a% tr% using web interface of PostgreSQL !TP site# That site will suggest %ou the suitable 'irror,s- for %ou# The 8RL is0 http://www.PostgreSQL.org/ftp / !or x(4 and x(4942 architectures# :hich RP$ for what purpose; P+D+ ships the following RP$s0 postgres<l&libs The postgres<l&libs package provides the essential shared libraries for an% PostgreSQL client progra' or interface# =ou will need to install this package to use an% other PostgreSQL package or an% clients that need to connect to a PostgreSQL server# postgres<l >f %ou want to 'anipulate a PostgreSQL database on a local or re'ote PostgreSQL server* %ou need this package# =ou also need to install this package if %ou?re installing the postgres<l&server package# postgres<l&contrib The postgres<l&contrib package contains contributed packages that are included in the PostgreSQL distribution# postgres<l&devel The postgres<l&devel package contains the header files and libraries needed to co'pile " or "@@ applications which will directl% interact with a PostgreSQL database 'anage'ent server and the ecpg E'bedded " Postgres preprocessor# =ou need to install this package if %ou want to develop applications which will interact with a PostgreSQL server# postgres<l&docs The postgres<l&docs package includes the S+$L source for the docu'entation as well as the docu'entation in PD! for'at and so'e extra docu'entation# >nstall this package if %ou want to help with the PostgreSQL docu'entation pro7ect* or if %ou want to generate printed docu'entation# postgres<l&server The postgres<l&server package includes the progra's needed to create and run a PostgreSQL server* which will in turn allow %ou to create and 'aintain PostgreSQL databases# =ou should install postgres<l&server if %ou want to create and 'aintain %our own PostgreSQL databases andor %our own PostgreSQL server# =ou also need to install the postgres<l package and its re<uire'ents# postgres<l&tcl The postgres<l&tcl package contains the Pgtcl client librar% and its docu'entation# postgres<l&7dbc The postgres<l&7dbc package includes the #7ar files needed for Aava progra's to access a PostgreSQL database# postgres<l&plperl The postgres<l&plperl package contains the the PLPerl procedural language for the backend# PLpgSQL is part of the core server package# postgres<l&pltcl The postgres<l&plperl package contains PLTcl procedural language for the backend# PLpgSQL is part of the core server package# postgres<l&plp%thon The postgres<l&plp%thon package contains the PLP%thon procedural language for the backend# PLpgSQL is part of the core server package# postgres<l&p%thon The postgres<l&p%thon package includes a 'odule for developers to use when writing P%thon code for accessing a PostgreSQL database# postgres<l&test The postgres<l&test package includes the sources and pre&built binaries of various tests for the PostgreSQL database 'anage'ent s%ste'* including regression tests and bench'arks# :hich packages should > use; >f %ou feel laB% about reading the descriptions above* here is a shortcut for 'ini'al scenarios0 >f %ou want to run a PostgreSQL server* install postgres<l&libs* postgres<l and postgres<l& server# >f %ou want to run a client* install postgres<l&libs and postgres<l rp's# !or so'e cases* %ou 'ight 7ust want to install postgres<l&libs for so'e packages like PHP# Package na'es also include version and architecture infor'ation# 6fficial PostgreSQL +lobal Develop'ent +roup RP$?s have a ?P+D+? after the release nu'ber# 6ther RP$set?s as distributed with Linux distributions 'a% have a different release nu'ber and initials# The version nu'bering is the sa'e as PostgreSQL# >t is preferable for the distribution&specific set to be the one used* as the P+D+ set is intentionall% generic# So* if %our distro has a set of RP$s* use the' in preference# >f %ou want to sta% up&to&date on the PostgreSQL core itself* use the P+D+ generic set && but understand that it is a +ECER>" set# These RP$s no longer support an% sort of upgrading process other than that docu'ented in the regular docu'entation# That is* %ou 'ust du'p* upgrade* initdb* and restore %our data# =ou 'ust re'ove the old server subpackage* install the new package and restore the data fro' du'p# RP$ !ile Locations To be in co'pliance with the Linux !HS* the PostgreSQL P+D+ RP$s install files in a 'anner not consistent with 'ost of the PostgreSQL docu'entation# .ccording to the standard PostgreSQL docu'entation* PostgreSQL is installed under the director% usrlocalpgs<l* with executables* source* and data existing in various subdirectories# Different distributions have different ideas of so'e of these file locations# >n particular* the docu'entation director% can be usrdoc* usrdocpackages* usrsharedoc* usrsharedocpackages* or so'e other si'ilar path# The Red Hat !edora "ore locations are listed below0 Executables /usr/bin Libraries /usr/lib Docu'entation /usr/share/doc/postgresql-x.y.z /usr/share/doc/postgresql-x.y.z/contrib "ontrib /usr/share/pgsql/contrib Data /var/lib/pgsql/data Dackup area /var/lib/pgsql/backup Te'plates /usr/share/pgsql Procedural Languages /usr/lib/pgsql Develop'ent Headers /usr/include/pgsql 6ther shared data /usr/share/pgsql Regression tests /usr/lib/pgsql/test/regress ,in the &test package- Executables /usr/bin Docu'entation S+$L /usr/share/doc/postgresql-docs-x.y.z The above list references the Red Hat !edora "ore structure# These locations 'a% change for other distributions# 8se of ?rp' &<l? for each package is reco''ended as the ?6fficial? location source# These RP$s are designed to be LSD&co'pliant && if %ou find this not to be the case* please let us know b% wa% of the pgs<lrp's&hackersEPg!oundr%#org 'ailing list# >nstalling and 8pgrading PostgreSQL RP$s >nstalling P+D+ RP$s are as eas% as installing an% RP$s rpm -ivh package_name.version.arch.rpm 8nless specified* on 'inor release upgrades ,i#e#* upgrading fro' (#)#F to (#)#/ or (#)#2* etc ) -* %ou 'a% use usual RP$ upgrade process0 rpm -Uvh package_name.version.arch.rpm Please note that on ever% new 'a7or version upgrade* %ou have to follow du'preload se<uence# However please dont forget to read the Release Notes before upgrading because on some cases minor versions may need a dump/reload process. At those times if you use -U switch, then you will probably lose data !lease refer to "#ow do $ perform a ma%or upgrade&' section. $an% of the RP$s are signed with the P+P ke% of the package builder# Directories contain a "8RRECT9$.>CT.>CER file which includes the na'ee'ail of the package builder and link to their P+P ke%# =ou 'ight want to i'port the signature before %ouGll install the RP$0 rpm import http://link/to/the/pgp/key 8nless this is not done* %ou can installupgrade the RP$s but %ouGll be thrown a warning# =ou 'a% subscribe to pgs<lrp's&generalEpgfoundr%#org list for 'ore details# Re'oving RP$S =ou 'ight want to take a full du'p ,and possibl% a files%ste' level backup- before re'oving RP$s# Re'oving an PostgreSQL RP$ is as eas% as re'oving an% RP$0 rpm -e package_name Defore the re'oval of server package* if there are an% running processes* all are stopped# =ou donGt need to stop it# Starting PostgreSQL for the first ti'e and init script Red Hat Linux uses the S%ste' H >nit package# . startup script for PostgreSQL is provided in the server package* as etcrc#dinit#dpostgres<l# To start the post'aster* with sanit% checking* as root* run service postgresql start To shut the post'aster down* service postgresql stop There are other para'eters to this script && execute ?service postgres<l? for a listing# 6n so'e cases %ou 'ight want to edit this init file# !or exa'ple* %ou 'ight want to pass a I localeJ### para'eter to initdb* etc# ) (#/ is the 'a7or version nu'ber* and F*/*1* etc are 'inor version nu'bers This script does the following sets defaults for configuration variables and then perfor's the given action ,stop* start* etc-# During the startup* first the script checks whether the database cluster has been initialiBed or not# >f not* then %ou 'ust run0 service postgresql initdb This option is new as of (#) # Defore (#)* service postgresql start was calling initdb when the cluster was not initaliBed# Then the service is started as usual# =ou 'a% also reload the server for so'e changes to take effectK but please look at the PostgreSQL docu'entation for the conditions that the database server needs a restart or a reload# Starting PostgreSQL auto'aticall% at s%ste' startup To get this script to run at s%ste' startup run0 chkconfig postgresql on and the proper s%'links will be created# See the chkconfig 'an page for 'ore infor'ation# Cote that this is 'anual && while the startup script can include tags to allow chkconfig to auto'aticall% perfor' the s%'linking* this is not done at this ti'e# How do > perfor' a 'a7or upgrade; "urrentl%* PostgreSQL RP$s does not provide a data upgrade feature a'ong 'a7or releases ,or clearl%* upgrades that re<uire an initdb#- This work in under progress# >n order to upgrade to a 'a7or version* %ou should follow the following steps0 Take a full du'p using pg9du'pall =ou 'ight want to take a files%ste'&level backup also# This is intentional# "heck the backupsL ,Do it againL- Cow* stop the database server0 /sbin/service postgresql stop Re'ove all postgres<l rp's# Please note that %ou?ll probabl% need a &&nodeps switch at the end0 /bin/rpm -e `/bin/rpm -qa|grep postgresql^` /bin/rpm -e `/bin/rpm -qa|grep postgresql^` --nodeps During the re'oval of packages* so'e scripts will be run to re'ove postgres user and to uninstall postgres<l service* etc# Please note that re'oving of postgres<l&server RP$ will not also re'ove varlibpgs<l Re'ove 1 database cluster0 /bin/rm -rf /var/lib/pgsql >nstall new RP$ sets Start database server /sbin/service postgresql start Edit conf files* if %ou need# Reload the data to the new server ,=ou 'a% need to edit %our data-# ### and %ou?re doneL 1 Detter0 binr' &rf Mpostgres or best take a files%ste'&level backup of this director% b% using bin'v for exa'ple Rebuilding fro' Source RP$ >f %our distribution is not supported b% the binar% RP$?s fro' PostgreSQL#org* %ou will need to rebuild fro' the source RP$# Download the #src#rp' for this release# =ou will need to be root to rebuild* unless %ou have alread% set up a non&root build environ'ent# >nstall the source RP$ with rp' &i* then "D to the rp' building area ,on Red Hat or !edora "ore this is usrsrcredhat b% default-# =ou will have to have a full develop'ent environ'ent to rebuild the full RP$ set# This release of the RP$set includes the abilit% to conditionall% build sets of packages# The para'eters* their defaults* and the 'eanings are0 beta F Nbuild with cassert and do not strip the binaries pltcl / Nbuild the postgres<l&pltcl package# 7dbc / Nbuild the postgres<l&7dbc package# plperl / Nbuild the postgres<l&plperl package# test / Nbuild the postgres<l&test package# plp%thon / Nbuild the postgres<l&plp%thon package# pltcl / Nbuild the pltcl portion of the postgres<l&pl package# plperl / Nbuild the plperl portion of the postgres<l&pl package# ssl / Nuse 6penSSL support# kerberos / Nuse Oerberos 3 support# nls / Nbuild with national language support# pa' / Nbuild with P.$ support# runselftest / Ndo P'ake checkP during the build# x'l / Nbuild contribx'l) pgfts F NDuild with Ienable&thread&safet% To use these defines* invoke a rebuild like this0 rpm --rebuild --define 'plperl 0' --define 'pltcl 0' \ --define 'test 0' --define 'runselftest 1' \ --define 'kerberos 0' postgresql-8.2.4-1PGDG.src.rpm This line would disable the plperl* pltcl* and test subpackages* enable the regression test run during build* and disable kerberos support# =ou 'ight need to disable runselftest if there is an installed version of PostgreSQL that is a different 'a7or version fro' what %ou are tr%ing to build# The self test tends to pick up the installed libp<#so shared librar% in place of the one being built 0& ,* so if that isn?t co'patible the test will fail# .lso* %ou can?t use runselftest when doing the build as root# $ore of these conditionals 'a% be addedre'oved in the future# "ontrib !iles The contents of the contrib tree are packaged into the &contrib subpackage and are processed with 'ake and 'ake install# There is docu'entation in usrsharedocpostgres<l&contrib& HERS>6C for these 'odules# $ost of the 'odules are in usrlibpgs<l for loadable 'odules* and binaries are in usrbin# >n the future these files 'a% be split out* depending upon function and dependencies# $ore >nfor'ation =ou can get 'ore infor'ation at http0www#postgres<l#org Please help 'ake this packaging better && let us know if %ou find proble's* or better wa%s of doing things# =ou can reach us b% e&'ail at pgs<lrp's&hackersEPg!oundr%#org#