Friday, 30 August 2019

Installating PostgreSQL Server on CentOS, RHEL 6 / 7 Systems


This article will help you for installing PostgreSQL on CentOS, RHEL 6 / 7 Systems



Adding PostgreSQL Yum Repository of OS

The first step is to install PostgreSQL repository in your system : 

Ø  CentOS/RHEL 7 // rpm -Uvh http://yum.postgresql.org/9.6/redhat/rhel-7-x86_64/pgdg-redhat96-9.6-3.noarch.rpm







·         Installing PostgreSQL Server


After enabling PostgreSQL yum repository in your system use following command to install PostgreSQL 9.6 on your system with yum package manager.


$ yum install postgresql96-server postgresql96 




·         Initialize the PGDATA


 After installing PostgreSQL server, It’s required to initialize it before using the first time. Why ?  

 All the data needed for a database cluster is stored within the cluster's data directory, commonly referred to as PGDATA

Do not run the initdb program while logged in as the root user!  The command may fail with below error message. 











The cluster needs to be created and owned by whichever normal user is going to become the new cluster's database superuser.

[root@oracleasm1 9.6]# su – postgres

And then initialize the DB
























/usr/pgsql-9.6/bin/postgresql96-setup initdb
Above command will take some time to initialize PostgreSQL first time.






·         Starting the  PostgreSQL Server

Once the installation succeeded , you will see status as below.  Use the following command to start PostgreSQL services








Verify the Installation






This verifies you have installed PostgreSQL 9.6 on your server.



we see the background processes such as logger process, checkpointer process and stats collector process.






What is initdb ? 

initdb is used to initialize a new data directory for a database cluster, and instruct postmaster to start up using that data cluster instead of the default

-          initdb is also used  to correct a corrupted template1 database by executing initb with the -t (or - -template ) parameter. This will re-generate the template1 database from scratch.
-          
-    

      Usage :

     [ -D dbdir | - -pgdata= dbdir ]

The directory that you wish to initialize a new database cluster within. If you do not specify a directory name, the command will look at the PGDATA environment variable.




Next 

Creation of PosgreSQL database 



No comments:

Post a Comment