amazon-web-services - 如何在 AWS 中将 AMI 从爱尔兰区域复制到中国区域

标签 amazon-web-services amazon-ec2 amazon-ami

我在 AWS 爱尔兰地区进行了设置,现在我想要在我的中国使用该 AMI。
有谁知道完成任务的最佳实践是什么?
任何帮助将不胜感激。

提前致谢。

最佳答案

中国地区目前不支持 AMI 复制。

根据 AWS:Transfer or copy AMI from US to China (Beijing)

The idea is to create a dump file of the volume using 'dd', copy the file to a temporary instance in China Region. Once copied, use dd again to dump the contents of the file to an EBS volume. Then create a snapshot of the EBS volume which contains the data and create an AMI out of it.

You may refer an over view of the process below:

  1. Launch a linux instance in the AWS Region then use "dd” command to save the instance’s whole root volume as a file to a secondary EBS volume.

mkfs.ext4 /dev/xvdf

mount /dev/xvdf /mnt

dd if=/dev/xvda of=root.img bs=1M

  1. Copy the file to an instance in cn-north-1 region.

scp -i key.pem root.img ec2-user@<ip_address>:/tmp

  1. In that cn-north-1 region’s instance, use ‘dd’ command to write that file to an EBS volume

dd if=/tmp/root.img of=/dev/xvdf bs=1M oflag=direct

  1. Delete the keypair on the volume, where{cloud username} is 'ubuntu' for ubuntu, 'ec2-user' for Amazon Linux, 'admin' for Debian, 'core' for CoreOS/Container Linux

mkdir -p /tmp/volume

partprobe

mount /dev/xvdf1 /tmp/volume

rm /tmp/volume/root/.ssh/authorized_keys

rm /tmp/volume/home/{cloud username}/.ssh/authorized_keys

umount /tmp/volume

  1. Create a snapshot of the volume, refer here.

  2. Create an AMI from the snapshot, refer here.

  3. Finally, use that AMI to launch an instance, which is the same as the instance running in the original AWS region.

NB=Please note that in some cases, you might need to update /etc/fstab, grub configuration files etc. with the label of the new volume.

关于amazon-web-services - 如何在 AWS 中将 AMI 从爱尔兰区域复制到中国区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36461042/

相关文章:

mysql - 创建新过程时,rds 上的 mariadb 会创建新用户@ ip.ec2.host

amazon-web-services - AWS EC2 用户数据加密

amazon-web-services - AWS AMI 中需要烘焙哪些内容以及使用 cloud-init 来配置哪些内容?

linux - 在aws ec2上如何找到可以访问的ip来查看play framework主页?

mysql - 通过 EC2 Jenkins 的 RDS MySql 上的连接过多错误

ubuntu - 我应该为 Ubuntu 10.04 或 11.04 使用哪个 AWS AMI,并运行 node.js?

json - 从自定义 AMI 创建 ec2 实例时提供不同的卷标签

amazon-web-services - 使用 AWS SDK for Java 2.x 检查 S3 对象的元数据

amazon-web-services - AWS CDK - 如何将事件通知添加到现有 S3 存储桶

python - 安排 python 脚本在 AWS 中运行