etcd-io/etcd

GitHub: etcd-io/etcd

基于 Raft 共识算法的高可用分布式键值存储系统,专为分布式系统中的关键数据设计,是 Kubernetes 等云原生平台的核心状态存储引擎。

Stars: 51679 | Forks: 10344

# etcd [![Go Report Card](https://goreportcard.com/badge/github.com/etcd-io/etcd?style=flat-square)](https://goreportcard.com/report/github.com/etcd-io/etcd) [![Coverage](https://codecov.io/gh/etcd-io/etcd/branch/main/graph/badge.svg)](https://app.codecov.io/gh/etcd-io/etcd/tree/main) [![Tests](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/3c242aa716162517.svg)](https://github.com/etcd-io/etcd/actions/workflows/tests.yaml) [![codeql-analysis](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/da351dabb3162519.svg)](https://github.com/etcd-io/etcd/actions/workflows/codeql-analysis.yml) [![Docs](https://img.shields.io/badge/docs-latest-green.svg)](https://etcd.io/docs) [![Godoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](https://godocs.io/go.etcd.io/etcd/v3) [![Releases](https://img.shields.io/github/release/etcd-io/etcd/all.svg?style=flat-square)](https://github.com/etcd-io/etcd/releases) [![LICENSE](https://img.shields.io/github/license/etcd-io/etcd.svg?style=flat-square)](https://github.com/etcd-io/etcd/blob/main/LICENSE) [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/etcd-io/etcd/badge)](https://scorecard.dev/viewer/?uri=github.com/etcd-io/etcd) **注意**:在开发过程中,`main` 分支可能处于*不稳定甚至损坏的状态*。如需稳定版本,请参阅 [releases][github-release]。 etcd logo etcd 是一个分布式可靠的键值存储,专为分布式系统中最关键的数据而设计,其重点在于: * *简单*:定义良好、面向用户的 API (gRPC) * *安全*:自动 TLS,支持可选的客户端证书认证 * *快速*:基准测试达到 10,000 写入/秒 * *可靠*:使用 Raft 正确实现分布式 etcd 使用 Go 编写,并使用 [Raft][] 共识算法来管理高可用的复制日志。 etcd 被[许多公司在生产环境中使用](./ADOPTERS.md),开发团队在关键部署场景中为其提供支持,在这些场景中,etcd 经常与 [Kubernetes][k8s]、[locksmith][]、[vulcand][]、[Doorman][] 等应用程序以及许多其他应用结合使用。通过严格的 [**健壮性测试**](https://github.com/etcd-io/etcd/tree/main/tests/robustness) 进一步确保了可靠性。 请参阅 [etcdctl][etcdctl] 以获取简单的命令行客户端。 ![etcd reliability is important](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/b77f7e1707162520.png) 原始图片版权归 xkcd.com/2347 所有,由 Josh Berkus 修改。 ## 文档 您可能需要的最常见 API 文档可以在这里找到: * [go.etcd.io/etcd/api/v3](https://godocs.io/go.etcd.io/etcd/api/v3) * [go.etcd.io/etcd/client/pkg/v3](https://godocs.io/go.etcd.io/etcd/client/pkg/v3) * [go.etcd.io/etcd/client/v3](https://godocs.io/go.etcd.io/etcd/client/v3) * [go.etcd.io/etcd/etcdctl/v3](https://godocs.io/go.etcd.io/etcd/etcdctl/v3) * [go.etcd.io/etcd/pkg/v3](https://godocs.io/go.etcd.io/etcd/pkg/v3) * [go.etcd.io/etcd/raft/v3](https://godocs.io/go.etcd.io/etcd/raft/v3) * [go.etcd.io/etcd/server/v3](https://godocs.io/go.etcd.io/etcd/server/v3) ## 维护者 [维护者](OWNERS) 致力于塑造包容的开源项目文化,倾听用户的声音,让贡献者感到受尊重和充满力量。维护者旨在跨不同公司和学科建立富有成效的关系。阅读更多关于 [维护者角色和职责](Documentation/contributor-guide/community-membership.md#maintainers) 的信息。 ## 快速入门 ### 获取 etcd 获取 etcd 最简单的方法是使用预构建的发布二进制文件,这些文件可在 [发布页面][github-release] 上找到,支持 OSX、Linux、Windows 和 Docker。 有关更多安装指南,请查看 [play.etcd.io](http://play.etcd.io) 和 [运维 etcd](https://etcd.io/docs/latest/op-guide)。 ### 运行 etcd 首先启动一个单成员的 etcd 集群。 如果是使用 [预构建的二进制文件][github-release] 安装 etcd,请按如下所示从安装位置运行: ``` /tmp/etcd-download-test/etcd ``` 如果 etcd 已移动到系统路径中,则可以简单地按如下方式运行 etcd 命令: ``` mv /tmp/etcd-download-test/etcd /usr/local/bin/ etcd ``` 这将启动 etcd,监听端口 2379 用于客户端通信,监听端口 2380 用于服务器到服务器通信。 接下来,让我们设置一个键,然后检索它: ``` etcdctl put mykey "this is awesome" etcdctl get mykey ``` etcd 现在正在运行并处理客户端请求。更多信息请查看: * [交互式 etcd 演练场](http://play.etcd.io) * [动画快速演示](https://etcd.io/docs/latest/demo) ### etcd TCP 端口 [官方 etcd 端口][iana-ports] 是 2379(用于客户端请求)和 2380(用于节点通信)。 ### 运行本地 etcd 集群 首先安装 [goreman](https://github.com/mattn/goreman),它用于管理基于 Procfile 的应用程序。 我们的 [Procfile 脚本](./Procfile) 将设置一个本地示例集群。使用以下命令启动: ``` goreman start ``` 这将启动 3 个 etcd 成员 `infra1`、`infra2` 和 `infra3`,以及可选的 etcd `grpc-proxy`,它们在本地运行并组成一个集群。 每个集群成员和代理都接受键值读取和键值写入。 按照 [Procfile 脚本](./Procfile) 中的注释将 learner 节点添加到集群中。 ### 安装 etcd client v3 ``` go get go.etcd.io/etcd/client/v3 ``` ### 下一步 现在是时候深入了解完整的 etcd API 和其他指南了。 * 阅读完整[文档][documentation]。 * 查看 etcd [常见问题][frequently asked questions]。 * 探索完整的 gRPC [API]。 * 设置[多机器集群][clustering]。 * 学习[配置格式、环境变量和参数][configuration]。 * 查找[语言绑定和工具][integrations]。 * 使用 TLS [保护 etcd 集群][security]。 * [调优 etcd][tuning]。 ## 报告 Bug 有关报告任何问题的详细信息,请参阅 [报告 Bug](https://github.com/etcd-io/etcd/blob/main/Documentation/contributor-guide/reporting_bugs.md)。在开启 issue 之前,请检查是否已包含在我们的 [常见问题][frequently asked questions] 中。 ## 报告安全漏洞 有关如何报告安全漏洞以及 etcd 团队如何处理这些漏洞的详细信息,请参阅 [安全披露和发布流程](security/README.md)。 ## Issue 和 PR 管理 有关如何管理 issue 的详细信息,请参阅 [Issue 分类指南](https://github.com/etcd-io/etcd/blob/main/Documentation/contributor-guide/triage_issues.md)。 有关如何管理 Pull Request 的指南,请参阅 [PR 管理](https://github.com/etcd-io/etcd/blob/main/Documentation/contributor-guide/triage_prs.md)。 ## etcd 荣誉维护者 etcd [荣誉维护者](OWNERS) 将其职业生涯的一部分奉献给了 etcd,他们在相当长的一段时间内审查代码、分类 Bug 并推动项目发展。我们非常感谢他们的贡献。 ### 许可证 etcd 采用 Apache 2.0 许可证。有关详细信息,请参阅 [LICENSE](LICENSE) 文件。
标签:CISA项目, etcd, EVTX分析, Go语言, gRPC接口, Kubernetes核心组件, KV数据库, Python工具, Raft协议, 一致性协调, 分布式系统, 分布式锁, 分布式键值存储, 响应大小分析, 底层编程, 开源数据库, 强一致性, 微服务基础设施, 日志审计, 服务发现, 程序破解, 配置中心