Asi jsem neco nepochopil. Takze mam:
1] 3x consul cluster
# consul members
Node Address Status Type Build Protocol DC Partition Segment
test-consul-01 192.168.200.205:8301 alive server 1.19.1 2 dc1 default <all>
test-consul-02 192.168.200.206:8301 alive server 1.19.1 2 dc1 default <all>
test-consul-03 192.168.200.207:8301 alive server 1.19.1 2 dc1 default <all>
2] 2x patroni + postgresql cluster (bez consul agenta), nasmerovano na jeden z consul serveru, priklad z jednoho patroni.yml:
scope: testcluster
name: test-patroni-01
namespace: /service
consul:
# host: 127.0.0.1:8500
host: 192.168.200.205:8500
checks: []
register_service: true
logy:
2024-08-02 13:36:46,391 INFO: Register service testcluster, params {'service_id': 'testcluster/test-patroni-01', 'address': 'test-patroni-01', 'port': 5432, 'check': {'http': 'http://test-patroni-01:8008/master', 'interval': '5s', 'DeregisterCriticalServiceAfter': '150.0s'}, 'tags': ['master', 'primary'], 'enable_tag_override': True}
2024-08-02 13:36:46,871 INFO: Register service testcluster, params {'service_id': 'testcluster/test-patroni-02', 'address': 'test-patroni-02', 'port': 5432, 'check': {'http': 'http://test-patroni-02:8008/replica', 'interval': '5s', 'DeregisterCriticalServiceAfter': '150.0s'}, 'tags': ['replica'], 'enable_tag_override': True}
# patronictl -c /etc/patroni/patroni.yml list
+ Cluster: testcluster (7398492059310470971) -+---------+----+-----------+
| Member | Host | Role | State | TL | Lag in MB |
+-----------------+-----------------+---------+---------+----+-----------+
| test-patroni-01 | test-patroni-01 | Leader | running | 3 | |
| test-patroni-02 | test-patroni-02 | Replica | running | 3 | 0 |
+-----------------+-----------------+---------+---------+----+-----------+
3] vypsani sluzeb consulu
# consul catalog services
consul
2024-08-02T13:48:36.561+0200 [DEBUG] agent.server.memberlist.lan: memberlist: Stream connection from=192.168.200.207:38158
2024-08-02T13:48:36.929+0200 [DEBUG] agent.http: Request finished: method=GET url="/v1/kv/service/testcluster/leader?index=106556&wait=9.415060997009277s" from=192.168.200.202:47640 latency=9.505591083s
2024-08-02T13:48:36.931+0200 [DEBUG] agent.http: Request finished: method=GET url=/v1/kv/service/testcluster/?recurse=1 from=192.168.200.202:47640 latency="518.553µs"
2024-08-02T13:48:36.934+0200 [DEBUG] agent.http: Request finished: method=PUT url=/v1/session/renew/02ee5a50-53e6-72cb-8643-211b7977d636 from=192.168.200.202:47640 latency="459.564µs"
2024-08-02T13:48:39.104+0200 [DEBUG] agent.server.memberlist.lan: memberlist: Initiating push/pull sync with: test-consul-03 192.168.200.207:8301
2024-08-02T13:48:46.332+0200 [DEBUG] agent.http: Request finished: method=GET url=/v1/kv/service/testcluster/?recurse=1 from=192.168.200.201:51780 latency="810.398µs"
2024-08-02T13:48:46.335+0200 [DEBUG] agent.http: Request finished: method=PUT url=/v1/session/renew/55775404-f52b-41f8-d2b6-a93cde35e36e from=192.168.200.201:51780 latency="549.728µs"
2024-08-02T13:48:46.928+0200 [DEBUG] agent.http: Request finished: method=GET url="/v1/kv/service/testcluster/leader?index=106556&wait=9.9032564163208s" from=192.168.200.202:47640 latency=9.992995419s
2024-08-02T13:48:46.930+0200 [DEBUG] agent.http: Request finished: method=GET url=/v1/kv/service/testcluster/?recurse=1 from=192.168.200.202:47640 latency="607.854µs"
2024-08-02T13:48:46.933+0200 [DEBUG] agent.http: Request finished: method=PUT url=/v1/session/renew/02ee5a50-53e6-72cb-8643-211b7977d636 from=192.168.200.202:47640 latency="421.627µs"
2024-08-02T13:48:51.233+0200 [DEBUG] agent.server.memberlist.lan: memberlist: Stream connection from=192.168.200.206:52730
I pres mohutne google-fu se nedokazi trefit do vypsani dns zaznamu primarniho patroni, ani vypsat, zda je to dns v consulu vubec registrovany. Je nutne, aby byl consul agent na patroni serveru pro tu registraci dns?
# dig master.testcluster.service.consul @localhost -p 8600
; <<>> DiG 9.18.28-1~deb12u2-Debian <<>> master.testcluster.service.consul @localhost -p 8600
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 47068
;; flags: qr aa rd; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1
;; WARNING: recursion requested but not available
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;master.testcluster.service.consul. IN A
;; AUTHORITY SECTION:
consul. 0 IN SOA ns.consul. hostmaster.consul. 1722600377 3600 600 86400 0
;; Query time: 0 msec
;; SERVER: 127.0.0.1#8600(localhost) (UDP)