我从 CoreOS 集群中删除了一个节点,并在其位置上添加了一个新节点。不幸的是,它获取了与旧机器相同的 IP。
这阻止了 etcd 发现集群的其余部分,日志中出现如下消息:“失败:加入请求失败:对等地址已存在”
如何从 discovery.etcd.io 中删除旧节点?
答案1
如果你知道机器 ID,可以简短回答
发送 HTTP DELETE 请求至https://discovery.etcd.io/<cluster-id>/<machine-id>
例如
curl https://discovery.etcd.io/abcdef0123456789abcdef0123456789/7cf9a5cf5e3b4baea82e28618bffeaf5 -XDELETE
更长的答案-如何找到要删除的机器 ID
首先,从发现 URL 获取 JSON 对象,例如
https://discovery.etcd.io/abcdef0123456789abcdef0123456789
它看起来有点像这样:
{
"action": "get",
"node": {
"key": "\/_etcd\/registry\/abcdef0123456789abcdef0123456789",
"dir": true,
"nodes": [
{
"key": "\/_etcd\/registry\/abcdef0123456789abcdef0123456789\/6148dbb812a44dbe8773bebf329634e7",
"value": "http:\/\/10.132.47.218:7001",
"expiration": "2015-04-15T17:58:12.753046544Z",
"ttl": 598570,
"modifiedIndex": 453369429,
"createdIndex": 453369429
},
{
"key": "\/_etcd\/registry\/abcdef0123456789abcdef0123456789\/646fbdaee73544e6ac289894e935f0c7",
"value": "http:\/\/10.132.47.218:7001",
"expiration": "2015-04-15T18:30:03.08506867Z",
"ttl": 600480,
"modifiedIndex": 453418705,
"createdIndex": 453418705
},
{
"key": "\/_etcd\/registry\/abcdef0123456789abcdef0123456789\/05e0decf1d9240819382db7a7f8ff2e7",
"value": "http:\/\/10.132.58.166:7001",
"expiration": "2015-04-14T23:47:31.402148037Z",
"ttl": 533129,
"modifiedIndex": 451690943,
"createdIndex": 451690943
},
{
"key": "\/_etcd\/registry\/abcdef0123456789abcdef0123456789\/af2783b2327e4f3a9b6e7ea169814a06",
"value": "http:\/\/10.132.58.167:7001",
"expiration": "2015-04-14T23:47:38.676204353Z",
"ttl": 533136,
"modifiedIndex": 451691169,
"createdIndex": 451691169
}
],
"modifiedIndex": 426955695,
"createdIndex": 426955695
}
}
假设我们重用的 IP 是10.132.47.218
- 我们想要识别与之对应的机器 ID。我们可以从密钥中看到这是6148dbb812a44dbe8773bebf329634e7
现在我们可以简单地使用 DELETE 动词来删除它
curl https://discovery.etcd.io/abcdef0123456789abcdef0123456789/7cf9a5cf5e3b4baea82e28618bffeaf5 -XDELETE