Thread: Two started cluster on the same data directory and port
Hi!
I have this situation on a server that is giving me problems.
I have this situation on a server that is giving me problems.
postgres@hostname:~$ pg_lsclusters
Ver Cluster Port Status Owner Data directory Log file
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
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?
Thanks!
On 11/30/23 05:37, Loles wrote: > Hi! > > I have this situation on a server that is giving me problems. > > postgres@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 > > Thanks! > -- Adrian Klaver adrian.klaver@aklaver.com
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@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.klaver@aklaver.com
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.
I don't know how I got into this situation and I don't know how to resolve it.
El jue, 30 nov 2023 a las 17:34, Loles (<lolesft@gmail.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.klaver@aklaver.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@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.klaver@aklaver.com
On 11/30/23 08:34, Loles wrote: Please reply to list also. Ccing list. > 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.klaver@aklaver.com <mailto:adrian.klaver@aklaver.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@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.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com> > -- Adrian Klaver adrian.klaver@aklaver.com
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@gmail.com > <mailto:lolesft@gmail.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.klaver@aklaver.com <mailto:adrian.klaver@aklaver.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@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.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com> > -- Adrian Klaver adrian.klaver@aklaver.com
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.
El jue, 30 nov 2023 a las 17:43, Adrian Klaver (<adrian.klaver@aklaver.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@gmail.com
> <mailto:lolesft@gmail.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.klaver@aklaver.com <mailto:adrian.klaver@aklaver.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@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.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
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.klaver@aklaver.com <mailto:adrian.klaver@aklaver.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@gmail.com > <mailto:lolesft@gmail.com> > > <mailto:lolesft@gmail.com <mailto:lolesft@gmail.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.klaver@aklaver.com > <mailto:adrian.klaver@aklaver.com> <mailto:adrian.klaver@aklaver.com > <mailto:adrian.klaver@aklaver.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@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.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com> > <mailto:adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>> > > > > -- > Adrian Klaver > adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com> > -- Adrian Klaver adrian.klaver@aklaver.com
root@hostname:~# su - postgres
postgres@hostname:~$ nano /etc/postgresql/14/main_old/start.conf
postgres@hostname:~$ exit
cerrar sesión
root@hostname:~# pg_ctlcluster stop 14 main
(change auto for disabled and exit with save)
postgres@hostname:~$ nano /etc/postgresql/14/main_old/start.conf
postgres@hostname:~$ exit
cerrar sesión
root@hostname:~# pg_ctlcluster stop 14 main
(change auto for disabled and exit with save)
root@hostname:~# ps -ef | grep postgres
root 2609 1512 0 18:24 pts/1 00:00:00 grep postgres
root@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@hostname:~#
root@hostname:~#
root@hostname:~# pg_ctlcluster start 14 main
root@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@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
root 2609 1512 0 18:24 pts/1 00:00:00 grep postgres
root@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@hostname:~#
root@hostname:~#
root@hostname:~# pg_ctlcluster start 14 main
root@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@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.klaver@aklaver.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.klaver@aklaver.com <mailto:adrian.klaver@aklaver.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@gmail.com
> <mailto:lolesft@gmail.com>
> > <mailto:lolesft@gmail.com <mailto:lolesft@gmail.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.klaver@aklaver.com
> <mailto:adrian.klaver@aklaver.com> <mailto:adrian.klaver@aklaver.com
> <mailto:adrian.klaver@aklaver.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@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.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>
> <mailto:adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>>
> >
>
> --
> Adrian Klaver
> adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
On 11/30/23 09:27, Loles wrote: > root@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. > Before going any further make sure you have a current backup of the database. Hmm, are /etc/postgresql/14/main/ and /etc/postgresql/14/main_old/ symlinked together? If not what if you move the ~14/main_old/ directory somewhere else and then restart Postgres? Adrian Klaver adrian.klaver@aklaver.com
No, they are not symbolic links. I have thought about moving the main_old directory somewhere else and it doesn't change anything because the cluster main_old is linked to the main data directory. In fact, neither the log nor any main_old data file changes, they are all from 2020. It's a strange case
El jue., 30 nov. 2023 16:23, Adrian Klaver <adrian.klaver@aklaver.com> escribió:
On 11/30/23 05:37, Loles wrote:
> Hi!
>
> I have this situation on a server that is giving me problems.
>
> postgres@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
>
> Thanks!
>
--
Adrian Klaver
adrian.klaver@aklaver.com
On 11/30/23 10:35, Adrian Klaver wrote: > On 11/30/23 09:27, Loles wrote: > >> root@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. >> > > Before going any further make sure you have a current backup of the > database. > > Hmm, are /etc/postgresql/14/main/ and /etc/postgresql/14/main_old/ > symlinked together? > > If not what if you move the ~14/main_old/ directory somewhere else and > then restart Postgres? Alright results of testing here: tree /etc/postgresql/14 /etc/postgresql/14 ├── main │ ├── conf.d │ ├── environment │ ├── pg_ctl.conf │ ├── pg_hba.conf │ ├── pg_ident.conf │ ├── postgresql.conf │ └── start.conf └── main_old ├── conf.d ├── environment ├── pg_ctl.conf ├── pg_hba.conf ├── pg_ident.conf ├── postgresql.conf └── start.conf Where I just copied main/ to main_old/. sudo pg_ctlcluster start 14 main 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 sudo pg_ctlcluster stop 14 main 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 cd /etc/postgresql/14/ sudo rm -r main_old/ or sudo cp -r main_old <some_new_path> sudo pg_ctlcluster start 14 main 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 I would need to understand systemd better to be sure, but I'm thinking the duplicated cluster are happening here: /lib/systemd/system-generators/postgresql-generator #!/bin/sh # This systemd generator creates dependency symlinks that make all PostgreSQL # clusters with "auto" in their start.conf file be started/stopped/reloaded # when postgresql.service is started/stopped/reloaded. set -eu gendir="$1" wantdir="$1/postgresql.service.wants" bindir="/usr/lib/postgresql/" #redhat# bindir="/usr/pgsql-" pgservice="/lib/systemd/system/postgresql@.service" mkdir -p "$wantdir" for conf in /etc/postgresql/*/*/postgresql.conf; do # abort loop if glob was not expanded (but accept dead symlinks) if ! test -e "$conf" && ! test -L "$conf"; then continue; fi dir="${conf%/*}" # evaluate start.conf if [ -e "$dir/start.conf" ]; then start=$(sed 's/#.*$//; /^[[:space:]]*$/d; s/^\s*//; s/\s*$//' "$dir/start.conf") else start=auto fi [ "$start" = "auto" ] || continue verdir="${dir%/*}" version="${verdir##*/}" test -x "$bindir$version/bin/postgres" || continue # package got removed cluster="${dir##*/}" ln -s "$pgservice" "$wantdir/postgresql@$version-$cluster.service" done exit 0 > > Adrian Klaver > adrian.klaver@aklaver.com > > > -- Adrian Klaver adrian.klaver@aklaver.com
On 11/30/23 12:35, Adrian Klaver wrote: > On 11/30/23 10:35, Adrian Klaver wrote: >> On 11/30/23 09:27, Loles wrote: >> > cd /etc/postgresql/14/ > sudo rm -r main_old/ > or > sudo cp -r main_old <some_new_path> Arrgh. sudo mv -r main_old <some_new_path> Memo to self don't eat lunch and copy/paste at same time. -- Adrian Klaver adrian.klaver@aklaver.com
El día jueves, noviembre 30, 2023 a las 02:10:25p. m. -0800, Adrian Klaver escribió: > On 11/30/23 12:35, Adrian Klaver wrote: > > On 11/30/23 10:35, Adrian Klaver wrote: > > > On 11/30/23 09:27, Loles wrote: > > > > > > cd /etc/postgresql/14/ > > sudo rm -r main_old/ > > or > > sudo cp -r main_old <some_new_path> > > Arrgh. > > sudo mv -r main_old <some_new_path> > > Memo to self don't eat lunch and copy/paste at same time. Hmmm purism@pureos:~$ uname -s Linux purism@pureos:~$ mv -r foo bar mv: invalid option -- 'r' Try 'mv --help' for more information. matthias -- Matthias Apitz, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045 Public GnuPG key: http://www.unixarea.de/key.pub I am not at war with Russia. Я не воюю с Россией. Ich bin nicht im Krieg mit Russland.
On 11/30/23 20:43, Matthias Apitz wrote: > El día jueves, noviembre 30, 2023 a las 02:10:25p. m. -0800, Adrian Klaver escribió: > >> On 11/30/23 12:35, Adrian Klaver wrote: >>> On 11/30/23 10:35, Adrian Klaver wrote: >>>> On 11/30/23 09:27, Loles wrote: >>>> >> >>> cd /etc/postgresql/14/ >>> sudo rm -r main_old/ >>> or >>> sudo cp -r main_old <some_new_path> >> >> Arrgh. >> >> sudo mv -r main_old <some_new_path> >> >> Memo to self don't eat lunch and copy/paste at same time. > > Hmmm > > purism@pureos:~$ uname -s > Linux > purism@pureos:~$ mv -r foo bar > mv: invalid option -- 'r' The gift that keeps on giving. Third time's a charm?: sudo mv main_old/ <some_new_path> > Try 'mv --help' for more information. > > matthias -- Adrian Klaver adrian.klaver@aklaver.com
Yes, it seems to be caused by systemd.
I'll investigate there. If not, I can upgrade PostgreSQL and get rid of server 14.
Thank you very much Adrian... I'm going to get a cup of coffee because the topic requires it :D
I'll investigate there. If not, I can upgrade PostgreSQL and get rid of server 14.
Thank you very much Adrian... I'm going to get a cup of coffee because the topic requires it :D
El vie, 1 dic 2023 a las 6:19, Adrian Klaver (<adrian.klaver@aklaver.com>) escribió:
On 11/30/23 20:43, Matthias Apitz wrote:
> El día jueves, noviembre 30, 2023 a las 02:10:25p. m. -0800, Adrian Klaver escribió:
>
>> On 11/30/23 12:35, Adrian Klaver wrote:
>>> On 11/30/23 10:35, Adrian Klaver wrote:
>>>> On 11/30/23 09:27, Loles wrote:
>>>>
>>
>>> cd /etc/postgresql/14/
>>> sudo rm -r main_old/
>>> or
>>> sudo cp -r main_old <some_new_path>
>>
>> Arrgh.
>>
>> sudo mv -r main_old <some_new_path>
>>
>> Memo to self don't eat lunch and copy/paste at same time.
>
> Hmmm
>
> purism@pureos:~$ uname -s
> Linux
> purism@pureos:~$ mv -r foo bar
> mv: invalid option -- 'r'
The gift that keeps on giving. Third time's a charm?:
sudo mv main_old/ <some_new_path>
> Try 'mv --help' for more information.
>
> matthias
--
Adrian Klaver
adrian.klaver@aklaver.com
On 12/1/23 01:17, Loles wrote: > Yes, it seems to be caused by systemd. To be more accurate it is caused by the the file postgresql-generator located here: /lib/systemd/system-generators/ That file is installed by the Postgres Debian/Ubuntu package, so it is the Postgres install that is using systemd in this manner. > > I'll investigate there. If not, I can upgrade PostgreSQL and get rid of > server 14. If your directory structure resembles: /etc/postgresql/14 ├── main │ ├── conf.d │ ├── environment │ ├── pg_ctl.conf │ ├── pg_hba.conf │ ├── pg_ident.conf │ ├── postgresql.conf │ └── start.conf └── main_old ├── conf.d ├── environment ├── pg_ctl.conf ├── pg_hba.conf ├── pg_ident.conf ├── postgresql.conf └── start.conf Then you just need to: 1) Stop the server 2) mv or rm the main_old/ directory 3) Restart the server > > Thank you very much Adrian... I'm going to get a cup of coffee because > the topic requires it :D > > > El vie, 1 dic 2023 a las 6:19, Adrian Klaver (<adrian.klaver@aklaver.com > <mailto:adrian.klaver@aklaver.com>>) escribió: > > On 11/30/23 20:43, Matthias Apitz wrote: > > El día jueves, noviembre 30, 2023 a las 02:10:25p. m. -0800, > Adrian Klaver escribió: > > > >> On 11/30/23 12:35, Adrian Klaver wrote: > >>> On 11/30/23 10:35, Adrian Klaver wrote: > >>>> On 11/30/23 09:27, Loles wrote: > >>>> > >> > >>> cd /etc/postgresql/14/ > >>> sudo rm -r main_old/ > >>> or > >>> sudo cp -r main_old <some_new_path> > >> > >> Arrgh. > >> > >> sudo mv -r main_old <some_new_path> > >> > >> Memo to self don't eat lunch and copy/paste at same time. > > > > Hmmm > > > > purism@pureos:~$ uname -s > > Linux > > purism@pureos:~$ mv -r foo bar > > mv: invalid option -- 'r' > > The gift that keeps on giving. Third time's a charm?: > > sudo mv main_old/ <some_new_path> > > > Try 'mv --help' for more information. > > > > matthias > > -- > Adrian Klaver > adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com> > -- Adrian Klaver adrian.klaver@aklaver.com