Re-installing Postgresql and Pgadmin

I want to learn PostgreSQL and would like to use PgAdmin as the GUI. With a technical book to go along, I inevitably made some mistakes and have tried first removing PostgreSQL.

linux-3ztp:/home/by79 # zypper rm "postgres*"

and then try re-installing it.

 zypper in -f postgresql postgresql10 postgresql10-contrib postgresql10-docs postgresql10-pgagent postgresql10-plperl postgresql10-plr postgresql10-plr-doc postgresql10-server postgresql10-test postgresql-contrib postgresql-docs postgresql-plperl postgresql-server postgresql-test
Loading repository data...
Reading installed packages...
Forcing installation of 'postgresql-10-lp151.6.6.1.noarch' from repository 'openSUSE-Leap-15.1-Update'.
Forcing installation of 'postgresql10-10.12-lp151.2.9.1.x86_64' from repository 'openSUSE-Leap-15.1-Update'.
Forcing installation of 'postgresql-server-10-lp151.6.6.1.noarch' from repository 'openSUSE-Leap-15.1-Update'.
Forcing installation of 'postgresql10-server-10.12-lp151.2.9.1.x86_64' from repository 'openSUSE-Leap-15.1-Update'.
Forcing installation of 'postgresql-docs-10-lp151.6.6.1.noarch' from repository 'openSUSE-Leap-15.1-Update'.
Forcing installation of 'postgresql10-contrib-10.12-lp151.2.9.1.x86_64' from repository 'openSUSE-Leap-15.1-Update'.
Forcing installation of 'postgresql10-docs-10.12-lp151.2.9.1.noarch' from repository 'openSUSE-Leap-15.1-Update'.
Forcing installation of 'postgresql10-plperl-10.12-lp151.2.9.1.x86_64' from repository 'openSUSE-Leap-15.1-Update'.
Forcing installation of 'postgresql10-plr-8.3.0.17-lp151.3.3.x86_64' from repository 'openSUSE-Leap-15.1-Oss'.
Forcing installation of 'postgresql-contrib-10-lp151.6.6.1.noarch' from repository 'openSUSE-Leap-15.1-Update'.
Forcing installation of 'postgresql-plperl-10-lp151.6.6.1.noarch' from repository 'openSUSE-Leap-15.1-Update'.
Forcing installation of 'postgresql-test-10-lp151.6.6.1.noarch' from repository 'openSUSE-Leap-15.1-Update'.
Forcing installation of 'postgresql10-pgagent-4.0.0-lp151.1.2.x86_64' from repository 'openSUSE-Leap-15.1-Oss'.
Forcing installation of 'postgresql10-plr-doc-8.3.0.17-lp151.3.3.x86_64' from repository 'openSUSE-Leap-15.1-Oss'.
Forcing installation of 'postgresql10-test-10.12-lp151.2.9.1.x86_64' from repository 'openSUSE-Leap-15.1-Update'.
Resolving package dependencies...
The following 15 packages are going to be reinstalled:
  postgresql postgresql10 postgresql10-contrib postgresql10-docs postgresql10-pgagent postgresql10-plperl postgresql10-plr postgresql10-plr-doc postgresql10-server postgresql10-test postgresql-contrib postgresql-docs postgresql-plperl postgresql-server postgresql-test

15 packages to reinstall.
Overall download size: 9.8 MiB. Already cached: 0 B. No additional space will be used or freed after the operation.
Continue? [y/n/v/...? shows all options] (y): y

It goes on to retrieve and install the files, and looks to be running (at least the server part):

linux-3ztp:/home/by79 # systemctl start postgresql
linux-3ztp:/home/by79 # systemctl status postgresql
● postgresql.service - PostgreSQL database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql.service; disabled; vendor preset: disabled)
   Active: active (running) since Sat 2020-07-18 15:15:07 +08; 6s ago
  Process: 30638 ExecStart=/usr/share/postgresql/postgresql-script start (code=exited, status=0/SUCCESS)
 Main PID: 30647 (postgres)
    Tasks: 8
   CGroup: /system.slice/postgresql.service
           ├─30647 /usr/lib/postgresql10/bin/postgres -D /var/lib/pgsql/data
           ├─30648 postgres: logger process   
           ├─30650 postgres: checkpointer process   
           ├─30651 postgres: writer process   
           ├─30652 postgres: wal writer process   
           ├─30653 postgres: autovacuum launcher process   
           ├─30654 postgres: stats collector process   
           └─30655 postgres: bgworker: logical replication launcher   

Jul 18 15:15:07 linux-3ztp.suse systemd[1]: Starting PostgreSQL database server...
Jul 18 15:15:07 linux-3ztp.suse postgresql-script[30638]: 2020-07-18 15:15:07.797 +08   [30647]LOG:  listening on IPv6 address "::1", port 5432
Jul 18 15:15:07 linux-3ztp.suse postgresql-script[30638]: 2020-07-18 15:15:07.797 +08   [30647]LOG:  listening on IPv4 address "127.0.0.1", port 5432
Jul 18 15:15:07 linux-3ztp.suse postgresql-script[30638]: 2020-07-18 15:15:07.800 +08   [30647]LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
Jul 18 15:15:07 linux-3ztp.suse postgresql-script[30638]: 2020-07-18 15:15:07.804 +08   [30647]LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
Jul 18 15:15:07 linux-3ztp.suse postgresql-script[30638]: 2020-07-18 15:15:07.809 +08   [30647]LOG:  redirecting log output to logging collector process
Jul 18 15:15:07 linux-3ztp.suse postgresql-script[30638]: 2020-07-18 15:15:07.809 +08   [30647]HINT:  Future log output will appear in directory "log".
Jul 18 15:15:07 linux-3ztp.suse systemd[1]: Started PostgreSQL database server.
linux-3ztp:/home/by79 # 

I guess the next step is to set up the psql and the pgadmin. For the psql, I was having the exact problem as
https://forums.opensuse.org/showthread.php/539617-Postgresql-configuration?highlight=postgresql

, so I follow the instruction to go:
https://en.opensuse.org/SDB:PostgreSQL

to eventually get:

linux-3ztp:/home/by79 # su - postgres
postgres@linux-3ztp:~> psql
psql (10.12)
Type "help" for help.

which works quite different from the below code as shown in the book and some other online sources:

$sudo - u postgres psql

but ok, I guess it works.

I have also changed the method from “peer” to “trust”, only for “local” in the pg_hba.conf file:

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     trust

Similarly for pgadmin, I remove

linux-3ztp:/home/by79 # zypper rm "pgadmin*"

and reinstall.

linux-3ztp:/home/by79 # zypper in -f pgadmin4 pgadmin4-doc pgadmin4-web
Loading repository data...
Reading installed packages...
Forcing installation of 'pgadmin4-4.1-lp151.1.2.x86_64' from repository 'openSUSE-Leap-15.1-Oss'.
Forcing installation of 'pgadmin4-doc-4.1-lp151.1.2.noarch' from repository 'openSUSE-Leap-15.1-Oss'.
Forcing installation of 'pgadmin4-web-4.1-lp151.1.2.noarch' from repository 'openSUSE-Leap-15.1-Oss'.
Resolving package dependencies...

The following 3 NEW packages are going to be installed:
  pgadmin4 pgadmin4-doc pgadmin4-web

3 new packages to install.
Overall download size: 27.8 MiB. Already cached: 0 B. After the operation, additional 50.1 MiB will be used.
Continue? [y/n/v/...? shows all options] (y): y
Retrieving package pgadmin4-doc-4.1-lp151.1.2.noarch                                                                                                                                                                                           (1/3),  23.8 MiB ( 25.8 MiB unpacked)
Retrieving: pgadmin4-doc-4.1-lp151.1.2.noarch.rpm ................................................................................................................................................................................................................[done (7.3 MiB/s)]
Retrieving package pgadmin4-web-4.1-lp151.1.2.noarch                                                                                                                                                                                           (2/3),   3.7 MiB ( 23.9 MiB unpacked)
Retrieving: pgadmin4-web-4.1-lp151.1.2.noarch.rpm ................................................................................................................................................................................................................[done (7.3 MiB/s)]
Retrieving package pgadmin4-4.1-lp151.1.2.x86_64                                                                                                                                                                                               (3/3), 276.8 KiB (399.5 KiB unpacked)
Retrieving: pgadmin4-4.1-lp151.1.2.x86_64.rpm ....................................................................................................................................................................................................................[done (2.0 MiB/s)]

Checking for file conflicts: .................................................................................................................................................................................................................................................[done]
(1/3) Installing: pgadmin4-doc-4.1-lp151.1.2.noarch ..........................................................................................................................................................................................................................[done]
(2/3) Installing: pgadmin4-web-4.1-lp151.1.2.noarch ..........................................................................................................................................................................................................................[done]
(3/3) Installing: pgadmin4-4.1-lp151.1.2.x86_64 ..............................................................................................................................................................................................................................[done]

However, I have the below “fatal error” when I click on the PgAdmin icon in GNOME:


An error occurred initialising the application server:

 

 Failed to launch the application server, server thread exiting.


Reading some online resources, I am guessing that this arises because there has been a previous installation. In the subsequent configuration window, it states

Python Path: /usr/lib64/python3.6/site-packages;/usr/lib/python3.6/site-packages
Application Path: //usr/lib/python3.6/site-packages/pgadmin4-web/

How to make pgadmin work? Would appreciate any suggestion. Thank you.

You need to collect more information why pgadmin4 isn’t starting properly…
One easier way is to open a console that can read system events in real time as they happen, this is great when you are troubleshooting something you’re invoking (less useful when you’re trying to troubleshoot something that’s supposed to automatically start on its own).

  1. Open an elevated console (You can use “su” or “sudo” but I recommend getting in the habit of using “su” on openSUSE), then run the following command and leave it running
journalctl -f
  1. Now invoke what you’re trying to troubleshoot, in your case pgadmin4.
    You should see events written that might be successes, but you should also see something descriptive about what’s not working.

Hopefully, that’s enough for you to go ahead and fix whatever the error says, but if you need help, copy and post the content to this thread for others to take a look at it.

TSU

Hi,



linux-3ztp:/home/by79 # journalctl -f
-- Logs begin at Tue 2018-06-05 06:45:23 +08. --
Jul 20 11:40:25 linux-3ztp.suse sudo[9942]:     root : TTY=pts/1 ; PWD=/home/by79 ; USER=root ; COMMAND=/usr/bin/systemctl status postgresql
Jul 20 11:40:25 linux-3ztp.suse sudo[9942]: pam_unix(sudo:session): session opened for user root by by79(uid=0)
Jul 20 11:40:25 linux-3ztp.suse sudo[9942]: pam_unix(sudo:session): session closed for user root
Jul 20 11:40:36 linux-3ztp.suse /usr/lib/gdm/gdm-x-session[2216]: Window manager warning: Invalid WM_TRANSIENT_FOR window 0x4200007 specified for 0x4200005 (pgadmin4).
Jul 20 11:40:36 linux-3ztp.suse pgadmin4.desktop[9976]: Python path:  "/usr/lib/python3.6/site-packages:/usr/lib64/python3.6/site-packages"
Jul 20 11:40:36 linux-3ztp.suse pgadmin4.desktop[9976]: Python Home:  ""
Jul 20 11:40:36 linux-3ztp.suse pgadmin4.desktop[9976]: Webapp path:  "/usr/lib/python3.6/site-packages/pgadmin4-web/pgAdmin4.py"
Jul 20 11:40:37 linux-3ztp.suse pgadmin4.desktop[9976]: "Failed to launch the application server, server thread exiting."
Jul 20 11:40:37 linux-3ztp.suse /usr/lib/gdm/gdm-x-session[2216]: Window manager warning: Invalid WM_TRANSIENT_FOR window 0x4200007 specified for 0x420000d (Fatal Erro).
Jul 20 11:40:39 linux-3ztp.suse /usr/lib/gdm/gdm-x-session[2216]: Window manager warning: Invalid WM_TRANSIENT_FOR window 0x4200007 specified for 0x4200013 (Configurat).

I am trying to locate the log file per https://www.pgadmin.org/faq/

linux-3ztp:~ # locate pgadmin4.log
/home/by79/.pgadmin/pgadmin4.log
linux-3ztp:~ # cd /home/by79/.pgadmin
linux-3ztp:/home/by79/.pgadmin # ls
sessions  storage

No luck, so I went to open the pgAdmin4.startup.log:

20.07.2020 11:40:36 Checking for system tray...
20.07.2020 11:40:36 System tray not found, creating floating window...
20.07.2020 11:40:36 Starting pgAdmin4 server...
20.07.2020 11:40:36 Creating server object, port:43409, key:2dbf1b50-b210-4ce5-b4a5-bc274f99b775, logfile:/home/by79/.pgAdmin4.14570597673959349582.log
20.07.2020 11:40:36 Python Path: /usr/lib/python3.6/site-packages:/usr/lib64/python3.6/site-packages
20.07.2020 11:40:36 Python Home: 
20.07.2020 11:40:36 Initializing Python...
20.07.2020 11:40:36 Python initialized.
20.07.2020 11:40:36 Adding new additional path elements
20.07.2020 11:40:36 Redirecting stderr...
20.07.2020 11:40:36 stderr redirected successfully.
20.07.2020 11:40:36 Initializing server...
20.07.2020 11:40:36 Webapp Path: /usr/lib/python3.6/site-packages/pgadmin4-web/pgAdmin4.py
20.07.2020 11:40:36 Server initialized.
20.07.2020 11:40:36 Starting Server Thread...
20.07.2020 11:40:36 Open the application code and run it.
20.07.2020 11:40:36 Set the port number, key and force SERVER_MODE off
20.07.2020 11:40:36 PyRun_SimpleFile launching application server...
20.07.2020 11:40:37 Failed to launch the application server, server thread exiting.
20.07.2020 11:40:39 An error occurred initialising the application server:

Failed to launch the application server, server thread exiting.

Problem with Python?

I’ve highlighted the critical error, which shows up from time to time apparently in Gnome.
Aside from installing another DE and WM, switching to that and trying again, this is an error that likely will need to be resolved upstream.

Recommend that you submit a bug to https://bugzilla.opensuse.org with the system log snippet you were able to capture running journalctl.
Provide details including OS, PostgreSQL and pgadmin4 versions and/or where you installed your apps from (The OSS).

TSU

Thanks Tsu, just done.