EC2 - 创建 AMI - 无法连接到新实例

发布于 2024-10-20 08:58:22 字数 1975 浏览 0 评论 0原文

我在尝试从 EBS 卷启动 AMI 时遇到困难。我基本上是在尝试启动另一个基于 Linux (i386) 的 AMI 实例,我已经按照我想要的方式配置了该实例。过去一周我遵循了许多指南。到目前为止,我能够创建自定义私有 AMI,但在启动新实例后无法连接到它。我怀疑我创建的 AMI 在某种程度上配置错误(也许文件没有完全复制)。

无论如何,以下是我尝试创建 AMI 时要经历的基本步骤:

ec2-create-volume -K pk-xxxxxx.pem -C cert-xxxxxx.pem --大小 10 --可用区 us-east-1a

ec2-attach-volume -K pk-xxxxxx.pem -C cert-xxxxxx.pem vol-xxxxxx --instance xxxxxx --设备 /dev/sdh

是的 | mkfs -t ext3 /dev/sdh mkdir/mnt/ebsimage

echo '/dev/sdh /mnt/ebsimage ext3 默认值,noatime 0 0'>> /etc/fstab

挂载/mnt/ebsimage

卸载/mnt/ebsimage

ec2-detach-volume -K pk-xxxxxx.pem -C cert-xxxxxx.pem vol-xxxxxx --instance xxxxxx

ec2-create-snapshot -K pk-xxxxxx.pem -C cert-xxxxxx.pem 卷-xxxxxx

ec2reg -K pk-xxxxxx.pem -C cert-xxxxxx.pem -s snap-xxxxx -a i386 -d -n --kernel aki-xxxxx --ramdisk ari-xxxxxx

我很确定要么我的 mount 周围的命令搞砸了,要么我的 ec2reg 周围的命令搞砸了。有什么建议吗?


我也尝试过更换

是的 | mkfs -t ext3 /dev/sdh

mkdir/mnt/ebsimage

回显'/dev/sdh /mnt/ebsimage ext3 默认值,noatime 0 0'>> /etc/fstab

挂载/mnt/ebsimage

带有一个旨在使用 rsync 的脚本并添加一些其他详细信息,但同样无法连接到启动的 ami 的新实例。这是脚本的副本。

#!/bin/sh
vol=/dev/sdh
ebsmnt=/mnt/ebsimage
mkdir ${ebsmnt}
mkfs.ext3 -F ${vol}
sync
echo "mount $vol $ebsmnt"
mount $vol $ebsmnt
mkdir ${ebsmnt}/mnt
mkdir ${ebsmnt}/proc
mkdir ${ebsmnt}/sys
devdir=${ebsmnt}/dev
echo "mkdir ${devdir}"
mkdir ${devdir}
mknod ${devdir}/null    c 1 3
mknod ${devdir}/zero    c 1 5
mknod ${devdir}/tty     c 5 0
mknod ${devdir}/console c 5 1
ln -s null ${devdir}/X0R
rsync -rlpgoD -t -r -S -l -vh \
--exclude /sys --exclude /proc \
--exclude /dev \
--exclude /media --exclude /mnt \
--exclude /sys --exclude /ebs --exclude /mnt \
-x /* ${ebsmnt}
df -h

因为我的结果与第一个示例相同,所以我不确定我是更接近解决这个问题还是更远。任何帮助将不胜感激。

I am experiencing difficulty trying to launch a AMI from an EBS volume. I am basically trying to launch another instance of a Linux (i386) based AMI that I have already configured the way I want. I have followed many guides for the past week. So far, I am able to create the custom private AMI but I am unable to connect to it after launching the new instance. I suspect that the AMI I have created is miss-configured in some way (maybe files didnt get fully copied over).

Anyhow here are the basic steps I'm going through to try to create the AMI:

ec2-create-volume -K pk-xxxxxx.pem -C
cert-xxxxxx.pem --size 10
--availability-zone us-east-1a

ec2-attach-volume -K pk-xxxxxx.pem -C
cert-xxxxxx.pem vol-xxxxxx --instance
xxxxxx --device /dev/sdh

yes | mkfs -t ext3 /dev/sdh
mkdir/mnt/ebsimage

echo '/dev/sdh /mnt/ebsimage ext3
defaults,noatime 0 0' >> /etc/fstab

mount /mnt/ebsimage

umount /mnt/ebsimage

ec2-detach-volume -K pk-xxxxxx.pem -C
cert-xxxxxx.pem vol-xxxxxx --instance
xxxxxx

ec2-create-snapshot -K pk-xxxxxx.pem
-C cert-xxxxxx.pem vol-xxxxxx

ec2reg -K pk-xxxxxx.pem -C
cert-xxxxxx.pem -s snap-xxxxx -a i386
-d -n --kernel aki-xxxxx --ramdisk ari-xxxxxx

I'm pretty sure either my commands around mount are messed up or my commands around ec2reg are messed up. Any suggestions?


I have also tried replacing

yes | mkfs -t ext3 /dev/sdh

mkdir/mnt/ebsimage

echo '/dev/sdh
/mnt/ebsimage ext3 defaults,noatime 0
0' >> /etc/fstab

mount /mnt/ebsimage

with a script designed to use rsync and add some other details but again the new instance of the ami launched cannot be connected to. Here is a copy of the script.

#!/bin/sh
vol=/dev/sdh
ebsmnt=/mnt/ebsimage
mkdir ${ebsmnt}
mkfs.ext3 -F ${vol}
sync
echo "mount $vol $ebsmnt"
mount $vol $ebsmnt
mkdir ${ebsmnt}/mnt
mkdir ${ebsmnt}/proc
mkdir ${ebsmnt}/sys
devdir=${ebsmnt}/dev
echo "mkdir ${devdir}"
mkdir ${devdir}
mknod ${devdir}/null    c 1 3
mknod ${devdir}/zero    c 1 5
mknod ${devdir}/tty     c 5 0
mknod ${devdir}/console c 5 1
ln -s null ${devdir}/X0R
rsync -rlpgoD -t -r -S -l -vh \
--exclude /sys --exclude /proc \
--exclude /dev \
--exclude /media --exclude /mnt \
--exclude /sys --exclude /ebs --exclude /mnt \
-x /* ${ebsmnt}
df -h

Because I have the same results as the first example, I'm not sure if I'm closer to solving this issue or further away. Any help would be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

挽心 2024-10-27 08:58:22

要从基于 S3 的 AMI 创建 EBS AMI,您可以使用我的博客文章:
http://www.capsunlock.net/2009/12/create -ebs-boot-ami.html

To create your EBS AMI from an S3 based AMI, you can use my blog post:
http://www.capsunlock.net/2009/12/create-ebs-boot-ami.html

飘过的浮云 2024-10-27 08:58:22

我不知道您要尝试运行哪个发行版,但如果您想运行 debian,有一个脚本可以管理整个引导过程,包括 ami 创建(EBS 引导)。

你可以在我的 github 帐户上找到它:
https://github.com/andsens/ec2debian-build-ami

该脚本已经过彻底测试,并允许您包含其他脚本来自定义您的 ami。如果你想修改脚本本身,只需分叉它,至少你有一个可以工作的基础,在那里你知道一切都有效。

不过,我不会推荐您概述的过程,它看起来相当“混乱”。

I don't know which distribution you are trying to run, but if you want to run debian, there is a script which manages the entire bootstrapping process including ami creation (EBS boot).

You can find it on my github account:
https://github.com/andsens/ec2debian-build-ami

The script has been thoroughly tested and allows you to include other scripts in order to customize your ami. If you want to modify the script itself, just fork it, at least you then have a base to work from, where you know everything works.

I would not recommend the process you outlined though, it seems quite 'messy'.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文