0% found this document useful (0 votes)
19 views3 pages

Configure WatchDog

Uploaded by

dbatalks
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views3 pages

Configure WatchDog

Uploaded by

dbatalks
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Watchdog devices are software or hardware mechanisms that will reset the whole

system when they do not get a heartbeat within a specified timeframe. This adds an
additional layer of fail safe in case usual Patroni split-brain protection
mechanisms fail.

Patroni will try to activate the watchdog before promoting PostgreSQL to primary.
Currently watchdogs are only supported using Linux watchdog device interface. For
more information about watchdog, see the Patroni documentation.

Default Patroni configuration will try to use /dev/watchdog on Linux if it is


accessible to Patroni. For most use cases using software watchdog built into the
Linux kernel is secure enough.

Edit /etc/watchdog.conf to enable software watchdog:

sudo nano /etc/watchdog.conf


Locate, and uncomment following line:

watchdog-device = /dev/watchdog
Save and close the editor when you are finished.

Execute following commands to activate software watchdog:

sudo mknod /dev/watchdog c 10 130

sudo modprobe softdog

sudo chown postgres /dev/watchdog


Make sure you repeat the same on each node before proceeding to next.

Start Patroni Cluster


Type below command on your (pgsql01) to start your first patroni cluster node:

sudo systemctl start patroni


Verify patroni status using the following command:

sudo systemctl status patroni


If you look carefully at the bottom of the patroni status output, you will see that
the (pgsql01) is acting as leader node in the cluster:
Next, start patroni on subsequent nodes, (pgsql02) for example, you will see
(pgsql02) is acting as secondary node in the cluster:
Start patroni on (pgsql03), and it will also act as the secondary node in the
cluster:

[root@pgsql01 ~]# systemctl status patroni


● patroni.service - Runners to orchestrate a high-availability PostgreSQL
Loaded: loaded (/usr/lib/systemd/system/patroni.service; disabled; vendor
preset: disabled)
Active: active (running) since Wed 2023-05-17 22:57:41 +03; 2h 33min ago
Main PID: 40980 (patroni)
Tasks: 15 (limit: 22938)
Memory: 163.2M
CGroup: /system.slice/patroni.service
├─40980 /usr/bin/python3 /usr/bin/patroni /etc/patroni/patroni.yml
├─50046 /usr/pgsql-15/bin/postgres -D /var/lib/pgsql/15/data --config-
file=/var/lib/pgsql/15/data/postgresql.conf --listen_addresses=192.168.56.231 --po>
├─50047 postgres: pg_cluster: logger
├─50048 postgres: pg_cluster: checkpointer
├─50049 postgres: pg_cluster: background writer
├─50076 postgres: pg_cluster: postgres postgres 192.168.56.231(37600)
idle
├─84365 postgres: pg_cluster: walwriter
├─84366 postgres: pg_cluster: autovacuum launcher
├─84367 postgres: pg_cluster: logical replication launcher
├─84401 postgres: pg_cluster: walsender replicator 192.168.56.233(46144)
streaming 0/449CC18
└─84425 postgres: pg_cluster: walsender replicator 192.168.56.232(39144)
streaming 0/449CC18

May 18 01:29:17 pgsql01.localdomain patroni[40980]: 2023-05-18 01:29:17,074 INFO:


no action. I am (pgsql01), the leader with the lock

Next, start patroni on subsequent nodes, (pgsql02) for example, you will see
(pgsql02) is acting as secondary node in the cluster:

[root@pgsql02 ~]# systemctl status patroni


● patroni.service - Runners to orchestrate a high-availability PostgreSQL
Loaded: loaded (/usr/lib/systemd/system/patroni.service; disabled; vendor
preset: disabled)
Active: active (running) since Wed 2023-05-17 01:34:37 +03; 2h 26min ago
Main PID: 21349 (patroni)
Tasks: 12 (limit: 22938)
Memory: 139.1M
CGroup: /system.slice/patroni.service
├─21349 /usr/bin/python3 /usr/bin/patroni /etc/patroni/patroni.yml
├─79141 /usr/pgsql-15/bin/postgres -D /var/lib/pgsql/15/data --config-
file=/var/lib/pgsql/15/data/postgresql.conf --listen_addresses=192.168.56.232 --po>
├─79142 postgres: pg_cluster: logger
├─79143 postgres: pg_cluster: checkpointer
├─79144 postgres: pg_cluster: background writer
├─79145 postgres: pg_cluster: startup recovering
000000070000000000000004
├─79151 postgres: pg_cluster: walreceiver streaming 0/449CC18
└─79153 postgres: pg_cluster: postgres postgres 192.168.56.232(35990)
idle

May 17 03:59:36 pgsql02.localdomain patroni[21349]: 2023-05-17 03:59:36,947 INFO:


no action. I am (pgsql02), a secondary, and following a leader (pgsql01)

Start patroni on (pgsql03), and it will also act as the secondary node in the
cluster:

[root@pgsql03 ~]# systemctl status patroni


● patroni.service - Runners to orchestrate a high-availability PostgreSQL
Loaded: loaded (/usr/lib/systemd/system/patroni.service; disabled; vendor
preset: disabled)
Active: active (running) since Wed 2023-05-17 01:50:39 +03; 2h 10min ago
Main PID: 25716 (patroni)
Tasks: 12 (limit: 22938)
Memory: 88.9M
CGroup: /system.slice/patroni.service
├─25716 /usr/bin/python3 /usr/bin/patroni /etc/patroni/patroni.yml
├─25779 /usr/pgsql-15/bin/postgres -D /var/lib/pgsql/15/data --config-
file=/var/lib/pgsql/15/data/postgresql.conf --listen_addresses=192.168.56.233 --po>
├─25780 postgres: pg_cluster: logger
├─25781 postgres: pg_cluster: checkpointer
├─25782 postgres: pg_cluster: background writer
├─25783 postgres: pg_cluster: startup recovering
000000070000000000000004
├─25790 postgres: pg_cluster: postgres postgres 192.168.56.233(51808)
idle
└─46797 postgres: pg_cluster: walreceiver streaming 0/449CC18

May 17 03:59:40 pgsql03.localdomain patroni[25716]: 2023-05-17 03:59:40,649 INFO:


no action. I am (pgsql03), a secondary, and following a leader (pgsql01)

You might also like