Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patroni not register service to consul ? #865

Closed
binooetomo opened this issue Nov 15, 2018 · 4 comments
Closed

Patroni not register service to consul ? #865

binooetomo opened this issue Nov 15, 2018 · 4 comments

Comments

@binooetomo
Copy link

Dear All.

I'm trying to setup patroni with consul.

First I write a very simple flask script to 'register' to consul, and do a dig just to make sure my consul is work.

dig @127.0.0.1 -p 8600 master.webapp.service.bino.inc. any +multiline +answer

; <<>> DiG 9.9.4-RedHat-9.9.4-61.el7_5.1 <<>> @127.0.0.1 -p 8600 master.webapp.service.bino.inc. any +multiline +answer
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62221
;; flags: qr aa rd; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;master.webapp.service.bino.inc. IN ANY

;; ANSWER SECTION:
master.webapp.service.bino.inc. 0 IN A 127.0.0.1
master.webapp.service.bino.inc. 0 IN TXT "consul-network-segment="

;; Query time: 2 msec
;; SERVER: 127.0.0.1#8600(127.0.0.1)
;; WHEN: Kam Nov 15 14:04:43 WIB 2018
;; MSG SIZE rcvd: 111

here is my consul configuration.

more /etc/consul.d/consul.json

{
"data_dir": "/opt/consul/data",
"server": true,
"bind_addr": "127.0.0.1",
"bootstrap_expect": 1,
"ui": true,
"domain": "bino.inc",
"client_addr": "127.0.0.1",
"node_name": "node01"
}

Below is my patroni config

$ more ./pg-1-consul.yml
scope: pgcluster
name: pg-1

restapi:
listen: 0.0.0.0:8008
connect_address: 127.0.0.1:8008

consul:
host: 127.0.0.1
port: 8500

bootstrap:
dcs:
ttl: 30
loop_wait: 10
retry_timeout: 10
maximum_lag_on_failover: 1048576
postgresql:
use_pg_rewind: true
use_slots: true
parameters:
wal_level: replica
hot_standby: "on"
wal_keep_segments: 8
max_wal_senders: 5
max_replication_slots: 5
checkpoint_timeout: 30

initdb:

  • encoding: UTF8

pg_hba:

  • host all dba all md5
  • host replication repl all md5

users:
dba:
password: secret
options:
- createrole
- createdb
repl:
password: secret
options:
- replication

postgresql:
listen: 0.0.0.0:5432
connect_address: 127.0.0.1:5432
data_dir: /home/patroni/patroni/psqldata/pg-1
config_dir: /home/patroni/patroni/psqldata/pg-1
bin_dir: /usr/pgsql-9.6/bin
authentication:
replication:
username: repl
password: secret
superuser:
username: dba
password: secret
parameters:
unix_socket_directories: '/tmp'

I tried to dig it

dig @127.0.0.1 -p 8600 pgcluster.service.bino.inc. any +multiline +answer

; <<>> DiG 9.9.4-RedHat-9.9.4-61.el7_5.1 <<>> @127.0.0.1 -p 8600 pgcluster.service.bino.inc. any +multiline +answer
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 30822
;; 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: 4096
;; QUESTION SECTION:
;pgcluster.service.bino.inc. IN ANY

;; AUTHORITY SECTION:
bino.inc. 0 IN SOA ns.bino.inc. hostmaster.bino.inc. (
1542266799 ; serial
3600 ; refresh (1 hour)
600 ; retry (10 minutes)
86400 ; expire (1 day)
0 ; minimum (0 seconds)
)

;; Query time: 2 msec
;; SERVER: 127.0.0.1#8600(127.0.0.1)
;; WHEN: Kam Nov 15 14:26:39 WIB 2018
;; MSG SIZE rcvd: 105

Is that right that patroni did not register it's service to consul, but just use consul for key/value store only ?

Sincerely
-bino-

@CyberDem0n
Copy link
Collaborator

Hi,

It is not doing that by default, in order to enable this functionality, you have to putregister_service: true into the consul section.

Unfortunately we totally forgot to update the documentation as a part of #802. Please feel free to open a PR fixing it.

@binooetomo
Copy link
Author

BTW ...
From my consul stdout, I got

2018/11/15 14:48:21 [DEBUG] http: Request GET /v1/kv/service/pgcluster/?recurse=1 (317.452µs) from=127.0.0.1:57358
2018/11/15 14:48:21 [DEBUG] http: Request PUT /v1/session/renew/4dcc5e19-59e7-8d27-4598-22f376f8ac42 (210.023µs) from=127.0.0.1:57358
2018/11/15 14:48:21 [DEBUG] http: Request PUT /v1/kv/service/pgcluster/optime/leader (719.335µs) from=127.0.0.1:57358
2018/11/15 14:48:21 [DEBUG] http: Request PUT /v1/kv/service/pgcluster/members/pg-1?acquire=4dcc5e19-59e7-8d27-4598-22f376f8ac42 (692.935µs) from=127.0.0.1:57358

@CyberDem0n
Copy link
Collaborator

@binooetomo #865 (comment)

@binooetomo
Copy link
Author

Thankyou ....
I verry appreciate all helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants