diff --git a/sources/tech/20210119 Set up a Linux cloud on bare metal.md b/sources/tech/20210119 Set up a Linux cloud on bare metal.md deleted file mode 100644 index 167f215010..0000000000 --- a/sources/tech/20210119 Set up a Linux cloud on bare metal.md +++ /dev/null @@ -1,128 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (wxy) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Set up a Linux cloud on bare metal) -[#]: via: (https://opensource.com/article/21/1/cloud-image-virt-install) -[#]: author: (Sumantro Mukherjee https://opensource.com/users/sumantro) - -Set up a Linux cloud on bare metal -====== -Create cloud images with virt-install on Fedora. -![Sky with clouds and grass][1] - -Virtualization is one of the most used technologies. Fedora Linux uses [Cloud Base images][2] to create general-purpose virtual machines (VM), but there are many ways to set up Cloud Base images. Recently, the virt-install command-line tool for provisioning VMs added support for **cloud-init**, so it can now be used to configure and run a cloud image locally. - -This article walks through how to set up a base Fedora cloud instance on bare metal. The same steps can be used with any raw or Qcow2 Cloud Base image. - -### What is --cloud-init? - -The **virt-install** command creates a KVM, Xen, or [LXC][3] guest using **libvirt**. The `--cloud-init` option uses a local file (called a **nocloud datasource**) so you don't need a network connection to create an image. The **nocloud** method derives user data and metadata for the guest from an iso9660 filesystem (an `.iso` file) during the first boot. When you use this option, **virt-install** generates a random (and temporary) password for the root user account, provides a serial console so you can log in and change your password, and then disables the `--cloud-init` option for subsequent boots.  - -### Set up a Fedora Cloud Base image - -First, [download a Fedora Cloud Base (for OpenStack) image][2]. - -![Fedora Cloud website screenshot][4] - -(Sumantro Mukherjee, [CC BY-SA 4.0][5]) - -Then install the **virt-install** command: - - -``` -`$ sudo dnf install virt-install` -``` - -Once **virt-install** is installed and the Fedora Cloud Base image is downloaded, create a small YAML file named `cloudinit-user-data.yaml` to contain a few configuration lines that virt-install will use. - - -``` -#cloud-config -password: 'r00t' -chpasswd: { expire: false } -``` - -This simple cloud-config sets the password for the default **fedora** user. If you want to use a password that expires, you can set it to expire after logging in. - -Create and boot the VM: - - -``` -$ virt-install --name local-cloud18012709 \ -\--memory 2000 --noreboot \ -\--os-variant detect=on,name=fedora-unknown \ -\--cloud-init user-data="/home/r3zr/cloudinit-user-data.yaml" \ -\--disk=size=10,backing_store="/home/r3zr/Downloads/Fedora-Cloud-Base-33-1.2.x86_64.qcow2" -``` - -In this example, `local-cloud18012709` is the name of the virtual machine, RAM is set to 2000MiB, disk size (the virtual hard drive) is set to 10GB, and `--cloud-init` and `backing_store` contain the absolute path to the YAML config file you created and the Qcow2 image you downloaded. - -### Log in - -After the image is created, you can log in with the username **fedora** and the password set in the YAML file (in my example, this is **r00t**, but you may have used something different). Change your password once you've logged in for the first time. - -To power off your virtual machine, execute the `sudo poweroff` command, or press **Ctrl**+**]** on your keyboard. - -### Start, stop, and kill VMs - -The `virsh` command is used to start, stop, and kill VMs. - -To start any VM that is running: - - -``` -`$ virsh start ` -``` - -To stop any running VM: - - -``` -`$ virsh shutdown ` -``` - -To list all VMs that are in a running state: - - -``` -`$ virsh list` -``` - -To destroy the VMs: - - -``` -`$ virsh destroy ` -``` - -![Destroying a VM][6] - -(Sumantro Mukherjee, [CC BY-SA 4.0][5]) - -### Fast and easy - -The **virt-install** command combined with the `--cloud-init` option makes it fast and easy to create cloud-ready images without worrying about whether you have a cloud to run them on yet.  Whether you're preparing for a a major deployment or just learning about containers, give `virt-install --cloud-init` a try. - -Do you have a favourite tool for your work in the cloud? Tell us about them in the comments. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/1/cloud-image-virt-install - -作者:[Sumantro Mukherjee][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/sumantro -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bus-cloud.png?itok=vz0PIDDS (Sky with clouds and grass) -[2]: https://alt.fedoraproject.org/cloud/ -[3]: https://www.redhat.com/sysadmin/exploring-containers-lxc -[4]: https://opensource.com/sites/default/files/uploads/fedoracloud.png (Fedora Cloud website) -[5]: https://creativecommons.org/licenses/by-sa/4.0/ -[6]: https://opensource.com/sites/default/files/uploads/destroyvm.png (Destroying a VM) diff --git a/translated/tech/20210119 Set up a Linux cloud on bare metal.md b/translated/tech/20210119 Set up a Linux cloud on bare metal.md new file mode 100644 index 0000000000..7219aa36d9 --- /dev/null +++ b/translated/tech/20210119 Set up a Linux cloud on bare metal.md @@ -0,0 +1,119 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Set up a Linux cloud on bare metal) +[#]: via: (https://opensource.com/article/21/1/cloud-image-virt-install) +[#]: author: (Sumantro Mukherjee https://opensource.com/users/sumantro) + +在裸机上建立 Linux 云 +====== + +> 在 Fedora 上用 virt-install 创建云镜像。 + +![云和草的天空][1] + +虚拟化是使用最多的技术之一。Fedora Linux 使用 [Cloud Base 镜像][2] 来创建通用虚拟机(VM),但设置 Cloud Base 镜像的方法有很多。最近,用于调配虚拟机的 `virt-install` 命令行工具增加了对 `cloud-init` 的支持,因此现在可以使用它在本地配置和运行云镜像。 + +本文介绍了如何在裸机上设置一个基本的 Fedora 云实例。同样的步骤可以用于任何 raw 或Qcow2 Cloud Base 镜像。 + +### 什么是 --cloud-init? + +`virt-install` 命令使用 `libvirt` 创建一个 KVM、Xen 或 [LXC][3] 客户机。`--cloud-init` 选项使用一个本地文件(称为 “nocloud 数据源”),所以你不需要网络连接来创建镜像。在第一次启动时,`nocloud` 方法会从 iso9660 文件系统(`.iso` 文件)中获取访客机的用户数据和元数据。当你使用这个选项时,`virt-install` 会为 root 用户账户生成一个随机的(临时)密码,提供一个串行控制台,以便你可以登录并更改密码,然后在随后的启动中禁用 `--cloud-init` 选项。  + +### 设置 Fedora Cloud Base 镜像 + +首先,[下载一个 Fedora Cloud Base(for OpenStack)镜像][2]。 + +![Fedora Cloud 网站截图][4] + +然后安装 `virt-install` 命令: + +``` +$ sudo dnf install virt-install +``` + +一旦 `virt-install` 安装完毕并下载了 Fedora Cloud Base 镜像,请创建一个名为`cloudinit-user-data.yaml` 的小型 YAML 文件,其中包含 `virt-install` 将使用的一些配置行: + +``` +#cloud-config +password: 'r00t' +chpasswd: { expire: false } +``` + +这个简单的云配置可以设置默认的 `fedora` 用户的密码。如果你想使用会过期的密码,可以将其设置为登录后过期。 + +创建并启动虚拟机: + +``` +$ virt-install --name local-cloud18012709 \ +--memory 2000 --noreboot \ +--os-variant detect=on,name=fedora-unknown \ +--cloud-init user-data="/home/r3zr/cloudinit-user-data.yaml" \ +--disk=size=10,backing_store="/home/r3zr/Downloads/Fedora-Cloud-Base-33-1.2.x86_64.qcow2" +``` + +在这个例子中,`local-cloud18012709` 是虚拟机的名称,内存设置为 2000MiB,磁盘大小(虚拟硬盘)设置为 10GB,`--cloud-init` 和 `backing_store` 分别带有你创建的 YAML 配置文件和你下载的 Qcow2 镜像的绝对路径。 + +### 登录 + +在创建镜像后,你可以用用户名 `fedora` 和 YAML 文件中设置的密码登录(在我的例子中,密码是 `r00t`,但你可能用了别的密码)。一旦你第一次登录,请更改你的密码。 + +要关闭虚拟机的电源,执行 `sudo poweroff` 命令,或者按键盘上的 `Ctrl+]`。 + +### 启动、停止和销毁虚拟机 + +`virsh` 命令用于启动、停止和销毁虚拟机。 + +要启动任何停止的虚拟机: + +``` +$ virsh start +``` + +要停止任何运行的虚拟机: + +``` +$ virsh shutdown +``` + +要列出所有处于运行状态的虚拟机: + +``` +$ virsh list +``` + +要销毁虚拟机: + +``` +$ virsh destroy +``` + +![销毁虚拟机][6] + +### 快速而简单 + +`virt-install` 命令与 `--cloud-init` 选项相结合,可以快速轻松地创建云就绪镜像,而无需担心是否有云来运行它们。无论你是在为重大部署做准备,还是在学习容器,都可以试试`virt-install --cloud-init`。 + +在云计算工作中,你有喜欢的工具吗?请在评论中告诉我们。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/1/cloud-image-virt-install + +作者:[Sumantro Mukherjee][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/sumantro +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bus-cloud.png?itok=vz0PIDDS (Sky with clouds and grass) +[2]: https://alt.fedoraproject.org/cloud/ +[3]: https://www.redhat.com/sysadmin/exploring-containers-lxc +[4]: https://opensource.com/sites/default/files/uploads/fedoracloud.png (Fedora Cloud website) +[5]: https://creativecommons.org/licenses/by-sa/4.0/ +[6]: https://opensource.com/sites/default/files/uploads/destroyvm.png (Destroying a VM)