ubuntu 18: PostgreSQL does not start. how can I totally remove and reinstall it

Started by robert rottermannabout 5 years ago12 messagesgeneral
Jump to latest
#1robert rottermann
robert@redcor.ch

Hi there

I made somehow a mess with my PostgreSQL installation an an ubuntu 18.4 with
PostgreSQL 10.0

service postgresql status
● postgresql.service - PostgreSQL RDBMS
   Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor
preset: enabled)
   Active: active (exited) since Sat 2021-01-23 21:21:13 CET; 2min 26s ago
  Process: 1853 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
 Main PID: 1853 (code=exited, status=0/SUCCESS)

I would like to remove everything, and reinstall.

How can I do that?

It seems, that

apt remove --purge postgresql
apt remove --purge postgresql-client

I not enough, as I have the same situation afterwards.

Or is there a way that I can rebuild PostgreSQL datastructure?

thanks

Robert

#2Ron
ronljohnsonjr@gmail.com
In reply to: robert rottermann (#1)
Re: ubuntu 18: PostgreSQL does not start. how can I totally remove and reinstall it

On 1/23/21 2:36 PM, robert rottermann wrote:

Hi there

I made somehow a mess with my PostgreSQL installation an an ubuntu 18.4
with PostgreSQL 10.0

service postgresql status
● postgresql.service - PostgreSQL RDBMS
   Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor
preset: enabled)
   Active: active (exited) since Sat 2021-01-23 21:21:13 CET; 2min 26s ago
  Process: 1853 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
 Main PID: 1853 (code=exited, status=0/SUCCESS)

What's the error?

I would like to remove everything, and reinstall.

How can I do that?

It seems, that

apt remove --purge postgresql
apt remove --purge postgresql-client

I not enough, as I have the same situation afterwards.

What happens after you purge the packages.

Or is there a way that I can rebuild PostgreSQL datastructure?

Yes, but you haven't given us nearly enough information.

--
Angular momentum makes the world go 'round.

#3Adrian Klaver
adrian.klaver@aklaver.com
In reply to: robert rottermann (#1)
Re: ubuntu 18: PostgreSQL does not start. how can I totally remove and reinstall it

On 1/23/21 12:36 PM, robert rottermann wrote:

Hi there

I made somehow a mess with my PostgreSQL installation an an ubuntu 18.4
with PostgreSQL 10.0

service postgresql status
● postgresql.service - PostgreSQL RDBMS
   Loaded: loaded (/lib/systemd/system/postgresql.service; enabled;
vendor preset: enabled)
   Active: active (exited) since Sat 2021-01-23 21:21:13 CET; 2min 26s ago
  Process: 1853 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
 Main PID: 1853 (code=exited, status=0/SUCCESS)

What if you try:

sudo service postgresql@10-main status

Also what does:

pg_lsclusters

show?

I would like to remove everything, and reinstall.

How can I do that?

It seems, that

apt remove --purge postgresql
apt remove --purge postgresql-client

I not enough, as I have the same situation afterwards.

Or is there a way that I can rebuild PostgreSQL datastructure?

thanks

Robert

--
Adrian Klaver
adrian.klaver@aklaver.com

#4robert
robert@redo2oo.ch
In reply to: Adrian Klaver (#3)
Re: ubuntu 18: PostgreSQL does not start. how can I totally remove and reinstall it

Thanks Adrian

On 23.01.21 21:45, Adrian Klaver wrote:

On 1/23/21 12:36 PM, robert rottermann wrote:

Hi there

I made somehow a mess with my PostgreSQL installation an an ubuntu 18.4 with
PostgreSQL 10.0

service postgresql status
● postgresql.service - PostgreSQL RDBMS
    Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor
preset: enabled)
    Active: active (exited) since Sat 2021-01-23 21:21:13 CET; 2min 26s ago
   Process: 1853 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
  Main PID: 1853 (code=exited, status=0/SUCCESS)

What if you try:

sudo service postgresql@10-main status

Also  what does:

pg_lsclusters

show?

root@elfero-test:~/scripts# pg_lsclusters
Ver Cluster Port Status Owner    Data directory              Log file
10  main    5433 online postgres /var/lib/postgresql/10/main
/var/log/postgresql/postgresql-10-main.log
root@elfero-test:~/scripts# service postgresql@10-main status
● postgresql@10-main.service - PostgreSQL Cluster 10-main
   Loaded: loaded (/lib/systemd/system/postgresql@.service; indirect; vendor
preset: enabled)
   Active: active (running) since Sat 2021-01-23 22:11:40 CET; 9h ago
  Process: 1348 ExecStart=/usr/bin/pg_ctlcluster --skip-systemctl-redirect
10-main start (code=exited, status=0/SUCCESS)
 Main PID: 1460 (postgres)
    Tasks: 7 (limit: 4543)
   CGroup: /system.slice/system-postgresql.slice/postgresql@10-main.service
           ├─1460 /usr/lib/postgresql/10/bin/postgres -D
/var/lib/postgresql/10/main -c config_file=/etc/postgresql/10/main/postgresql.conf
           ├─1471 postgres: 10/main: checkpointer process
           ├─1472 postgres: 10/main: writer process
           ├─1473 postgres: 10/main: wal writer process
           ├─1474 postgres: 10/main: autovacuum launcher process
           ├─1475 postgres: 10/main: stats collector process
           └─1476 postgres: 10/main: bgworker: logical replication launcher

Jan 23 22:11:38 elfero-test systemd[1]: Starting PostgreSQL Cluster 10-main...

Jan 23 22:11:40 elfero-test systemd[1]: Started PostgreSQL Cluster 10-main.

Now I can also run psql. (why I could not before, I do not know ..)
BUT still I can not access the db from python.
even a simple python script like:

importpsycopg2
conn = psycopg2.connect(host="localhost", user="postgres", database="postgres")

Produces:

root@elfero-test:~/scripts# python test_elfero.py
Traceback (most recent call last):
  File "test_elfero.py", line 2, in <module>
    conn = psycopg2.connect(host="localhost", user="postgres", database="postgres")
  File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 130, in
connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not connect to server: Connection refused
    Is the server running on host "localhost" (127.0.0.1) and accepting
    TCP/IP connections on port 5432?

Any help is much appreciated

Robert

#5Julien Rouhaud
rjuju123@gmail.com
In reply to: robert (#4)
Re: ubuntu 18: PostgreSQL does not start. how can I totally remove and reinstall it

On Sun, Jan 24, 2021 at 2:58 PM robert@redo2oo.ch <robert@redo2oo.ch> wrote:

root@elfero-test:~/scripts# pg_lsclusters
Ver Cluster Port Status Owner Data directory Log file
10 main 5433 online postgres /var/lib/postgresql/10/main /var/log/postgresql/postgresql-10-main.log
[...]
psycopg2.OperationalError: could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?

It looks like your instance is configured to listen on port 5433, not 5432.

#6Hemil Ruparel
hemilruparel2002@gmail.com
In reply to: Julien Rouhaud (#5)
Re: ubuntu 18: PostgreSQL does not start. how can I totally remove and reinstall it

One small note. Aside from the fact that your server is running from a
different port, psycopg2 does not support authentication without password
afaik. It has bit me twice

On Sun, Jan 24, 2021 at 12:34 PM Julien Rouhaud <rjuju123@gmail.com> wrote:

Show quoted text

On Sun, Jan 24, 2021 at 2:58 PM robert@redo2oo.ch <robert@redo2oo.ch>
wrote:

root@elfero-test:~/scripts# pg_lsclusters
Ver Cluster Port Status Owner Data directory Log file
10 main 5433 online postgres /var/lib/postgresql/10/main

/var/log/postgresql/postgresql-10-main.log

[...]
psycopg2.OperationalError: could not connect to server: Connection

refused

Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?

It looks like your instance is configured to listen on port 5433, not 5432.

#7robert rottermann
robert@redcor.ch
In reply to: Julien Rouhaud (#5)
solved (was plain stupidity) Re: ubuntu 18: PostgreSQL does not start. how can I totally remove and reinstall it

thanks a lot.
why dos such stupidity not hurt. ?????

have a nice weekend
robert

Show quoted text

On 24.01.21 08:04, Julien Rouhaud wrote:

On Sun, Jan 24, 2021 at 2:58 PM robert@redo2oo.ch <robert@redo2oo.ch> wrote:

root@elfero-test:~/scripts# pg_lsclusters
Ver Cluster Port Status Owner Data directory Log file
10 main 5433 online postgres /var/lib/postgresql/10/main /var/log/postgresql/postgresql-10-main.log
[...]
psycopg2.OperationalError: could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?

It looks like your instance is configured to listen on port 5433, not 5432.

#8Paul Förster
paul.foerster@gmail.com
In reply to: robert rottermann (#7)
Re: solved (was plain stupidity) Re: ubuntu 18: PostgreSQL does not start. how can I totally remove and reinstall it

Hi Robert,

On 24. Jan, 2021, at 08:13, robert rottermann <robert@redcor.ch> wrote:

thanks a lot.
why dos such stupidity not hurt. ?????

the human brain does not contain pain generating or transmitting nerve cells, that's why. :-P

Cheers,
Paul

#9Nick Renders
postgres@arcict.com
In reply to: robert rottermann (#7)
Re: solved (was plain stupidity) Re: ubuntu 18: PostgreSQL does not start. how can I totally remove and reinstall it

Robert,

Otherwise mankind would constantly be in pain ;-)

Enjoy the weekend !

Marc

On 24 Jan 2021, at 8:13, robert rottermann wrote:

thanks a lot.
why dos such stupidity not hurt. ?????

have a nice weekend
robert

On 24.01.21 08:04, Julien Rouhaud wrote:

On Sun, Jan 24, 2021 at 2:58 PM robert@redo2oo.ch <robert@redo2oo.ch>
wrote:

root@elfero-test:~/scripts# pg_lsclusters
Ver Cluster Port Status Owner Data directory Log
file
10 main 5433 online postgres /var/lib/postgresql/10/main
/var/log/postgresql/postgresql-10-main.log
[...]
psycopg2.OperationalError: could not connect to server: Connection
refused
Is the server running on host "localhost" (127.0.0.1) and
accepting
TCP/IP connections on port 5432?

It looks like your instance is configured to listen on port 5433, not
5432.

ARC - your Apple service partner

#10Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Hemil Ruparel (#6)
Re: ubuntu 18: PostgreSQL does not start. how can I totally remove and reinstall it

On 1/23/21 11:08 PM, Hemil Ruparel wrote:

One small note. Aside from the fact that your server is running from a
different port, psycopg2 does not support authentication without
password afaik. It has bit me twice

You will need to explain that further as I have not seen that over many
years using psycopg2.

--
Adrian Klaver
adrian.klaver@aklaver.com

#11Daniele Varrazzo
daniele.varrazzo@gmail.com
In reply to: Hemil Ruparel (#6)
Re: ubuntu 18: PostgreSQL does not start. how can I totally remove and reinstall it

On Sun, 24 Jan 2021 at 08:09, Hemil Ruparel <hemilruparel2002@gmail.com> wrote:

One small note. Aside from the fact that your server is running from a different port, psycopg2 does not support authentication without password afaik. It has bit me twice

It is more likely that you have some misunderstanding around
PostgreSQL authentication. If you have an example we can look into it.

-- Daniele

#12Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Hemil Ruparel (#6)
Re: ubuntu 18: PostgreSQL does not start. how can I totally remove and reinstall it

On 1/23/21 11:08 PM, Hemil Ruparel wrote:

One small note. Aside from the fact that your server is running from a
different port, psycopg2 does not support authentication without
password afaik. It has bit me twice

Some thinking on this made me realize where you could get into this
situation. Namely if you are using psycopg2 compiled against an older
version of libpq that you then use to connect to a newer version of the
server that is using an authentication method that the libpq version
does not know about. This however is a generic issue of mismatched
libraries and not unique to psycopg2.

--
Adrian Klaver
adrian.klaver@aklaver.com