标签:style blog http color io os 使用 ar strong
参考我前面的一篇文章(点击这里),前面引入一个在Etcd集群环境下的关键性问题:
三个Etcd节点组成Clustering应该访问那个(进行操作请求)???
(1)针对读取操作三个任意一个都可以,即使它不是leader
(2)针对写入操作,好像只能通过连接leader来进行写入。
我有一个由三个节点组成的集群(127.0.0.1:4001、127.0.0.1:4002以及127.0.0.1:4003),有一个连接到集群开启定时器定时注册服务(实际上是定时创建带TTL的Node)的程序,如下所示:
问题: 为什么我按照这个教程启动的三个节点的集群,随时时间推移,leader会变来变去???
然后我把这个问题在Etcd的GitHub上向作者提问:
然后作者回答了:
(1) It is a common case for etcd to change leader, though it should not be so frequent.
(2) if you connect to non leader, it will send back a 307 redirect http response, which indicates where the leader is
然后我又问了:
thanks
why the etcd can not redirect my http request to leader automatically? i just need to connect to any peer of the clustering whitout concerning which is the leader
@jiq408694711 for now, honouring the redirect is the responsibility of the client, and many implementations will follow it automatically.
In future, etcd will have a proxy mode which will provide the behaviour you‘re after.
看来我用的这个C#的etcd客户端没有考虑这个呀!!!
作者还说将来etcd会使用代理模式来弥补这一点。
etcd还比较新,现在还在不断开发中,1.0版本都还没有出来,让我们拭目以待吧!
目前我就先暂时不使用集群了,先用着一个节点吧。。。呵呵
Etcd学习(三)集群搭建Clustering中Leader问题
标签:style blog http color io os 使用 ar strong
原文地址:http://blog.csdn.net/jiyiqinlovexx/article/details/39253843
Hello:
I have built a cluster of three machines according to this document:https://github.com/coreos/etcd/blob/master/Documentation/clustering.md .
then i connect to 127.0.0.1:4001 by etcetera and register a service address(actually write service info to etcd node with ttl) by using .NET timer:
when i run my code, i find that the output sometimes is "register success", sometimes is "register fail", The reseaon is that the leader of cluster always change by itself, The registeration will fail if the leader is not "127.0.0.1:4001", The registeration will success if the leader is "127.0.0.1:4001".
I want to know :
(1) why the leader always keep changing???
(2) If i want to write to etcd correctly, which active peer i should connect ???
if the correct active peer is leader, how can i get the leader???
Thank you!!!