通过“bind:无法分配请求的地址”启动etcd失败

时间:2017-09-13 09:03:02

标签: etcd3

我运行etcd作为docker容器,10.132.41.234是我的主机ip,我运行docker容器,我得到这样的错误信息,我不知道它是否正确,我现在熟悉etcd,一些一个可以帮忙吗? THX!

2017-09-13 08:55:03.339612 I | etcdmain: etcd Version: 3.0.17
2017-09-13 08:55:03.339891 I | etcdmain: Git SHA: cc198e2
2017-09-13 08:55:03.339902 I | etcdmain: Go Version: go1.6.4
2017-09-13 08:55:03.339912 I | etcdmain: Go OS/Arch: linux/amd64
2017-09-13 08:55:03.339921 I | etcdmain: setting maximum number of CPUs to 2, total number of available CPUs is 2
2017-09-13 08:55:03.340059 I | etcdmain: peerTLS: cert = /etc/ssl/certs/server.pem, key = /etc/ssl/certs/server-key.pem, ca = , trusted-ca = /etc/ssl/certs/ca.pem, client-cert-auth = true
2017-09-13 08:55:03.342794 I | etcdmain: listening for peers on https://127.0.0.1:2380
2017-09-13 08:55:03.342844 I | etcdmain: clientTLS: cert = /etc/ssl/certs/server.pem, key = /etc/ssl/certs/server-key.pem, ca = , trusted-ca = /etc/ssl/certs/ca.pem, client-cert-auth = true
2017-09-13 08:55:03.345340 I | etcdmain: stopping listening for peers on https://127.0.0.1:2380
2017-09-13 08:55:03.345386 C | etcdmain: listen tcp 10.132.41.234:2379: bind: cannot assign requested address


 docker run -d -v /opt/certs:/etc/ssl/certs -v /opt/etcd-data:/etcd-data -p 2380:2380 -p 2379:2379 \
 --name etcd gcr.io/google_containers/etcd-amd64:3.0.17 \
  /usr/local/bin/etcd \
 --name etcd0 \
 --data-dir=/etcd-data \
 --advertise-client-urls https://10.132.41.234:2379,https://127.0.0.1:2379 \
 --listen-client-urls https://10.132.41.234:2379,https://127.0.0.1:2379 \
 --initial-advertise-peer-urls https://127.0.0.1:2380 \
 --listen-peer-urls https://127.0.0.1:2380 \
 --initial-cluster-token etcd-cluster-1 \
 --initial-cluster etcd0=https://127.0.0.1:2380,etcd1=https://127.0.0.1:2380,etcd2=https://127.0.0.1:2380 \
 --initial-cluster-state new \
 --cert-file=/etc/ssl/certs/server.pem \
 --key-file=/etc/ssl/certs/server-key.pem \
 --peer-cert-file=/etc/ssl/certs/server.pem \
 --peer-key-file=/etc/ssl/certs/server-key.pem \
 --trusted-ca-file=/etc/ssl/certs/ca.pem \
 --peer-trusted-ca-file=/etc/ssl/certs/ca.pem \
 --peer-client-cert-auth=true \
 --client-cert-auth=true

2 个答案:

答案 0 :(得分:1)

尝试绑定到服务器的IP时遇到了同样的错误。 我通过在--listen-peer-urls和--listen-client-urls中添加0.0.0.0来修复此问题(但不确定后果是什么):



docker run --net=host -d -p 2379:2379 \
  -p 2380:2380 \
  --restart=always \
  --volume=${DATA_DIR}:/etcd-data \
  --name etcd0 quay.io/coreos/etcd:${ETCD_VERSION} \
  /usr/local/bin/etcd \
  --data-dir=/etcd-data --name ${THIS_NAME} \
  --initial-advertise-peer-urls http://${THIS_IP}:2380 --listen-peer-urls http://0.0.0.0:2380 \
  --advertise-client-urls http://${THIS_IP}:2379 --listen-client-urls http://0.0.0.0:2379** \
  --initial-cluster ${CLUSTER} \
  --initial-cluster-state ${CLUSTER_STATE} --initial-cluster-token ${TOKEN}




使用curl验证工作集群:



curl http://IP:2379/v2/members
{"members":[{"id":"d587abebd4bc78d","name":"etcd1","peerURLs":["http://IP:2380"],"clientURLs":["http://IP:2379"]},{"id":"17efb04cb71d981c","name":"etcd0","peerURLs":["http://IP:2380"],"clientURLs":["http://IP:2379"]},{"id":"3d50a0b6f7f6bda6","name":"etcd3","peerURLs":["http://IP:2380"],"clientURLs":["http://IP:2379"]}]}




Docker命令直接来自coreos etcd网站: https://coreos.com/etcd/docs/3.2.9/op-guide/container.html#docker

答案 1 :(得分:0)

如果遵循etcd指南,请检查这是否指向您在以下位置运行命令的计算机:

THIS_NAME=${NAME_4}
THIS_IP=${HOST_4}

用正确的数字替换4。