我正在尝试在Ubuntu 18.04主机上设置集群。使用DNS进行服务器发现时出现以下错误。
error setting up initial cluster: cannot find local etcd member "etcd-1" in SRV records
我已经按照文档进行了操作,感觉好像已经正确完成了所有操作,但是我是刚建立本地dns(使用bind9)的新手,在这里不能说出我在做什么错。我尝试过更改自己的dns,但无法解决问题。仅在尝试发现本地节点时才会发生此问题。
这是_etcd服务器的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