In this article, we will examine the installation of PostgreSQL, which has attracted attention with its ability to handle large-scale data, has increased its market share in recent years, and is completely open-source, on Linux systems.
We will perform the RPM-based installation for enterprise Linux-based systems such as RedHat/CentOS/Scientific. Additionally, we will compile and install it from generic source code.
Installation on RedHat
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 enable it to start automatically at boot.
/usr/pgsql-10/bin/postgresql-10-setup initdb systemctl enable postgresql-10 systemctl start postgresql-10
Installation is complete; now we can connect.
The default port of PostgreSQL is 5432. Let’s check if it’s running.
[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.
[sql]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)[/sql]
Installation from Source Code
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:
Stop/Start
pg_ctl -D /usr/local/pgsql966/data -l logfile start pg_ctl stop