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数据库

相关推荐
2301_775148152 小时前
c++怎么抛出文件读写异常_exceptions()方法开启流异常【详解】
jvm·数据库·python
2401_883600252 小时前
如何用 super 绑定机制在子类构造函数中调用父类
jvm·数据库·python
yuanpan2 小时前
Python 连接 SQLite 数据库:从建表到增删改查的完整演示项目
数据库·python·sqlite
2401_871696522 小时前
HTML怎么构建开发者仪表盘_HTML关键指标卡片汇总【教程】
jvm·数据库·python
2301_796588502 小时前
c++ aot编程 c++如何使用oneapi进行跨平台并行编程
jvm·数据库·python
qq_413847402 小时前
JavaScript中剩余参数在函数签名中的定义位置与限制
jvm·数据库·python
DavidSoCool2 小时前
Dify使用ChatFlow实现调用数据库问答
数据库·ai·知识库·dify
qq_330037992 小时前
mysql如何配置多实例运行环境_单机部署多个数据库服务
jvm·数据库·python
weixin_580614002 小时前
如何防止SQL注入泄露元数据_限制数据库信息查询权限
jvm·数据库·python