YUM installation PostgreSQL

Source: Internet
Author: User
Tags postgresql postgresql version

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

    • Fedora
    • Red Hat Enterprise Linux
    • Centos
    • Scientific Linux
    • Oracle Enterprise Linux

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

    • A List of available packages
    • Repository packages for different version combinations
    • Status of RPM Builds
Contents [hide]
  • 1 instructions
    • 1.1 Configure your YUM repository
    • 1.2 Install pgdg RPM file
    • 1.3 Install PostgreSQL
    • 1.4 Post-Installation Commands
      • 1.4.1 Data Directory
      • 1.4.2 Initialize
      • 1.4.3 Startup
    • 1.5 Control Service
  • 2 removing
  • 3 Support
  • 4 after installation
Instructionsconfigure 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 sections (s) identified above, you need to append a line (otherwise dependencies might resolve to the PostgreSQL supp Lied by the base repository):

exclude=postgresql*
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.4 on CentOS 6 64-bit:

http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.4-1.noarch.rpm
Install PostgreSQL

To list available packages:

List postgres*

For example, to install a basic PostgreSQL 9.4 server:

Install postgresql94-Server

Other packages can is 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> would 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.4

For versions 8.x, the <name> are 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.4/data 

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

/var/lib/pgsql/data/
Initialize

The first command (only needed once) was to initialize the database in PGDATA.

<name>  initdb

e.g. for version 9.4:

Postgresql-9Initdb

If the previous command did not work, try directly calling the Setup binary, located in a similar naming scheme:

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

e.g. for version 9.4:

/usr/pgsql-9.4/bin/postgresql94-setup initdb 

Startup

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

<name>  on

e.g. for version 9.4:

Chkconfig postgresql-9.   on

In RHEL 7+, try:

Enable PostgreSQL
Control Service

To control the database service, use:

<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


e.g. to start version 9.4:

Postgresql-9Start


With RHEL 7.1+ and CentOS 7.1+, SYSTEMD is introduced. Use this instead:

Postgresql-9. 4postgresql-9.4.service   
removing

To remove everything:

Yum Erase postgresql94*

Or remove individual packages as desired.

YUM installation PostgreSQL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.