Cluster:
A database cluster is a collection of databases that are managed by a single server instance.
-> It will creates the directories in which the database data will live generating the shared catalog tables and creating the template1 and postgres databases.
-> Before that add the user in which you are going to create the data directory. From the root we can not initialize.
cmd:adduser postgres
-> Now the user is created and login as postgres.
cmd:su postgres
pwd:pwd#1234
-> If we want to change the password of postgres
cmd:passwd postgres
-> Create a new directory to initilize the cluster.
cmd: mkdir /DB/postgresql-9.5.8
->Now the data directory is create. If the postgres user does not have the super user privilliges then change the privilliges.
cmd: sudo chown postgres:postgres /DB/postgres9.5.8/
-> To add the user as sudo user
cmd: sudo usermod -a -G sudo postgres
Note: The default installation directory of postgresql will be available here.
/usr/local/pgsql/bin/
-> Now we can initialize the database cluster using the cmd.
cmd:/usr/local/pgsql/bin/initdb -D /DB/postgres9.5.8/
-> Finally the cluster is created and all the database instances will be stored here.