Installation PostgreSQL On Centos 7




Now, i can to tell you and teach you installation postgresql on centos 7. and i can tell you step by step how can installation until finished.
One step, you must be login to shell linux with root, and create directory "pgsql" in /var/lib/pgsql

[root@localhost /]# mkdir /var/lib/pgsql/

Next step, copy file postgresql to location directory your created with command "cp" and -R (with all copy file), in here i have file postgresql in the extention tar.

[root@localhost pgsql]# cp -Rf postgresql-8.3.5.tar.gz /var/lib/pgsql/

And next, you can move directory to location file copy with command "cd". so extract file in here, because i can build installation in location "/var/lib/pgsql" with command extract tar.

[root@localhost /]# cd /var/lib/pgsql/
[root@localhost pgsql]# tar -zxvf postgresql-8.3.5.tar.gz / xvjf postgresql-8.3.5.tar.bz2

And after extract data you can move to directory in your extract, in here inf i finished extract, you can see that is a folder that extraction data file. So you can see show new folder after extract "postgresql-8.3.5"

[root@localhost pgsql]# cd /var/lib/pgsql/postgresql-8.3.5

So, next step again, now can do installation postgres with choose file configure and running file with command "./file".

[root@localhost postgresql-8.3.5]# ./configure
[root@localhost postgresql-8.3.5]# gmake
[root@localhost postgresql-8.3.5]# make install

And then, in here i can add new user with name "postgres" because i want congiguration data postgres in here, in user postgres, dont be use another user. how can do add user ? with command "adduser hostname" and build new directory data postgres in "/usr/local/pgsql".

[root@localhost postgresql-8.3.5]# su
[root@localhost postgresql-8.3.5]# adduser postgres
[root@localhost postgresql-8.3.5]# mkdir /usr/local/pgsql/data

After create new directory, you must be change owner to postgres because in here you must be owner always postgres can be processed

[root@localhost postgresql-8.3.5]# chown postgres /usr/local/pgsql/data

Next, you can move in user root to user postgres with command "su - postgres", so in here you can do initialitation database postgres with path binary postgres. and you can be link for log file

[root@localhost postgresql-8.3.5]# su - postgres
[postgres@localhost postgresql-8.3.5]$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data

After initialitation, you can createdb with command "createdb" in binary location postgresql:

[root@localhost postgresql-8.3.5]# /usr/local/pgsql/bin/createdb test

So after do that, you can use psql with command psql and follow new database name.

[root@localhost postgresql-8.3.5]# /usr/local/pgsql/bin/psql test

And if you can exit in sql postgres, you can do command \q, or \quit or exit; , because if you dont do that, you dont move or close in sql postgres.
And the next, you can move to location data in postgresql "/usr/local/pgsql/data/" ;

[root@localhost postgresql-8.3.5]# cd /usr/local/pgsql/data/

So, in here you can do edit file pg_hba.conf for configuration postgres, why? because if you want use postgresql you must be configuration in akses data for another ip.

[root@localhost data]# vi pg_hba.conf

And the press button keyword "i" for insert, so add new ip in line "IPv4 Local connection"
# TYPE DATABASE USER CIDR-ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
#host all all 127.0.0.1/32 trust
host all all IP_PC_KITA/24 trust
# IPv6 local connections:
host all all ::1/128 trust

After added, then you can do press button "esc" in keyword and follow command shift+: --> press button "x" then enter. And then move to directory "/var/lib/pgsql/postgresql-8.3.5/contrib/start-scripts/"

[root@localhost data]# cd /var/lib/pgsql/postgresql-8.3.5/contrib/start-scripts/

So, copy folder "linux" to directory "/etc/rc.d/init.d/pgsql" and follow these step:

[root@localhost start-scripts]# cp linux /etc/rc.d/init.d/pgsql
[root@localhost start-scripts]# chmod +x /etc/rc.d/init.d/pgsql
[root@localhost start-scripts]# chkconfig --add pgsql
[root@localhost start-scripts]# ntsysv (checklist service pgsql)
[root@localhost start-scripts]# service pgsql stop
[root@localhost start-scripts]# service pgsql start

The dependencies needed during PostgreSQL installation are (Readline-devel, ncurses-devel & zlib-devel) are present in its CentOS iso
If installing postgres on different partitions (examples of cases on different partitions with folders / DATA) then there is little difference in step no 7
Follow step installation in here:

[root@localhost postgresql-8.3.5]# ./configure
[root@localhost postgresql-8.3.5]# gmake
[root@localhost postgresql-8.3.5]# make install
[root@localhost postgresql-8.3.5]# su
[root@localhost postgresql-8.3.5]# adduser postgres
[root@localhost postgresql-8.3.5]# chown postgres /DATA
[root@localhost postgresql-8.3.5]# su - postgres
[postgres@localhost postgresql-8.3.5]$ /usr/local/pgsql/bin/initdb -D /DATA
[postgres@localhost postgresql-8.3.5]$ /usr/local/pgsql/bin/postgres -D /DATA >logfile 2>&1 &

And edit file pg_hba.conf for akses ip addres.

[root@localhost postgresql-8.3.5]# cd /DATA

Last edit file postgresql.conf in line PGDATA, change PGDATA = /DATA, and dont forget change line :

#listen_addresses = '*' to --> listen_addresses = '*'
#port = 5432 to --> port = 5432

Comments