Linux实战教学笔记54:开源虚拟化KVM(二)管理虚拟存储 (7)

22.png-28.1kB

33.png-12.8kB

44.png-12.3kB

55.png-40.3kB

66.png-12.1kB

77.png-30.8kB

#用命令查看存储池状态 [root@localhost ~]# virsh pool-list 名称 状态 自动开始 ------------------------------------------- default 活动 是 guest_images_dir 活动 是 #创建完毕 iso 活动 是 VM 活动 是 #查看新创建的存储池的配置文件 [root@localhost ~]# cat /etc/libvirt/storage/guest_images_dir.xml <!-- WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE OVERWRITTEN AND LOST. Changes to this xml configuration should be made using: virsh pool-edit guest_images_dir or other application using the libvirt API. --> <pool type=\'dir\'> <name>guest_images_dir</name> <uuid>1a0b0e7f-8f40-4b59-96d0-42d8eb4ad709</uuid> <capacity unit=\'bytes\'>0</capacity> <allocation unit=\'bytes\'>0</allocation> <available unit=\'bytes\'>0</available> <source> </source> <target> <path>/guest_images</path> </target> </pool>

通过virt-manager删除存储池

QQ截图20180506164142.png-33.3kB

[root@localhost ~]# virsh pool-list --all setlocale: No such file or directory Name State Autostart ------------------------------------------- default active yes guest_images_dir inactive yes #状态变成了不活跃 iso active yes VM active yes

QQ截图20180506164142.png-36.1kB

[root@localhost ~]# virsh pool-list --all setlocale: No such file or directory Name State Autostart ------------------------------------------- default active yes iso active yes VM active yes [root@localhost ~]# ls /etc/libvirt/storage/ VM.xml autostart default.xml iso.xml

(2)通过virsh创建一个自定义存储池

#定义一个存储池 [root@localhost ~]# virsh pool-define --help setlocale: No such file or directory NAME pool-define - define an inactive persistent storage pool or modify an existing persistent one from an XML file SYNOPSIS pool-define <file> #如果直接去定义存储池参数比较多,我们可以选择直接通过存储池的配置文件去定义存储池 DESCRIPTION Define or modify a persistent storage pool. OPTIONS [--file] <string> file containing an XML pool description [root@localhost ~]# virsh pool-define-as guest_images dir --target "/guest_images2" #guest_images存储池名字,target目标路径 Pool guest_images defined [root@localhost ~]# virsh pool-list --all setlocale: No such file or directory Name State Autostart ------------------------------------------- default active yes guest_images inactive no #新定义的存储池并没有启动 iso active yes VM active yes [root@localhost ~]# virsh pool-start guest_images #启动存储池 error: Failed to start pool guest_images #启动失败 error: cannot open directory \'/guest_images2\': 没有那个文件或目录 #我们不要用手动去创建存储池目录,因为可能会有权限问题。 #创建一个定义好的存储池的存储目录 root@localhost ~]# virsh pool-build guest_images Pool guest_images built [root@localhost ~]# ll -d /gue* drws--S--- 2 root root 6 May 6 16:25 /guest_images drwxr-xr-x 2 root root 6 May 11 10:55 /guest_images2 [root@localhost ~]# virsh pool-start guest_images #启动存储池 Pool guest_images started [root@localhost ~]# virsh pool-list --all setlocale: No such file or directory Name State Autostart ------------------------------------------- default active yes guest_images active no #存储池处于启动状态 iso active yes VM active yes [root@localhost ~]# virsh pool-autostart guest_images #标记存储池自动启动 setlocale: No such file or directory Pool guest_images marked as autostarted [root@localhost ~]# virsh pool-list --all setlocale: No such file or directory Name State Autostart ------------------------------------------- default active yes guest_images active yes iso active yes VM active yes

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zzjxzx.html