将 Droplet 从 DO 迁移到 AWS,使用 AWS Migration Application Service (MGN)
发布: (2025年12月29日 GMT+8 16:51)
5 min read
原文: Dev.to
Source: Dev.to
抱歉,您只提供了来源链接,未提供需要翻译的正文内容。请粘贴您想要翻译的文本,我将按照要求保留链接、格式和技术术语进行简体中文翻译。
准备
- AWS 账户 – 已激活并有权限创建 EC2、VPC 和 MGN 资源。
- DigitalOcean 账户 – 对要迁移的 Droplet 拥有 root SSH 访问权限。
- AWS IAM 用户 – 拥有
AWSApplicationMigrationAgentInstallationPolicy权限的 IAM 用户。使用此用户获取 Access Key ID(访问密钥 ID)和 Secret Access Key(秘密访问密钥)。
Step 1: Initialize the VPC
- 打开 AWS 控制台并导航至 VPC → Create VPC。
- 使用所需的 CIDR 块、名称和其他设置配置 VPC。
- 创建完成后,确认 VPC 已出现在 VPC 仪表板中。
步骤 2:初始化 AWS MGN
如果这是您首次在所选区域使用 MGN:
- 登录 AWS 控制台。
- 搜索 AWS Application Migration Service 并选择它。
- 点击 Get started 以初始化服务。
复制设置
-
在 Replication settings 页面,点击 Edit。
-
配置复制实例的模板:
- Staging area subnet – 选择将在 VPC 中接收临时数据的子网。
- Replication Server instance type – 选择与您的 DigitalOcean Droplet 相当的实例类型。
- 其余选项保持默认。
-
点击 Save template。
启动模板
- 前往 Launch template → Edit。
- 取消勾选 Activate instance type right‑sizing 以自定义配置。
- 选择所需的安全组(SG)和实例类型,然后保存。
第3步:在 DigitalOcean Droplet 上安装复制代理
注意: 在继续之前请备份您的 Droplet。
- 以
root身份 SSH 登录 Droplet,如有需要,修改 root 密码。 - 在 AWS MGN 控制台中,打开 Source servers 并点击 Add server。
- 选择操作系统(例如 Linux),并复制 AWS 显示的两个命令。
# Download the installer
sudo wget -O ./aws-replication-installer-init https://aws-application-migration-service-ap-southeast-1.s3.ap-southeast-1.amazonaws.com/latest/linux/aws-replication-installer-init
# Make it executable and run it (replace the region if needed)
sudo chmod +x aws-replication-installer-init
sudo ./aws-replication-installer-init --region ap-southeast-1
- 系统提示时,输入之前创建的 Access Key ID 和 Secret Access Key,并选择要同步的磁盘。
- 安装大约需要 5‑10 分钟;复制代理随后会开始将数据复制到 AWS。
第 4 步:配置启动设置(目标服务器)
-
安装代理后,Droplet 会出现在 Source servers 中,并显示 Initial Sync 正在进行。
-
点击服务器名称,然后选择 Launch settings 选项卡。
-
在 EC2 Launch Template 部分,点击 Edit 并调整以下内容:
- Instance Type – 例如
t3.medium、c5.large等。 - Subnet – 选择 EC2 实例将运行的子网。
- Instance Type – 例如
-
保存启动模板。
第 5 步:启动测试实例
5.1 启动测试实例
- 等待复制状态显示 “Ready for testing” 且 Data replication 为 “Healthy”。
- 选择服务器 → Test and cutover → Launch test instances。
- 生命周期状态会变为 “Test in progress.”
5.2 验证测试实例
- 测试实例启动后,MGN 会显示通知。
- 在 EC2 控制台中,你会看到一个主机名类似于源服务器的实例。
- 要查看启动日志,请前往 MGN → Launch history。
5.3 启动切换
- 在 MGN 中,选择服务器 → Test and cutover → Mark as Ready for cutover(此操作会删除测试实例)。
- 当生命周期显示 “Ready for cutover,” 时,点击 Launch cutover instances。
5.4 验证切换过程
- 新的 EC2 实例是根据之前复制的快照创建的,并遵循启动模板中定义的配置。
- 确认应用程序和数据在 EC2 实例上正常运行。
5.5 完成切换
- 验证完成后,你可以退役原来的 DigitalOcean Droplet。
后续文章将涵盖迁移过程中的故障排除和经验教训。感谢阅读。