2

This is my consul.service file.

[Unit]
Description="HashiCorp Consul - A service mesh solution"
Documentation=https://www.consul.io/
Requires=network-online.target
After=network-online.target

[Service]
Type=simple
User=consul
Group=consul
LimitNOFILE=1024
ExecStart=/usr/bin/consul agent  -config-dir=/etc/consul.d/
ExecReload=/bin/kill --signal HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=5
KillSignal=SIGINT

[Install]
WantedBy=multi-user.target

I did sudo chown -R consul:consul /etc/consul.d/ because I created a consul user as well.

and this is my /etc/config.d directory:

$ tree /etc/consul.d/
/etc/consul.d/
├── bootstrap
│   └── config.json
├── client
└── server
    └── config.json

this is the server config. cat /etc/consul.d/server/config.json

{
    "bootstrap": false,
    "server": true,
    "datacenter": "lon",
    "advertise_addr": "192.168.0.16",
    "client_addr": "0.0.0.0",
    "bind_addr": "{{GetInterfaceIP \"eth0\"}}",
    "data_dir": "/var/consul/",
    "log_level": "INFO",
    "enable_syslog": true,
    "retry_join": ["192.168.0.16"]
}

cat /etc/consul.d/bootstrap/config.json

{
    "bootstrap": true,
    "server": true,
    "datacenter": "lon",
    "advertise_addr": "192.168.0.16",
    "client_addr": "0.0.0.0",
    "bind_addr": "{{GetInterfaceIP \"eth0\"}}",
    "data_dir": "/var/consul/",
    "log_level": "INFO",
    "enable_syslog": true,
    "retry_join": ["192.168.0.16"]
}

And I have validated the consul config for server and bootstrap configurations.

consul validate  /etc/consul.d/server/config.json 
Configuration is valid!

but I keep getting error saying:

 consul[21711]: ==> Multiple private IPv4 addresses found. Please configure one with 'bind' and/or 'advertise'.

I tried this command too

~/go/bin$ ./sockaddr eval GetPrivateIP
192.168.0.16

what am I missing ?

Chang Zhao
  • 132
  • 1
  • 9
  • This config looks valid to me. What version of Consul are you using? – Blake Covarrubias Sep 15 '20 at 05:39
  • it was version 1.8.3, if I pass specific config-file it works but not if I pass config directory to -config-dir even with new version 1.8.4 – Chang Zhao Sep 17 '20 at 12:51
  • Do you perhaps have another configuration file in that directory which contains `bind_addr` or `advertise_addr`? – Blake Covarrubias Sep 18 '20 at 05:11
  • You start your server pointing at a file hierarchy containing configurations for client, server and and old deprecated way of starting in bootstrap mode. If you really want to keep that filetree, you should point your systemd service file to `-config-dir=/etc/consul.d/server`. But I strongly suggest your remove all unneeded config to keep only the server part at `/etc//consul.d/` root and review the documentation to use the recent [`bootstrap-expect`](https://www.consul.io/docs/agent/options#_bootstrap_expect) (that you can always keep in your config) in place of the legacy `bootstrap` option – Zeitounator Apr 09 '21 at 19:11

0 Answers0