etcd problēmu novēršana
Informācija
Visa procedūra jāveic kā root. Lai paaugstinātu savas privilēģijas līdz root, varat izmantot komandu su -.
etcd ir izkliedēta atslēgu un vērtību glabātuve, ko izmanto kā koordinācijas punktu starp PostgreSQL klastera mezgliem. Tā droši centralizē un koplieto klastera stāvokli, tostarp līdera identitāti, dalībnieku stāvokli un bloķēšanas mehānismus.
patroni izmanto etcd, lai vadītu līdera mezgla ievēlēšanu un incidenta gadījumā automātiski aktivizētu kļūmjpārlēci. etcd ir instalēts visos mezglos un garantē klastera vispārējo konsekvenci, nepiedaloties PostgreSQL datu glabāšanā vai apstrādē.
Tāpēc patroni ir atkarīgs no etcd un nevar pareizi darboties, ja etcd nedarbojas.
Informācija
etcd konfigurācija katrā mezglā tiek glabāta failā /etc/default/etcd.
Logs
Visa procedūra balstās uz pakalpojuma etcd žurnāliem, kurus iegūstat ar tālāk norādīto komandu:
Padoms
Lai sekotu žurnāliem reāllaikā, pievienojiet komandai opciju -f:
Informācija
etcd žurnāli ir pieejami arī failā /var/log/syslog.
Kļūdu žurnālu skaidrojumi
health check for peer <PEER_PSQL_NODE_ID> could not connect: dial tcp <PEER_IP_PSQL_NODE>:2380: i/o timeout
Ja plūsma TCP/2380 starp diviem mezgliem nav atvērta, savienojumam iestājas noildze un etcd ieraksta šādus žurnāla ierakstus:
| 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
|
Kur <PEER_PSQL_NODE_ID> ir ID, ko etcd piešķīris mērķa mezglam, un <PEER_IP_PSQL_NODE> ir mērķa mezgla IP adrese.
Piemērs
Mūsu piemērā PostgreSQL klasteris ir konfigurēts šādi:
| Mezgls |
Mezgla IP adrese |
etcd ID |
| PSQL_1 |
192.168.1.1 |
53d2c129945ccb8b |
| PSQL_2 |
192.168.1.2 |
7176dd381f583d83 |
| PSQL_3 |
192.168.1.3 |
e3d5ef565a5bb46c |
Izpildot komandu journalctl -fu etcd serverī PSQL_1, tiek iegūti šādi žurnāla ieraksti:
| 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 žurnāla ieraksti norāda, ka savienojums no servera PSQL_1 uz serveri ar IP adresi 192.168.1.2 (PSQL_2) un etcd ID 7176dd381f583d83 portā TCP/2380 neizdevās: iestājās noildze.
No tā varam secināt, ka plūsmu no servera PSQL_1 uz serveri PSQL_2 atmet (DROP) ugunsmūris.
Šo plūsmu var atmest (DROP) PostgreSQL appliance lokālais ugunsmūris: pārbaudiet appliance ugunsmūra konfigurāciju attiecīgajos mezglos.
Ja šī konfigurācija ir pareiza, plūsmu TCP/2380 starp abiem mezgliem atmet (DROP) kāds infrastruktūras ugunsmūris.
health check for peer <PEER_PSQL_NODE_ID> could not connect: dial tcp <PEER_IP_PSQL_NODE>:2380: connect: connection refused
Ja savienojums starp diviem mezgliem tiek noraidīts, etcd par to ziņo ar šādiem žurnāla ierakstiem:
| 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
|
Kur <PEER_PSQL_NODE_ID> ir ID, ko etcd piešķīris mērķa mezglam, un <PEER_IP_PSQL_NODE> ir mērķa mezgla IP adrese.
Noraidījumam var būt vairāki iemesli:
- Pakalpojums
etcd mērķa mezglā darbojas nepareizi vai ir apturēts. Šādā gadījumā pārbaudiet pakalpojuma etcd statusu (systemctl status etcd) un žurnālus šajā mezglā.
- Ugunsmūris noraida (
REJECT) plūsmu TCP/2380 starp abiem mezgliem. Tas var būt appliance lokālais ugunsmūris vai kāds infrastruktūras ugunsmūris.
Piemērs
Mūsu piemērā PostgreSQL klasteris ir konfigurēts šādi:
| Mezgls |
Mezgla IP adrese |
etcd ID |
| PSQL_1 |
192.168.1.1 |
53d2c129945ccb8b |
| PSQL_2 |
192.168.1.2 |
7176dd381f583d83 |
| PSQL_3 |
192.168.1.3 |
e3d5ef565a5bb46c |
Izpildot komandu journalctl -fu etcd serverī PSQL_1, tiek iegūti šādi žurnāla ieraksti:
| 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 žurnāla ieraksti norāda, ka savienojums no servera PSQL_1 uz serveri ar IP adresi 192.168.1.3 (PSQL_3) un etcd ID e3d5ef565a5bb46c portā TCP/2380 tika noraidīts.
Serverī PSQL_3 komanda systemctl status etcd parāda, ka etcd ir apturēts:
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.
|
Tiklīdz etcd ir startēts, problēma ir novērsta.
rejected connection from "<PEER_IP_PSQL_NODE>:35956" (error "remote error: tls: bad certificate", ServerName "PSQL_1")
Ja PostgreSQL klastera sertifikātu derīgums ir beidzies vai tie nav pareizi instalēti vai atjaunoti mezglā, kurā lasāt žurnālus, etcd žurnālos parādās šāda kļūda:
| 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")
|
Kur <PEER_IP_PSQL_NODE> ir viena klastera mezgla IP adrese.
Šis žurnāla ieraksts norāda, ka tad, kad mezgls, ar kuru pašlaik ir izveidots savienojums, mēģināja izveidot savienojumu ar citiem klastera mezgliem (<PEER_IP_PSQL_NODE>), tie to noraidīja, ziņojot par kļūdu pašreizējā mezgla sertifikātā.
Tāpēc pārbaudiet klastera sertifikātu derīgumu mezglā, ar kuru pašlaik ir izveidots savienojums.
Brīdinājums
Ja attālajā mezglā konfigurētā sertificēšanas iestāde (failā /etc/etcd/ca.crt) ir nepareiza, kļūda parādās arī mezglā, kurā lasāt žurnālus: tad tā norāda, ka attālais mezgls nevar validēt uzrādīto sertifikātu, jo tam nav pareizās CA.
Piemērs
Mūsu piemērā PostgreSQL klasteris ir konfigurēts šādi:
| Mezgls |
Mezgla IP adrese |
etcd ID |
| PSQL_1 |
192.168.1.1 |
53d2c129945ccb8b |
| PSQL_2 |
192.168.1.2 |
7176dd381f583d83 |
| PSQL_3 |
192.168.1.3 |
e3d5ef565a5bb46c |
Izpildot komandu journalctl -fu etcd serverī PSQL_1, tiek iegūti šādi žurnāla ieraksti:
| 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 žurnāla ieraksti norāda, ka mezgli PSQL_2 un PSQL_3 noraidīja savienojumu no mezgla PSQL_1, jo PSQL_1 sertifikāts šajā kontekstā nav derīgs.
Tāpēc pārbaudām mezgla PSQL_1 sertifikātu derīgumu, izpildot klastera sertifikātu pārbaudes procedūru:
| openssl x509 -in /etc/etcd/peer.crt -noout -enddate
openssl x509 -in /etc/etcd/ca.crt -noout -enddate
|
Izvade parāda, ka mezgla sertifikāta derīgums ir beidzies:
| notAfter=Dec 18 14:04:09 2025 GMT
notAfter=Dec 17 14:03:47 2030 GMT
|
Šādā gadījumā ir jāatjauno PostgreSQL klastera sertifikāti.
error listing data dir: /var/lib/etcd/cleanroom
Ja etcd nav pareizo atļauju direktorijam /var/lib/etcd/cleanroom, pakalpojums atsakās startēt un ieraksta šādus žurnāla ierakstus:
| 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
|
Lai novērstu šo problēmu, piešķiriet direktorijam pareizās atļaujas ar šo komandu:
| chown -R etcd:etcd /var/lib/etcd/cleanroom
|