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@xxxxxxxxxxx
--
Adrian Klaver
adrian.klaver@xxxxxxxxxxx