[英]How to run etcd in multiple instance?
我正在尝试在 AWS 中使用 3 个实例运行 etcd,但是当我尝试列出成员时出现以下错误:
[ec2-user@etcd1 ~]$ etcdctl 成员列表 {"level":"warn","ts":"2021-10-19T04:50:01.981Z","logger":"etcd-client","caller ":"v3/retry_interceptor.go:62","msg":"重试一元调用失败","target":"etcd-endpoints://0xc0002e0a80/127.0.0.1:2379","attempt":0, “错误”:“rpc 错误:代码 = DeadlineExceeded desc = 超出上下文截止日期”} 错误:超出上下文截止日期
我正在使用以下命令启动我的实例:
实例 1:
etcd --data-dir=data.etcd --name etcd1
--initial-advertise-peer-urls http://localhost:2380 --listen-peer-urls http://localhost:2380
--advertise-client-urls http://localhost:2379 --listen-client-urls http://localhost:2379
--initial-cluster etcd1=http://etcd1:2380,etcd2=http://etcd2:2380,etcd3=http://etcd3:2380
--initial-cluster-state new --initial-cluster-token token-01
实例2:
etcd --data-dir=data.etcd --name etcd2
--initial-advertise-peer-urls http://localhost:2380 --listen-peer-urls http://localhost:2380
--advertise-client-urls http://localhost:2379 --listen-client-urls http://localhost:2379
--initial-cluster etcd1=http://etcd1:2380,etcd2=http://etcd2:2380,etcd3=http://etcd3:2380
--initial-cluster-state new --initial-cluster-token token-01
实例3:
etcd --data-dir=data.etcd --name etcd3
--initial-advertise-peer-urls http://localhost:2380 --listen-peer-urls http://localhost:2380
--advertise-client-urls http://localhost:2379 --listen-client-urls http://localhost:2379
--initial-cluster etcd1=http://etcd1:2380,etcd2=http://etcd2:2380,etcd3=http://etcd3:2380
--initial-cluster-state new --initial-cluster-token token-01
请让我知道你是否知道我做错了什么。
对我来说,您似乎遵循了https://etcd.io/docs/v3.5/demo/#set-up-a-cluster ,如果是这种情况,您应该更改两件事:
${THIS_IP}
IP 地址时,您使用localhost
代替${THIS_IP}
变量(只要可访问,它可以是公共或私有地址)--initial-cluster
选项中使用了etcdX
,这些应该是 vm 的 IP,而不是 etcd 成员的名称我建议在每个虚拟机中设置这些变量:
TOKEN=token-01
CLUSTER_STATE=new
NAME_1=etcd1
NAME_2=etcd2
NAME_3=etcd3
HOST_1=10.240.0.17 # <- should be ip of 1st vm
HOST_2=10.240.0.18 # <- should be ip of 2nd vm
HOST_3=10.240.0.19 # <- should be ip of 3rd vm
CLUSTER=${NAME_1}=http://${HOST_1}:2380,${NAME_2}=http://${HOST_2}:2380,${NAME_3}=http://${HOST_3}:2380
然后使用以下命令为 etcd1 启动 etcd
THIS_NAME=${NAME_1}
THIS_IP=${HOST_1}
etcd --data-dir=data.etcd --name ${THIS_NAME} \
--initial-advertise-peer-urls http://${THIS_IP}:2380 --listen-peer-urls http://${THIS_IP}:2380 \
--advertise-client-urls http://${THIS_IP}:2379 --listen-client-urls http://${THIS_IP}:2379 \
--initial-cluster ${CLUSTER} \
--initial-cluster-state ${CLUSTER_STATE} --initial-cluster-token ${TOKEN}
下面是 etcd2 的命令
THIS_NAME=${NAME_2}
THIS_IP=${HOST_2}
etcd --data-dir=data.etcd --name ${THIS_NAME} \
--initial-advertise-peer-urls http://${THIS_IP}:2380 --listen-peer-urls http://${THIS_IP}:2380 \
--advertise-client-urls http://${THIS_IP}:2379 --listen-client-urls http://${THIS_IP}:2379 \
--initial-cluster ${CLUSTER} \
--initial-cluster-state ${CLUSTER_STATE} --initial-cluster-token ${TOKEN}
及以下用于 etcd3
THIS_NAME=${NAME_3}
THIS_IP=${HOST_3}
etcd --data-dir=data.etcd --name ${THIS_NAME} \
--initial-advertise-peer-urls http://${THIS_IP}:2380 --listen-peer-urls http://${THIS_IP}:2380 \
--advertise-client-urls http://${THIS_IP}:2379 --listen-client-urls http://${THIS_IP}:2379 \
--initial-cluster ${CLUSTER} \
--initial-cluster-state ${CLUSTER_STATE} --initial-cluster-token ${TOKEN}
谢谢你。 我按照你提到的方式执行了命令,但现在我遇到了其他错误:
{"level":"info","ts":"2021-10-19T11:38:23.882Z","caller":"etcdmain/etcd.go:72","msg":"运行:"," args":["etcd","--data-dir=data.etcd","--name","etcd1","--initial-advertise-peer-urls","http://13.58.134.34 :2380","--listen-peer-urls","http://13.58.134.34:2380","--advertise-client-urls","http://13.58.134.34:2379","- -listen-client-urls","http://13.58.134.34:2379","--initial-cluster","etcd1=http://13.58.134.34:2380,etcd2=http://18.118.5.45 :2380,etcd3=http://18.119.98.88:2380","--initial-cluster-state","new","--initial-cluster-token","token-01"]} {"level ":"info","ts":"2021-10-19T11:38:23.882Z","caller":"etcdmain/etcd.go:115","msg":"服务器已经初始化"," data-dir":"data.etcd","dir-type":"member"} {"level":"info","ts":"2021-10-19T11:38:23.882Z","caller" :"embed/etcd.go:131","msg":"配置对等监听器","listen-peer-urls":["http://13.58.134.34:2380"]} {"level":"info ","ts":"2021-10-19T11:38:23.882Z","caller":"embed/etcd.go:367","msg":"关闭 etcd 服务器","name":"etcd1" ,”数据 a-dir":"data.etcd","advertise-peer-urls":["http://13.58.134.34:2380"],"advertise-client-urls":["http://13.58.134.34 :2379"]} {"level":"info","ts":"2021-10-19T11:38:23.883Z","caller":"embed/etcd.go:369","msg":"关闭 etcd 服务器","name":"etcd1","data-dir":"data.etcd","advertise-peer-urls":["http://13.58.134.34:2380"],"advertise- client-urls":["http://13.58.134.34:2379"]} {"level":"fatal","ts":"2021-10-19T11:38:23.883Z","caller":" etcdmain/etcd.go:203","msg":"发现失败","error":"listen tcp 13.58.134.34:2380: bind: 无法分配请求的地址","stacktrace":"go.etcd.io/ etcd/server/v3/etcdmain.startEtcdOrProxyV2\\n\\t/tmp/etcd-release-3.5.1/etcd/release/etcd/server/etcdmain/etcd.go:203\\ngo.etcd.io/etcd/server/ v3/etcdmain.Main\\n\\t/tmp/etcd-release-3.5.1/etcd/release/etcd/server/etcdmain/main.go:40\\nmain.main\\n\\t/tmp/etcd-release- 3.5.1/etcd/release/etcd/server/main.go:32\\nruntime.main\\n\\t/home/remote/sbatsche/.gvm/gos/go1.16.3/src/runtime/proc.go:225 "}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.