杭州怎样建设网站,兴安盟新百度县seo快速排名,wordpress flat主题,漳州建设项目公告网站etcd是CoreOS团队于2013年6月发起的开源项目#xff0c;它的目标是构建一个高可用的分布式键值(key-value)数据库#xff0c;用于配置共享和服务发现 etcd内部采用raft协议作为一致性算法#xff0c;etcd基于Go语言实现。 etcd作为服务发现系统#xff0c;有以下的特点它的目标是构建一个高可用的分布式键值(key-value)数据库用于配置共享和服务发现 etcd内部采用raft协议作为一致性算法etcd基于Go语言实现。 etcd作为服务发现系统有以下的特点 简单安装配置简单HTTPJSON的 API进行交互使用curl命令可以轻松使用安全支持SSL证书验证机制快速根据官方提供的benchmark数据单实例支持每秒1k写操作可靠采用raft算法实现分布式系统数据的可用性和一致性分布式系统中数据分为控制数据和应用数据etcd处理的数据为控制数据 同一个分布式集群中的进程或服务互相感知并建立链接这就是服务发现。解决服务发现问题的三大支柱 一个强一致性、高可用的服务存储目录 基于Raft算法一种注册服务和监控服务健康状态的机制一种查找和链接服务的机制微服务协同工作架构中服务动态添加 etcd基本命令 集群搭建参考k8s集群搭建里的etcd 更新一个节点 #首先查看所有节点
[rootslave2 ~]# etcdctl member list
646ec025a72fc8a: nameetcd3 peerURLshttp://192.168.132.133:2380 clientURLshttp://192.168.132.133:2379 isLeadertrue
dde447f371b55f50: nameetcd1 peerURLshttp://192.168.132.131:2380 clientURLshttp://192.168.132.131:2379 isLeaderfalse
e96057c7f8ba5f4b: nameetcd2 peerURLshttp://192.168.132.132:2380 clientURLshttp://192.168.132.132:2379 isLeaderfalse#更新一个节点
[rootslave2 ~]# etcdctl member update 646ec025a72fc8a http://192.168.132.133:2380
Updated member with ID 646ec025a72fc8a in cluster 删除一个节点 #查看所有节点[rootslave2 ~]# etcdctl member list
646ec025a72fc8a: nameetcd3 peerURLshttp://192.168.132.133:2380 clientURLshttp://192.168.132.133:2379 isLeaderfalse
dde447f371b55f50: nameetcd1 peerURLshttp://192.168.132.131:2380 clientURLshttp://192.168.132.131:2379 isLeadertrue
e96057c7f8ba5f4b: nameetcd2 peerURLshttp://192.168.132.132:2380 clientURLshttp://192.168.132.132:2379 isLeaderfalse
#删除一个节点[rootslave2 ~]# etcdctl member remove 646ec025a72fc8a
Removed member 646ec025a72fc8a from cluster
#再次查看节点使用当前命令报错[rootslave2 ~]# etcdctl member list
Error: client: etcd cluster is unavailable or misconfigured; error #0: dial tcp 127.0.0.1:2379: getsockopt: connection refused
; error #1: dial tcp 127.0.0.1:4001: getsockopt: connection refusederror #0: dial tcp 127.0.0.1:2379: getsockopt: connection refused
error #1: dial tcp 127.0.0.1:4001: getsockopt: connection refused
#换一个命令[rootslave2 ~]# etcdctl --endpoints http://192.168.132.131:2379 member list
dde447f371b55f50: nameetcd1 peerURLshttp://192.168.132.131:2380 clientURLshttp://192.168.132.131:2379 isLeadertrue
e96057c7f8ba5f4b: nameetcd2 peerURLshttp://192.168.132.132:2380 clientURLshttp://192.168.132.132:2379 isLeaderfalse 添加节点 #将删除的节点添加回来[rootslave2 ~]# etcdctl --endpoints http://192.168.132.132:2379 member add etcd3 http://192.168.132.133:2380
Added member named etcd3 with ID 7a6809311b4a3579 to clusterETCD_NAMEetcd3
ETCD_INITIAL_CLUSTERetcd3http://192.168.132.133:2380,etcd1http://192.168.132.131:2380,etcd2http://192.168.132.132:2380
ETCD_INITIAL_CLUSTER_STATEexisting#再次查看状态为unstarted
[rootslave2 ~]# etcdctl --endpoints http://192.168.132.132:2379 member list
7a6809311b4a3579[unstarted]: peerURLshttp://192.168.132.133:2380
dde447f371b55f50: nameetcd1 peerURLshttp://192.168.132.131:2380 clientURLshttp://192.168.132.131:2379 isLeadertrue
e96057c7f8ba5f4b: nameetcd2 peerURLshttp://192.168.132.132:2380 clientURLshttp://192.168.132.132:2379 isLeaderfalse 清空目标节点数据 目标节点从集群中删除后成员信息会更新。新节点是作为一个全新的节点加入集群如果data-dir有数据etcd启动时会读取己经存在的数据仍然用旧的memberID会造成无法加入集群所以一定要清空新节点的data-dir。 #删除的节点的主机$ rm -rf /var/lib/etcd/etcd3 在目标节点上启动新增加的成员 修改配置文件中ETCD_INITIAL_CLUSTER_STATE标记为existing如果为new则会自动生成一个新的memberID这和前面添加节点时生成的ID不一致故日志中会报节点ID不匹配的错。 [rootslave2 ~]# cat /etc/etcd/etcd.conf |grep -v ^#
[Member]
ETCD_DATA_DIR/var/lib/etcd/etcd3
ETCD_LISTEN_PEER_URLShttp://192.168.132.133:2380
ETCD_LISTEN_CLIENT_URLShttp://192.168.132.133:2379,http://127.0.0.1:2379
ETCD_NAMEetcd3
[Clustering]
ETCD_INITIAL_ADVERTISE_PEER_URLShttp://192.168.132.133:2380
ETCD_ADVERTISE_CLIENT_URLShttp://192.168.132.133:2379
ETCD_INITIAL_CLUSTER_STATEexisting
ETCD_INITIAL_CLUSTERetcd1http://192.168.132.131:2380,etcd2http://192.168.132.132:2380,etcd3http://192.168.132.133:2380 重启服务再次查看 [rootslave2 ~]# systemctl restart etcd
[rootslave2 ~]# etcdctl --endpoints http://192.168.132.132:2379 member list
7a6809311b4a3579: nameetcd3 peerURLshttp://192.168.132.133:2380 clientURLshttp://192.168.132.133:2379 isLeaderfalse
dde447f371b55f50: nameetcd1 peerURLshttp://192.168.132.131:2380 clientURLshttp://192.168.132.131:2379 isLeadertrue
e96057c7f8ba5f4b: nameetcd2 peerURLshttp://192.168.132.132:2380 clientURLshttp://192.168.132.132:2379 isLeaderfalse
[rootslave2 ~]# etcdctl member list
7a6809311b4a3579: nameetcd3 peerURLshttp://192.168.132.133:2380 clientURLshttp://192.168.132.133:2379 isLeaderfalse
dde447f371b55f50: nameetcd1 peerURLshttp://192.168.132.131:2380 clientURLshttp://192.168.132.131:2379 isLeadertrue
e96057c7f8ba5f4b: nameetcd2 peerURLshttp://192.168.132.132:2380 clientURLshttp://192.168.132.132:2379 isLeaderfalse 转载于:https://www.cnblogs.com/FRESHMANS/p/9268693.html