我正在尝试在 Ubuntu 18.04 主机上设置集群。使用 DNS 进行服务器发现时出现以下错误。
error setting up initial cluster: cannot find local etcd member "etcd-1" in SRV records
我已经按照文档进行操作,感觉我已经正确完成了所有操作,但是我是设置本地 dns 的新手(使用 bind9),无法判断我在这里做错了什么。我已经尝试改变我的 dns 但无法解决问题。该问题仅在尝试发现本地节点时发生...
这是 _etcd-server 的 SRV 记录
user@etcd-1:~$ dig +noall +answer SRV _etcd-server._tcp.etcd.abc-bird.com
_etcd-server._tcp.etcd.abc-bird.com. 9 IN SRV 0 0 2380 etcd-2.etcd.abc-bird.com.
_etcd-server._tcp.etcd.abc-bird.com. 9 IN SRV 0 0 2380 etcd-3.etcd.abc-bird.com.
_etcd-server._tcp.etcd.abc-bird.com. 9 IN SRV 0 0 2380 etcd-1.etcd.abc-bird.com.
我的 _etcd-client-ssl 的 SRV 记录
user@etcd-1:~$ dig +noall +answer SRV _etcd-client-ssl._tcp.etcd.abc-bird.com
_etcd-client-ssl._tcp.etcd.abc-bird.com. 60 IN SRV 0 0 2379 etcd-2.etcd.abc-bird.com.
_etcd-client-ssl._tcp.etcd.abc-bird.com. 60 IN SRV 0 0 2379 etcd-1.etcd.abc-bird.com.
_etcd-client-ssl._tcp.etcd.abc-bird.com. 60 IN SRV 0 0 2379 etcd-3.etcd.abc-bird.com.
我的 A 记录
user@etcd-1:~$ dig +noall +answer etcd-1.etcd.abc-bird.com. etcd-2.etcd.abc-bird.com. etcd-3.etcd.abc-bird.com.
etcd-1.etcd.abc-bird.com. 35 IN A 192.168.0.28
etcd-2.etcd.abc-bird.com. 35 IN A 192.168.0.20
etcd-3.etcd.abc-bird.com. 35 IN A 192.168.0.29
这是我的 etcd.service 文件内容
[Unit]
Description=ETCD Service
After=network.target
[Service]
User=etcd
ExecStart=/usr/local/bin/etcd --data-dir=/opt/etcd/data --name=${hostname} \
--discovery-srv etcd.${domain} \
--initial-advertise-peer-urls=https://${hostname}.etcd.${domain}:2380 \
--listen-peer-urls=https://0.0.0.0:2380 \
--listen-client-urls=https://0.0.0.0:2379 \
--peer-cert-allowed-cn=etcd.${domain} \
--advertise-client-urls=https://${hostname}.etcd.${domain}:2379 \
--initial-cluster-token=etcd-cluster-1 \
--initial-cluster-state=new \
--client-cert-auth --trusted-ca-file=/opt/etcd/ca.pem \
--cert-file=/opt/etcd/cert.pem --key-file=/opt/etcd/key.pem \
--peer-client-cert-auth --peer-trusted-ca-file=/opt/etcd/ca.pem \
--peer-cert-file=/opt/etcd/cert.pem --peer-key-file=/opt/etcd/key.pem
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
包含错误的 journalctl 日志
Apr 14 15:23:37 etcd-1 systemd[1]: Started ETCD Service.
Apr 14 15:23:37 etcd-1 etcd[6918]: etcd Version: 3.3.12
Apr 14 15:23:37 etcd-1 etcd[6918]: Git SHA: d57e8b8
Apr 14 15:23:37 etcd-1 etcd[6918]: Go Version: go1.10.8
Apr 14 15:23:37 etcd-1 etcd[6918]: Go OS/Arch: linux/amd64
Apr 14 15:23:37 etcd-1 etcd[6918]: setting maximum number of CPUs to 2, total number of available CPUs is 2
Apr 14 15:23:37 etcd-1 etcd[6918]: peerTLS: cert = /opt/etcd/cert.pem, key = /opt/etcd/key.pem, ca = , trusted-ca = /opt/etcd/ca.pem, client-cert-auth = true, crl-file =
Apr 14 15:23:37 etcd-1 etcd[6918]: listening for peers on https://0.0.0.0:2380
Apr 14 15:23:37 etcd-1 etcd[6918]: listening for client requests on 0.0.0.0:2379
Apr 14 15:23:37 etcd-1 etcd[6918]: got bootstrap from DNS for etcd-server at 0=http://etcd-2.etcd.abc-bird.com:2380
Apr 14 15:23:37 etcd-1 etcd[6918]: got bootstrap from DNS for etcd-server at 1=http://etcd-3.etcd.abc-bird.com:2380
Apr 14 15:23:37 etcd-1 etcd[6918]: error setting up initial cluster: cannot find local etcd member "etcd-1" in SRV records
Apr 14 15:23:37 etcd-1 systemd[1]: etcd.service: Main process exited, code=exited, status=1/FAILURE
Apr 14 15:23:37 etcd-1 systemd[1]: etcd.service: Failed with result 'exit-code'.
Apr 14 15:23:42 etcd-1 systemd[1]: etcd.service: Service hold-off time over, scheduling restart.
对于它的价值,这是我的名称服务器上的 dns 配置。 https://gist.github.com/spstratis/1e89f867d86c6b37dc15387ccd310fcc