Search Engine



RedhatEnterpriseLinux Blog

Installing PostgreSQL9.2 on Redhat (RHEL5 & 6)

Installing PostgreSQL9.2 on Redhat (RHEL)
the same installation you can use for CentOS

1. Install PostgreSQL 9.2.1 Database Server on CentOS/Red Hat (RHEL)
1.1 Change root user or login as a root
su –
Example: su - root
1.2 Red Hat (RHEL)
Add exclude to /etc/yum/pluginconf.d/rhnplugin.conf file [main] section:

1.3 Install PostgreSQL 9.2 Repository
## Red Hat Enterprise Linux 6 - i386 - 32-bit ##
rpm -Uvh
## Red Hat Enterprise Linux 6 - x86_64 - 64-bit ##
rpm -Uvh
 ## Red Hat Enterprise Linux 5 - i386 - 32-bit ##
rpm -Uvh
 ## Red Hat Enterprise Linux 5 - x86_64 - 64-bit ##
rpm -Uvh

1.4 Install PostgreSQL 9.2 with YUM
yum install postgresql postgresql-server postgresql-contrib

2. Configure PostgreSQL 9.2
2.1 Set PostgreSQL Server to Listen Addresses and Set Port
Open /var/lib/pgsql/9.2/data/postgresql.conf file, and add/uncomment/modify following:
listen_addresses = '*'
port = 5432
If you want just localhost setup, then use following:
listen_addresses = 'localhost'
port = 5432

2.2 Set PostgreSQL Permissions
Modify PostgreSQL /var/lib/pgsql/9.2/data/pg_hba.conf (host-based authentication) file:
# Local networks
host       all            all                    xx.xx.xx.xx/xx           md5
# Example
host       all            all         md5
# Example 2
host       test        testuser            md5

2.3 Start PostgreSQL Server and Autostart PostgreSQL on Boot
CentOS/Red Hat (RHEL)
## Start PostgreSQL 9.2 ##
service postgresql-9.2 start
## OR ##
/etc/init.d/postgresql-9.2 start
 ## Start PostgreSQL 9.2 on every boot ##
chkconfig --levels 235 postgresql-9.2 on

2.4 Create Test Database and Create New User
Change to postgres user
su - postgres
Create test database (as postgres user) type the following
createdb test
Login test database (as postgres user)
psql test
Create New “dbuser” Role with Superuser and Password
Test Connection from localhost (as Normal Linux User)
psql -h localhost -U dbuser test

3. Enable Remote Connections to PostgreSQL Server –> Open PostgreSQL Port (5432) on Iptables Firewall
3.1. Edit /etc/sysconfig/iptables file
vi /etc/sysconfig/iptables

3.2. Add following line before -A INPUT -j REJECT…
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5432 -j ACCEPT

CentOS/Red Hat (RHEL)
service iptables restart
## OR ##
/etc/init.d/iptables restart

3.3 Test remote connection
psql -h dbserver_name_or_ip_address -U dbuser -W test
Psql –h –U dbuser –W test


Post a Comment

Powered by Blogger.


Copyright © Redhat Enterprise linux. Original Concept and Design by My Blogger Themes
My name is Abdul Razaq but people call me Raziq. Here is my home page: I live in Quetta, Pakistan and work as an IT-Engineer.