ETCD时CoreOS团队与2013年6月发起的开源项目,他的目标的构建一个高可用的分布式键值仓库,遵循apache v2许可,基于go语言开发,目前稳定版为3.3.10版本,分布式系统中最基本的问题就是数据的一致性问题,在此基础之上,才能实现对服务配置信息的管理,服务的发现,更新,同步,等等问题,像我们熟悉的ZooKeepor采用的Paxos算法来实现数据的强一致性,而ETCD则采用了更加简洁的Raft算法,同样可以实现数据的强一致性,并支持集群节点的状态管理和服务自动发现功能等等
github项目地址
下载安装:
[root@node8 ~]# wget https://github.com/etcd-io/etcd/releases /download/v3.3.10/etcd-v3.3.10-linux-amd64.tar.gz
[root@node8 ~]# tar xzvf etcd-v3.3.10-linux-amd64.tar.gz
[root@node8 ~]# ls
etcd etcdctl Documentation README-etcdctl.md README.md READMEv2-etcdctl.md
需要注意的就两个文件,一个是etcd,这个就是etcd的主文件
第二个是etcdctl,命令行客户端
然后启动etcd
[root@node6 ~]# etcd
2018-11-20 17:22:09.831342 I | etcdmain: etcd Version: 3.3.10 ##etcd版本3.3.10
2018-11-20 17:22:09.831382 I | etcdmain: Git SHA: 27fc7e2 ##git的摘要
2018-11-20 17:22:09.831385 I | etcdmain: Go Version: go1.10.4 ##go的版本
2018-11-20 17:22:09.831388 I | etcdmain: Go OS/Arch: linux/amd64 ## linux的64位机器上
2018-11-20 17:22:09.831391 I | etcdmain: setting maximum number of CPUs to 1, total number of available CPUs is 1 ##我的机器的CPU
2018-11-20 17:22:09.831412 W | etcdmain: no data-dir provided, using default data-dir ./default.etcd ##数据默认存储在./default.etcd里
2018-11-20 17:22:09.831474 N | etcdmain: the server is already initialized as member before, starting as etcd member... ##member里是状态快照和日志
2018-11-20 17:22:09.831720 I | embed: listening for peers on http://localhost:2380 ##其他节点连接端口
2018-11-20 17:22:09.831783 I | embed: listening for client requests on localhost:2379 ##客户端请求端口
2018-11-20 17:22:09.832855 I | etcdserver: name = default ##成员节点的别名
2018-11-20 17:22:09.832864 I | etcdserver: data dir = default.etcd ## 数据存储目录
2018-11-20 17:22:09.832867 I | etcdserver: member dir = default.etcd/member ##member的默认路径
2018-11-20 17:22:09.832870 I | etcdserver: heartbeat = 100ms ##心跳时间间隔ms
2018-11-20 17:22:09.832873 I | etcdserver: election = 1000ms ## 重新选举时间间隔ms
2018-11-20 17:22:09.832875 I | etcdserver: snapshot count = 100000 ##提交多少次事物发出一次快照
2018-11-20 17:22:09.832882 I | etcdserver: advertise client URLs = http://localhost:2379 ##客户端访问的URL
2018-11-20 17:22:10.728496 I | etcdserver: restarting member 8e9e05c52164694d in cluster cdf818194e3a8c32 at commit index 4
2018-11-20 17:22:10.728527 I | raft: 8e9e05c52164694d became follower at term 2
2018-11-20 17:22:10.728536 I | raft: newRaft 8e9e05c52164694d [peers: [], term: 2, commit: 4, applied: 0, lastindex: 4, lastterm: 2]
2018-11-20 17:22:10.754102 W | auth: simple token is not cryptographically signed
2018-11-20 17:22:10.769925 I | etcdserver: starting server... [version: 3.3.10, cluster version: to_be_decided]
2018-11-20 17:22:10.771863 I | etcdserver/membership: added member 8e9e05c52164694d [http://localhost:2380] to cluster cdf818194e3a8c32
2018-11-20 17:22:10.771934 N | etcdserver/membership: set the initial cluster version to 3.3
2018-11-20 17:22:10.771956 I | etcdserver/api: enabled capabilities for version 3.3
2018-11-20 17:22:11.728889 I | raft: 8e9e05c52164694d is starting a new election at term 2
2018-11-20 17:22:11.728918 I | raft: 8e9e05c52164694d became candidate at term 3
2018-11-20 17:22:11.728934 I | raft: 8e9e05c52164694d received MsgVoteResp from 8e9