Postgresql

Trying to install Postgresql
https://software.opensuse.org/package/postgresql10

It looks like a successful install but then I run into the issue below:

by79@linux-3ztp:~> systemctl start postgresql
Failed to start postgresql.service: Unit postgresql.service failed to load: No such file or directory.
by79@linux-3ztp:~> sudo systemctl -l status postgresql
● postgresql.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)

Any ideas?

Thanks!

Please post

zypper se -si postgresql

The service is in the postgresql-server.rpm and requires root:

linux64:~ # systemctl start postgresql.service 
linux64:~ # systemctl status postgresql.service 
● postgresql.service - PostgreSQL database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql.service; disabled; vendor preset: disabled)
   Active: active (running) since Sat 2018-11-03 09:14:47 CET; 14s ago
  Process: 7822 ExecStart=/usr/share/postgresql/postgresql-script start (code=exited, status=0/SUCCESS)
 Main PID: 7846 (postgres)
    Tasks: 8 (limit: 4915)
   CGroup: /system.slice/postgresql.service
           ├─7846 /usr/lib/postgresql10/bin/postgres -D /var/lib/pgsql/data
           ├─7847 postgres: logger process   
           ├─7849 postgres: checkpointer process   
           ├─7850 postgres: writer process   
           ├─7851 postgres: wal writer process   
           ├─7852 postgres: autovacuum launcher process   
           ├─7853 postgres: stats collector process   
           └─7854 postgres: bgworker: logical replication launcher   

Nov 03 09:14:43 linux64.linux systemd[1]: Starting PostgreSQL database server...
Nov 03 09:14:43 linux64.linux postgresql-script[7822]: Initializing PostgreSQL 10.5 at location /var/lib>
Nov 03 09:14:47 linux64.linux postgresql-script[7822]: 2018-11-03 09:14:47.236 CET   [7846]LOG:  listeni>
Nov 03 09:14:47 linux64.linux postgresql-script[7822]: 2018-11-03 09:14:47.236 CET   [7846]LOG:  could n>
Nov 03 09:14:47 linux64.linux postgresql-script[7822]: 2018-11-03 09:14:47.236 CET   [7846]HINT:  Is ano>
Nov 03 09:14:47 linux64.linux postgresql-script[7822]: 2018-11-03 09:14:47.238 CET   [7846]LOG:  listeni>
Nov 03 09:14:47 linux64.linux postgresql-script[7822]: 2018-11-03 09:14:47.242 CET   [7846]LOG:  listeni>
Nov 03 09:14:47 linux64.linux postgresql-script[7822]: 2018-11-03 09:14:47.274 CET   [7846]LOG:  redirec>
Nov 03 09:14:47 linux64.linux postgresql-script[7822]: 2018-11-03 09:14:47.274 CET   [7846]HINT:  Future>
Nov 03 09:14:47 linux64.linux systemd[1]: Started PostgreSQL database server.

Hi,

by79@linux-3ztp:~> systemctl start postgresql.service
Failed to start postgresql.service: Unit postgresql.service failed to load: No such file or directory.
by79@linux-3ztp:~> systemctl status postgresql.service
● postgresql.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)
by79@linux-3ztp:~> zypper se -si postgresql
Loading repository data...
Reading installed packages...

S  | Name         | Type    | Version  | Arch   | Repository                
---+--------------+---------+----------+--------+---------------------------
i+ | postgresql   | package | 11-2.3   | noarch | server:database:postgresql
i+ | postgresql10 | package | 10.5-2.1 | x86_64 | openSUSE-Leap-42.3-Update 
i  | postgresql11 | package | 11.0-1.3 | x86_64 | server:database:postgresql
by79@linux-3ztp:~> 


qed

The service is in the postgresql-server.rpm and requires root:

Read carefully.

one more thing to consider afaik postgresql requires a postgresql user to access the server and it refuses connections from localhost you need to edit some files before you can access the server from localhost also don’t forget to create a postgresql user login to that account before accessing the server
http://suite.opengeo.org/docs/latest/dataadmin/pgGettingStarted/firstconnect.html

ps don’t forget to open the postgresql ports in firewalld or you won’t get any connections

I don’t know if it’s relevant,
\But you seem to have tried to install PosgreSQL 10.5, but instead installed 11.

Before installing a major app like a relational database, I always manually update my machine first. Although you might not have done that, I recommend you run the following now on the chance it might clean up any inconsistencies

zypper up

You may also want to reboot although it shouldn’t ordinarily be required.

TSU

Thanks guys for pointers.

@Sauerland

The service is in the postgresql-server.rpm and requires root:

Tried that again but seems to run into the same problem.

by79@linux-3ztp:~> su
Password: 
su: Authentication failure
by79@linux-3ztp:~> su
Password: 
linux-3ztp:/home/by79 # systemctl start postgresql.service
Failed to start postgresql.service: Unit postgresql.service failed to load: No such file or directory.
linux-3ztp:/home/by79 # systemctl status postgresql.service
● postgresql.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)
linux-3ztp:/home/by79 # 

@Tsu2

this is after

zypper up

You may also want to reboot although it shouldn’t ordinarily be required.

Tried rebooting but same outcome

I don’t know if it’s relevant,
\But you seem to have tried to install PosgreSQL 10.5, but instead installed 11.

After 1-click install, and YAST came out, it listed two repos:

  1. http://download.opensuse.org/update/leap/42.3/oss

and

  1. http://download.opensuse.org/distribution/leap/42.3/repo/oss

By default, only the box for “1” is checked but I checked the box for “2” as well before clicking on “Next”

Not sure if that would install Postgresql 11 as well but it says that the installation is successful. By the way, understand that Postgresql 11 is currently in beta version but don’t think that is a big hindrance as I doubt what I plan to do will be that complex for a start. Both 10.5 or 11 will be ok for now. I have not knowingly use postgreql on this computer before as I did a reinstall of Leap 42.3.

@I_A

one more thing to consider afaik postgresql requires a postgresql user to access the server and it refuses connections from localhost you need to edit some files before you can access the server from localhost also don’t forget to create a postgresql user login to that account before accessing the server

This is my concern but before that, I just want to know if what I have done so far is correct. Would like to hear from the experts here first as I messed up a previous installation and did a complete reinstall of LEAP 42.3. Try not to go down that path again.

Tried that again but seems to run into the same problem.

Post

zypper lr -d
zypper se -si postgresql
update-alternatives --config postgresql

Hi Sauerland,

zypper lr -d

by79@linux-3ztp:~> zypper lr -d

 Repository priorities are without effect. All enabled repositories share the same priority.

 
 
 #  | Alias                               | Name                                    | Enabled | GPG Check | Refresh | Priority | Type   | URI                                                                                        | Service
 ---+-------------------------------------+-----------------------------------------+---------+-----------+---------+----------+--------+--------------------------------------------------------------------------------------------+--------
  1 | NVIDIA                              | NVIDIA                                  | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://http.download.nvidia.com/opensuse/leap/42.3                                         |         
  2 | google-chrome                       | google-chrome                           | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://dl.google.com/linux/chrome/rpm/stable/x86_64                                        |         
  3 | http-download.opensuse.org-2123bb60 | server:database:postgresql              | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/repositories/server:/database:/postgresql/openSUSE_Leap_42.3/ |         
  4 | libdvdcss                           | libdvdcss                               | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://opensuse-guide.org/repo/openSUSE_Leap_42.3/                                         |         

  5 | openSUSE-Leap-42.3-0                | openSUSE-Leap-42.3-0                    | No      | ----      | ----    |   99     | yast2  | hd:///?device=/dev/disk/by-id/usb-SanDisk_Ultra_Fit_4C531001560725109115-0:0-part1         |         

  6 | packman                             | packman                                 | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://packman.inode.at/suse/openSUSE_Leap_42.3/                                           |         
  7 | repo-debug                          | openSUSE-Leap-42.3-Debug                | No      | ----      | ----    |   99     | NONE   | http://download.opensuse.org/debug/distribution/leap/42.3/repo/oss/                        |         
  8 | repo-debug-non-oss                  | openSUSE-Leap-42.3-Debug-Non-Oss        | No      | ----      | ----    |   99     | NONE   | http://download.opensuse.org/debug/distribution/leap/42.3/repo/non-oss/                    |         
  9 | repo-debug-update                   | openSUSE-Leap-42.3-Update-Debug         | No      | ----      | ----    |   99     | NONE   | http://download.opensuse.org/debug/update/leap/42.3/oss/                                   |         
 10 | repo-debug-update-non-oss           | openSUSE-Leap-42.3-Update-Debug-Non-Oss | No      | ----      | ----    |   99     | NONE   | http://download.opensuse.org/debug/update/leap/42.3/non-oss/                               |         
 11 | repo-non-oss                        | openSUSE-Leap-42.3-Non-Oss              | Yes     | (r ) Yes  | Yes     |   99     | yast2  | http://download.opensuse.org/distribution/leap/42.3/repo/non-oss/                          |         

 12 | repo-oss                            | openSUSE-Leap-42.3-Oss                 | Yes     | (r ) Yes  | Yes     |   99     | yast2  | http://download.opensuse.org/distribution/leap/42.3/repo/oss/                              |         

 13 | repo-source                         | openSUSE-Leap-42.3-Source               | No      | ----      | ----    |   99     | NONE   | http://download.opensuse.org/source/distribution/leap/42.3/repo/oss/                       |         
 14 | repo-source-non-oss                 | openSUSE-Leap-42.3-Source-Non-Oss       | No      | ----      | ----    |   99     | NONE   | http://download.opensuse.org/source/distribution/leap/42.3/repo/non-oss/                   |         
 15 | repo-update                         | openSUSE-Leap-42.3-Update               | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/update/leap/42.3/oss/                                         |         
 16 | repo-update-non-oss                 | openSUSE-Leap-42.3-Update-Non-Oss       | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/update/leap/42.3/non-oss/                                     |         
 by79@linux-3ztp:~> 
 
 
 
 
 
 

zypper se -si postgresql


by79@linux-3ztp:~> zypper se -si postgresql
Download (curl) error for 'http://download.opensuse.org/repositories/server:/database:/postgresql/openSUSE_Leap_42.3/media.1/media':
Error code: Curl error 52
Error message: Empty reply from server

Abort, retry, ignore? [a/r/i/...? shows all options] (a): r
Download (curl) error for 'http://download.opensuse.org/update/leap/42.3/non-oss/media.1/media':
Error code: Curl error 52
Error message: Empty reply from server

Abort, retry, ignore? [a/r/i/...? shows all options] (a): a
Repository 'openSUSE-Leap-42.3-Update-Non-Oss' is out-of-date. You can run 'zypper refresh' as root to update it.
Loading repository data...
Reading installed packages...

S  | Name         | Type    | Version  | Arch   | Repository                
---+--------------+---------+----------+--------+---------------------------
i+ | postgresql   | package | 11-2.3   | noarch | server:database:postgresql
i+ | postgresql10 | package | 10.5-2.1 | x86_64 | openSUSE-Leap-42.3-Update 
i  | postgresql11 | package | 11.0-1.3 | x86_64 | server:database:postgresql
by79@linux-3ztp:~> 
 



update-alternatives --config postgresql


 by79@linux-3ztp:~> update-alternatives --config postgresql

 Absolute path to 'update-alternatives' is '/usr/sbin/update-alternatives', so running it may require superuser privileges (eg. root).
 by79@linux-3ztp:~> sudo update-alternatives --config postgresql

 [sudo] password for root:  

 There are 2 choices for the alternative postgresql (providing /usr/lib/postgresql).
 
 
   Selection    Path                   Priority   Status
 ------------------------------------------------------------
 * 0            /usr/lib/postgresql11   110       auto mode
   1            /usr/lib/postgresql10   100       manual mode
   2            /usr/lib/postgresql11   110       manual mode

 
 
 Press <enter> to keep the current choice
[li], or type selection number:  [/li]

You have only the Clients installed, which you use to connect to a working server.
As I said:
You have to install the server component:
If you want postgresql11-server:

zypper in postgresql-server

or postgresql10-server:

zypper in postgresql10-server

and use

update-alternatives --config postgresql

to switch to your version you want.

After that, enable and start the server

FYI -

If you want to follow the following steps to install PostgreSQL, you will want to

  • Uninstall any and all existing PostgreSQL packages
  • Remove any repositories you added using “one=click Install”

If you don’t know how to do the above, ask.
Start by posting your existing list of repos

zypper lr

Edit - The following should remove your added repo

zypper rr "server:database:postgresql"

You might be able to do a simple “rm” as follows, but might not be sufficient

zypper rm "postgresql*"

I found postgresql10 in the default OSS, you don’t need to install any additional repos.
Note that if you try to install just “postgresql” the current default is PostgreSQL 9.6, so the following describes finding and installing PostgreSQL 10.
The following describes using zypper in an elevated console (using su, but you can “sudo” your commands instead of you wish).
You also have the option to use the YaST Software Manager to perform the same steps.

# zypper se postgresql10
Loading repository data...
Reading installed packages...


S | Name                  | Summary                                                     | Type      
--+-----------------------+-------------------------------------------------------------+-----------
  | postgresql10          | Basic Clients and Utilities for PostgreSQL                  | srcpackage
  | postgresql10          | Basic Clients and Utilities for PostgreSQL                  | package   
  | postgresql10-contrib  | Contributed Extensions and Additions to PostgreSQL          | package   
  | postgresql10-devel    | PostgreSQL development header files and libraries           | package   
  | postgresql10-docs     | HTML Documentation for PostgreSQL                           | package   
  | postgresql10-libs     | Basic Clients and Utilities for PostgreSQL                  | srcpackage
  | postgresql10-plperl   | The PL/Tcl, PL/Perl, and  PL/Python procedural languages -> | package   
  | postgresql10-plpython | The PL/Python Procedural Languages for PostgreSQL           | package   
  | postgresql10-pltcl    | PL/Tcl Procedural Language for PostgreSQL                   | package   
  | postgresql10-server   | The Programs Needed to Create and Run a PostgreSQL Server   | package   
  | postgresql10-test     | The test suite for PostgreSQL                               | package 

Since that appears to be what you are looking for, I didn’t look further for PostgreSQL 11.

The following installs the PostgreSQL Client tools, Server, documentation and test suite. You don’t have to install all of these, you can modify for whatever you wish to install

# zypper in postgresql10 postgresql10-docs postgresql10-test

Now you can start your Postgresql Server

systemctl start postgresql

You can set your PostgreSQL Server to start automatically on boot

systemctl enable postgresql

You can verify the running status and settings of your postgresql server

systemctl status postgresql

Thanks Sauerland and Tsu2 for your guidance.

Ok, Please help me out. I just want postgresql 10 on my computer to work with. To make it clean, maybe it is better to remove all my other postgresql versions currently on my computer and then reinstall postgresql10? Is the below a plan?

  1. Start by posting your existing list of repos
zypper lr
  1. Remove all related Postgresql files (Is the repository name correct?):
zypper -n rr PostgreSQL && zypper ref 
  1. Check if any postgresql packages are still installed to be sure.
zypper se -i postgres
  1. Install all things related to Postgresql 10
# zypper in postgresql10 postgresql10-docs postgresql10-test
  1. Check installation
zypper se postgresql10
  1. Start your Postgresql Server assume
systemctl start postgresql

  1. Verify the running status and settings of your postgresql server
systemctl status postgresql

Not too sure if the below 2 commands are needed if I follow no.2 above?

zypper rm "postgre*"
zypper rr "server:database:postgresql"

Thanks again!

With this you will remove a Repo named PostgreSQL and than refresh the repos.

zypper -n rr PostgreSQL && zypper ref 

With this you will remove packages with postgrexxxxxxx in the name:

zypper rm "postgre*"

With this you wiil remove a repo called server:database:postgresq

zypper rr "server:database:postgresql"

So this one is the first step you should do as tsu2 has said.

PS:
Please do not use Color or Fonts in CODE, that will not work but make it not easier to quote for others…

First,
Be careful about your camel case.
Although it’s proper to use camel case for the application name in documentation and the like,
To my eye all packages and repository names name “postgresql” in lower case only.

Use the command i gave you in my previous post to remove the special database repository where your current postgresql is from. This ensures that when you install, postgresql will come from your OSS (your default repos) only.

In fact,
If you just run through the steps in my post, you should have your desired result.
I don’t think you’ve done anything that would require a deeper purge, believe a simple “rm” should be sufficient.

TSU

Noted your comments about the formatting of the posts.

I tried to follow the steps:

by79@linux-3ztp:~> zypper lr
Repository priorities are without effect. All enabled repositories share the same priority.

 
 
 #  | Alias                               | Name                                    | Enabled | GPG Check | Refresh
 ---+-------------------------------------+-----------------------------------------+---------+-----------+--------
  1 | NVIDIA                              | NVIDIA                                  | Yes     | (r ) Yes  | Yes     

  2 | google-chrome                       | google-chrome                           | Yes     | (r ) Yes  | Yes     

  3 | http-download.opensuse.org-2123bb60 | server:database:postgresql              | Yes     | (r ) Yes  | Yes     
  4 | libdvdcss                           | libdvdcss                               | Yes     | (r ) Yes  | Yes     

  5 | openSUSE-Leap-42.3-0                | openSUSE-Leap-42.3-0                    | No      | ----      | ----    
  6 | packman                             | packman                                 | Yes     | (r ) Yes  | Yes     
  7 | repo-debug                          | openSUSE-Leap-42.3-Debug                | No      | ----      | ----    
  8 | repo-debug-non-oss                  | openSUSE-Leap-42.3-Debug-Non-Oss        | No      | ----      | ----    
  9 | repo-debug-update                   | openSUSE-Leap-42.3-Update-Debug         | No      | ----      | ----    
 10 | repo-debug-update-non-oss           | openSUSE-Leap-42.3-Update-Debug-Non-Oss | No      | ----      | ----    
 11 | repo-non-oss                        | openSUSE-Leap-42.3-Non-Oss              | Yes     | (r ) Yes  | Yes     
 12 | repo-oss                            | openSUSE-Leap-42.3-Oss                  | Yes     | (r ) Yes  | Yes     
 13 | repo-source                         | openSUSE-Leap-42.3-Source               | No      | ----      | ----    
 14 | repo-source-non-oss                 | openSUSE-Leap-42.3-Source-Non-Oss       | No      | ----      | ----    

 15 | repo-update                         | openSUSE-Leap-42.3-Update               | Yes     | (r ) Yes  | Yes     

 16 | repo-update-non-oss                 | openSUSE-Leap-42.3-Update-Non-Oss       | Yes     | (r ) Yes  | Yes     
 by79@linux-3ztp:~> 


linux-3ztp:~ # zypper rr "server:database:postgresql"

 Removing repository 'server:database:postgresql' .........................[done]
 Repository 'server:database:postgresql' has been removed.
 
 
  
linux-3ztp:~ # linux-3ztp:~ # zypper in postgresql10 postgresql10-docs postgresql10-test

 Retrieving repository 'packman' metadata .................................[done]

 Building repository 'packman' cache ......................................[done]

 Retrieving repository 'openSUSE-Leap-42.3-Update' metadata ...............[done]

 Building repository 'openSUSE-Leap-42.3-Update' cache ....................[done]

 Loading repository data...
 Reading installed packages...
 'postgresql10' is already installed.

 No update candidate for 'postgresql10-10.5-2.1.x86_64'. The highest available version is already installed.
 Resolving package dependencies...

 
 
 The following 4 NEW packages are going to be installed:

   postgresql-init postgresql10-docs postgresql10-server postgresql10-test

 
 
 4 new packages to install.

 Overall download size: 7.5 MiB. Already cached: 0 B. After the operation,
 additional 44.5 MiB will be used.
 Continue? [y/n/...? shows all options] (y): y
 Retrieving package postgresql-init-10-16.3.1.noarch
                                            (1/4),  14.3 KiB (  4.2 KiB unpacked)Retrieving: postgresql-init-10-16.3.1.noarch.rpm .........................[done]
 Retrieving package postgresql10-docs-10.5-2.1.noarch

                                            (2/4),   2.3 MiB ( 17.1 MiB unpacked)
 Retrieving: postgresql10-docs-10.5-2.1.noarch.rpm ............[done (2.1 MiB/s)]
 Retrieving package postgresql10-server-10.5-2.1.x86_64
                                            (3/4),   4.0 MiB ( 18.2 MiB unpacked)
 Retrieving: postgresql10-server-10.5-2.1.x86_64.rpm ..........[done (3.2 MiB/s)]
 Retrieving package postgresql10-test-10.5-2.1.x86_64
                                            (4/4),   1.2 MiB (  9.2 MiB unpacked)
 Retrieving: postgresql10-test-10.5-2.1.x86_64.rpm ........................[done]
 Checking for file conflicts: .............................................[done]

 (1/4) Installing: postgresql-init-10-16.3.1.noarch .......................[done]

 Additional rpm output:
 Updating /etc/sysconfig/postgresql...
 
 
 
 
 (2/4) Installing: postgresql10-docs-10.5-2.1.noarch ......................[done]
 (3/4) Installing: postgresql10-server-10.5-2.1.x86_64 ....................[done]
 (4/4) Installing: postgresql10-test-10.5-2.1.x86_64 ......................[done]


linux-3ztp:~ # by79@linux-3ztp:~> systemctl start postgresql

 Job for postgresql.service failed because the control process exited with error code. See "systemctl status postgresql.service" and "journalctl -xe" for details.

The first run:

by79@linux-3ztp:~> systemctl status postgresql

 ● postgresql.service - PostgreSQL database server
    Loaded: loaded (/usr/lib/systemd/system/postgresql.service; disabled; vendor preset: disabled)
    Active: failed (Result: exit-code) since Tue 2018-11-06 20:56:53 +08; 15s ago
   Process: 5122 ExecStart=/usr/lib/postgresql-init start (code=exited, status=1/FAILURE)
 by79@linux-3ztp:~> 



                        

I restarted my computer:

linux-3ztp:/home/by79 # systemctl start postgresql
Job for postgresql.service failed because the control process exited with error code. See "systemctl status postgresql.service" and "journalctl -xe" for details.
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: failed (Result: exit-code) since Tue 2018-11-06 21:08:00 +08; 16s ago
   Process: 3237 ExecStart=/usr/lib/postgresql-init start (code=exited, status=1/FAILURE)
 
 
 Nov 06 21:08:00 linux-3ztp systemd[1]: Starting PostgreSQL database server...
 Nov 06 21:08:00 linux-3ztp systemd[1]: postgresql.service: Control process ...=1
 Nov 06 21:08:00 linux-3ztp systemd[1]: Failed to start PostgreSQL database ...r.
 Nov 06 21:08:00 linux-3ztp systemd[1]: postgresql.service: Unit entered fai...e.
 Nov 06 21:08:00 linux-3ztp systemd[1]: postgresql.service: Failed with resu...'.
 Hint: Some lines were ellipsized, use -l to show in full.

by79@linux-3ztp:~> zypper se -i postgres

 Loading repository data...
 Reading installed packages...
 
 
 S  | Name                | Summary                                     | Type    
 ---+---------------------+---------------------------------------------+--------
 i+ | postgresql          | Basic Clients and Utilities for PostgreSQL  | package
 i  | postgresql-init     | Init script and other infrastructure for -> | package
 i+ | postgresql10        | Basic Clients and Utilities for PostgreSQL  | package
 i+ | postgresql10-docs   | HTML Documentation for PostgreSQL           | package
 i  | postgresql10-server | The Programs Needed to Create and Run a P-> | package
 i+ | postgresql10-test   | The test suite for PostgreSQL               | package
 i  | postgresql11        | Basic Clients and Utilities for PostgreSQL  | package
  

The installed postgresql10 packages seem to be different from what is intended. Any ideas?

You didn’t uninstall your version of postgresql from the database repo.
Since you already removed your database repo, run the following

ypper rm "postgres*"

Then do the steps again starting with the install… In fact, just for extra measure use the following install command instead which forces re-installation even if components are found to already exist

# zypper in -f ]postgresql10 postgresql10-docs postgresql10-test

IMO that should work,
But if it doesn’t post again, if necessary we can purge the old files manually.

TSU

Thanks Tsu2.

The rm “postgres*” is not able to remove “directory /var/lib/pgsql”…

by79@linux-3ztp:~> su

 Password:  
 linux-3ztp:/home/by79 # zypper rm "postgres*"
 Loading repository data...
 Reading installed packages...
 Resolving package dependencies...
 
 
 The following 7 packages are going to be REMOVED:
   postgresql postgresql10 postgresql10-docs postgresql10-server
   postgresql10-test postgresql11 postgresql-init
 
 
 7 packages to remove.
 After the operation, 56.6 MiB will be freed.
 Continue? [y/n/...? shows all options] (y): y
 (1/7) Removing postgresql10-docs-10.5-2.1.noarch .........................[done]
 (2/7) Removing postgresql10-test-10.5-2.1.x86_64 .........................[done]
 (3/7) Removing postgresql11-11.0-1.3.x86_64 ..............................[done]
 Additional rpm output:
 update-alternatives: using /usr/lib/postgresql10 to provide /usr/lib/postgresql (postgresql) in auto mode
 (4/7) Removing postgresql10-server-10.5-2.1.x86_64 .......................[done]
 Additional rpm output:
 warning: directory /var/lib/pgsql: remove failed: Device or resource busy

 
 
 
 
 (5/7) Removing postgresql-11-2.3.noarch ..................................[done]
 (6/7) Removing postgresql10-10.5-2.1.x86_64 ..............................[done]
 (7/7) Removing postgresql-init-10-16.3.1.noarch ..........................[done]
 linux-3ztp:/home/by79 #  

Installation looks ok though

linux-3ztp:/home/by79 # zypper in -f ]postgresql10 postgresql10-docs postgresql10-test

 Retrieving repository 'google-chrome' metadata ...........................[done]
 Building repository 'google-chrome' cache ................................[done]
 Loading repository data...
 Reading installed packages...
 Forcing installation of 'postgresql10-test-10.5-2.1.x86_64' from repository 'openSUSE-Leap-42.3-Update'.
 Forcing installation of 'postgresql10-docs-10.5-2.1.noarch' from repository 'openSUSE-Leap-42.3-Update'.
 Package ']postgresql10' not found.
 Resolving package dependencies...
 
 
 The following 5 NEW packages are going to be installed:
   postgresql10 postgresql10-docs postgresql10-server postgresql10-test
   postgresql-init
 
 
 5 new packages to install.
 Overall download size: 9.0 MiB. Already cached: 0 B. After the operation,
 additional 50.5 MiB will be used.
 Continue? [y/n/...? shows all options] (y): y
 Retrieving package postgresql-init-10-16.3.1.noarch
                                            (1/5),  14.3 KiB (  4.2 KiB unpacked)
 Retrieving: postgresql-init-10-16.3.1.noarch.rpm .............[done (3.9 KiB/s)]
 Retrieving package postgresql10-10.5-2.1.x86_64
                                            (2/5),   1.4 MiB (  5.9 MiB unpacked)
 Retrieving: postgresql10-10.5-2.1.x86_64.rpm ...............[done (263.7 KiB/s)]
 Retrieving package postgresql10-docs-10.5-2.1.noarch
                                            (3/5),   2.3 MiB ( 17.1 MiB unpacked)
 Retrieving: postgresql10-docs-10.5-2.1.noarch.rpm ............[done (1.3 MiB/s)]
 Retrieving package postgresql10-server-10.5-2.1.x86_64
                                            (4/5),   4.0 MiB ( 18.2 MiB unpacked)
 Retrieving: postgresql10-server-10.5-2.1.x86_64.rpm ..........[done (1.9 MiB/s)]
 Retrieving package postgresql10-test-10.5-2.1.x86_64
                                            (5/5),   1.2 MiB (  9.2 MiB unpacked)
 Retrieving: postgresql10-test-10.5-2.1.x86_64.rpm ............[done (1.0 KiB/s)]
 Checking for file conflicts: .............................................[done]
 (1/5) Installing: postgresql-init-10-16.3.1.noarch .......................[done]
 Additional rpm output:
 Updating /etc/sysconfig/postgresql...
 
 
 
 
 (2/5) Installing: postgresql10-10.5-2.1.x86_64 ...........................[done]
 (3/5) Installing: postgresql10-docs-10.5-2.1.noarch ......................[done]
 (4/5) Installing: postgresql10-server-10.5-2.1.x86_64 ....................[done]
 (5/5) Installing: postgresql10-test-10.5-2.1.x86_64 ......................[done]
 Installation has completed with error.
 linux-3ztp:/home/by79 # linux-3ztp:/home/by79 # zypper in -f postgresql10 postgresql10-docs postgresql10-test
 Loading repository data...
 Reading installed packages...
 Forcing installation of 'postgresql10-10.5-2.1.x86_64' from repository 'openSUSE-Leap-42.3-Update'.
 Forcing installation of 'postgresql10-test-10.5-2.1.x86_64' from repository 'openSUSE-Leap-42.3-Update'.
 Forcing installation of 'postgresql10-docs-10.5-2.1.noarch' from repository 'openSUSE-Leap-42.3-Update'.
 Resolving package dependencies...
 
 
 The following 3 packages are going to be reinstalled:
   postgresql10 postgresql10-docs postgresql10-test
 
 
 3 packages to reinstall.
 Overall download size: 4.9 MiB. Already cached: 0 B. No additional space will be
 used or freed after the operation.Continue? [y/n/...? shows all options] (y): y
 Retrieving package postgresql10-10.5-2.1.x86_64
                                            (1/3),   1.4 MiB (  5.9 MiB unpacked)
 Retrieving: postgresql10-10.5-2.1.x86_64.rpm .................[done (1.0 KiB/s)]
 Retrieving package postgresql10-docs-10.5-2.1.noarch
                                            (2/3),   2.3 MiB ( 17.1 MiB unpacked)
 Retrieving: postgresql10-docs-10.5-2.1.noarch.rpm ............[done (2.5 KiB/s)]
 Retrieving package postgresql10-test-10.5-2.1.x86_64
                                            (3/3),   1.2 MiB (  9.2 MiB unpacked)
 Retrieving: postgresql10-test-10.5-2.1.x86_64.rpm ............[done (1.0 KiB/s)]
 Checking for file conflicts: .............................................[done]
 (1/3) Installing: postgresql10-10.5-2.1.x86_64 ...........................[done]
 (2/3) Installing: postgresql10-docs-10.5-2.1.noarch ......................[done]
 (3/3) Installing: postgresql10-test-10.5-2.1.x86_64 ......................[done]

Finally still ok

by79@linux-3ztp:~> systemctl start postgresql

 by79@linux-3ztp:~> systemctl status postgresql

 ● postgresql.service - PostgreSQL database server
    Loaded: loaded (/usr/lib/systemd/system/postgresql.service; disabled; vendor preset: disabled)
    Active: active (running) since Wed 2018-11-07 05:54:55 +08; 2s ago

   Process: 3386 ExecStart=/usr/lib/postgresql-init start (code=exited, status=0/SUCCESS)

  Main PID: 3397 (postgres)
     Tasks: 8 (limit: 512)
    CGroup: /system.slice/postgresql.service
            ├─3397 /usr/lib/postgresql10/bin/postgres -D /var/lib/pgsql/data
            ├─3398 postgres: logger process    
            ├─3400 postgres: checkpointer process    
            ├─3401 postgres: writer process    
            ├─3402 postgres: wal writer process    
            ├─3403 postgres: autovacuum launcher process    

            ├─3404 postgres: stats collector process    
            └─3405 postgres: bgworker: logical replication launcher    
 by79@linux-3ztp:~> 

  

Is the failure to remove directory /var/lib/pgsql critical? Or I can just leave it? Thanks again.

That’s likely because the postgresql server process wasn’t stopped and is still running, happens with some apps.
Either stop the service or reboot,
Then remove.

Then, you should have a relatively clean machine to re-install postresql from your OSS.

TSU

I tried systemctl stop “postgres*” as well as rebooting but still no luck…

by79@linux-3ztp:~> systemctl stop "postgres*"

 by79@linux-3ztp:~> sudo zypper rm "postgres*"
 Loading repository data...
 Reading installed packages...
 Resolving package dependencies...

 
 
 The following 5 packages are going to be REMOVED:
   postgresql10 postgresql10-docs postgresql10-server postgresql10-test
   postgresql-init
 
 
 5 packages to remove.
 After the operation, 50.5 MiB will be freed.
 Continue? [y/n/...? shows all options] (y): y
 (1/5) Removing postgresql10-docs-10.5-2.1.noarch .........................[done]
 (2/5) Removing postgresql10-test-10.5-2.1.x86_64 .........................[done]

 (3/5) Removing postgresql10-server-10.5-2.1.x86_64 .......................[done]
 Additional rpm output:

 warning: directory /var/lib/pgsql: remove failed: Device or resource busy
 
 
 
 
 (4/5) Removing postgresql10-10.5-2.1.x86_64 ..............................[done]
 (5/5) Removing postgresql-init-10-16.3.1.noarch ..........................[done]


If removing directory /var/lib/pgsql is not critical, can I just move on? Unknown risks are mine.