我在 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:
- 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
- Copy the file to an instance in cn-north-1 region.
scp -i key.pem root.img ec2-user@<ip_address>:/tmp
- 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
- 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
Create a snapshot of the volume, refer here.
Create an AMI from the snapshot, refer here.
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/