YUM Installation

From PostgreSQL wiki

(Difference between revisions)
Jump to: navigation, search
(First steps in PostgreSQL)
(correction to new initdb method; use PostgreSQL 9.3 as example)
Line 22: Line 22:
 
=== Download and install PGDG RPM file ===
 
=== Download and install PGDG RPM file ===
  
A PGDG file is available for each distribution/architecture/database version combination. Browse http://yum.postgresql.org and find your correct RPM. For example, to install PostgreSQL 9.1 on CentOS 6 32-bit:
+
A PGDG file is available for each distribution/architecture/database version combination. Browse http://yum.postgresql.org and find your correct RPM. For example, to install PostgreSQL 9.3 on CentOS 6 64-bit:
  curl -O http://yum.postgresql.org/9.1/redhat/rhel-6-i386/pgdg-centos91-9.1-4.noarch.rpm
+
  curl -O http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-1.noarch.rpm
  
 
Now install RPM distribution:
 
Now install RPM distribution:
  rpm -ivh pgdg-centos91-9.1-4.noarch.rpm
+
  rpm -ivh pgdg-centos93-9.3-1.noarch.rpm
  
 
=== Install PostgreSQL ===
 
=== Install PostgreSQL ===
Line 33: Line 33:
 
  yum list postgres*
 
  yum list postgres*
  
For example, to install a basic PostgreSQL 9.1 server:
+
For example, to install a basic PostgreSQL 9.3 server:
  yum install postgresql91-server
+
  yum install postgresql93-server
  
 
Other packages can be installed according to your needs.
 
Other packages can be installed according to your needs.
Line 44: Line 44:
 
In the commands below, the value of ''<name>'' will vary depending on the version of PostgreSQL used.   
 
In the commands below, the value of ''<name>'' will vary depending on the version of PostgreSQL used.   
  
For PostgreSQL version 9.0 and above, the ''<name>'' includes the ''major.minor'' version of PostgreSQL, e.g., ''postgresql-9.1''
+
For PostgreSQL version 9.0 and above, the ''<name>'' includes the ''major.minor'' version of PostgreSQL, e.g., ''postgresql-9.3''
  
For versions 7.x and 8.x, the ''<name>'' is always ''postgresql'' (without the version signifier).
+
For versions 8.x, the ''<name>'' is always ''postgresql'' (without the version signifier).
  
 
==== Data Directory ====
 
==== Data Directory ====
Line 56: Line 56:
  
 
For example:  
 
For example:  
  /var/lib/pgsql/9.1/data
+
  /var/lib/pgsql/9.3/data
  
 
For versions 7.x and 8.x, default data directory is:
 
For versions 7.x and 8.x, default data directory is:
Line 62: Line 62:
  
 
==== Initialize ====
 
==== Initialize ====
The first command (only needed once) is to initialize the database in PGDATA:
+
The first command (only needed once) is to initialize the database in PGDATA. The setup binary is located in a similar naming scheme:
  service ''<name>'' initdb
+
  /usr/pgsql-''y.x''/bin/postgresql''yx''-setup initdb
 +
 
 +
E.g. for version 9.3:
 +
/usr/pgsql-9.3/bin/postgresql93-setup initdb
  
 
==== Startup ====
 
==== Startup ====
 
If you want PostgreSQL to start automatically when the OS starts:
 
If you want PostgreSQL to start automatically when the OS starts:
 
  chkconfig ''<name>'' on
 
  chkconfig ''<name>'' on
 +
 +
E.g. for version 9.3:
 +
chkconfig postgresql-9.3 on
  
 
=== Control service ===
 
=== Control service ===
Line 80: Line 86:
 
== Removing ==
 
== Removing ==
 
To remove everything:
 
To remove everything:
  yum erase postgresql91*
+
  yum erase postgresql93*
  
 
Or remove individual packages as desired.
 
Or remove individual packages as desired.

Revision as of 11:40, 26 September 2013

PostgreSQL can be installed using RPMs (binary) or SRPMs (source) managed by YUM. This is available for the following Linux distributions (both 32- and 64-bit platforms):

  • Fedora (versions 16 and up)
  • Red Hat Enterprise Linux (versions 5 and up)
  • CentOS (versions 5 and up)
  • Scientific Linux (versions 5 and up)

See links from the main repository, http://yum.postgresql.org:

Contents

Instructions

Configure your YUM repository

Locate and edit your distributions .repo file, located:

  • On Fedora: /etc/yum.repos.d/fedora.repo and /etc/yum.repos.d/fedora-updates.repo, [fedora] sections
  • On CentOS: /etc/yum.repos.d/CentOS-Base.repo, [base] and [updates] sections
  • On Red Hat: /etc/yum/pluginconf.d/rhnplugin.conf [main] section

To the section(s) identified above, you need to append a line:

exclude=postgresql*

Download and install PGDG RPM file

A PGDG file is available for each distribution/architecture/database version combination. Browse http://yum.postgresql.org and find your correct RPM. For example, to install PostgreSQL 9.3 on CentOS 6 64-bit:

curl -O http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-1.noarch.rpm

Now install RPM distribution:

rpm -ivh pgdg-centos93-9.3-1.noarch.rpm

Install PostgreSQL

To list available packages:

yum list postgres*

For example, to install a basic PostgreSQL 9.3 server:

yum install postgresql93-server

Other packages can be installed according to your needs.

Post-installation commands

After installing the packages, a database needs to be initialized and configured.

In the commands below, the value of <name> will vary depending on the version of PostgreSQL used.

For PostgreSQL version 9.0 and above, the <name> includes the major.minor version of PostgreSQL, e.g., postgresql-9.3

For versions 8.x, the <name> is always postgresql (without the version signifier).

Data Directory

The PostgreSQL data directory contains all of the data files for the database. The variable PGDATA is used to reference this directory.

For PostgreSQL version 9.0 and above, the default data directory is:

/var/lib/pgsql/<name>/data

For example:

/var/lib/pgsql/9.3/data

For versions 7.x and 8.x, default data directory is:

/var/lib/pgsql/data/

Initialize

The first command (only needed once) is to initialize the database in PGDATA. The setup binary is located in a similar naming scheme:

/usr/pgsql-y.x/bin/postgresqlyx-setup initdb

E.g. for version 9.3:

/usr/pgsql-9.3/bin/postgresql93-setup initdb

Startup

If you want PostgreSQL to start automatically when the OS starts:

chkconfig <name> on

E.g. for version 9.3:

chkconfig postgresql-9.3 on

Control service

To control the database service, use:

service <name> <command>

where <command> can be:

  • start : start the database
  • stop : stop the database
  • restart : stop/start the database; used to read changes to core configuration files
  • reload : reload pg_hba.conf file while keeping database running

Removing

To remove everything:

yum erase postgresql93*

Or remove individual packages as desired.

Support

  • Email: maintainers@lists.pgrpms.org or pgsql-pkg-yum@postgresql.org (requires subscription)

After installation

First steps in PostgreSQL

See also

Personal tools