Redian新闻
>
在云端自动化设置和交付虚拟机 | Linux 中国

在云端自动化设置和交付虚拟机 | Linux 中国

科技
 
导读:通过使用 Testcloud 自动化设置过程并交付一个准备运行的虚拟机,在几分钟之内准备好一个云镜像。
本文字数:4682,阅读时长大约:5分钟

LCTT 译者 :北梦南歌
🌟🌟🌟
翻译: 17.0 篇
|
贡献: 1663 天
2017-10-08
2022-04-28
https://linux.cn/lctt/hwlife

如果你是一个在云端使用 Fedora qcow2 镜像🔗 en.wikipedia.org 的开发者或者爱好者,在一个镜像准备使用之前,你总是不得不做一大堆初始化设置。我对此深有体会,所以我很想找到一种使设置过程更加简单的方法。碰巧,整个 Fedora 质量保证团队也有同感,所以我们开发了 Testcloud🔗 pagure.io 。

Testcloud 是一个可以轻松的在几分钟之内准备云镜像测试的工具。它用几个命令就可以在云端自动化设置并交付准备运行的虚拟机(VM)。

Testcloud:

1. 下载 qcow2 镜像
2. 用你选择的名称创建实例
3. 创建一个密码为 passw0rd,用户名为 fedora 的用户
4. 分配一个 IP 地址,以便于你之后用 SSH 登录到云端
5. 启动、停止、删除和列出一个实例

安装 Testcloud

要开始你的旅程,首先你必须安装 Testcloud 软件包。你可以通过终端或者“软件”应用来安装它。在这两种情况下,软件包的名字都是 testcloud 。用以下命令安装:

  1. $ sudo dnf install testcloud -y

一旦安装完成,将你所需要的用户添加到 testcloud 用户组,这有助于 Testcloud 自动完成设置过程的剩余部分。执行这两个命令,添加你的用户到 testcloud 用户组,并通过提升组权限重启会话:

  1. $ sudo usermod -a -G testcloud $USER
  2. $ su - $USER

添加用户到 testcloud 组

像老手一样玩转云镜像

一旦你的用户获得了所需的组权限,创建一个实例:

  1. $ testcloud instance create <instance name> -u <url for qcow2 image>

或者,你可以使用 fedora:latest/fedora:XXXX 是你的 Fedora 发行版本)来代替 完整的 URL 地址:

  1. $ testcloud instance create <instance name> -u fedora:latest

这将返回你的虚拟机的 IP 地址:

  1. $ testcloud instance create testcloud272593 -u https://download.fedoraproject.org/pub/fedora/linux/releases/33/Cloud/x86_64/images/Fedora-Cloud-Base-33-1.2.x86_64.qcow2
  2. [...]
  3. INFO:Successfully booted instance testcloud272593
  4. The IP of vm testcloud272593: 192.168.122.202
  5. ------------------------------------------------------------
  6. To connect to the VM, use the following command (password is 'passw0rd'):
  7. ssh fedora@192.168.122.202

你可以用默认用户 fedora 登录,密码是 passw0rd(注意是零)。你可以使用 sshvirt-manager 或者支持连接到 libvirt 虚拟机方式来连接到它。

另一种创建 Fedora 云的方式是:

  1. $ testcloud instance create testcloud193 -u fedora:33
  2. WARNING:Not proceeding with backingstore cleanup because there are some testcloud instances running.
  3. You can fix this by following command(s):
  4. testcloud instance stop testcloud272593
  5. DEBUG:Local downloads will be stored in /var/lib/testcloud/backingstores.
  6. DEBUG:successfully changed SELinux context for image /var/lib/testcloud/backingstores/Fedora-Cloud-Base-33-1.2.x86_64.qcow2
  7. DEBUG:Creating instance directories
  8. DEBUG:creating seed image /var/lib/testcloud/instances/testcloud193/testcloud193-seed.img
  9. INFO:Seed image generated successfully
  10. INFO:Successfully booted instance testcloud193
  11. The IP of vm testcloud193: 192.168.122.225
  12. ------------------------------------------------------------
  13. To connect to the VM, use the following command (password is 'passw0rd'):
  14. ssh fedora@192.168.122.225
  15. ------------------------------------------------------------

玩转实例

Testcloud 可以用来管理实例。这包括像列出镜像或者停止和启动一个实例等活动。

要列出实例,使用 list 子命令:

  1. $ testcloud instance list                
  2. Name                            IP                      State    
  3. ------------------------------------------------------------
  4. testcloud272593                 192.168.122.202         running    
  5. testcloud193                    192.168.122.225         running    
  6. testcloud252793                 192.168.122.146         shutoff    
  7. testcloud93                     192.168.122.152         shutoff

要停止一个运行的实例:

  1. $ testcloud instance stop testcloud193  
  2. DEBUG:stop instance: testcloud193
  3. DEBUG:stopping instance testcloud193.

要删除一个实例:

  1. $ testcloud instance destroy testcloud193  
  2. DEBUG:remove instance: testcloud193
  3. DEBUG:removing instance testcloud193 from libvirt.
  4. DEBUG:Unregistering instance from libvirt.
  5. DEBUG:removing instance /var/lib/testcloud/instances/testcloud193 from disk

要重启一个运行中的实例:

  1. $ testcloud instance reboot testcloud93                                                                                        
  2. DEBUG:stop instance: testcloud93
  3. [...]
  4. INFO:Successfully booted instance testcloud93
  5. The IP of vm testcloud93:  192.168.122.152
  6. usage: testcloud [-h] {instance,image} ...

尝试一下 Testcloud ,在评论中让我知道你的想法。


via: https://opensource.com/article/21/1/testcloud-virtual-machines

作者:Sumantro Mukherjee 选题:lujun9972 译者:hwlife 校对:wxy

本文由 LCTT 原创编译,Linux中国 荣誉推出


欢迎遵照 CC-BY-SA 协议规定转载,
如需转载,请在文章下留言 “转载:公众号名称”,
我们将为您添加白名单,授权“转载文章时可以修改”。


微信扫码关注该文公众号作者

戳这里提交新闻线索和高质量文章给我们。
相关阅读
无声世界里的爱,简评《健听女孩》在 Linux 上使用 sudo 命令的 5 个理由 | Linux 中国与糖共舞-15使用 apt 进行 Linux 包管理 | Linux 中国使用 watch 和 tail 命令监视 Linux 上的活动 | Linux 中国突发!博通洽购虚拟机巨头,交易价或超403亿美元这家差点吃掉高通的公司,今天花610亿美元买了家搞虚拟机的???你的 Linux 启动时有几只小企鹅? | Linux 中国安装 Fedora 36 后一些适合中国用户的简单设置 | Linux 中国英伟达在提升 Linux 上的 GPU 使用体验上迈出了一大步 | Linux 中国用 Gwenview 在 Linux 上裁剪和调整照片大小 | Linux 中国如何在 Linux 和 Windows 电脑之间共享文件 | Linux 中国在虚拟机中运行 Linux 的十大优点 | Linux 中国我如何在 Linux 上扫描家庭照片 | Linux 中国如何在 Ubuntu 22.04 / 20.04 LTS 中重新设置 sudo 密码 | Linux 中国分享 8 篇使用 Linux 命令行的技巧 | Linux 中国使用 dnf 进行 Linux 包管理 | Linux 中国如何在 Linux 桌面中启用 “激活 Linux” 水印通知 | Linux 中国Fedora Linux 36 发布 | Linux 中国开源朗读者:在虚拟机中运行 Linux 的十大优点 | Linux 中国Archinstall 新的菜单系统让安装 Arch Linux 更容易了 | Linux 中国在 Ubuntu Linux 如何安装 H.264 解码器 | Linux 中国Linux 中国开通播客频道:“开源朗读者”和“硬核观察” | Linux 中国今天唱坛歌多,都插不上嘴,送花给无糖版主!《桃花谣》花儿传情!HydraPaper:一个支持多显示器的 Linux 壁纸管理器 | Linux 中国实测 Linux Mint 升级工具 | Linux 中国Fudgie?令人惊叹的 Budgie 桌面即将登陆 Fedora Linux | Linux 中国微软还有另一个 Linux 发行版,而且是基于 Debian 的 | Linux 中国下一个风口在哪里?跟着英雄走如何在 Fedora Linux 中安装多媒体编码器 | Linux 中国好消息!Docker Desktop 现已支持 Linux | Linux 中国在美国29. 在大学的生活上一个说“丼”不读jǐng的人,已经被我骂哭了使用自动化时的五个常见错误 | Linux 中国最适合程序员的 10 款 Linux 发行版 | Linux 中国
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。