ETCD数据迁移

ETCD数据迁移

背景:由于k8s集群数据迁移,集群的网关数据库Etcd也随之迁移,因此涉及到Etcd数据的导出导入

1、源库导出:

bash 复制代码
etcdctl snapshot save snapshot-2026.db --endpoints=10.100.100.15:12379
# 数据库端口修改为自己的

2、当目标库为单机时:

bash 复制代码
直接在目标库机器上执行:
etcdctl snapshot restore snapshot-2026.db --data-dir=/var/lib/etcd-new

然后使用这个新目录etcd-new作为Etcd的数据目录重启Etcd服务

3、当目标库为集群但是只有一节点时:

bash 复制代码
etcdctl snapshot restore snapshot-2026.db \
  --name etcd-1 \
  --initial-cluster-token etcd-cluster \
  --initial-advertise-peer-urls http://10.10.10.1:12380 \
  --data-dir /var/lib/etcd-new
参数解释:
--initial-cluster-token 为整个 etcd 集群设置一个唯一标识令牌
--initial-advertise-peer-urls 告诉其他 etcd 节点如何访问本节点

4、当目标库为集群多节点时:

在节点1 (名为 node1) 上执行

bash 复制代码
etcdctl snapshot restore ssnapshot-2026.db \
  --name node1 \
  --initial-cluster-token etcd-cluster \
  --initial-advertise-peer-urls http://192.168.1.101:12380 \
  --initial-cluster "node1=http://192.168.1.101:12380,node2=http://192.168.1.102:12380 \
  --data-dir=/var/lib/etcd-new

在节点2 (名为 node2) 上执行

bash 复制代码
etcdctl snapshot restore snapshot-2026.db \
  --name node2 \
  --initial-cluster-token etcd-cluster \
  --initial-advertise-peer-urls http://192.168.1.102:2380 \
  --initial-cluster "node1=http://192.168.1.101:12380,node2=http://192.168.1.102:12380 \
  --data-dir=/var/lib/etcd-new

然后分别使用新的数据目录重启Etcd数据库

相关推荐
Nturmoils2 小时前
订单列表慢查询,先看 WHERE、ORDER BY 和 LIMIT
数据库
渣波6 小时前
拒绝 SQL 焦虑!手把手带你用 NestJS + Prisma + DTO 写出“防弹”级后端代码
javascript·数据库·后端
倔强的石头_1 天前
KingbaseES 新版MySQL 兼容版体验:旧版迁移 + 功能实测
数据库
倔强的石头_4 天前
《Kingbase护城河》——数据库存储空间全景探测与精细化瘦身实战
数据库
冬奇Lab5 天前
每日一个开源项目(第134篇):Zvec - 阿里开源的嵌入式向量数据库,向量搜索界的 SQLite
数据库·人工智能·llm
ClouGence5 天前
Oracle CDC 架构优化:从主库直连到 DataGuard 备库同步
数据库·后端·oracle
无响应de神5 天前
三、用户与权限管理
数据库·mysql
麦聪聊数据6 天前
数据服务化时代:企业数据能力输出的核心路径
数据库
shushangyun_6 天前
2026年快消品B2B系统推荐:支持终端门店订货、促销政策自动化的工具?
java·运维·网络·数据库·人工智能·spring·自动化
DARLING Zero two♡6 天前
【MySQL数据库】数据类型与表约束
数据库·mysql