Re: Two started cluster on the same data directory and port

From: Loles <lolesft(at)gmail(dot)com>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: Two started cluster on the same data directory and port
Date: 2023-11-30 17:27:35
Message-ID: CA+FWGK5t6nE3e1fAWc5j1yXEKkDFhP3ZTNUyHRGbxysDN7k7kA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

root(at)hostname:~# su - postgres
postgres(at)hostname:~$ *nano /etc/postgresql/14/main_old/start.conf*
postgres(at)hostname:~$ exit
cerrar sesión
root(at)hostname:~# *pg_ctlcluster stop 14 main*
*(change auto for disabled and exit with save)*
root(at)hostname:~# ps -ef | grep postgres
root 2609 1512 0 18:24 pts/1 00:00:00 grep postgres
root(at)hostname:~# pg_lsclusters
Ver Cluster Port Status Owner Data directory Log file
*14 main 5432 down* postgres /var/lib/postgresql/14/main
/var/log/postgresql/postgresql-14-main.log
*14 main_old 5432 down * postgres /var/lib/postgresql/14/main
/var/log/postgresql/postgresql-14-main_old.log
root(at)hostname:~#
root(at)hostname:~#
root(at)hostname:~# *pg_ctlcluster start 14 main*
root(at)hostname:~# ps -ef | grep postgres
postgres 2620 1 2 18:24 ? 00:00:00
/usr/lib/postgresql/14/bin/postgres -D /var/lib/postgresql/14/main -c
config_file=/etc/postgresql/14/main/postgresql.conf
postgres 2625 2620 0 18:24 ? 00:00:00 postgres: 14/main:
checkpointer
postgres 2626 2620 0 18:24 ? 00:00:00 postgres: 14/main:
background writer
postgres 2627 2620 0 18:24 ? 00:00:00 postgres: 14/main:
walwriter
postgres 2628 2620 0 18:24 ? 00:00:00 postgres: 14/main:
autovacuum launcher
postgres 2629 2620 0 18:24 ? 00:00:00 postgres: 14/main:
stats collector
postgres 2630 2620 0 18:24 ? 00:00:00 postgres: 14/main:
logical replication launcher
root 2642 1512 0 18:24 pts/1 00:00:00 grep postgres
root(at)hostname:~# pg_lsclusters
Ver Cluster Port Status Owner Data directory Log file
*14 main 5432 online* postgres /var/lib/postgresql/14/main
/var/log/postgresql/postgresql-14-main.log
*14 main_old 5432 online *postgres /var/lib/postgresql/14/main
/var/log/postgresql/postgresql-14-main_old.log

Start, up the two cluster.

El jue, 30 nov 2023 a las 18:01, Adrian Klaver (<adrian(dot)klaver(at)aklaver(dot)com>)
escribió:

> On 11/30/23 08:46, Loles wrote:
> > Yes, it exists but it is obsolete. The files and directories are all
> > dated 2022.
> >
> > It was obsolete and no longer valid, it could be deleted. Only the main
> > cluster is correct.
>
> First try:
>
> vi /etc/postgresql/14/main_old/start.conf
>
> and change auto to disabled.
>
> Stop the server(s) and then:
>
> sudo pg_ctlcluster starp 14 main
>
> >
> > El jue, 30 nov 2023 a las 17:43, Adrian Klaver
> > (<adrian(dot)klaver(at)aklaver(dot)com <mailto:adrian(dot)klaver(at)aklaver(dot)com>>)
> escribió:
> >
> > On 11/30/23 08:37, Loles wrote:
> > > Every time I stop the main_old cluster with sudo pg_ctlcluster
> > stop 14
> > > main_old, both are stopped. And when I raise sudo pg_ctlcluster
> > start 14
> > > main, both are raised.
> > >
> > > I don't know how I got into this situation and I don't know how to
> > > resolve it.
> >
> > Is there both?:
> >
> > /etc/postgresql/14/main/
> > /etc/postgresql/14/main_old/
> >
> > >
> > >
> > > El jue, 30 nov 2023 a las 17:34, Loles (<lolesft(at)gmail(dot)com
> > <mailto:lolesft(at)gmail(dot)com>
> > > <mailto:lolesft(at)gmail(dot)com <mailto:lolesft(at)gmail(dot)com>>>) escribió:
> > >
> > > Indeed, that is the problem, they are two different clusters,
> > > pointing to the same data directory and reading from the same
> > port.
> > >
> > > I can't change the port because it is the same postgresql.conf
> > >
> > > I don't know how to disassociate the main_old cluster from
> > the data
> > > directory or how to resolve this situation.
> > >
> > > El jue, 30 nov 2023 a las 16:32, Adrian Klaver
> > > (<adrian(dot)klaver(at)aklaver(dot)com
> > <mailto:adrian(dot)klaver(at)aklaver(dot)com> <mailto:adrian(dot)klaver(at)aklaver(dot)com
> > <mailto:adrian(dot)klaver(at)aklaver(dot)com>>>)
> > > escribió:
> > >
> > > On 11/30/23 07:23, Adrian Klaver wrote:
> > > > On 11/30/23 05:37, Loles wrote:
> > > >> Hi!
> > > >>
> > > >> I have this situation on a server that is giving me
> > problems.
> > > >>
> > > >> postgres(at)hostname:~$ pg_lsclusters
> > > >> Ver Cluster Port Status Owner Data directory
> > > Log file
> > > >> 14 main 5432 online postgres
> > /var/lib/postgresql/14/main
> > > >> /var/log/postgresql/postgresql-14-main.log
> > > >> 14 main_old 5432 online postgres
> > /var/lib/postgresql/14/main
> > > >> /var/log/postgresql/postgresql-14-main_old.log
> > > >>
> > > >> How can I stop, even delete, the main_old cluster?
> > > >
> > > > Assuming you are on Debian/Ubuntu.
> > > >
> > > > 1) sudo pg_ctlcluster stop 14 main_old
> > > >
> > > > This will stop the server for this session
> > > >
> > > > 2) sudo vi /etc/postgresql/14/main_old/start.conf
> > > >
> > > > Change auto to manual.
> > > > This will keep the server from restarting on
> reboot.
> > > > You can still start it using
> > > > sudo pg_ctlcluster start 14 main_old
> > > > Though if you want to do that then:
> > > > vi /etc/postgresql/14/main_old/postgresql.conf
> > > > and change port to something other then 5432.
> > > >
> > > > 3) If you have determined you really don't need that
> > server
> > > and have all
> > > > the data safely backed up or moved to the other server,
> > > then(THIS IS NOT
> > > > REVERSIBLE):
> > > >
> > > > sudo pg_dropcluster 14 main_old
> > >
> > > Blaming it on not enough coffee, but I just noticed both
> > > clusters are
> > > pointing at the same data directory. I would NOT do:
> > >
> > > sudo pg_dropcluster 14 main_old
> > >
> > > >
> > > >>
> > > >> Thanks!
> > > >>
> > > >
> > >
> > > --
> > > Adrian Klaver
> > > adrian(dot)klaver(at)aklaver(dot)com <mailto:adrian(dot)klaver(at)aklaver(dot)com>
> > <mailto:adrian(dot)klaver(at)aklaver(dot)com <mailto:adrian(dot)klaver(at)aklaver(dot)com
> >>
> > >
> >
> > --
> > Adrian Klaver
> > adrian(dot)klaver(at)aklaver(dot)com <mailto:adrian(dot)klaver(at)aklaver(dot)com>
> >
>
> --
> Adrian Klaver
> adrian(dot)klaver(at)aklaver(dot)com
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephen Frost 2023-11-30 17:48:05 Re: Fixing or Mitigating this ERROR: invalid page in block 35217 of relation base/16421/3192429
Previous Message Adrian Klaver 2023-11-30 17:01:02 Re: Two started cluster on the same data directory and port