etcd trikčių šalinimas
Informacija
Visą procedūrą reikia atlikti kaip root. Norėdami padidinti savo teises iki root, galite naudoti komandą su -.
etcd – tai paskirstytoji raktų ir reikšmių saugykla, naudojama kaip PostgreSQL klasterio mazgų koordinavimo taškas. Ji patikimai centralizuoja ir bendrina klasterio būseną, įskaitant lyderio tapatybę, narių būseną ir užrakinimo mechanizmus.
patroni remiasi etcd, kad valdytų lyderio mazgo rinkimus ir, įvykus incidentui, automatiškai inicijuotų perjungimą po gedimo. Įdiegta visuose mazguose, etcd užtikrina bendrą klasterio nuoseklumą, nedalyvaudama saugant ar apdorojant PostgreSQL duomenų.
Todėl patroni priklauso nuo etcd ir negali tinkamai veikti, jei etcd neveikia.
Informacija
etcd konfigūracija saugoma kiekvieno mazgo faile /etc/default/etcd.
Logs
Visa procedūra remiasi paslaugos etcd žurnalais, kuriuos gaunate toliau pateikta komanda:
Patarimas
Norėdami stebėti žurnalus realiuoju laiku, pridėkite prie komandos parinktį -f:
Informacija
etcd žurnalai taip pat pasiekiami faile /var/log/syslog.
Klaidų žurnalų paaiškinimai
health check for peer <PEER_PSQL_NODE_ID> could not connect: dial tcp <PEER_IP_PSQL_NODE>:2380: i/o timeout
Jei srautas TCP/2380 tarp dviejų mazgų neatidarytas, baigiasi ryšio skirtasis laikas ir etcd įrašo šiuos žurnalo įrašus:
| Apr 15 11:48:09 PSQL_1 etcd[1342933]: health check for peer <PEER_PSQL_NODE_ID> could not connect: dial tcp <PEER_IP_PSQL_NODE>:2380: i/o timeout
Apr 15 11:48:09 PSQL_1 etcd[1342933]: health check for peer <PEER_PSQL_NODE_ID> could not connect: dial tcp <PEER_IP_PSQL_NODE>:2380: i/o timeout
Apr 15 11:48:14 PSQL_1 etcd[1342933]: health check for peer <PEER_PSQL_NODE_ID> could not connect: dial tcp <PEER_IP_PSQL_NODE>:2380: i/o timeout
Apr 15 11:48:14 PSQL_1 etcd[1342933]: health check for peer <PEER_PSQL_NODE_ID> could not connect: dial tcp <PEER_IP_PSQL_NODE>:2380: i/o timeout
Apr 15 11:48:19 PSQL_1 etcd[1342933]: health check for peer <PEER_PSQL_NODE_ID> could not connect: dial tcp <PEER_IP_PSQL_NODE>:2380: i/o timeout
Apr 15 11:48:19 PSQL_1 etcd[1342933]: health check for peer <PEER_PSQL_NODE_ID> could not connect: dial tcp <PEER_IP_PSQL_NODE>:2380: i/o timeout
|
Čia <PEER_PSQL_NODE_ID> – etcd tiksliniam mazgui priskirtas ID, o <PEER_IP_PSQL_NODE> – tikslinio mazgo IP adresas.
Pavyzdys
Mūsų pavyzdyje PostgreSQL klasteris sukonfigūruotas taip:
| Mazgas |
Mazgo IP |
etcd ID |
| PSQL_1 |
192.168.1.1 |
53d2c129945ccb8b |
| PSQL_2 |
192.168.1.2 |
7176dd381f583d83 |
| PSQL_3 |
192.168.1.3 |
e3d5ef565a5bb46c |
Paleidus komandą journalctl -fu etcd serveryje PSQL_1, gaunami šie žurnalo įrašai:
| Apr 15 11:50:39 PSQL_1 etcd[1342933]: health check for peer 7176dd381f583d83 could not connect: dial tcp 192.168.1.2:2380: i/o timeout
Apr 15 11:50:44 PSQL_1 etcd[1342933]: health check for peer 7176dd381f583d83 could not connect: dial tcp 192.168.1.2:2380: i/o timeout
Apr 15 11:50:44 PSQL_1 etcd[1342933]: health check for peer 7176dd381f583d83 could not connect: dial tcp 192.168.1.2:2380: i/o timeout
Apr 15 11:50:49 PSQL_1 etcd[1342933]: health check for peer 7176dd381f583d83 could not connect: dial tcp 192.168.1.2:2380: i/o timeout
Apr 15 11:50:49 PSQL_1 etcd[1342933]: health check for peer 7176dd381f583d83 could not connect: dial tcp 192.168.1.2:2380: i/o timeout
|
Šie žurnalo įrašai rodo, kad ryšys iš serverio PSQL_1 su serveriu, kurio IP adresas 192.168.1.2 (PSQL_2), o etcd ID – 7176dd381f583d83, prievadu TCP/2380 nebuvo užmegztas: baigėsi skirtasis laikas.
Galima daryti išvadą, kad srautą iš serverio PSQL_1 į serverį PSQL_2 išmeta (DROP) ugniasienė.
Šį srautą gali išmesti (DROP) vietinė PostgreSQL appliance ugniasienė: patikrinkite susijusių mazgų appliance ugniasienės konfigūraciją.
Jei ši konfigūracija teisinga, srautą TCP/2380 tarp dviejų mazgų išmeta (DROP) infrastruktūros ugniasienė.
health check for peer <PEER_PSQL_NODE_ID> could not connect: dial tcp <PEER_IP_PSQL_NODE>:2380: connect: connection refused
Kai ryšys tarp dviejų mazgų atmetamas, etcd praneša apie tai šiais žurnalo įrašais:
| Apr 15 14:04:30 PSQL_1 etcd[1342933]: health check for peer <PEER_PSQL_NODE_ID> could not connect: dial tcp <PEER_IP_PSQL_NODE>:2380: connect: connection refused
Apr 15 14:04:30 PSQL_1 etcd[1342933]: health check for peer <PEER_PSQL_NODE_ID> could not connect: dial tcp <PEER_IP_PSQL_NODE>:2380: connect: connection refused
Apr 15 14:04:35 PSQL_1 etcd[1342933]: health check for peer <PEER_PSQL_NODE_ID> could not connect: dial tcp <PEER_IP_PSQL_NODE>:2380: connect: connection refused
Apr 15 14:04:35 PSQL_1 etcd[1342933]: health check for peer <PEER_PSQL_NODE_ID> could not connect: dial tcp <PEER_IP_PSQL_NODE>:2380: connect: connection refused
Apr 15 14:04:40 PSQL_1 etcd[1342933]: health check for peer <PEER_PSQL_NODE_ID> could not connect: dial tcp <PEER_IP_PSQL_NODE>:2380: connect: connection refused
Apr 15 14:04:40 PSQL_1 etcd[1342933]: health check for peer <PEER_PSQL_NODE_ID> could not connect: dial tcp <PEER_IP_PSQL_NODE>:2380: connect: connection refused
|
Čia <PEER_PSQL_NODE_ID> – etcd tiksliniam mazgui priskirtas ID, o <PEER_IP_PSQL_NODE> – tikslinio mazgo IP adresas.
Atmetimo priežasčių gali būti kelios:
- Paslauga
etcd tiksliniame mazge veikia netinkamai arba yra sustabdyta. Tokiu atveju patikrinkite to mazgo paslaugos etcd būseną (systemctl status etcd) ir žurnalus.
- Ugniasienė atmeta (
REJECT) srautą TCP/2380 tarp dviejų mazgų. Tai gali būti vietinė appliance ugniasienė arba infrastruktūros ugniasienė.
Pavyzdys
Mūsų pavyzdyje PostgreSQL klasteris sukonfigūruotas taip:
| Mazgas |
Mazgo IP |
etcd ID |
| PSQL_1 |
192.168.1.1 |
53d2c129945ccb8b |
| PSQL_2 |
192.168.1.2 |
7176dd381f583d83 |
| PSQL_3 |
192.168.1.3 |
e3d5ef565a5bb46c |
Paleidus komandą journalctl -fu etcd serveryje PSQL_1, gaunami šie žurnalo įrašai:
| Apr 15 14:04:15 PSQL_1 etcd[1342933]: health check for peer e3d5ef565a5bb46c could not connect: dial tcp 192.168.1.3:2380: connect: connection refused
Apr 15 14:04:15 PSQL_1 etcd[1342933]: health check for peer e3d5ef565a5bb46c could not connect: dial tcp 192.168.1.3:2380: connect: connection refused
Apr 15 14:04:20 PSQL_1 etcd[1342933]: health check for peer e3d5ef565a5bb46c could not connect: dial tcp 192.168.1.3:2380: connect: connection refused
Apr 15 14:04:20 PSQL_1 etcd[1342933]: health check for peer e3d5ef565a5bb46c could not connect: dial tcp 192.168.1.3:2380: connect: connection refused
Apr 15 14:04:25 PSQL_1 etcd[1342933]: health check for peer e3d5ef565a5bb46c could not connect: dial tcp 192.168.1.3:2380: connect: connection refused
|
Šie žurnalo įrašai rodo, kad ryšys iš serverio PSQL_1 su serveriu, kurio IP adresas 192.168.1.3 (PSQL_3), o etcd ID – e3d5ef565a5bb46c, prievadu TCP/2380 buvo atmestas.
Serveryje PSQL_3 komanda systemctl status etcd rodo, kad etcd sustabdyta:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 | ○ etcd.service - etcd - highly-available key value store
Loaded: loaded (/lib/systemd/system/etcd.service; enabled; preset: enabled)
Active: inactive (dead) since Wed 2026-04-15 16:09:34 CEST; 38s ago
Duration: 1min 36.087s
Docs: https://etcd.io/docs
man:etcd
Process: 1400558 ExecStart=/usr/bin/etcd $DAEMON_ARGS (code=killed, signal=TERM)
Main PID: 1400558 (code=killed, signal=TERM)
CPU: 49.071s
Apr 15 12:26:32 PSQL_3 etcd[1197556]: finished scheduled compaction at 1665243 (took 583.297µs)
Apr 15 13:26:32 PSQL_3 etcd[1197556]: store.index: compact 1665949
Apr 15 13:26:32 PSQL_3 etcd[1197556]: finished scheduled compaction at 1665949 (took 574.496µs)
Apr 15 14:26:32 PSQL_3 etcd[1197556]: store.index: compact 1666658
Apr 15 14:26:32 PSQL_3 etcd[1197556]: finished scheduled compaction at 1666658 (took 567.196µs)
Apr 15 15:26:32 PSQL_3 etcd[1197556]: store.index: compact 1667368
Apr 15 15:26:32 PSQL_3 etcd[1197556]: finished scheduled compaction at 1667368 (took 568.096µs)
Apr 15 16:09:34 PSQL_3 systemd[1]: etcd.service: Deactivated successfully.
Apr 15 16:09:34 PSQL_3 systemd[1]: Stopped etcd.service - etcd - highly-available key value store.
Apr 15 16:09:34 PSQL_3 systemd[1]: etcd.service: Consumed 49.071s CPU time.
|
Paleidus etcd, problema išsprendžiama.
rejected connection from "<PEER_IP_PSQL_NODE>:35956" (error "remote error: tls: bad certificate", ServerName "PSQL_1")
Jei PostgreSQL klasterio sertifikatų galiojimas baigėsi arba jie buvo netinkamai įdiegti ar atnaujinti mazge, kurio žurnalus skaitote, etcd žurnaluose rodoma ši klaida:
| Apr 15 16:38:54 PSQL_1 etcd[1407644]: rejected connection from "<PEER_IP_PSQL_NODE>:49274" (error "remote error: tls: bad certificate", ServerName "PSQL_1")
Apr 15 16:38:54 PSQL_1 etcd[1407644]: rejected connection from "<PEER_IP_PSQL_NODE>:49294" (error "remote error: tls: bad certificate", ServerName "PSQL_1")
Apr 15 16:38:54 PSQL_1 etcd[1407644]: rejected connection from "<PEER_IP_PSQL_NODE>:49288" (error "remote error: tls: bad certificate", ServerName "PSQL_1")
Apr 15 16:38:55 PSQL_1 etcd[1407644]: rejected connection from "<PEER_IP_PSQL_NODE>:49316" (error "remote error: tls: bad certificate", ServerName "PSQL_1")
Apr 15 16:38:55 PSQL_1 etcd[1407644]: rejected connection from "<PEER_IP_PSQL_NODE>:49304" (error "remote error: tls: bad certificate", ServerName "PSQL_1")
Apr 15 16:38:55 PSQL_1 etcd[1407644]: rejected connection from "<PEER_IP_PSQL_NODE>:60958" (error "remote error: tls: bad certificate", ServerName "PSQL_1")
|
Čia <PEER_IP_PSQL_NODE> – vieno iš klasterio mazgų IP adresas.
Šis žurnalo įrašas rodo, kad kai mazgas, prie kurio esate prisijungę, bandė užmegzti ryšį su kitais klasterio mazgais (<PEER_IP_PSQL_NODE>), šie jį atmetė, pranešdami apie dabartinio mazgo sertifikato klaidą.
Todėl mazge, prie kurio esate prisijungę, patikrinkite klasterio sertifikatų galiojimą.
Perspėjimas
Jei nuotoliniame mazge sukonfigūruota sertifikavimo institucija (faile /etc/etcd/ca.crt) neteisinga, klaida taip pat rodoma mazge, kurio žurnalus skaitote: tada ji reiškia, kad nuotolinis mazgas negali patikrinti pateikto sertifikato, nes neturi tinkamos CA.
Pavyzdys
Mūsų pavyzdyje PostgreSQL klasteris sukonfigūruotas taip:
| Mazgas |
Mazgo IP |
etcd ID |
| PSQL_1 |
192.168.1.1 |
53d2c129945ccb8b |
| PSQL_2 |
192.168.1.2 |
7176dd381f583d83 |
| PSQL_3 |
192.168.1.3 |
e3d5ef565a5bb46c |
Paleidus komandą journalctl -fu etcd serveryje PSQL_1, gaunami šie žurnalo įrašai:
| Apr 15 16:38:54 PSQL_1 etcd[1407644]: rejected connection from "192.168.1.2:49274" (error "remote error: tls: bad certificate", ServerName "PSQL_1")
Apr 15 16:38:54 PSQL_1 etcd[1407644]: rejected connection from "192.168.1.3:49294" (error "remote error: tls: bad certificate", ServerName "PSQL_1")
Apr 15 16:38:54 PSQL_1 etcd[1407644]: rejected connection from "192.168.1.2:49288" (error "remote error: tls: bad certificate", ServerName "PSQL_1")
Apr 15 16:38:55 PSQL_1 etcd[1407644]: rejected connection from "192.168.1.2:49316" (error "remote error: tls: bad certificate", ServerName "PSQL_1")
Apr 15 16:38:55 PSQL_1 etcd[1407644]: rejected connection from "192.168.1.3:49304" (error "remote error: tls: bad certificate", ServerName "PSQL_1")
Apr 15 16:38:55 PSQL_1 etcd[1407644]: rejected connection from "192.168.1.3:60958" (error "remote error: tls: bad certificate", ServerName "PSQL_1")
|
Šie žurnalo įrašai rodo, kad mazgai PSQL_2 ir PSQL_3 atmetė mazgo PSQL_1 ryšį, nes PSQL_1 sertifikatas šiame kontekste negalioja.
Todėl patikriname mazgo PSQL_1 sertifikatų galiojimą pagal klasterio sertifikatų tikrinimo procedūrą:
| openssl x509 -in /etc/etcd/peer.crt -noout -enddate
openssl x509 -in /etc/etcd/ca.crt -noout -enddate
|
Išvestis rodo, kad mazgo sertifikato galiojimas baigėsi:
| notAfter=Dec 18 14:04:09 2025 GMT
notAfter=Dec 17 14:03:47 2030 GMT
|
Tokiu atveju turite atnaujinti PostgreSQL klasterio sertifikatus.
error listing data dir: /var/lib/etcd/cleanroom
Jei etcd neturi tinkamų leidimų katalogui /var/lib/etcd/cleanroom, paslauga nepasileidžia ir įrašo šiuos žurnalo įrašus:
| Apr 10 14:15:26 PSQL_1 etcd[454701]: Go OS/Arch: linux/amd64
Apr 10 14:15:26 PSQL_1 etcd[454701]: setting maximum number of CPUs to 1, total number of available CPUs is 1
Apr 10 14:15:26 PSQL_1 etcd[454701]: error listing data dir: /var/lib/etcd/cleanroom
Apr 10 14:15:26 PSQL_1 systemd[1]: etcd.service: Main process exited, code=exited, status=1/FAILURE
Apr 10 14:15:26 PSQL_1 systemd[1]: etcd.service: Failed with result 'exit-code'.
Apr 10 14:15:26 PSQL_1 systemd[1]: Failed to start etcd.service - etcd - highly-available key value store
|
Norėdami išspręsti šią problemą, šia komanda suteikite katalogui tinkamus leidimus:
| chown -R etcd:etcd /var/lib/etcd/cleanroom
|