diff --git a/docs/en/docs/Virtualization/environment-preparation.md b/docs/en/docs/Virtualization/environment-preparation.md index b9c39a0897156e257aca2b00c1e628b2fb393ce5..dce6758303ec5205e1011e9af0681e55ce11a721 100644 --- a/docs/en/docs/Virtualization/environment-preparation.md +++ b/docs/en/docs/Virtualization/environment-preparation.md @@ -1,59 +1,68 @@ -# Environment Preparation +# Preparing the environment for use -- [Environment Preparation](#environment-preparation) - - [Preparing a VM Image](#preparing-a-vm-image) - - [Preparing the VM Network](#preparing-the-vm-network) - - [Preparing Boot Firmware](#preparing-boot-firmware) - -## Preparing a VM Image +## Prepare VM image ### Overview -A VM image is a file that contains a virtual disk that has been installed and can be used to start the OS. VM images are in different formats, such as raw and qcow2. Compared with the raw format, the qcow2 format occupies less space and supports features such as snapshot, copy-on-write, AES encryption, and zlib compression. However, the performance of the qcow2 format is slightly lower than that of the raw format. The qemu-img tool is used to create image files. This section uses the qcow2 image file as an example to describe how to create a VM image. +The virtual machine image is a file that contains the virtual disks that +have been installed and can start the operating system. Virtual machine +images have different formats. The common formats are raw format and qcow2 +format. Compared with raw format image, The qcow2 format image occupies +less space and supports snapshots Copy On Write, AES encryption Zlib +compression and other features, but its performance is slightly inferior +to the raw format image. The creation of the image file uses the qemu img +tool. This section takes the qcow2 format image file as an example to +introduce the creation process of the virtual machine image. -### Creating an Image +### Make a mirror image -To create a qcow2 image file, perform the following steps: +The operation steps for creating a qcow2 format image file are as follows: -1. Install the **qemu-img** software package. +1. Use the root user to install the qemu img software package. - ```shell - yum install -y qemu-img + ```sh + # yum install -y qemu-img ``` -2. Run the **create** command of the qemu-img tool to create an image file. The command format is as follows: +2. Use the create command of the qemu img tool to create an image file. +The command format is: - ```shell + ```sh qemu-img create -f -o ``` - The parameters are described as follows: + where the meaning of each parameter is as follows. + + - _imgFormat_:image format, the value is raw, Qcow2, etc. + - _fileOption_: File option, used to set the characteristics of the image file, such as specifying the back-end image file,compression,encryption and other characteristics. + - _fileName_:File name. + - _diskSize_:disk size, used to specify the size of a disk device.The supported units are K M、G、T, KiB MiB、GiB、TiB。 - - _imgFormat_: Image format. The value can be **raw** or **qcow2**. - - _fileOption_: File option, which is used to set features of an image file, such as specifying a backend image file, compression, and encryption. - - _fileName_: File name. - - _diskSize_: Disk size, which specifies the size of a block disk. The unit can be K, M, G, or T, indicating KiB, MiB, GiB, or TiB. + For example, create an image file openEuler-image. qcow2 with a disk device size of 4GB and a format of qcow2. The command and echo are as +follows: - For example, to create an image file openEuler-image.qcow2 whose disk size is 4 GB and format is qcow2, the command and output are as follows: - ```shell + ```sh $ qemu-img create -f qcow2 openEuler-image.qcow2 4G Formatting 'openEuler-image.qcow2', fmt=qcow2 size=4294967296 cluster_size=65536 lazy_refcounts=off refcount_bits=16 ``` -### Changing the Image Disk Space +### Modify the size of the mirrored disk space -If a VM requires larger disk space, you can use the qemu-img tool to change the disk space of the VM image. The method is as follows: +When the virtual machine needs more disk space, you can use the qemu img +tool to modify the size of the virtual machine image disk space. The +modification method is as follows. -1. Run the following command to query the disk space of the VM image: - ```shell - qemu-img info +1. Query the current virtual machine image disk space size, the command +is as follows. + ```sh + qemu-img info ``` - For example, if the command and output for querying the disk space of the openEuler-image.qcow2 image are as follows, the disk space of the image is 4 GiB. + For example, the command to query the space size of the openEuler-image. qcow2 image disk is echoed as follows, indicating that the space size of the image disk is 4GiB. - ```shell + ```sh $ qemu-img info openEuler-image.qcow2 image: openEuler-image.qcow2 file format: qcow2 @@ -67,28 +76,30 @@ If a VM requires larger disk space, you can use the qemu-img tool to change the corrupt: false ``` -2. Run the following command to change the image disk space. In the command, _imgFileName_ indicates the image name, and **+** and **-** indicate the image disk space to be increased and decreased, respectively. The unit is KB, MB, GB, and T, indicating KiB, MiB, GiB, and TiB, respectively. +2. Modify the size of the image disk space. The command is as follows, where _imgFiLeName_ is the image name, and "+" and "-" respectively indicate the size of the image disk space that needs to be increased or decreased. The units are K M、G、T, On behalf of KiB MiB、GiB、TiB。 + - ```shell - qemu-img resize [+|-] + ```sh + qemu-img resize [+|-] ``` - For example, to expand the disk space of the openEuler-image.qcow2 image to 24 GiB, that is, to add 20 GiB to the original 4 GiB, the command and output are as follows: + For example, expand the size of the above openEuler-image. qcow2 image disk space to 24GiB, that is, add 20GiB to the original 4GiB. The command and echo are as follows: - ```shell + ```sh $ qemu-img resize openEuler-image.qcow2 +20G Image resized. ``` -3. Run the following command to check whether the image disk space is changed successfully: +3. Query the size of the mirrored disk space after modification to confirm whether the modification is successful, the command is as follows. - ```shell - qemu-img info + ```sh + qemu-img info ``` - For example, if the openEuler-image.qcow2 image disk space has been expanded to 24 GiB, the command and output are as follows: + For example, the above openEuler-image. qcow2 image disk space has been expanded to 24GiB. The command and echo are as follows: - ```shell + + ```sh $ qemu-img info openEuler-image.qcow2 image: openEuler-image.qcow2 file format: qcow2 @@ -102,85 +113,94 @@ If a VM requires larger disk space, you can use the qemu-img tool to change the corrupt: false ``` -## Preparing the VM Network +## Prepare the VM network ### Overview +In order to enable the virtual machine to communicate with the external network, the network environment needs to be configured for the virtual machine.KVM virtualization supports Linux bridge、Open vSwitch bridge and other types of bridges.As shown in [Figure 1](#fig1785384714917).the +data transmission path is "virtual machine ->virtual network interface device ->Linux bridge or Open vSwitch bridge->physical network interface". To create a bridge, in addition to configuring virtual network card devices for virtual machines, creating a bridge for hosts is the key to connecting virtual machine networks. -To enable the VM to communicate with external networks, you need to configure the network environment for the VM. KVM virtualization supports multiple types of bridges, such as Linux bridge and Open vSwitch bridge. As shown in [Figure 1](#fig1785384714917), the data transmission path is **VM \> virtual NIC device \> Linux bridge or Open vSwitch bridge \> physical NIC**. In addition to configuring virtual NICs \(vNICs\) for VMs, creating a bridge for a host is the key to connecting to a virtualized network. +This section gives the method of building Linux bridge and Open vSwitch bridge, so that the virtual machine can be connected to the network. The user can choose the type of bridge to build according to the situation. -This section describes how to set up a Linux bridge and an Open vSwitch bridge to connect a VM to the network. You can select a bridge type based on the site requirements. -**Figure 1** Virtual network structure -![](./figures/virtual-network-structure.png "virtual-network-structure") +**Figure 1 ** Virtual Network Structure Diagram +![](./figures/virtual-network-structure.png) -### Setting Up a Linux Bridge +### Build Linux bridge -The following describes how to bind the physical NIC eth0 to the Linux bridge br0. +Taking the operation of physical network card eth0 binding to Linux bridge br0 as an example, use the root user to execute the following command to +build a Linux bridge: -1. Install the **bridge-utils** software package. +1. Install the bridge utils software package. - The Linux bridge is managed by the brctl tool. The corresponding installation package is bridge-utils. The installation command is as follows: + The Linux bridge is usually managed through the brctl tool. The corresponding installation package is bridge utils. The installation command is as follows: - ```shell - yum install -y bridge-utils + ```sh + # yum install -y bridge-utils ``` -2. Create bridge br0. +2. Create the bridge br0. - ```shell - brctl addbr br0 + ```sh + # brctl addbr br0 ``` -3. Bind the physical NIC eth0 to the Linux bridge. +3. Bind the physical network card eth0 to the Linux bridge. - ```shell - brctl addif br0 eth0 + ```sh + # brctl addif br0 eth0 ``` -4. After eth0 is connected to the bridge, the IP address of eth0 is set to 0.0.0.0. +4. After eth0 is connected to the bridge, the IP address is no longer needed. Install the net tools software package and set the IP address of eth0 to +0.0.0.0. - ```shell - ifconfig eth0 0.0.0.0 + ```sh + # yum install -y net-tools + # ifconfig eth0 0.0.0.0 ``` 5. Set the IP address of br0. - - If a DHCP server is available, set a dynamic IP address through the dhclient. + -If you have a DHCP server, you can set a dynamic IP address through dhclient. + - ```shell - dhclient br0 + ```sh + # dhclient br0 ``` - - If no DHCP server is available, configure a static IP address for br0. For example, set the static IP address to 192.168.1.2 and subnet mask to 255.255.255.0. + -If there is no DHCP server, configure a static IP for br0. For example, set the static IP to 192.168. 1.2 and the subnet mask to 255.255.255.0. + - ```shell - ifconfig br0 192.168.1.2 netmask 255.255.255.0 + ```sh + # ifconfig br0 192.168.1.2 netmask 255.255.255.0 ``` -### Setting Up an Open vSwitch Bridge +### Build an Open vSwitch bridge -The Open vSwitch bridge provides more convenient automatic orchestration capabilities. This section describes how to install network virtualization components to set up an Open vSwitch bridge. +Open vSwitch bridge, with more convenient automatic editing capability. To build an Open vSwitch bridge, you need to install network virtualization components. Here is the overall operation. -**1. Install the Open vSwitch component.** +#### I.Install the Open vSwitch component. -If the Open vSwitch is used to provide virtual network, you need to install the Open vSwitch network virtualization component. +If you use Open vSwitch to provide virtual network, you need to install the Open vSwitch network virtualization component, and use the root user to execute the following command: -1. Install the Open vSwitch component. +1. Install the Open vSwitch component. - ```shell - yum install -y openvswitch + ```sh + # yum install -y openvswitch ``` -2. Start the Open vSwitch service. +2. Load the Open vSwitch module into the kernel. - ```shell - systemctl start openvswitch + ```sh + # systemctl start openvswitch ``` -**2. Check whether the installation is successful.** +#### II.Confirmation of successful installation -1. Check whether the openvswitch component is successfully installed. If the installation is successful, the software package information is displayed. The command and output are as follows: +Confirm whether the Open vSwitch component is successfully installed. - ```shell +1. Confirm whether the openvswitch component is successfully installed. If the installation is successful, you can see the information about the software package. The commands and echoes are as follows: + + + ```sh $ rpm -qi openvswitch Name : openvswitch Version : 2.11.1 @@ -204,9 +224,10 @@ If the Open vSwitch is used to provide virtual network, you need to install the traffic. ``` -2. Check whether the Open vSwitch service is started successfully. If the service is in the **Active** state, the service is started successfully. You can use the command line tool provided by the Open vSwitch. The command and output are as follows: +2. Check whether the Open vSwitch service is started successfully. If the service is in "Active" status, it indicates that the service is successfully started. You can normally use the command line tool provided by Open vSwitch. The command and echo are as follows: + - ```shell + ```sh $ systemctl status openvswitch ● openvswitch.service - LSB: Open vSwitch switch Loaded: loaded (/etc/rc.d/init.d/openvswitch; generated) @@ -222,76 +243,81 @@ If the Open vSwitch is used to provide virtual network, you need to install the └─54603 ovs-vswitchd unix:/var/run/openvswitch/db.sock -vconsole:emer -vsyslog:err -vfile:info --mlockall --no-chdir --log-file=/var/log/openvswitch/ovs-vswitchd.log --pidfile=/var/run/open> ``` -**3. Set up an Open vSwitch bridge** +#### III.Build an Open vSwitch bridge -The following describes how to set up an Open vSwitch layer-1 bridge br0. +Taking the creation of the Open vSwitch Layer 1 bridge br0 as an example, this paper introduces the building method, and uses the root user to execute the following commands: -1. Create the Open vSwitch bridge br0. +1. Create an Open vSwitch bridgebr0. - ```shell - ovs-vsctl add-br br0 + ```sh + # ovs-vsctl add-br br0 ``` -2. Add the physical NIC eth0 to br0. +2. Create an Open vSwitch bridgebr0. - ```shell - ovs-vsctl add-port br0 eth0 + ```sh + # ovs-vsctl add-port br0 eth0 ``` -3. After eth0 is connected to the bridge, the IP address of eth0 is set to 0.0.0.0. +3. After eth0 is connected to the bridge, the IP address is no longer needed.Set the IP address of eth0 to 0.0.0.0. - ```shell - ifconfig eth0 0.0.0.0 + ```sh + # ifconfig eth0 0.0.0.0 ``` -4. Assign an IP address to OVS bridge br0. - - If a DHCP server is available, set a dynamic IP address through the dhclient. +4. Assign an IP address to the OVS bridge br0. - ```shell - dhclient br0 + > ![](./public_sys-resources/icon-note.gif) **illustrate:** + > + > If you use DHCP to set a dynamic IP address for br0, you need to clear the existing dynamic IP address. Run the dhclient -r command to clear the possible dynamic IP addresses. + + -If you have a DHCP server, you can set a dynamic IP address through dhclient. + + ```sh + # dhclient br0 ``` - - If no DHCP server is available, configure a static IP address for br0, for example, 192.168.1.2. + -If there is no DHCP server, configure a static IP address for br0, such as 192.168.1.2. - ```shell - ifconfig br0 192.168.1.2 + ```sh + # ifconfig br0 192.168.1.2 ``` -## Preparing Boot Firmware +## Preparing to boot the firmware -### Overview +### Preparing to boot the firmware -The boot mode varies depending on the architecture. x86 servers support the Unified Extensible Firmware Interface \(UEFI\) and BIOS boot modes, and AArch64 servers support only the UEFI boot mode. By default, boot files corresponding to the BIOS mode have been installed on openEuler. No additional operations are required. This section describes how to install boot files corresponding to the UEFI mode. +The guidance methods are different for different architectures. X86 supports UEFI (Unified Extensible Firmware Interface) and BIOS mode startup, AArch64 only supports UEFI mode startup. By default, openEuler has installed the boot file corresponding to BIOS startup, and no additional user operation is required. Therefore, only the installation method of UEFI startup mode is introduced here. -The Unified Extensible Firmware Interface \(UEFI\) is a new interface standard used for power-on auto check and OS boot. It is an alternative to the traditional BIOS. EDK II is a set of open source code that implements the UEFI standard. In virtualization scenarios, the EDK II tool set is used to start a VM in UEFI mode. Before using the EDK II tool, you need to install the corresponding software package before starting a VM. This section describes how to install the EDK II tool. +The unified extensible firmware interface (UEFI) is a new type of interface standard, which is used for POST and booting the operating system. It is an alternative to the traditional BIOS. EDK II is a set of open source code that implements the UEFI standard. In virtualization scenarios, the virtual machine is usually started through UEFI using the EDK II toolset. To use the EDK II tool, you need to install the corresponding software package before starting the virtual machine. This section describes the installation method of EDK II. -### Installation Methods +### Installation method -If the UEFI mode is used, the tool set EDK II needs to be installed. The installation package for the AArch64 architecture is **edk2-aarch64**, and that for the x86 architecture is **edk2-ovmf**. This section uses the AArch64 architecture as an example to describe the installation method. For the x86 architecture, you only need to replace **edk2-aarch64** with **edk2-ovmf**. +If you use UEFI mode to boot, you need to install the tool set EDK II, The installation package corresponding to AArch64 architecture is edk2-aarch64, The installation package corresponding to x86 architecture is edk2-ovmf. Taking the AArch64 architecture as an example, the specific installation method is given here, The x86 architecture only needs to replace edk2-aarch64 with edk2-ovmf. -1. Run the following command to install the **edk** software package: +1. Install the edk software package, and use the root user to execute the following commands: - In the AArch64 architecture, the **edk2** package name is **edk2-aarch64**. + The package name of edk2 under AArch64 architecture is edk2-aarch64 - ```shell - yum install -y edk2-aarch64 + ```sh + # yum install -y edk2-aarch64 ``` - In the x86\_64 architecture, the **edk2** package name is **edk2-ovmf**. + The package name of edk2 under x86\_64 architecture is edk2-ovmf - ```shell - yum install -y edk2-ovmf + ```sh + # yum install -y edk2-ovmf ``` -2. Run the following command to check whether the **edk** software package is successfully installed: +2. Query whether the edk software is successfully installed. The command is as follows: - In the AArch64 architecture, the command is as follows: + Query under AArch64 architecture as follows - ```shell + ```sh rpm -qi edk2-aarch64 ``` - If information similar to the following is displayed, the **edk** software package is successfully installed: + If the edk software is successfully installed, the echo is similar to the following: ```text Name : edk2-aarch64 @@ -302,13 +328,13 @@ If the UEFI mode is used, the tool set EDK II needs to be installed. The install Group : Applications/Emulators ``` - In the x86\_64 architecture, the command is as follows: + uery under x86\_64 architecture as follows - ```shell - rpm -qi edk2-ovmf + ```sh + # rpm -qi edk2-ovmf ``` - If information similar to the following is displayed, the **edk** software package is successfully installed: + If the edk software is successfully installed, the echo is similar to the following: ```text Name : edk2-ovmf @@ -318,50 +344,50 @@ If the UEFI mode is used, the tool set EDK II needs to be installed. The install Install Date: Thu 19 Mar 2020 09:09:06 AM CST ``` -## Configuring a Non-root User +## Non root user configuration ### Overview -openEuler virtualization uses virsh to manage VMs. If you want to use the virsh commands to manage VMs as a non-root user, you need to perform related configurations before using the commands. This section provides the configuration guide. +OpenEuler virtualization uses virsh to manage virtual machines. If you want to use the virsh command to manage the virtual machine for non root users, you need to configure it before using it. Here are the configuration instructions. -### Operation Guide +### Operating instructions -To allow a non-root user to run the virsh commands to manage VMs, perform the following operations (replace **userName** in the following commands with the actual non-root user name): +The configuration operations for allowing non root users to use the virsh command to manage virtual machines are as follows. Please change the userName in the following commands to the actual non root user name: -1. Log in to the host as the **root** user. +1. Log in to the host as root. -2. Add the non-root user to the libvirt user group. +2. Add the non root user to the libvirt user group. - ```shell - usermod -a -G libvirt userName + ```sh + # usermod -a -G libvirt userName ``` -3. Switch to the non-root user. +3. Switch to a non root user. - ```shell - su userName + ```sh + # su userName ``` -4. Configure environment variables for the non-root user. Run the **vim** command to open the ~/.bashrc file: +4. Configure environment variables for non root users. Use vim to open the~/.bashrc file: - ```shell + ```sh vim ~/.bashrc ``` - Add the following content to the end of the file and save the file: + and save it after adding the following at the end. - ```shell + ```sh export LIBVIRT_DEFAULT_URI="qemu:///system" ``` - Run the following command for the configuration to take effect: + Execute the following command to make the configuration effective. - ```shell + ```sh source ~/.bashrc ``` -5. Add the following content to the domain root element in the XML configuration file of the VM so that the qemu-kvm process can access the disk image files. +5. Add the following content to the domain root element in the XML configuration file of the virtual machine, so that the qemu_kvm process can access the disk image file. ```xml - ``` + ``` \ No newline at end of file