In this article, we will examine the installation of PostgreSQL on linux, which attracts attention with its large-scale data management and increases the market share in the last years.
We will perform RPM based installation for enterprise linux based systems such as RedHat / Centos / Scientefic. In addition, we will compile from generic source code.
Installation on Redhat
1 2 3 |
yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-redhat10-10-2.noarch.rpm yum install postgresql10 yum install postgresql10-server |
The following commands are executed to start Postgres and open it automatically on boot progress.
1 2 3 |
/usr/pgsql-10/bin/postgresql-10-setup initdb systemctl enable postgresql-10 systemctl start postgresql-10 |
Installation completed then we can connect to postgresql now. To check whether it is runing properly or not you can execute following commands. (5432 default TCP port for postgreSQL)
1 2 3 4 5 6 7 |
[root@yesrib ~]# netstat -ntlp |grep 5432 tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN 17795/postmaster tcp6 0 0 :::5432 :::* LISTEN 17795/postmaster sudo su - postgres -bash-4.2$ psql psql (10.3) Type "help" for help. |
1 2 3 4 |
postgres=# select version(); --------------------------------------------------------------------------------------------------------- PostgreSQL 10.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16), 64-bit (1 row) |
Steps to install from source code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
yum install -y readline-devel libtermcap-devel zlib zlib-devel tar xvfz postgresql-9.6.6 cd postgresql-9.6.6 ./configure mkdir /pg966 ./configure --prefix=/pg966 make (make -h 8 ###for 8 core parallizm) make install cd contrib make make install mkdir /pg966/data chown postgres.postgres /pg966/data su - postgres initdb -D /data -E unicode |
.
.
Success. You can now start the database server using:
startup/shutdown
1 2 |
pg_ctl -D /usr/local/pgsql966/data -l logfile start pg_ctl stop |