我试图使用AWS中的3个实例运行etcd,但是当我试图列出成员时,我会得到下面的错误:
[ec2-user@etcd1 ~]$ etcdctl member list
{"level":"warn","ts":"2021-10-19T04:50:01.981Z","logger":"etcd-client","caller":"v3/retry_interceptor.go:62","msg":"retrying of unary invoker failed","target":"etcd-endpoints://0xc0002e0a80/127.0.0.1:2379","attempt":0,"error":"rpc error: code = DeadlineExceeded desc = context deadline exceeded"}
Error: context deadline exceeded我用下面的命令开始我的实例:
实例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拜托,如果你知道我做错了什么,请告诉我。
发布于 2021-10-19 07:59:14
对我来说,您似乎遵循了https://etcd.io/docs/v3.5/demo/#set-up-a-cluster,如果是这样的话,有两件事您应该改变:
localhost代替了${THIS_IP}变量,当它应该是可以从集群中的每个vm访问的vm IP地址(只要它是可访问的)--initial-cluster选项中使用etcdX,这些应该是vm的IP,而不是etcd成员的名称G 210
我建议的是在每个vm中设置这些变量:
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}https://stackoverflow.com/questions/69625159
复制相似问题