EC2 AMI 的 KVM 等效项

发布于 2025-01-01 03:58:43 字数 168 浏览 1 评论 0原文

我正在构建一个需要从脚本动态启动 KVM 来宾的软件。我希望 KVM 提供类似“AMI”的功能,以便我可以启动新的来宾,而无需完成整个操作系统安装过程。

我读过一些有关“迁移”功能的内容,但听起来不太正确。

我真的很希望能够构建一个来宾,对其进行映像,然后能够一遍又一遍地启动该映像的克隆。

I'm building a piece of software that needs to spin up KVM guests dynamically from a script. I'm hoping that KVM offers an 'AMI' like functionality so that I can spin up new guests without having to go through the entire OS install process.

I've read a little about the 'migrate' functionality but its doesn't sound quite right.

I would really like to be able to build up a guest, image it, and then be able to spin up clones of that image over and over.

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

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

发布评论

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

评论(1

演多会厌 2025-01-08 03:58:43

以防万一这个问题的答案对任何其他试图在 EC2 和 KVM 之间进行类比的人有所帮助。

使用 KVM,当您启动 guest 虚拟机时,您可以指定一个磁盘映像文件 (guestos.img)。要与另一个来宾重用相同的“图像”,您所要做的就是关闭原始来宾,复制其图像(可能为了清晰起见重命名),然后启动一个指向复制图像的新来宾。瞧!

这是一些咯咯笑的代码:

// Shutdown the image
virsh shutdown vm-name

// Copy the image
cp image-file-name.img copy-file-name.img

// Export the old XML definition file with:
virsh dumpxml vm-name > copy-vm-def.xml

// Edit the copy-vm-def.xml to point to copied image file and choose new vm name
// Then, create the new guest
virsh create copy-vm-def.xml

Just in case the answer to this can be helpful to anyone else who is trying to create analogies between EC2 and KVM here you go.

With KVM, when you start up a guest you specify a disk image file (guestos.img). To reuse that same "image" with another guest all you have to do is shutdown the original guest, copy it's image (and probably rename for clarity's sake) and then start a new guest that points to the copied image. Voila!

Here's some code for giggles:

// Shutdown the image
virsh shutdown vm-name

// Copy the image
cp image-file-name.img copy-file-name.img

// Export the old XML definition file with:
virsh dumpxml vm-name > copy-vm-def.xml

// Edit the copy-vm-def.xml to point to copied image file and choose new vm name
// Then, create the new guest
virsh create copy-vm-def.xml
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文