Install PostgreSQL 8.4 Database Server on CentOS, Fedora, Red Hat

This is quick guide howto install PostgreSQL 8.4 (current stable 8.4.7) database server on CentOS, Fedora and Red Hat. Fedora 14, Fedora 13, CentOS 5.5 and Red Hat (RHEL) 5.5 has PostgreSQL 8.4 database server as default so extra repositories is not needed. Personally, I like to use Postgres own repositories, because the latest version of PostgreSQL may be quickly and easily installed. The following commands run as root and postgres user, so “su -” or “sudo -i” first.

Install PostgreSQL 8.4 Database Server Using PostgreSQL’s repositories

Install PostgreSQL repository:

Install postgresql and postgresql-server packages from PostgreSQL’s repositories:

Alternative PostgreSQL 8.4 Install Method for Fedora 12, Fedora 13, CentOS 5.5, Red Hat (RHEL) 5.5

Install postgresql and postgresql-server packages on CentOS 5.5 and Red Hat (RHEL) 5.5:

Install postgresql and postgresql-server packages on Fedora 12 and Fedora 13:

Configure PostgreSQL 8.4 Database Server

Initialize the cluster first with initdb command:

Edit /var/lib/pgsql/data/postgresql.conf file:

Set PostgreSQL server to listen all addresses and Change PostgreSQL port (default is 5432). Add/Uncomment/Edit following lines:

Edit /var/lib/pgsql/data/pg_hba.conf file:

Add (example) your local network with md5 passwords:

Start/Restart PostgreSQL Server:

Change to postgres user:

Create test database (as postgres user):

Login test database (as postgres user):

Create New “testuser” Role with Superuser and Password:

Open PostgreSQL Port (5432) on Iptables Firewall (as root user again)

Edit /etc/sysconfig/iptables file:

Add following line before COMMIT:

Restart Iptables Firewall:

Test remote connection:

Share this post

38 Comments

  1. I am finally installing postgreSQL on my Centos 5.8….using nano editor i Set PostgreSQL server to listen all addresses and Change PostgreSQL port (default is 5432). Just don’t know how to add local host when my IP looks likes this…..192.168.77.85….example shows something like 10.20.4.0/24
    *********************************************
    host all all xx.xx.xx.xx/xx md5
    # Example
    host all all 10.20.4.0/24 md5
    *********************************************
    Please help….assignment is haunting me. Thanks

    Reply
    • Hi John,

      You can add single address, like following:

      Reply
  2. Hi all,

    I can’t connect localhost to postgres in RHEL 6, I try:

    # psql -h localhost -U testuser test
    psql: FATAL: la autentificación Ident falló para el usuario «testuser»

    But in my /var/lib/pgsql/data/pg_hba.conf I have:

    host all all 127.0.0.1/32 ident
    host all all 0.0.0.0/0 md5

    Also I have disabled iptables too so, what can be happening?

    Regards,

    Reply
    • Hi Pedro,

      You use ident-based authentication (uses your os user accounts), but I guess you want use trust or md5 instead?

      Reply
  3. [root@localhost ~]# /etc/init.d/postgresql initdb
    Data directory is not empty! [FAILED]

    What am I missing?

    Reply
      • Third party software requirements. I’m not sure if 9.2 works with Cisco DCNM. But I’ll give it a try.

        Reply
        • I see.

          Actually PostgreSQL 8.4 should work still okay, so could you post output of following commands:

          Do you have already database running, or tried to install it another way?

          Reply
          • JR,

            I could’ve sworn I replied back with my results. Anyways thanks for the guide it helped me alot. I’m not sure why I couldn’t find the iptables for Cent0S6.4 but I skipped that step and tested. Everything is fine now. I ended up starting from scratch, uninstalled the software and removing psql folders, started the guide over using this guide and the 9.2 guide. Thanks again.

            Reply
  4. Also even if I couldn’t add the repo I still ran:

    yum install postgresql84 postgresql84-server postgresql84-contrib

    I got a list of what was available:

    ================================================================================
    Installing:
    postgresql84 x86_64 8.4.13-1.el5_8 base 3.7 M
    postgresql84-contrib x86_64 8.4.13-1.el5_8 base 399 k
    postgresql84-server x86_64 8.4.13-1.el5_8 base 5.2 M
    Installing for dependencies:
    libxslt x86_64 1.1.17-4.el5_8.3 base 424 k
    postgresql84-libs x86_64 8.4.13-1.el5_8 base 211 k

    Transaction Summary
    ================================================================================
    Install 5 Package(s)
    Upgrade 0 Package(s)

    Total download size: 9.9 M
    Is this ok [y/N]:

    But when I hit y and enter I get this:

    Downloading Packages:
    http:///mrepo/rhel5-prod-x86_64/RPMS.os/postgresql84-libs-8.4.13-1.el5_8.x86_64.rpm: [Errno 14] HTTP Error 404: Not Found
    Trying other mirror.
    http:///mrepo/rhel5-prod-x86_64/RPMS.os/postgresql84-contrib-8.4.13-1.el5_8.x86_64.rpm: [Errno 14] HTTP Error 404: Not Found
    Trying other mirror.
    http:///mrepo/rhel5-prod-x86_64/RPMS.os/libxslt-1.1.17-4.el5_8.3.x86_64.rpm: [Errno 14] HTTP Error 404: Not Found
    Trying other mirror.
    http://puppet.unica.net/mrepo/rhel5-prod-x86_64/RPMS.os/postgresql84-8.4.13-1.el5_8.x86_64.rpm: [Errno 14] HTTP Error 404: Not Found
    Trying other mirror.
    http:///mrepo/rhel5-prod-x86_64/RPMS.os/postgresql84-server-8.4.13-1.el5_8.x86_64.rpm: [Errno 14] HTTP Error 404: Not Found
    Trying other mirror.

    Error Downloading Packages:
    postgresql84-contrib-8.4.13-1.el5_8.x86_64: failure: postgresql84-contrib-8.4.13-1.el5_8.x86_64.rpm from base: [Errno 256] No more mirrors to try.
    postgresql84-8.4.13-1.el5_8.x86_64: failure: postgresql84-8.4.13-1.el5_8.x86_64.rpm from base: [Errno 256] No more mirrors to try.
    postgresql84-libs-8.4.13-1.el5_8.x86_64: failure: postgresql84-libs-8.4.13-1.el5_8.x86_64.rpm from base: [Errno 256] No more mirrors to try.
    postgresql84-server-8.4.13-1.el5_8.x86_64: failure: postgresql84-server-8.4.13-1.el5_8.x86_64.rpm from base: [Errno 256] No more mirrors to try.
    libxslt-1.1.17-4.el5_8.3.x86_64: failure: libxslt-1.1.17-4.el5_8.3.x86_64.rpm from base: [Errno 256] No more mirrors to try.

    Reply
  5. Is it possible to have postgresql installed in a different directory?

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *