Header Shadow Image


Patroni cluster not initializing

Not getting a cluster initialized when using patroni?

[root@psql06 patroni]# systemctl status patroni
? patroni.service – Runners to orchestrate a high-availability PostgreSQL
   Loaded: loaded (/etc/systemd/system/patroni.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2022-03-06 14:08:28 EST; 2min 13s ago
 Main PID: 5857 (patroni)
   CGroup: /system.slice/patroni.service
           ??5857 /usr/bin/python3 /usr/bin/patroni /etc/patroni.yml

Mar 06 14:08:28 psql06.nix.mds.xyz systemd[1]: Started Runners to orchestrate a high-availability PostgreSQL.
[root@psql06 patroni]#

Run this command to tell the system to recreate it (assuming it's new ) in the ETCD database.  :

[root@psql06 patroni]# etcdctl rm /db/postgres/initialize /db/postgres/members/postgresql0 /db/postgres/members/postgresql1 /db/postgres/members/postgresql2
PrevNode.Value: 7072040681072184024
[root@psql06 patroni]#

Otherwise, take a backup and issue the above etcd command to reinitialize it in the etcd database.  You should now see the cluster initialized:

[root@psql06 patroni]# ls -altri
total 128
 69165434 drwxr-xr-x.  3 root     root        20 Mar  1 23:20 ..
135599427 -rw——-.  1 postgres postgres   206 Mar  6 14:13 backup_label.old
201488665 drwx——.  2 postgres postgres     6 Mar  6 14:13 pg_twophase
135599430 drwx——.  2 postgres postgres     6 Mar  6 14:13 pg_subtrans
 69297824 drwx——.  2 postgres postgres     6 Mar  6 14:13 pg_snapshots
    79235 drwx——.  2 postgres postgres     6 Mar  6 14:13 pg_serial
135599429 drwx——.  2 postgres postgres     6 Mar  6 14:13 pg_dynshmem
 69297823 drwx——.  2 postgres postgres     6 Mar  6 14:13 pg_commit_ts
    79236 drwx——.  4 postgres postgres    34 Mar  6 14:13 pg_multixact
201488666 drwx——.  5 postgres postgres    38 Mar  6 14:13 base
201488669 drwx——.  2 postgres postgres    17 Mar  6 14:13 pg_xact
   490575 drwx——.  2 postgres postgres     6 Mar  6 14:13 pg_tblspc
134330472 drwx——.  2 postgres postgres     6 Mar  6 14:13 pg_stat_tmp
 69062750 drwx——.  2 postgres postgres     6 Mar  6 14:13 pg_stat
201488668 drwx——.  2 postgres postgres     6 Mar  6 14:13 pg_replslot
134330475 -rw——-.  1 postgres postgres    88 Mar  6 14:13 postgresql.auto.conf
134330474 -rw——-.  1 postgres postgres     3 Mar  6 14:13 PG_VERSION
   490608 drwx——.  4 postgres postgres    65 Mar  6 14:13 pg_logical
134330476 -rw——-.  1 postgres postgres  4739 Mar  6 14:13 pg_hba.conf
134330477 -rw——-.  1 postgres postgres  1636 Mar  6 14:13 pg_ident.conf
134330481 -rw——-.  1 postgres postgres 23002 Mar  6 14:13 postgresql.base.conf
201488671 drwx——.  2 postgres postgres    31 Mar  6 14:13 log
134983769 -rw——-.  1 postgres postgres   297 Mar  6 14:13 recovery.conf
134330482 -rw-r–r–.  1 postgres postgres   580 Mar  6 14:13 postgresql.conf
134983765 -rw——-.  1 postgres postgres    37 Mar  6 14:13 .s.PGSQL.5432.lock
134983771 srwxrwxrwx.  1 postgres postgres     0 Mar  6 14:13 .s.PGSQL.5432
201488664 drwx——.  2 postgres postgres    17 Mar  6 14:13 pg_notify
134983772 -rw——-.  1 postgres postgres   435 Mar  6 14:13 postmaster.opts
134983766 -rw——-.  1 postgres postgres    30 Mar  6 14:13 current_logfiles
134983770 -rw——-.  1 postgres postgres    85 Mar  6 14:13 postmaster.pid
  1165873 drwx——.  2 postgres postgres  4096 Mar  6 14:13 global
134330478 -rw-r–r–.  1 postgres postgres   580 Mar  6 14:13 postgresql.conf.backup
134983767 -rw——-.  1 postgres postgres 23002 Mar  6 14:13 postgresql.base.conf.backup
134330479 -rw——-.  1 postgres postgres  4739 Mar  6 14:13 pg_hba.conf.backup
134330480 -rw——-.  1 postgres postgres  1636 Mar  6 14:13 pg_ident.conf.backup
134330484 -rw——-.  1 postgres postgres   124 Mar  6 14:13 patroni.dynamic.json
135582283 drwx——. 20 postgres postgres  4096 Mar  6 14:13 .
135599426 drwx——.  3 postgres postgres  4096 Mar  6 14:13 pg_wal
[root@psql06 patroni]#

And now you should see a healthy cluster:

[root@psql04 patroni]# patronictl –config-file=/etc/patroni.yml list
+————-+——————–+———+———+—-+———–+
| Member      | Host               | Role    | State   | TL | Lag in MB |
+ Cluster: postgres (7072067282323834615) —+———+—-+———–+
| postgresql0 | psql04.nix.mds.xyz | Replica | running |  1 |         0 |
| postgresql1 | psql05.nix.mds.xyz | Leader  | running |  1 |           |
| postgresql2 | psql06.nix.mds.xyz | Replica | running |  1 |         0 |
+————-+——————–+———+———+—-+———–+
[root@psql04 patroni]#

 

HF!

Cheers,


     
  Copyright © 2003 - 2013 Tom Kacperski (microdevsys.com). All rights reserved.

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License