+86 135 410 16684Mon. - Fri. 10:00-22:00

如何将虚拟机导入到AWS教程

如何将虚拟机导入到AWS教程

如何将虚拟机导入到AWS教程

借助ec2-import-instance我们可以将我们的虚拟机导入到AWS中的EC2实例里。

~$ ec2-import-instance centos6.4-vm01.disk -f raw -p Linux -t m3.large \
 -a x86_64 -b <your_s3_bucket> --region ap-southeast-1 -O <access_key_id> \
 -W <secret_access_key> -o <access_key_id> -w <secret_access_key>

(参数为多个字母的都是双-,不知为啥我的总显示为多-,不管有几个-。例如–region参数。请注意,后同)
然后可以用ec2-describe-conversion-tasks命令查看导入过程。ec2-cancel-conversion-task命令取消导入任务。

~$ ec2-describe-conversion-tasks --region ap-southeast-1 import-i-ffm0xv71 -O xxxx -W

xxxxx(import-i-ffm0xv71这个是ec2-import-instance任务的任务ID,在命令输出结果中有)
如果都顺利的话,你能到指定的region得到一台EC2实例,默认是关机状态。
在这个过程中需要注意如下事项:
导入虚拟机的时候,虚拟机只支持一个DHCP的网卡,多网卡的删掉,光驱可以删掉(至少不能让他挂载这ISO的状态导入),如果有多个磁盘,此命令只能导入跟分区所在的虚拟磁盘(注意不是指根分区所在的分区)其他的磁盘用下面介绍的ec2-import-volume导入
导入的虚拟机配置类型是有限制的(Linux虚拟机是有限制的,Windows虚拟机时无限制)
We support importing Windows instances into any instance type. Linux instances can be imported into the following instance types:m3.xlarge、m3.2xlarge、hi1.4xlarge、hs1.8xlarge、cc1.4xlarge、 cg1.4xlarge、cc2.8xlarge、cr1.8xlarge
如果将导入的虚拟机右键注册成AMI(如果你使用的默认的AKI)将会导致你的AMI只能创建指定类型的EC2实例,需要选择合适的AKI,见上一篇文档的分享链接。

用ec2-import-volume将虚拟机磁盘导入AWS EBS

~$ ec2-import-volume centos6.4.disk -f raw -b <your-s3-bucket> \
 --region ap-southeast-1 -O xxxx -W xxxxxxxx -o xxxx -w xxxxxx

使用ec2-describe-conversion-tasks查看导入的进度,完成之后你会得到一个状态为Available的EBS Volume。