Tuesday, August 25, 2015

Red Hat7 - How to install postgresql94

Most of the content is borrowed from (http://www.unixmen.com/postgresql-9-4-released-install-centos-7/)

Exclude postgresql packages from /etc/yum/pluginconf.d/rhnplugin.conf (We will not use rhnplugin from Red Hat Satellite support):
# vim /etc/yum/pluginconf.d/rhnplugin.conf
to [main]

Download the correct RPM from http://yum.postgresql.org and install it:
# wget http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-redhat94-9.4-1.noarch.rpm
# rpm -ivh pgdg-redhat94-9.4-1.noarch.rpm

Install postgresql:
List available packages:
# yum list postgres*

Install a basic postgresql94:
# yum install postgresql94-server

Post-installation commands:
Initialize the database in postgresql:
For postgresql version 9.0 and plus, the default data directory is:

Initialize the database in PGDATA:
# /usr/pgsql-9.4/bin/postgresql94-setup initdb
Initializing database ... OK

Enable postgresql at startup:
# systemctl enable postgresql-9.4
ln -s '/usr/lib/systemd/system/postgresql-9.4.service' '/etc/systemd/system/multi-user.target.wants/postgresql-9.4.service'

Start postgresql:
# systemctl start postgresql-9.4

If you have iptables enabled, make sure you open the port 5432:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5432 -j ACCEPT

For SELinux:
setsebool -P httpd_can_network_connect_db 1

To test:
# su - postgres
# psql
psql (9.4.0)
Type "help" for help.


To set password:
postgres=# \password postgres
Enter new password:
Enter it again:
postgres=# \q

No comments: