etcd节点通信的协议和端口

etcd是一个分布式键值存储系统,它提供了一种高可用的方式来存储配置和服务信息。在etcd中,节点之间的通信主要依赖于HTTP协议,并且使用gRPC作为客户端与etcd服务端之间的通信接口 。以下是etcd节点通信的协议和端口的详细信息:

  1. 客户端请求:etcd客户端通过gRPC向服务端发送请求,使用的端口通常是2379 。

  2. 节点间通信:etcd节点间的通信使用的是2380端口,这个端口用于节点之间的数据同步和心跳检测 。

  3. 协议:etcd v3的通信基于gRPC,使用proto3作为消息格式定义服务端和客户端通讯接口 。

  4. 服务分类:etcd3中的RPC接口根据功能被分类到不同的服务中,如KV服务用于键值操作,Watch服务用于监视键的更改等 。

  5. 响应头:所有etcd API的响应都有一个响应头,包括集群ID、成员ID、修订版本号和Raft术语等信息,这些可以帮助应用服务识别通信的集群或成员,以及了解键值存储的最新状态 。

  6. 网络层实现:在早期版本的etcd中,网络层通过HTTP协议提供服务,并且集群节点之间也是通过HTTP协议进行数据交互 。网络层的功能包括监听服务端口,完成集群节点间的数据通信以及接收客户端数据。

  7. 节点网络拓扑:etcd集群的节点之间形成一个网状结构,任意两个节点之间都有长连接相互连接,用于节点之间的数据同步和心跳检测 。

  8. 消息交互:节点之间根据不同用途定义了不同的消息类型,通过google protocol buffer协议进行封装,并通过两种类型的消息传输通道(Stream类型和Pipeline类型)高效地处理不同数据量的消息 。

这些信息提供了对etcd节点通信协议和端口使用的全面了解。

  • 5
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
etcd 是一个高可用的分布式 key-value 存储系统,可以用于分布式锁、服务发现、共享配置等场景。在使用 etcd 时,为了保证其高可用性,通常需要使用多个节点组成 etcd 集群。以下是配置 etcd 3 节点集群的步骤: 1. 安装 etcd 在每个节点上安装 etcd。具体步骤可以参考 etcd 的官方文档。 2. 修改配置文件 在每个节点上修改 etcd 的配置文件,一般位于 /etc/etcd/etcd.conf: ``` # Node 1 name: "node1" data-dir: "/var/lib/etcd" listen-peer-urls: "https://192.168.0.1:2380" listen-client-urls: "https://192.168.0.1:2379" initial-advertise-peer-urls: "https://192.168.0.1:2380" advertise-client-urls: "https://192.168.0.1:2379" initial-cluster: "node1=https://192.168.0.1:2380,node2=https://192.168.0.2:2380,node3=https://192.168.0.3:2380" initial-cluster-token: "my-etcd-cluster" initial-cluster-state: "new" client-transport-security: cert-file: "/etc/ssl/etcd/etcd.pem" key-file: "/etc/ssl/etcd/etcd-key.pem" trusted-ca-file: "/etc/ssl/etcd/ca.pem" peer-transport-security: cert-file: "/etc/ssl/etcd/etcd.pem" key-file: "/etc/ssl/etcd/etcd-key.pem" trusted-ca-file: "/etc/ssl/etcd/ca.pem" # Node 2 name: "node2" data-dir: "/var/lib/etcd" listen-peer-urls: "https://192.168.0.2:2380" listen-client-urls: "https://192.168.0.2:2379" initial-advertise-peer-urls: "https://192.168.0.2:2380" advertise-client-urls: "https://192.168.0.2:2379" initial-cluster: "node1=https://192.168.0.1:2380,node2=https://192.168.0.2:2380,node3=https://192.168.0.3:2380" initial-cluster-token: "my-etcd-cluster" initial-cluster-state: "new" client-transport-security: cert-file: "/etc/ssl/etcd/etcd.pem" key-file: "/etc/ssl/etcd/etcd-key.pem" trusted-ca-file: "/etc/ssl/etcd/ca.pem" peer-transport-security: cert-file: "/etc/ssl/etcd/etcd.pem" key-file: "/etc/ssl/etcd/etcd-key.pem" trusted-ca-file: "/etc/ssl/etcd/ca.pem" # Node 3 name: "node3" data-dir: "/var/lib/etcd" listen-peer-urls: "https://192.168.0.3:2380" listen-client-urls: "https://192.168.0.3:2379" initial-advertise-peer-urls: "https://192.168.0.3:2380" advertise-client-urls: "https://192.168.0.3:2379" initial-cluster: "node1=https://192.168.0.1:2380,node2=https://192.168.0.2:2380,node3=https://192.168.0.3:2380" initial-cluster-token: "my-etcd-cluster" initial-cluster-state: "new" client-transport-security: cert-file: "/etc/ssl/etcd/etcd.pem" key-file: "/etc/ssl/etcd/etcd-key.pem" trusted-ca-file: "/etc/ssl/etcd/ca.pem" peer-transport-security: cert-file: "/etc/ssl/etcd/etcd.pem" key-file: "/etc/ssl/etcd/etcd-key.pem" trusted-ca-file: "/etc/ssl/etcd/ca.pem" ``` 每个节点的配置文件需要修改以下参数: - name:节点名称,需要在集群中唯一。 - data-dir:数据存储目录。 - listen-peer-urls:节点通信的地址。需要指定 https 协议端口号。 - listen-client-urls:客户端访问 etcd 的地址。需要指定 https 协议端口号。 - initial-advertise-peer-urls:节点向其他节点宣告自己的地址。需要指定 https 协议端口号。 - advertise-client-urls:节点向客户端宣告自己的地址。需要指定 https 协议端口号。 - initial-cluster:集群中所有节点的信息。每个节点信息格式为 name=https://ip:port。需要注意,节点名称一定要与配置文件中的 name 参数一致。 - initial-cluster-token:集群令牌,需要在所有节点中保持一致。 - initial-cluster-state:集群状态。第一次启动时为 new,之后为 existing。 - client-transport-security:客户端访问 etcd 的安全配置。 - peer-transport-security:节点通信的安全配置。 3. 启动 etcd 在每个节点上启动 etcd 服务: ``` $ systemctl start etcd ``` 4. 验证集群状态 在任意一个节点上执行以下命令,可以查看集群状态: ``` $ etcdctl --endpoints=https://192.168.0.1:2379,https://192.168.0.2:2379,https://192.168.0.3:2379 --ca-file=/etc/ssl/etcd/ca.pem --cert-file=/etc/ssl/etcd/etcd.pem --key-file=/etc/ssl/etcd/etcd-key.pem cluster-health ``` 输出结果为: ``` member 9c61b7b4b666f72 is healthy: got healthy result from https://192.168.0.1:2379 member d21cfc0987b4d8f is healthy: got healthy result from https://192.168.0.2:2379 member f4d7a7f4d2a5cee is healthy: got healthy result from https://192.168.0.3:2379 cluster is healthy ``` 表示集群状态正常。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值