How to Install and Configuration of PostgreSQL to a Headless CentOS Server Step-By-Step

Step 1: Install PostgreSQL

This step can install the PostgreSQL package cluster that comes with 64-bit CentOS.  This cluster includes the subsequent packages:
Open a terminal on the target server.  Login to the basis account.

Install the PostgreSQL server package and its dependencies victimization YUM. make sure to disable gpg signature checking, so as to avoid annoying warnings:
[root]# yum install postgresql-server --nogpgcheck
Installation of this package cluster can produce the subsequent subdirectories:

Step 2: Initialize the info
Note that info low-level formatting on RHEL (and so additionally CentOS) are somewhat totally different than different UNIX operating system flavors.

Execute the subsequent command:
[root]# service postgresql initdb –D /var/lib/pgsql/data
Or, you will got to initialize the info victimization this approach:
[root]# /etc/init.d/postgresql begin

Step 3: begin the Service
Execute the subsequent command:
[root]# /etc/rc.d/init.d/postgresql begin

Step 4: produce the Symlink
The default location on RHEL (and so additionally CentOS) systems is /var/lib/pgsql.  However, applications like bash can expect the situation to be /usr/local/pgsql. this could be fastened via soft symlink:
[root]# ln –s /var/lib/pgsql   /usr/local/pgsql

Step 5: guarantee possession
Check to create certain that the postgres account owns the pgsql directory and subdirectories:
[root]# ls –l /var/lib
If not, you may got to amendment possession. once dynamical possession, do therefore recursively. check the account by work into it and so performing arts stop and begin commands:
[root]# su – postgres 
-bash-3.2$ pg_ctl –stop
-bash-3.2$ pg_ctrl begin
Step 6: modify External consumer Access

Stop the PostgreSQL instance in order that you'll be able to edit configuration settings files:
[root]# service postgresql stop
Save a duplicate of the initial configuration file:
[root]# cp /var/lib/pgsql/data/postgresql.conf /var/lib/pgsql/data/postgresql.conf.ORIGINAL
Update the PostgreSQL configuration file to modify it to concentrate in on the server science address at the default port:
[root]# vi /var/lib/pgsql/data/postgresql.conf
Uncomment the road “listen_addresses” and set it adequate ‘*’.  Uncomment the “port” and leave it set to the default port (5432). Save a duplicate of the initial security access file:
[root]# cp /var/lib/pgsql/data/pg_hba.conf /var/lib/pgsql/data/pg_hba.conf.ORIGINAL
Update the PostgreSQL security access file to modify consumer access to the present PostgreSQL instance from inside the subnet
[root]# vi /var/lib/pgsql/data/pg_hba.conf
Identify the mask acceptable to your network. for instance, if it's, you'd add this line:
host all all  md5
Additionally, if you would like to be ready to use a graphical user interface to move with this postgresql instance over a VPN, you’ll got to determine the science address that's received by the PostgreSQL instance and add this to the list of hosts allowed to attach. for instance, if your VPN science address was sixty nine.143.195.130, then to permit solely your science address to be ready to connect you'd add the following:
host all all sixty nine.143.195.130/32  md5
Startup the postgressql service back up:
[root]# service postgresql begin
This completes this PostgreSQL installation procedure.


Post a Comment