How to install PostgreSQL with pgAdmin on Centos8

PostgreSQL is the most advanced RDBMS and pgAdmin is a web UI for Postgres.

Environment Specification:

  • CPU - 4 Ghz (2 cores)
  • Memory - 4 GB
  • Storage -  80GB
  • Operating System - CentOS 8.4
  • Hostname – postgres
  • IP Address - 192.168.8.133 /24

Update Linux Server Packages:

Use a ssh client and login to postgres as root user.

Update Linux server packages by using dnf command.

[root@postgres ~]# dnf update -y
Last metadata expiration check: 0:03:30 ago on Mon 21 Nov 2022 08:22:50 PM HKT.
Dependencies resolved.
Nothing to do.
Complete!
[root@postgres ~]#

Check the Linux operating system and Kernel version.

[root@postgres ~]# uname -r
4.18.0-408.el8.x86_64
[root@postgres ~]# cat /etc/redhat-release
CentOS Stream release 8
[root@postgres ~]# 

Installing Postgres Official Yum Repository:

[root@postgres ~]# dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
Last metadata expiration check: 0:05:05 ago on Mon 21 Nov 2022 08:22:50 PM HKT.
pgdg-redhat-repo-latest.noarch.rpm                                                                                                                                                                       5.8 kB/s |  13 kB     00:02    
Dependencies resolved.
=========================================================================================================================================================================================================================================
 Package                                                       Architecture                                        Version                                               Repository                                                 Size
=========================================================================================================================================================================================================================================
Installing:
 pgdg-redhat-repo                                              noarch                                              42.0-28                                               @commandline                                               13 k

Transaction Summary
=========================================================================================================================================================================================================================================
Install  1 Package

Total size: 13 k
Installed size: 14 k
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                                                 1/1 
  Installing       : pgdg-redhat-repo-42.0-28.noarch                                                                                                                                                                                 1/1 
  Verifying        : pgdg-redhat-repo-42.0-28.noarch                                                                                                                                                                                 1/1 

Installed:
  pgdg-redhat-repo-42.0-28.noarch                                                                                                                                                                                                        

Complete!
[root@postgres ~]# 

Disable the PostgreSQL module in standard yum repository by executing following command.

[root@postgres ~]# dnf -qy module disable postgresql
Importing GPG key 0x442DF0F8:
 Userid     : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
 Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Importing GPG key 0x442DF0F8:
 Userid     : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
 Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Importing GPG key 0x442DF0F8:
 Userid     : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
 Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Importing GPG key 0x442DF0F8:
 Userid     : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
 Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Importing GPG key 0x442DF0F8:
 Userid     : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
 Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Importing GPG key 0x442DF0F8:
 Userid     : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
 Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Importing GPG key 0x442DF0F8:
 Userid     : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
 Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
[root@postgres ~]# 

Installing Postgres Database Server on CentOS 8:

Install Postgres database server 13 (latest at the time of this writing) on your Linux server by using dnf command.

[root@postgres ~]# dnf install -y postgresql13-server
Last metadata expiration check: 0:07:16 ago on Mon 21 Nov 2022 08:30:01 PM HKT.
Dependencies resolved.
=========================================================================================================================================================================================================================================
 Package                                                        Architecture                                      Version                                                        Repository                                         Size
=========================================================================================================================================================================================================================================
Installing:
 postgresql13-server                                            x86_64                                            13.9-1PGDG.rhel8                                               pgdg13                                            5.5 M
Installing dependencies:
 postgresql13                                                   x86_64                                            13.9-1PGDG.rhel8                                               pgdg13                                            1.5 M
 postgresql13-libs                                              x86_64                                            13.9-1PGDG.rhel8                                               pgdg13                                            417 k

Transaction Summary
=========================================================================================================================================================================================================================================
Install  3 Packages

Total download size: 7.4 M
Installed size: 31 M
Downloading Packages:
(1/3): postgresql13-libs-13.9-1PGDG.rhel8.x86_64.rpm                                                                                                                                                     147 kB/s | 417 kB     00:02    
(2/3): postgresql13-13.9-1PGDG.rhel8.x86_64.rpm                                                                                                                                                          429 kB/s | 1.5 MB     00:03    
(3/3): postgresql13-server-13.9-1PGDG.rhel8.x86_64.rpm                                                                                                                                                   1.2 MB/s | 5.5 MB     00:04    
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                    1.5 MB/s | 7.4 MB     00:04     
PostgreSQL 13 for RHEL / Rocky 8 - x86_64                                                                                                                                                                1.6 MB/s | 1.7 kB     00:00    
Importing GPG key 0x442DF0F8:
 Userid     : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
 Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                                                 1/1 
  Installing       : postgresql13-libs-13.9-1PGDG.rhel8.x86_64                                                                                                                                                                       1/3 
  Running scriptlet: postgresql13-libs-13.9-1PGDG.rhel8.x86_64                                                                                                                                                                       1/3 
  Installing       : postgresql13-13.9-1PGDG.rhel8.x86_64                                                                                                                                                                            2/3 
  Running scriptlet: postgresql13-13.9-1PGDG.rhel8.x86_64                                                                                                                                                                            2/3 
  Running scriptlet: postgresql13-server-13.9-1PGDG.rhel8.x86_64                                                                                                                                                                     3/3 
  Installing       : postgresql13-server-13.9-1PGDG.rhel8.x86_64                                                                                                                                                                     3/3 
  Running scriptlet: postgresql13-server-13.9-1PGDG.rhel8.x86_64                                                                                                                                                                     3/3 
  Verifying        : postgresql13-13.9-1PGDG.rhel8.x86_64                                                                                                                                                                            1/3 
  Verifying        : postgresql13-libs-13.9-1PGDG.rhel8.x86_64                                                                                                                                                                       2/3 
  Verifying        : postgresql13-server-13.9-1PGDG.rhel8.x86_64                                                                                                                                                                     3/3 

Installed:
  postgresql13-13.9-1PGDG.rhel8.x86_64                                     postgresql13-libs-13.9-1PGDG.rhel8.x86_64                                     postgresql13-server-13.9-1PGDG.rhel8.x86_64                                    

Complete!
[root@postgres ~]#

You need to execute following command once to initialize the Postgres database.

[root@postgres ~]# /usr/pgsql-13/bin/postgresql-13-setup initdb
Initializing database ... OK

[root@postgres ~]# 

Enable and start Postgres database service.

[root@postgres ~]# 
[root@postgres ~]# systemctl enable --now postgresql-13
Created symlink /etc/systemd/system/multi-user.target.wants/postgresql-13.service → /usr/lib/systemd/system/postgresql-13.service.
[root@postgres ~]#

Check the status of Postgres database service.

[root@postgres ~]# 
[root@postgres ~]# systemctl status postgresql-13.service
● postgresql-13.service - PostgreSQL 13 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-13.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2022-11-21 20:42:18 HKT; 36s ago
     Docs: https://www.postgresql.org/docs/13/static/
  Process: 47479 ExecStartPre=/usr/pgsql-13/bin/postgresql-13-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
 Main PID: 47485 (postmaster)
    Tasks: 8 (limit: 24548)
   Memory: 16.9M
   CGroup: /system.slice/postgresql-13.service
           ├─47485 /usr/pgsql-13/bin/postmaster -D /var/lib/pgsql/13/data/
           ├─47486 postgres: logger 
           ├─47488 postgres: checkpointer 
           ├─47489 postgres: background writer 
           ├─47490 postgres: walwriter 
           ├─47491 postgres: autovacuum launcher 
           ├─47492 postgres: stats collector 
           └─47493 postgres: logical replication launcher 

Nov 21 20:42:18 postgres systemd[1]: Starting PostgreSQL 13 database server...
Nov 21 20:42:18 postgres postmaster[47485]: 2022-11-21 20:42:18.296 HKT [47485] LOG:  redirecting log output to logging collector process
Nov 21 20:42:18 postgres postmaster[47485]: 2022-11-21 20:42:18.296 HKT [47485] HINT:  Future log output will appear in directory "log".
Nov 21 20:42:18 postgres systemd[1]: Started PostgreSQL 13 database server.
[root@postgres ~]#

Check the version of installed PostgreSQL server.

[root@postgres ~]# psql -V
psql (PostgreSQL) 13.9
[root@postgres ~]# 

Switch to postgres user and connect to psql shell to set admin user password.

[root@postgres ~]# 
[root@postgres ~]# psql -V
psql (PostgreSQL) 13.9
[root@postgres ~]# 
[root@postgres ~]# 
[root@postgres ~]# su - postgres
[postgres@postgres ~]$ psql
psql (13.9)
Type "help" for help.

postgres=# ALTER USER postgres WITH PASSWORD 'postgres';
ALTER ROLE
postgres=# \q
[postgres@postgres ~]$

Configure Postgres Database Service for Network Access:

PostgreSQL default service port is 5432/tcp. Execute the following command to verify that PostgreSQL service is listening on this port.

[postgres@postgres ~]$ ss -tulpn | grep 5432
tcp   LISTEN 0      128         127.0.0.1:5432       0.0.0.0:*    users:(("postmaster",pid=47485,fd=7))
tcp   LISTEN 0      128             [::1]:5432          [::]:*    users:(("postmaster",pid=47485,fd=6))
[postgres@postgres ~]$ 

As you may notice that the PostgreSQL service is initially runs on localhost interface only. However, to make our Postgres database available for network clients, you have to configure PostgreSQL to run on all (or on some specific) interfaces.

For this purpose, you have to edit PostgreSQL configuration file in vim text editor.

# vi /var/lib/pgsql/13/data/postgresql.conf

Search for following directive therein.

# listen_addresses = 'localhost'

And replace it with the following directive.

listen_addresses = '*'

Your Postgres database service is now configured to listen on all network interfaces.

Allow network clients to access PostgreSQL service in pg_hba.conf file.

[root@postgres ~]# echo "host all all 192.168.8.0/24 md5" >> /var/lib/pgsql/13/data/pg_hba.conf
[root@postgres ~]# 

Restart Postgres database service to apply changes.

[root@postgres ~]# systemctl restart postgresql-13.service
[root@postgres ~]# 
[root@postgres ~]#

Again check the network services by using ss command.

[root@postgres ~]# 
[root@postgres ~]# ss -tulpn | grep 5432
tcp   LISTEN 0      128           0.0.0.0:5432       0.0.0.0:*    users:(("postmaster",pid=49011,fd=6))                     
tcp   LISTEN 0      128              [::]:5432          [::]:*    users:(("postmaster",pid=49011,fd=7))                     
[root@postgres ~]# 

Postgres Service is now running on all network interfaces.

Configure Linux Firewall for Postgres Database Service:

In CentOS 8, we already have a firewall service for PostgreSQL, therefore we are allowing it by using firewall-cmd command. However, you can create a custom firewall service of your own, if your PostgreSQL server is configured to listen on a non-default port.

[root@postgres ~]# systemctl status firewall-cmd
Unit firewall-cmd.service could not be found.
[root@postgres ~]# systemctl status --now firewalld       
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)
[root@postgres ~]# systemctl enable --now firewalld      
Created symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service → /usr/lib/systemd/system/firewalld.service.
Created symlink /etc/systemd/system/multi-user.target.wants/firewalld.service → /usr/lib/systemd/system/firewalld.service.
[root@postgres ~]# firewall-cmd --permanent --add-service=postgresql
success
[root@postgres ~]# firewall-cmd --reload
success
[root@postgres ~]# 

Postgres database server has been installed on Linux server.

Installing pgAdmin Yum Repository on CentOS 8:

pgAdmin is a popular web interface for database administration of PostgreSQL databases.

Although pgAdmin is also provided within PostgreSQL official yum repositories. But it doesn’t work on our CentOS 8 server.

Therefore, we are installing the latest stable version of pgAdmin from pgAdmin official yum repository.

For this purpose, first you need to remove the PostgreSQL yum repositories from your Linux server.

[root@postgres ~]# 
[root@postgres ~]# dnf remove -y pgdg-redhat-repo
Dependencies resolved.
=========================================================================================================================================================================================================================================
 Package                                                       Architecture                                        Version                                              Repository                                                  Size
=========================================================================================================================================================================================================================================
Removing:
 pgdg-redhat-repo                                              noarch                                              42.0-28                                              @@commandline                                               14 k

Transaction Summary
=========================================================================================================================================================================================================================================
Remove  1 Package

Freed space: 14 k
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                                                 1/1 
  Erasing          : pgdg-redhat-repo-42.0-28.noarch                                                                                                                                                                                 1/1 
  Verifying        : pgdg-redhat-repo-42.0-28.noarch                                                                                                                                                                                 1/1 

Removed:
  pgdg-redhat-repo-42.0-28.noarch                                                                                                                                                                                                        

Complete!
[root@postgres ~]# 

Now, add the pgAdmin official yum repository in your Linux operating system.

[root@postgres ~]# 
[root@postgres ~]# dnf install -y https://ftp.postgresql.org/pub/pgadmin/pgadmin4/yum/pgadmin4-redhat-repo-2-1.noarch.rpm
Last metadata expiration check: 0:42:04 ago on Mon 21 Nov 2022 08:37:30 PM HKT.
pgadmin4-redhat-repo-2-1.noarch.rpm                                                                                                                                                                      3.8 kB/s | 6.6 kB     00:01    
Dependencies resolved.
=========================================================================================================================================================================================================================================
 Package                                                           Architecture                                        Version                                           Repository                                                 Size
=========================================================================================================================================================================================================================================
Installing:
 pgadmin4-redhat-repo                                              noarch                                              2-1                                               @commandline                                              6.6 k

Transaction Summary
=========================================================================================================================================================================================================================================
Install  1 Package

Total size: 6.6 k
Installed size: 4.0 k
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                                                 1/1 
  Installing       : pgadmin4-redhat-repo-2-1.noarch                                                                                                                                                                                 1/1 
  Verifying        : pgadmin4-redhat-repo-2-1.noarch                                                                                                                                                                                 1/1 

Installed:
  pgadmin4-redhat-repo-2-1.noarch                                                                                                                                                                                                        

Complete!
[root@postgres ~]# 

You are also required to install EPEL (Extra Packages for Enterprise Linux) yum repository, because pgAdmin requires some software packages that are not available in standard yum repositories.

Use dnf command and install EPEL yum repository.

[root@postgres ~]# 
[root@postgres ~]# dnf install -y epel-release
pgadmin4                                                                                                                                                                                                 265  B/s | 833  B     00:03    
pgadmin4                                                                                                                                                                                                 3.8 MB/s | 3.8 kB     00:00    
Importing GPG key 0x210976F2:
 Userid     : "Package Manager (Package Signing Key) <packages@pgadmin.org>"
 Fingerprint: E869 7E2E EF76 C02D 3A63 3277 8881 B2A8 2109 76F2
 From       : /etc/pki/rpm-gpg/PGADMIN_PKG_KEY
pgadmin4                                                                                                                                                                                                 106 kB/s | 896 kB     00:08    
Last metadata expiration check: 0:00:02 ago on Mon 21 Nov 2022 09:20:44 PM HKT.
Dependencies resolved.
=========================================================================================================================================================================================================================================
 Package                                                     Architecture                                          Version                                                   Repository                                             Size
=========================================================================================================================================================================================================================================
Installing:
 epel-release                                                noarch                                                8-11.el8                                                  extras                                                 24 k

Transaction Summary
=========================================================================================================================================================================================================================================
Install  1 Package

Total download size: 24 k
Installed size: 35 k
Downloading Packages:
epel-release-8-11.el8.noarch.rpm                                                                                                                                                                          53 kB/s |  24 kB     00:00    
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                     21 kB/s |  24 kB     00:01     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                                                 1/1 
  Installing       : epel-release-8-11.el8.noarch                                                                                                                                                                                    1/1 
  Running scriptlet: epel-release-8-11.el8.noarch                                                                                                                                                                                    1/1 
  Verifying        : epel-release-8-11.el8.noarch                                                                                                                                                                                    1/1 

Installed:
  epel-release-8-11.el8.noarch                                                                                                                                                                                                           

Complete!
[root@postgres ~]# 

Build cache for newly installed yum repositories.

[root@postgres ~]# 
[root@postgres ~]# dnf makecache
CentOS Stream 8 - AppStream                                                                                                                                                                              1.1 kB/s | 4.4 kB     00:03    
CentOS Stream 8 - BaseOS                                                                                                                                                                                 4.6 kB/s | 3.9 kB     00:00    
CentOS Stream 8 - Extras                                                                                                                                                                                 2.9 kB/s | 2.9 kB     00:00    
CentOS Stream 8 - Extras common packages                                                                                                                                                                 3.2 kB/s | 3.0 kB     00:00    
Extra Packages for Enterprise Linux 8 - x86_64                                                                                                                                                           3.1 MB/s |  13 MB     00:04    
Extra Packages for Enterprise Linux Modular 8 - x86_64                                                                                                                                                   181 kB/s | 733 kB     00:04    
pgadmin4                                                                                                                                                                                                 198  B/s | 833  B     00:04    
Metadata cache created.
[root@postgres ~]# 

Installing pgAdmin Web UI on CentOS 8:

All repositories has been added. You can now install pgAdmin by using dnf command.

[root@postgres ~]# 
[root@postgres ~]# dnf install -y pgadmin4
Last metadata expiration check: 0:00:47 ago on Mon 21 Nov 2022 09:22:31 PM HKT.
Dependencies resolved.
=========================================================================================================================================================================================================================================
 Package                                                 Architecture                                Version                                                                        Repository                                      Size
=========================================================================================================================================================================================================================================
Installing:
 pgadmin4                                                noarch                                      6.16-1.el8                                                                     pgAdmin4                                       6.2 k
Installing dependencies:
 apr                                                     x86_64                                      1.6.3-12.el8                                                                   appstream                                      129 k
 apr-util                                                x86_64                                      1.6.1-6.el8                                                                    appstream                                      105 k
 centos-logos-httpd                                      noarch                                      85.8-2.el8                                                                     appstream                                       75 k
 httpd                                                   x86_64                                      2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1                                       appstream                                      1.4 M
 httpd-filesystem                                        noarch                                      2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1                                       appstream                                       41 k
 httpd-tools                                             x86_64                                      2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1                                       appstream                                      108 k
 mod_http2                                               x86_64                                      1.15.7-5.module_el8.6.0+1111+ce6f4ceb                                          appstream                                      155 k
 pgadmin4-desktop                                        x86_64                                      6.16-1.el8                                                                     pgAdmin4                                        92 M
 pgadmin4-server                                         x86_64                                      6.16-1.el8                                                                     pgAdmin4                                        77 M
 pgadmin4-web                                            noarch                                      6.16-1.el8                                                                     pgAdmin4                                       8.7 k
 python3-mod_wsgi                                        x86_64                                      4.6.4-5.el8                                                                    appstream                                      2.5 M
Installing weak dependencies:
 apr-util-bdb                                            x86_64                                      1.6.1-6.el8                                                                    appstream                                       25 k
 apr-util-openssl                                        x86_64                                      1.6.1-6.el8                                                                    appstream                                       27 k
Enabling module streams:
 httpd                                                                                               2.4                                                                                                                                

Transaction Summary
=========================================================================================================================================================================================================================================
Install  14 Packages

Total download size: 173 M
Installed size: 621 M
Downloading Packages:
(1/14): apr-util-bdb-1.6.1-6.el8.x86_64.rpm                                                                                                                                                               71 kB/s |  25 kB     00:00    
(2/14): apr-util-1.6.1-6.el8.x86_64.rpm                                                                                                                                                                  209 kB/s | 105 kB     00:00    
(3/14): apr-util-openssl-1.6.1-6.el8.x86_64.rpm                                                                                                                                                          168 kB/s |  27 kB     00:00    
(4/14): apr-1.6.3-12.el8.x86_64.rpm                                                                                                                                                                      250 kB/s | 129 kB     00:00    
(5/14): centos-logos-httpd-85.8-2.el8.noarch.rpm                                                                                                                                                         789 kB/s |  75 kB     00:00    
(6/14): httpd-filesystem-2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1.noarch.rpm                                                                                                                             442 kB/s |  41 kB     00:00    
(7/14): httpd-tools-2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1.x86_64.rpm                                                                                                                                  958 kB/s | 108 kB     00:00    
(8/14): mod_http2-1.15.7-5.module_el8.6.0+1111+ce6f4ceb.x86_64.rpm                                                                                                                                       837 kB/s | 155 kB     00:00    
(9/14): httpd-2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1.x86_64.rpm                                                                                                                                        2.4 MB/s | 1.4 MB     00:00    
(10/14): python3-mod_wsgi-4.6.4-5.el8.x86_64.rpm                                                                                                                                                         4.2 MB/s | 2.5 MB     00:00    
(11/14): pgadmin4-6.16-1.el8.noarch.rpm                                                                                                                                                                  4.0 kB/s | 6.2 kB     00:01    
(12/14): pgadmin4-web-6.16-1.el8.noarch.rpm                                                                                                                                                               32 kB/s | 8.7 kB     00:00    
(13/14): pgadmin4-server-6.16-1.el8.x86_64.rpm                                                                                                                                                           4.7 MB/s |  77 MB     00:16    
(14/14): pgadmin4-desktop-6.16-1.el8.x86_64.rpm                                                                                                                                                          4.7 MB/s |  92 MB     00:19    
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                    8.1 MB/s | 173 MB     00:21     
pgadmin4                                                                                                                                                                                                 3.8 MB/s | 3.8 kB     00:00    
Importing GPG key 0x210976F2:
 Userid     : "Package Manager (Package Signing Key) <packages@pgadmin.org>"
 Fingerprint: E869 7E2E EF76 C02D 3A63 3277 8881 B2A8 2109 76F2
 From       : /etc/pki/rpm-gpg/PGADMIN_PKG_KEY
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                                                 1/1 
  Installing       : pgadmin4-server-6.16-1.el8.x86_64                                                                                                                                                                              1/14 
  Installing       : apr-1.6.3-12.el8.x86_64                                                                                                                                                                                        2/14 
  Running scriptlet: apr-1.6.3-12.el8.x86_64                                                                                                                                                                                        2/14 
  Installing       : apr-util-bdb-1.6.1-6.el8.x86_64                                                                                                                                                                                3/14 
  Installing       : apr-util-openssl-1.6.1-6.el8.x86_64                                                                                                                                                                            4/14 
  Installing       : apr-util-1.6.1-6.el8.x86_64                                                                                                                                                                                    5/14 
  Running scriptlet: apr-util-1.6.1-6.el8.x86_64                                                                                                                                                                                    5/14 
  Installing       : httpd-tools-2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1.x86_64                                                                                                                                                    6/14 
  Installing       : pgadmin4-desktop-6.16-1.el8.x86_64                                                                                                                                                                             7/14 
  Running scriptlet: pgadmin4-desktop-6.16-1.el8.x86_64                                                                                                                                                                             7/14 
  Running scriptlet: httpd-filesystem-2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1.noarch                                                                                                                                               8/14 
  Installing       : httpd-filesystem-2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1.noarch                                                                                                                                               8/14 
  Installing       : centos-logos-httpd-85.8-2.el8.noarch                                                                                                                                                                           9/14 
  Installing       : mod_http2-1.15.7-5.module_el8.6.0+1111+ce6f4ceb.x86_64                                                                                                                                                        10/14 
  Installing       : httpd-2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1.x86_64                                                                                                                                                         11/14 
  Running scriptlet: httpd-2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1.x86_64                                                                                                                                                         11/14 
  Installing       : python3-mod_wsgi-4.6.4-5.el8.x86_64                                                                                                                                                                           12/14 
  Installing       : pgadmin4-web-6.16-1.el8.noarch                                                                                                                                                                                13/14 
  Installing       : pgadmin4-6.16-1.el8.noarch                                                                                                                                                                                    14/14 
  Running scriptlet: httpd-2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1.x86_64                                                                                                                                                         14/14 
  Running scriptlet: pgadmin4-6.16-1.el8.noarch                                                                                                                                                                                    14/14 
  Verifying        : apr-1.6.3-12.el8.x86_64                                                                                                                                                                                        1/14 
  Verifying        : apr-util-1.6.1-6.el8.x86_64                                                                                                                                                                                    2/14 
  Verifying        : apr-util-bdb-1.6.1-6.el8.x86_64                                                                                                                                                                                3/14 
  Verifying        : apr-util-openssl-1.6.1-6.el8.x86_64                                                                                                                                                                            4/14 
  Verifying        : centos-logos-httpd-85.8-2.el8.noarch                                                                                                                                                                           5/14 
  Verifying        : httpd-2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1.x86_64                                                                                                                                                          6/14 
  Verifying        : httpd-filesystem-2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1.noarch                                                                                                                                               7/14 
  Verifying        : httpd-tools-2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1.x86_64                                                                                                                                                    8/14 
  Verifying        : mod_http2-1.15.7-5.module_el8.6.0+1111+ce6f4ceb.x86_64                                                                                                                                                         9/14 
  Verifying        : python3-mod_wsgi-4.6.4-5.el8.x86_64                                                                                                                                                                           10/14 
  Verifying        : pgadmin4-6.16-1.el8.noarch                                                                                                                                                                                    11/14 
  Verifying        : pgadmin4-desktop-6.16-1.el8.x86_64                                                                                                                                                                            12/14 
  Verifying        : pgadmin4-server-6.16-1.el8.x86_64                                                                                                                                                                             13/14 
  Verifying        : pgadmin4-web-6.16-1.el8.noarch                                                                                                                                                                                14/14 

Installed:
  apr-1.6.3-12.el8.x86_64                                                           apr-util-1.6.1-6.el8.x86_64                                                  apr-util-bdb-1.6.1-6.el8.x86_64                                        
  apr-util-openssl-1.6.1-6.el8.x86_64                                               centos-logos-httpd-85.8-2.el8.noarch                                         httpd-2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1.x86_64                  
  httpd-filesystem-2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1.noarch                  httpd-tools-2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1.x86_64                  mod_http2-1.15.7-5.module_el8.6.0+1111+ce6f4ceb.x86_64                 
  pgadmin4-6.16-1.el8.noarch                                                        pgadmin4-desktop-6.16-1.el8.x86_64                                           pgadmin4-server-6.16-1.el8.x86_64                                      
  pgadmin4-web-6.16-1.el8.noarch                                                    python3-mod_wsgi-4.6.4-5.el8.x86_64                                         

Complete!
[root@postgres ~]# 

To configure SELinux policies, the pgAdmin setup script requires semanage command, which is provided in policycoreutils-python-utils packages. Therefore, you should install it before executing pgAdmin setup script.

[root@postgres ~]# 
[root@postgres ~]# dnf install -y policycoreutils-python-utils
Last metadata expiration check: 0:02:28 ago on Mon 21 Nov 2022 09:22:31 PM HKT.
Package policycoreutils-python-utils-2.9-20.el8.noarch is already installed.
Dependencies resolved.
Nothing to do.
Complete!
[root@postgres ~]#

The pgAdmin software comes with a well written configuration script to configure pgAdmin web service. Execute it to create a admin user, configure SELinux policies and Apache web server to deploy pgAdmin web service.

[root@postgres ~]# 
[root@postgres ~]# /usr/pgadmin4/bin/setup-web.sh
Setting up pgAdmin 4 in web mode on a Redhat based platform...
Creating configuration database...
NOTE: Configuring authentication for SERVER mode.

Enter the email address and password to use for the initial pgAdmin user account:

Email address: maxwell@postgres-01.centlinux.com
Password: 
Retype password:
pgAdmin 4 - Application Initialisation
======================================

Creating storage and log directories...
Configuring SELinux...
The Apache web server is not running. We can enable and start the web server for you to finish pgAdmin 4 installation. Continue (y/n)? y
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
Apache successfully enabled.
Apache successfully started.
You can now start using pgAdmin 4 in web mode at http://127.0.0.1/pgadmin4
[root@postgres ~]#

The above script installs a configuration file (/etc/httpd/conf.d/pgadmin4.conf) to deploy pgAdmin on Apache web server.

No customization is required in this file. You are only required to enable and start httpd service.

[root@postgres ~]# 
[root@postgres ~]# systemctl enable --now httpd.service
[root@postgres ~]# systemctl status --now httpd.service      
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2022-11-21 21:32:03 HKT; 1min 11s ago
     Docs: man:httpd.service(8)
 Main PID: 4763 (httpd)
   Status: "Running, listening on: port 80"
    Tasks: 241 (limit: 24548)
   Memory: 57.7M
   CGroup: /system.slice/httpd.service
           ├─4763 /usr/sbin/httpd -DFOREGROUND
           ├─4764 /usr/sbin/httpd -DFOREGROUND
           ├─4765 /usr/sbin/httpd -DFOREGROUND
           ├─4766 /usr/sbin/httpd -DFOREGROUND
           ├─4767 /usr/sbin/httpd -DFOREGROUND
           └─4768 /usr/sbin/httpd -DFOREGROUND

Nov 21 21:32:03 postgres systemd[1]: Starting The Apache HTTP Server...
Nov 21 21:32:03 postgres httpd[4763]: [Mon Nov 21 21:32:03.459384 2022] [so:warn] [pid 4763:tid 140125930293568] AH01574: module wsgi_module is already loaded, skipping
Nov 21 21:32:03 postgres httpd[4763]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.8.133. Set the 'ServerName' directive globally to suppress this message
Nov 21 21:32:03 postgres systemd[1]: Started The Apache HTTP Server.
Nov 21 21:32:03 postgres httpd[4763]: Server configured, listening on: port 80
[root@postgres ~]# 

Configure Linux firewall to allow incoming traffic to Apache web server.

[root@postgres ~]# 
[root@postgres ~]# 
[root@postgres ~]# firewall-cmd --permanent --add-service=http
success
[root@postgres ~]# firewall-cmd --reload
success
[root@postgres ~]# 

Open URL http://postgres-01.centlinux.com/pgadmin4/ in a web browser.

 Login to pgAdmin as admin user (maxwell@postgres-01.centlinux.com)that we have created by setup-web.sh script.

After successful login, you may reach at the pgAdmin dashboard.

To add your PostgreSQL database server in pgAdmin inventory, click on "Add New Server".

Provide the Server name and click on “Connection” tab.

Provide the database connection information in this dialog box as we did in the above screenshots.

Click on "Save".

Our Postgres database server has been added in pgAdmin. You can see a tree of you database server in the left side panel.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值