Skip to Content
Kubernetes 认证管理员 (CKA) 学习指南 (Chinese Edition), 2nd Edition
book

Kubernetes 认证管理员 (CKA) 学习指南 (Chinese Edition), 2nd Edition

by Benjamin Muschko
January 2026
Intermediate to advanced
392 pages
4h 44m
Chinese
O'Reilly Media, Inc.
Content preview from Kubernetes 认证管理员 (CKA) 学习指南 (Chinese Edition), 2nd Edition

第5章. etcd的备份 与恢复

本作品已使用人工智能进行翻译。欢迎您提供反馈和意见:translation-feedback@oreilly.com

Kubernetes 服务数据存储( )将集群的声明状态和观察状态存储在分布式 etcd 键值存储中。制定备份计划至关重要,这能在数据损坏时帮助您恢复数据。备份操作应以较短时间间隔定期执行,以最大限度避免历史数据丢失。

使用 etcd 管理工具

备份流程 将etcd数据 存储于快照文件中。该快照文件可用于在任意时间点恢复etcd数据。您可加密 快照文件以保护敏感信息。使用工具etcdctl创建备份 快照文件。从快照文件恢复etcd数据需使用工具 etcdutl

作为管理员,您需掌握这两项操作工具的使用方法。若控制平面节点尚未安装etcdctletcdutl,您可能需要自行安装。安装指南详见etcd GitHub 仓库。图 5-1展示了 etcd 备份与恢复流程。

Diagram illustrating the workflow for backing up and restoring etcd, showcasing steps before and after a disaster occurs.
图 5-1. etcd 备份与恢复流程

根据集群拓扑结构,集群可能包含一个或多个etcd实例。有关配置方法的详细信息,请参阅"管理高可用性集群"。以下章节将说明单节点etcd集群的配置 。多节点etcd集群的备份与恢复流程补充说明可查阅官方Kubernetes文档。

备份 etcd

使用ssh命令打开交互式 shell 连接到托管 etcd 的机器。以下命令针对运行 Ubuntu 24.04 LTS 的名为kube-control-plane的控制平面节点:

$ ssh kube-control-plane
Welcome to Ubuntu 24.04 LTS (GNU/Linux 6.8.0-51-generic x86_64)
...

检查已安装的etcdctl版本以确认工具是否安装。在此节点上,版本为3.5.15:

$ etcdctl version
etcdctl version: 3.5.15
API version: 3.5

Etcd以Pod形式部署在kube-system命名空间中。通过描述Pod查看版本信息。如下输出所示,当前版本为3.5.15-0:

$ kubectl get pods -n kube-system
NAME                                       READY   STATUS    RESTARTS   AGE
...
etcd-kube-control-plane                    1/1     Running   0          33m
...
$ kubectl describe pod etcd-kube-control-plane -n kube-system ... Containers: etcd: Container ID: containerd://47a6cf3ed27d455be6c9b782d2e35ee77b429ee5c0b \ 3c6c3d6282628f6492b15 Image: registry.k8s.io/etcd:3.5.15-0 Image ID: registry.k8s.io/etcd@sha256:a6dc63e6e8cfa0307d7851762fa6 \ b629afb18f28d8aa3fab5a6e91b4af60026a ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Kubernetes 上的生成式人工智能 (Chinese Edition)

Kubernetes 上的生成式人工智能 (Chinese Edition)

Roland Huß, Daniele Zonca
游戏化头脑风暴

游戏化头脑风暴

Dave Gray, Sunni Brown, James Macanufo

Publisher Resources

ISBN: 0642572314712