Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Storage pools for kvm Virtualization

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

KVM storage pool is a file, directory or storage device managed by libvirt. The storage pool can be located locally or shared through the network, and the storage pool can eventually be used by virtual hosts. The default libvirt uses a directory-based storage pool design, and the / var/lib/libvirt/images directory is the default storage pool. A local storage pool can be a local directory, disk device, physical partition, or LVM volume, but the local storage pool is not suitable for large-scale product deployments and does not support virtual machine migration. The network sharing storage pool uses standard network protocols to share storage devices, which supports protocols such as SAN, IP-SAN, NFS, GFS2 and so on. In KVM virtualization technology, a storage pool can contain multiple storage volumes, which are recognized as physical hardware storage devices for virtual hosts.

The following will demonstrate the process of creating a KVM storage pool and a storage volume, taking directory storage and shared NFS storage as examples.

(1) create directory-based virtual storage pools and volumes.

1) create a directory:

[root@centos7 ~] # mkdir / var/lib/libvirt/test

2) modify file security-related attributes:

[root@centos7 ~] # chown root.root / var/lib/libvirt/test

[root@centos7 ~] # chmod 700 / var/lib/libvirt/test

[root@centos7] # semanage fcontext-a-t virt_image_t / var/lib/libvirt/test

[root@centos7] # restorecon-v / var/lib/libvirt/test

3) create a storage pool:

[root@centos7 ~] # virt-manager # start the virtual machine manager

Select "Edit" → "Connection Details" menu, as shown in figure-1, open the virtual machine connection specific settings window, in the Storage tab, select the add icon in the lower left corner to create a storage pool, as shown in figure-2. Enter the name and type of the storage pool in the first step of creating the storage pool. In this example, the storage pool name is test, and the type is directory-based storage pool, as shown in figure-3; the second step is to enter the specific path to the storage pool directory, as shown in figure-4. At this point, the directory-based storage pool has been created, as shown in figure-5. Next, you need to create a storage volume in the pool.

Figure-1

Figure-2

Figure-3

Figure-4

Figure-5

4) create a storage volume.

After completing the creation of the storage pool, we can create the storage volume in the pool, as shown in figure-5. Click to select the storage pool where the volume needs to be created, in this case test storage pool, and then select the "New Volume" button. Enter the volume name, format type, maximum storage space, and actual allocation of space as prompted, as shown in figure-6. Click the "Finish" button to finish creating the storage volume, as shown in figure-7.

Figure-6

Figure-7

(2) add usage storage devices for virtual machines.

After the storage volumes are created, our virtual hosts can use them. Double-click a virtual machine through virt-manager to open the control window. Click the device button to display the list of devices, as shown in figure-8, select the "Add Hardware" button to add a new device, and select the Storage storage device in the add Virtual hardware window, because we have created a storage volume device for the virtual host. Therefore, we select the existing storage space and enter the absolute path to the storage volume, as shown in figure-9. Enter the virtual host operating system and view the disk information via fdisk to include the storage volume device you just added, labeled / dev/vdb, as shown in figure-10.

Figure-8

Figure-9

Figure-10

The following shows how to create NFS-based storage pools and storage volume devices in a KVM virtualized environment, where we have a NFS shared server prepared in advance.

1) create a storage pool.

Similar to directory-based storage pools, we create a new storage pool with the add button shown in figure-11. The first step is still to fill in the storage pool name and type, as shown in figure-12; the second step is to fill in the NFS server hostname or IP address (192.168.0.254), server shared directory (/ nfs), local mount point (/ var/lib/libvirt/nfs), as shown in figure 7-28, click the "Finish" button to complete.

Figure-11

Figure-12

2) create a storage volume.

Similar to directory-based storage volumes, we use the "New Volume" button to create a storage volume and enter the volume name, format type, maximum storage capacity, and allocated storage capacity as prompted, as shown in figure-13.

Figure-13

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report