Environment Preparation
Prerequisites
- You need to obtain a CentOS 8 installation image from the official website by yourself. Ensure your compliance of relevant authorizations and permissions.
- This Tutorial references CentOS-8.4.2105-x86_64-DVD1.iso.
About this task
- Add an installation image.
- Create a disk offering.
Procedure
-
Add an installation image.
On the main menu of ZStack Cloud, choose . On the Image page, click Add Image. Then, the Add Image page is displayed.
On the displayed page, set the following parameters:- Name: Enter a name for the image.
- Description: Optional. Enter a description for the image.
- Image Type: Select an image type. Here, select System Image.
- Image Format: Select an image format. Here, Select iso.
- CPU Architecture: Select a CPU architecture for the image. VM instances created from the image use this CPU architecture.
- Platform: Select an image platform. Here, select Linux.
- OS: Select an operating system that is consistent with the image.
- VirtIO: Choose whether to enable VirtIO according to your actual operating system and platform. Here, enable VirtIO.
- Image Storage: Select an image storage added before.
- Image Path: Specify an image URL or upload a
local file.
- URL: Enter a specified URL to add an
image. You can enter a URL by using either of the following
syntax:
- A URL starting with http or https:
- Syntax: http://host[:port]/path/file or https://host[:port]/path/file.
- A URL starting with ftp:
- Syntax that does not specify the user: ftp://hostname[:port]/path/file.
- Syntax that specifies the user: ftp://user:password@hostname[:port]/path/file.
- A URL starting with sftp:
- Syntax that specifies the user identity: sftp://user:password@hostname[:port]/path/file.
- User-identity-free syntax: sftp://user@hostname[:port]/path/file.
- The absolute path of an image file that is stored on
an image storage. The image storage can be an
ImageStore image storage.
Syntax: file:///path/file.
Note:
- Make sure that the URL entered is accessible to the image storage and the image file exists.
- When using a URL that starts with stfp and does not specify user identity, make sure that you enable mutual password-free SSH login between the image storage and the SFTP server.
- For the progress bar and resumption from
breakpoints features:
- Both ImageStore and Ceph image storage support a progress bar to display the upload progress. And both ImageStore and Ceph image storage support the resumption from breakpoints.
- If you specify a URL with the
file:/// syntax to add an
image:
- Ceph image storage does not support the file:/// syntax currently.
- The three forward slashes (/) in file:/// represents the absolute path of a file on an image storage. For example, if you want to specify the URL file:///opt/dvd/image-1.4.qcow2, the /opt/dvd path of the image storage must contain such a file named image-1.4.qcow2.
- A URL starting with http or https:
- Local file: Select a local image file
that the current browser can access to and upload the image
file to the specified image storage. The image storage that
stores the image file can be an ImageStore or a Ceph image
storage.
Note: When you add a local
file as an image, your local browser is serving as a
transit point to upload the image. Do not refresh or
close the current browser, nor stop the service of the
management node. Otherwise, the operation may
fail.
- URL: Enter a specified URL to add an
image. You can enter a URL by using either of the following
syntax:
- BIOS Mode: Select a BIOS mode. Here, select Legacy.
Figure 1. Add an Image 
-
Create a disk offering.
On the main menu of ZStack Cloud, choose . On the Disk Offering page, click Create Disk Offering. Then, the Create Disk Offering page is displayed.
On the displayed page, set the following parameters:- Name: Enter a name for the disk offering.
- Description: Optional. Enter a description for the disk offering.
- Disk Size: Set the capacity of a
volume.
Note: Select an appropriate disk size as needed. This
disk size will serve to create the system disks for the CentOS 8
VM instances.- If you are installing a command line interface of CentOS 8, we recommend that you choose a disk size greater or equal to 40 GB.
- If you are installing a graphical interface of CentOS 8 (GNOME), we recommend that you choose a disk size greater or equal to 60 GB.
- Set Disk Bandwidth: Optional. Set an upper limit for the I/O bandwidth of a volume.
- Set Disk IOPS: Optional. Set an upper limit of the disk reads/writes per second (IOPS).
- Advanced Parameter: Optional. You can set this parameter by configuring a JSON file.
Figure 2. Create a Disk Offering 
Template
Install an Operating System
About this task
- Create a VM instance.
- Install CentOS 8.
Procedure
-
Create a VM instance.
For the detailed information about how to create a VM instance on ZStack Cloud, and how to use an installation image to boot the VM instance, see the chapter "Create a VM Instance" in User Guide.
Note: To install and
apply CentOS 8, make sure that you choose a memory of at least 2 GB for
the VM instance. We recommend that you choose a memory greater or equal
to 4 GB. -
Install CentOS 8.
Configure the Template System
About this task
- Specify the hostname.
- Configure the network.
- Install the QEMU Guest Agent.
- (Optional) Install the cloud-init.
- (Optional) Install the GuestTools.
- (Optional) Close vulnerability patches.
Procedure
-
Specify the hostname.
In the CentOS 8, run
hostnamectl set-hostname localhost.localdomain && bash. This command specifies the hostname of the VM instance created with the template as the IP address of the NIC. -
Configure the network.
To enable the VM instance created with the template to automatically obtain an IP address, you need to modify the NIC configurations. Run the following commands:
[root@localhost ~]# sed -i '/ONBOOT=/cONBOOT=yes' /etc/sysconfig/network-scripts/ifcfg-ens3 #Set the NIC to be activated automatically at boot [root@localhost ~]# sed -i '/^UUID'/d /etc/sysconfig/network-scripts/ifcfg-ens3 #Delete the UUID in the NIC configuration file [root@localhost ~]# sed -i '/^HWADDR'/d /etc/sysconfig/network-scripts/ifcfg-ens3 #Delete the MAC in the NIC configuration file -
Install the QEMU Guest Agent.
-
(Optional) Install the cloud-init.
To ensure the customized configuration features such as User Data and SSH Public Key are available when you create a VM instance with the template, you need to install the cloud-init before encapsulating the template. We recommend that you install the cloud-init of 0.7.9, 17.1, 19.4 or latter versions. You can select and install the version you need.
Note: Notice the following points when installing the
cloud-init:- Please install the versions recommended, otherwise, the User Data or SSH Public Key may become unavailable during VM instance creation.
- SSH key authentication is disabled by default after you install
the cloud-init. If you want to enable the authentication, please
run vi /etc/cloud/cloud.cfg to set the value
of
ssh_pwauthas1.
-
(Optional) Install VM GuestTools
Note: Notice the following points: - Run yum install tar -y to install the tar command before installing the GuestTools.
- If you attach data volumes to the Linux system image created, do not write the attachment information of the data volumes into /etc/fstab. Otherwise, the VM instances created with this template may fail to start.
- If you want to attach the data volumes to a VM instance when it
starts, we recommend the following method:
[root@localhost ~]# echo "mount -t ext4 -U "d0shC2-2GO1-Vyuc-XKXf-Pb3c-uvG5-92Fzeu" /mnt" >> /etc/rc.d/rc.local [root@localhost ~]# # -t indicates the file system of the disk; -U indicates using UUID to attach the disk;/mnt indicates the mount path [root@localhost ~]# # run blkid to obtain the device UUID [root@localhost ~]# chmod +x /etc/rc.d/rc.local [root@localhost ~]# # We recommend you to attach the disk with the device UUID instead of the disk symbol such as /dev/vdb.
-
(Optional) Close vulnerability patches.
For CentOS 8.x, closing the patches for spectre and meltdown can effectively improve the performance of the VM instances. To close the patches, follow these steps:
- Check whether the patch is on.Run
grep . /sys/devices/system/cpu/vulnerabilities/*. You can check whether the patch is on by viewing /sys. For example:# grep . /sys/devices/system/cpu/vulnerabilities/* /sys/devices/system/cpu/vulnerabilities/itlb_multihit:KVM: Mitigation: Split huge pages /sys/devices/system/cpu/vulnerabilities/l1tf:Mitigation: PTE Inversion; VMX: conditional cache flushes, SMT disabled /sys/devices/system/cpu/vulnerabilities/mds:Mitigation: Clear CPU buffers; SMT Host state unknown /sys/devices/system/cpu/vulnerabilities/meltdown:Mitigation: PTI /sys/devices/system/cpu/vulnerabilities/spec_store_bypass:Mitigation: Speculative Store Bypass disabled via prctl and seccomp /sys/devices/system/cpu/vulnerabilities/spectre_v1:Mitigation: usercopy/swapgs barriers and __user pointer sanitization /sys/devices/system/cpu/vulnerabilities/spectre_v2:Mitigation: Full generic retpoline, IBPB: conditional, IBRS_FW, STIBP: disabled, RSB filling /sys/devices/system/cpu/vulnerabilities/srbds:Not affected /sys/devices/system/cpu/vulnerabilities/tsx_async_abort:Mitigation: Clear CPU buffers; SMT Host state unknownYou can check the patch status through the last result returned. Mitigation means that the patch is on, while vulnerable means the patch is closed.
- View the vulnerability fix method.If the patch is on, check the bug fix method through the last result returned in the previous step. There are two bug fix methods: Retpoline without IBPB and Enhanced IBRS.
- Retpoline without IBPB: This method has a smaller impact on the performance of the system. You can either close the patch or keep it on. This depends on your needs.
- Enhanced IBRS: This method has a greater impact on the performance of the system. We recommend that you close the patch to improve the system performance. (The performance can improve by about 30% as measured.)
- Close the vulnerability patch.To close the vulnerability patch, following these steps:
- In the /etc/default/grub file, set the value as noibrs noibpb nopti spectre_v2=off nospectre_v1 l1tf=off nospec_store_bypass_disable no_stf_barrier mds=off mitigations=off for the parameter GRUB_CMDLINE_LINUX.
- Run
grub2-mkconfig > /boot/grub2/grub.cfgto apply the configuration. - Reboot the VM instance to make the configuration effective.
[root@10-0-5-87 ~]# cat /etc/default/grub #view /etc/default/grub file configuration.Make configurations based on your needs. GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)" GRUB_DEFAULT=saved GRUB_DISABLE_SUBMENU=true GRUB_TERMINAL_OUTPUT="console" GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=zstack/root rd.lvm.lv=zstack/swap rhgb quiet noibrs noibpb nopti spectre_v2=off nospectre_v1 l1tf=off nospec_store_bypass_disable no_stf_barrier mds=off mitigations=off" GRUB_DISABLE_RECOVERY="true" [root@10-0-5-87 ~]# grub2-mkconfig > /boot/grub2/grub.cfg #Apply the configuration [root@10-0-5-87 ~]# reboot #Restart the VM instance to make the configuration effective
- Check whether the patch is on.
Create a System Template
About this task
- Create an image.
- Export the image.
Procedure
-
Create an Image.
On the details page of the VM instance created, choose . Then, the Create Image page is displayed.
On the displayed page, set the following parameters:- Name: Enter a name for the image.
- Description: Optional. Enter a description for the image.
- Image Type: Select System Image here.
- Image Storage: Select an image storage created before.
Figure 6. Create an Image 
-
Export the image.
You can use the image exported to create VM instances on other cloud platforms directly. The method to export images varies according to image storage types.
- ImageStore image storage.
On the Image page, choose . This button helps export the image.
After generating the image, you can copy the URL of the image exported on the Overview page to download the image. Or, you can copy the URL of the exported image on the Exported page. You can also click Download on the page to download the image directly.
- Ceph image storage. If you use a Ceph image storage, you can export
the image on the UI or from the image storage.
- Export on the UI:
On the Image page, choose . This button helps export the image.
After generating the image, you can copy the URL of the image exported on the Overview page to download the image. Or, you can copy the URL of the exported image on the Exported page. You can also click Download on the page to download the image directly.
- Export from the image storage:
- On the Overview page of the created image, copy Installation Path.
- Login to the terminal of the Ceph image storage, run
rbd export to export the image.
For example: If you obtain the installation path ceph://bak-t-cac5eee23a204c1a914d1743f1584644/7232237c0059409babcd1c7a69452b98, you can run the following commands to export the image:
[root@ceph-node1 ~]# rbd export bak-t-cac5eee23a204c1a914d1743f1584644/7232237c0059409babcd1c7a69452b98 /root/export-test.qcow2 [root@ceph-node1 ~]# # bak-t indicates the installation path of the image [root@ceph-node1 ~]# # /root/export-test.qcow2 indicates the target path and the file name of the exported image
Note: The
command rbd export does not
include such a prefix as ceph://.
- Export on the UI:
- ImageStore image storage.



