虚拟机磁盘与qemu-img、存储池、存储卷
文章目录
- 写在开头的话
- 虚拟机磁盘与qemu-img
- 00. 虚拟磁盘概述
- 0.1 虚拟化项目中存储的注意事项
- 0.2 `kvm` 存储模式
- 0.3 虚拟磁盘类型
- 0.4 KVM 支持的磁盘类型
- 01. 使用 qemu-img管理虚拟磁盘
- 1.1 `qemu-img` 概述
- 1.2 qcow2 格式选项
- 1.3 命令演示
- 1.4 预分配策略
- 1.5 后备差异虚拟磁盘
- 1.6 backing_file
- 1.7 back_file 实验演示
- 1.8 虚拟磁盘格式转换
- 1.9 调整虚拟磁盘大小
- 1.10 快照管理 Snapshot / Checkpoint
- 1.11 磁盘快照分类
- 1.11 `qemu-img` 的快照管理
- 02. 存储池
- 2.1 存储池的基本概念
- 2.2 virsh中的存储卷相关命令
- 2.3 基于目录的存储池
- 2.4 基于分区的存储池:fs
- 2.5 基于磁盘的存储池
- 2.6 基于 LVM的存储池
- 2.7 `iscsi`存储池
- 2.7.1 基本概念
- 2.7.2 Linux-IO Target概述
- 2.7.3 实验环境准备:安装linux的存储服务器
- 2.7.4 配置`target`
- 2.7.5 实验: Initiator连接 Target
- 2.7.6 参考资料
- 2.7.7 基于iSCSI的存储池 iscsi: iSCSI Target
- 2.8 基于NFS的存储池
- 03. 存储卷
- 3.1 存储卷概述
- 3.2 存储卷管理
- 3.3 存储卷管理
- 3.3.1 基于目录的存储池中的存储卷管理
- 3.3.2 基于`LVM`的存储池中的存储卷管理
- 3.3.3 向虚拟机添加卷
- 写在最后的话:
这里是一段防爬虫文本,请读者忽略。
本文原创首发于CSDN,作者IDYS
博客首页:https://blog.csdn.net/weixin_41633902/
本文链接:https://blog.csdn.net/weixin_41633902/article/details/109405950
未经授权,禁止转载!恶意转载,后果自负!尊重原创,远离剽窃!
写在开头的话
- 请记住:实践是掌握知识的最快方法
- 如果你只是怀着看看的态度去快速浏览文章,而不去认认真真的把文章里面讲的任何一个知识点去实践一遍,那么你永远也掌握不了它
- 生命不息,折腾不止!
虚拟机磁盘与qemu-img
00. 虚拟磁盘概述
0.1 虚拟化项目中存储的注意事项
- 存储的性能几乎总是虚拟化的瓶颈
- 通过多个硬盘驱动以分布磁盘
I/O
来实现存储解决方案 - 驱动器的速度越快越好,考虑
SSD
与机械硬盘的混合使用 - 考虑部署集中化的
SAN/NFS
来实现高可用性和实时迁移
0.2 kvm
存储模式
- 基于文件系统的存储
dir:Filesystem Directory
fs:Pre-Formatted Block Device
netfs:Network Exported Directory
- 基于设备的存储
Disk:Physical Disk Device
Iscsi:iSCSI Target
logical: LVM Volume Group
- 通过存储池来简化存储的管理
0.3 虚拟磁盘类型
- 固定
Fixed
- 在配置时,指定磁盘大小
- 不管在虚拟磁盘上实际存储多少数据,都将占用相同大小主机磁盘空间
- 动态
Dynamic
- 增长到最大容量,但是只根据需求使用更多的空间
- 差异
Differencing
- 因为创建是差异磁盘,所以只保存变更的数据
- 例如:将操作系统安装在复盘,然后创建差异化磁盘来执行进一步配置
0.4 KVM 支持的磁盘类型
01. 使用 qemu-img管理虚拟磁盘
qemu-img
概述- 创建虚拟磁盘
- 检查虚拟磁盘
- 预分配磁盘策略
- 后配差异虚拟磁盘
- 虚拟磁盘格式转换
- 调整虚拟磁盘大小
1.1 qemu-img
概述
qemu-img
是一个功能强制磁盘镜像管理工具qemu-img --help
包括以下功能check
:检查完整性create
:创建镜像commit
:提交更改compare
:比较convert
:转换info
:获得信息map
:映射snapshot
:快照管理rebase
:在已有的镜像的基础上创建新的镜像resize
:调整大小amend
:修订镜像格式选项
- 查看磁盘文件信息
[root@idys1 /vm] qemu-img info centos6-disk0.qcow2
image: centos6-disk0.qcow2
file format: qcow2
virtual size: 8.0G (8589934592 bytes)
disk size: 1.2G
cluster_size: 65536
Format specific information:compat: 1.1lazy refcounts: true
- 查看
qcow2
磁盘类型支持的选项
[root@idys1 /vm] qemu-img create -f qcow2 -o ?
Supported options:
size Virtual disk size
compat Compatibility level (0.10 or 1.1)
backing_file File name of a base image
backing_fmt Image format of the base image
encryption Encrypt the image
cluster_size qcow2 cluster size
preallocation Preallocation mode (allowed values: off, metadata, falloc, full)
lazy_refcounts Postpone refcount updates
1.2 qcow2 格式选项
backing_file
- 用于指定后端镜像文件
backing_fmt
- 设置后端镜像的镜像格式
cluster_size
- 设置镜像中的簇大小,取值在
512
到2M
之间,默认值位64k
- 设置镜像中的簇大小,取值在
preallocation
- 设置镜像文件空间的预分配模式
encryption
- 用于设置加密
1.3 命令演示
- 创建一个虚拟大小为
50M
,实际大小为50M
的raw
类型的磁盘文件
[root@idys1 /vm] dd if=/dev/zero of=./disk-test.raw bs=1024k count=50
记录了50+0 的读入
记录了50+0 的写出
52428800字节(52 MB)已复制,0.0558294 秒,939 MB/秒
[root@idys1 /vm] qemu-img info disk-test.raw
image: disk-test.raw
file format: raw
virtual size: 50M (52428800 bytes)
disk size: 50M
- 创建一个虚拟大小为
50M
,实际大小为0M
的raw
类型的磁盘文件
[root@idys1 /vm] ls -lh disk-second.raw
-rw-r--r-- 1 root root 50M 10月 24 05:12 disk-second.raw
[root@idys1 /vm] du -sh disk-second.raw
0 disk-second.raw
[root@idys1 /vm] qemu-img info disk-second.raw
image: disk-second.raw
file format: raw
virtual size: 50M (52428800 bytes)
disk size: 0
- 把标准文件,实际占用
50M
的文件,复制为稀疏文件
[root@idys1 /vm] cp disk-test.raw disk-testa.raw --sparse=always
[root@idys1 /vm] du -sh disk-*
0 disk-second.raw
0 disk-testa.raw
50M disk-test.raw
- 把稀疏文件复制为标准文件
[root@idys1 /vm] cp disk-second.raw disk-seconda.raw --sparse=never
[root@idys1 /vm] du -sh disk-*
50M disk-seconda.raw
0 disk-second.raw
0 disk-testa.raw
50M disk-test.raw
- 检查磁盘文件是否发生错误
[root@idys1 /vm] qemu-img check centos6-disk0.qcow2
No errors were found on the image.
131072/131072 = 100.00% allocated, 0.00% fragmented, 0.00% compressed clusters
Image end offset: 8591507456
1.4 预分配策略
off
- 缺省策略,即不使用预分配策略
metadata
- 分配元数据(
metadata
),预分配后的虚拟磁盘仍然属于稀疏映像类型
- 分配元数据(
full
- 分配所有磁盘空间并置零,预分配后的虚拟磁盘属于非稀疏映像类型
falloc
- 分配文件的块并标示它们的状态为
未
初始化,相对于full
模式来说,创建虚拟磁盘的速度要快很多
- 分配文件的块并标示它们的状态为
创建磁盘文件时,不指定分配策略的话。默认分配策略就是
off
创建磁盘文件,分配策略为
off
[root@idys1 /vm] qemu-img create -f qcow2 testa.img 50M -o preallocation=off
Formatting 'testa.img', fmt=qcow2 size=52428800 encryption=off cluster_size=65536 preallocation='off' lazy_refcounts=off
[root@idys1 /vm] du -sh testa.img
196K testa.img
- 创建磁盘文件,分配策略为
metadata
[root@idys1 /vm] qemu-img create -f qcow2 testb.img 50M -o preallocation=metadata
Formatting 'testb.img', fmt=qcow2 size=52428800 encryption=off cluster_size=65536 preallocation='metadata' lazy_refcounts=off
[root@idys1 /vm] du -sh test*
196K testa.img
264K testb.img
可以看到,
metadata
创建时文件大小比off
文件大一点
- 创建磁盘文件,分配策略为
falloc
[root@idys1 /vm] qemu-img create -f qcow2 testc.img 50M -o preallocation=falloc
Formatting 'testc.img', fmt=qcow2 size=52428800 encryption=off cluster_size=65536 preallocation='falloc' lazy_refcounts=off
[root@idys1 /vm] du -sh test*
196K testa.img
264K testb.img
51M testc.img
- 创建磁盘文件,分配策略为
full
[root@idys1 /vm] qemu-img create -f qcow2 testd.img 50M -o preallocation=full
Formatting 'testd.img', fmt=qcow2 size=52428800 encryption=off cluster_size=65536 preallocation='full' lazy_refcounts=off
[root@idys1 /vm] du -sh test*
196K testa.img
264K testb.img
51M testc.img
51M testd.img
- 使用
ls -lh
去查看文件大小
[root@idys1 /vm] ls -lh test*
-rw-r--r-- 1 root root 193K 10月 24 06:09 testa.img
-rw-r--r-- 1 root root 51M 10月 24 06:09 testb.img
-rw-r--r-- 1 root root 51M 10月 24 06:10 testc.img
-rw-r--r-- 1 root root 51M 10月 24 06:10 testd.img
1.5 后备差异虚拟磁盘
- 存储与基础镜像(父)磁盘的变化
- 基础镜像(父)磁盘不会改变
- 差异磁盘隔离变化
- 多个差异磁盘可以使用相同的基础镜像(父)磁盘
- 优点:标准化基础镜像,节省空间
- 缺点:增加了开销,较差的性能
1.6 backing_file
- 图解
- 创建基础镜像
qemu-img create -f qcow2 -o backing_file=Base_CentOS7-1151-disk0.qcow2 oa-disk0-with-b.qcow2
- 创建基于虚拟机的基础镜像
virt-install --import --name=oa --vcpus=1 --ram=1024 --disk path=/vm/oa-disk0-with-b.qcow2 --network network=default --graphics vnc,listen=0.0.0.0 --os-type=linux --os-variant=rhel6
1.7 back_file 实验演示
- 复制出一个后备文件
[root@idys1 /vm] cp centos6-disk0.qcow2 base-centos6-disk0.qcow2
- 查看名为
centos6.10
的虚拟机所使用的磁盘镜像
[root@idys1 /vm] cat /etc/libvirt/qemu/centos6.10.xml | grep source\ file<source file='/vm/centos6-disk0.qcow2'/>
- 创建基于后备文件
base-centos6-disk0.qcow2
的链接文件oa-disk0.qcow2
[root@idys1 /vm] qemu-img create -f qcow2 -o backing_file=base-centos6-disk0.qcow2 oa-disk0.qcow2
Formatting 'oa-disk0.qcow2', fmt=qcow2 size=8589934592 backing_file='base-centos6-disk0.qcow2' encryption=off cluster_size=65536 lazy_refcounts=off
- 查看磁盘文件信息
[root@idys1 /vm] qemu-img info oa-disk0.qcow2
image: oa-disk0.qcow2
file format: qcow2
virtual size: 8.0G (8589934592 bytes)
disk size: 196K
cluster_size: 65536
backing file: base-centos6-disk0.qcow2
Format specific information:compat: 1.1lazy refcounts: false
- 再次创建一个基于
base-centos6-disk0.qcow2
的链接磁盘文件erp-disk0.qcow2
,并且查看其信息
[root@idys1 /vm] qemu-img create -f qcow2 -o backing_file=base-centos6-disk0.qcow2 erp-disk0.qcow2
Formatting 'erp-disk0.qcow2', fmt=qcow2 size=8589934592 backing_file='base-centos6-disk0.qcow2' encryption=off cluster_size=65536 lazy_refcounts=off
[root@idys1 /vm] qemu-img info erp-disk0.qcow2
image: erp-disk0.qcow2
file format: qcow2
virtual size: 8.0G (8589934592 bytes)
disk size: 196K
cluster_size: 65536
backing file: base-centos6-disk0.qcow2
Format specific information:compat: 1.1lazy refcounts: false
- 用
ls -lh
查看一下
[root@idys1 /vm] ls -lh
总用量 3.9G
drwxr-xr-x 2 root root 4.0K 10月 25 16:37 back_img
-rw------- 1 root root 8.1G 10月 25 17:18 base-centos6-disk0.qcow2
-rw------- 1 root root 8.1G 10月 22 00:37 centos6-disk0.qcow2
-rw-r--r-- 1 root root 1.5G 10月 23 18:15 CentOS-disk1.qcow2
-rw-r--r-- 1 root root 193K 10月 25 17:32 erp-disk0.qcow2
drwx------ 2 root root 16K 10月 21 17:01 lost+found
-rw-r--r-- 1 root root 193K 10月 25 17:24 oa-disk0.qcow2
-rw-r--r-- 1 root root 193K 10月 23 18:22 win32-disk2
- 创建基于磁盘链接克隆的虚拟机
virt-install --import --name=oa --vcpus=1 --ram=512 --disk path=/vm/oa-disk0.qcow2 --network network=default \
> --graphics vnc,listen=0.0.0.0 --os-type=linux --os-variant=rhel6
- 直接创建出来
- 再创建一个
erp
链接克隆
virt-install --import --name=erp --vcpus=1 --ram=512 --disk path=/vm/erp-disk0.qcow2 --network network=default --graphics vnc,listen=0.0.0.0 --os-type=linux --os-variant=rhel6
- 立马就创建好了
- 查看正在运行的域
[root@idys1 /vm] virsh list Id 名称 状态
----------------------------------------------------1 oa running2 erp running[root@idys1 /vm] virsh shutdown 1
域 1 被关闭[root@idys1 /vm] virsh shutdown 2
域 2 被关闭
- 关闭域的运行
[root@idys1 /vm] virsh shutdown 1
域 1 被关闭[root@idys1 /vm] virsh shutdown 2
域 2 被关闭
[root@idys1 /vm] virsh list # 可以看到所有的域已经关闭Id 名称 状态
----------------------------------------------------
- 将后备文件移入到其他目录下
[root@idys1 /vm] mv base-centos6-disk0.qcow2 back_img/
- 将基于后备文件
base-centos6-disk0.qcow2
而创建链接克隆的虚拟机oa
打开
[root@idys1 /vm] virsh start oa
错误:开始域 oa 失败
错误:Cannot access backing file '/vm/base-centos6-disk0.qcow2' of storage file '/vm/oa-disk0.qcow2' (as uid:107, gid:107): 没有那个文件或目录
可以看到虚拟机无法打开,因为找不到后备文件的原因
- 把后备文件移入到
/vm/
目录下,然后再次启动虚拟机
[root@idys1 /vm] mv back_img/base-centos6-disk0.qcow2 ./
[root@idys1 /vm] virsh start oa
域 oa 已开始
此时可以看到虚拟机成功启动
1.8 虚拟磁盘格式转换
convert
选项用法格式
convert [-c] [-p] [-q] [-n] [-f fmt] [-t cache] [-T src_cache] [-O output_fmt] [-o options] [-s snapshot_name] [-S sparse_size] filename [filename2 [...]] output_filename
- 命令举例
qemu-img convert my-vmware.vmdk my-kvm.img
qemu-img convert -O qcow2 rhel6u3.img rhel6u3-a.img
- 安装参数举例
virt-install
--import --name=FALC_NSS_8 --vcpus=2 --ram=4096
--disk bus=scsi,path=/vm/falc/FS6U5-NSSVA-800NK-disk1.qcow2 \
--disk bus=scsi,path=/vm/falc/FS6U5-NSSVA-800NK-disk1.qcow2 \
--network type=bridge,source=br0 \
--network type=bridge,source=br0 \
--network type=bridge,source=br0 \
--network type=bridge,source=br0 \
--graphics vnc,listen=0.0.0.0 \
--os-type=linux \
--os-variant=rhel6
--noautoconsole
2
个cpu
4GB
内存四个
virtio
网卡将二个转换过来的磁盘,配置为
scsi
接口
vnc
显卡
OS
类型为RHEL6
--noautoconsole
只导入,不启动
1.9 调整虚拟磁盘大小
- 语法格式
resize filename [ + | -]size
操作之前,一定要做好数据备份
增加文件大小后,需要在客户机中使用
fdisk
、parted
等分区工具进行相应的操作才能真正让客户机使用到增加后的镜像空间。缩小镜像之前,要在客户机中保证里面的文件系统有空余空间,否则会数据丢失
qcow2
不支持缩小镜像的操作命令演示
qemu-img resize crm-disk0-with-b.qcow2 +2G
- 给某块链接磁盘加上
10G
[root@idys1 /vm] qemu-img resize oa-disk0.qcow2 +10G
- 查看这块磁盘的信息
[root@idys1 /vm] qemu-img info oa-disk0.qcow2
image: oa-disk0.qcow2
file format: qcow2
virtual size: 18G (19327352832 bytes)
disk size: 102M
cluster_size: 65536
backing file: base-centos6-disk0.qcow2
Format specific information:compat: 1.1lazy refcounts: false
1.10 快照管理 Snapshot / Checkpoint
- 磁盘快照
- 对磁盘数据进行快照
- 主要用于虚拟机备份等场合
- 内存快照
- 对虚拟机的内存/设备信息进行保存
- 该机制同时用于休眠恢复,迁移等场景
- 主要使用
virsh save(qemu migrate to file)
实现,只能对运行的虚拟机进行
- 检查点快照
- 同时保存虚拟机的磁盘快照和内存快照
- 用于将虚拟机恢复到某个时间点
- 可以保证数据的一致性
1.11 磁盘快照分类
- 按快照信息保存为:
- 内置快照:快照数据和
base
磁盘数据放在一个qcow2
文件中 - 外置快照:快照数据单独的
qcow2
文件存放
- 内置快照:快照数据和
- 按虚拟机状态可以分为:
- 关机态快照:数据可以保证一致性
- 运行快照:数据无法保证一致性,类似于系统
crash
后的磁盘数据。使用是可能需要fsck
等操作
- 按磁盘数量可以分为:
- 单盘:单盘快照不涉及原子性
- 多盘:涉及原子性。主要分为两个方面:
- 是所有盘快照点相同
- 所有盘要么都快照成功,要么都快照失败。主要依赖于
qemu
的transaction
实现
1.11 qemu-img
的快照管理
- 语法格式
snapshot [-q] [-l | -a snapshot | -c snapshot | -d snapshot] filename
qemu-img
snapshot
is the name of the snapshot to create, apply or delete-a applies a snapshot (revert disk to saved state)-c creates a snapshot-d deletes a snapshot-l lists all snapshots in the given image
- 列举出创建的虚拟机列表信息
[root@idys1 /vm] virsh list --allId 名称 状态
----------------------------------------------------- CentOS6-32-virt-kickstart-test 关闭- centos6.10 关闭- erp 关闭- oa 关闭- win2k3a 关闭
- 查看
centos6.10
对应的硬盘信息
[root@idys1 /vm] virsh domblklist centos6.10
目标 源
------------------------------------------------
vda /vm/centos6-disk0.qcow2
hda -
- 开启
centos6.10
虚拟机
[root@idys1 /vm] virsh start centos6.10
域 centos6.10 已开始
virt-manager
图形界面连接到虚拟机
- 在虚拟机的
/tmp
目录下创建目录和文件
mkdir /tmp/dir{1..4}/file{1..10}
- 查看
tmp
下的目录结构
[root@localhost tmp] tree /tmp/ | head -15
/tmp/
├── dir1
│ ├── file1
│ ├── file10
│ ├── file2
│ ├── file3
│ ├── file4
│ ├── file5
│ ├── file6
│ ├── file7
│ ├── file8
│ └── file9
├── dir2
│ ├── file1
│ ├── file10
- 关闭虚拟机
[root@idys1 /vm] virsh shutdown centos6.10
域 centos6.10 被关闭
- 查看虚拟机对应的磁盘信息
[root@idys1 /vm] virsh domblklist centos6.10
目标 源
------------------------------------------------
vda /vm/centos6-disk0.qcow2
hda -
- 查看磁盘对应的快照信息
[root@idys1 /vm] qemu-img snapshot -l centos6-disk0.qcow2
可以发现没有快照
- 创建磁盘快照
[root@idys1 /vm] qemu-img snapshot -c snap-cent6.10-1 /vm/centos6-disk0.qcow2
快照名称为
snap-cent6.10-1
- 查看快照信息
[root@idys1 /vm] qemu-img snapshot -l centos6-disk0.qcow2
Snapshot list:
ID TAG VM SIZE DATE VM CLOCK
1 snap-cent6.10-1 0 2020-10-27 00:41:18 00:00:00.000
qemu-img
也可以查看快照信息
[root@idys1 /vm] qemu-img info centos6-disk0.qcow2
image: centos6-disk0.qcow2
file format: qcow2
virtual size: 8.0G (8589934592 bytes)
disk size: 1.2G
cluster_size: 65536
Snapshot list:
ID TAG VM SIZE DATE VM CLOCK
1 snap-cent6.10-1 0 2020-10-27 00:41:18 00:00:00.000
Format specific information:compat: 1.1lazy refcounts: true
- 查看磁盘对应的虚拟机的快照信息
[root@idys1 /vm] virsh snapshot-list centos6.10名称 生成时间 状态
------------------------------------------------------------
可以看到虽然磁盘做了快照,但是查看磁盘对应的虚拟机的快照信息是为空的
- 再次开启虚拟机
[root@idys1 /vm] virsh start centos6.10
域 centos6.10 已开始
- 删除掉之前创建的目录和文件
cd /tmp
rm -rf ./dir*
- 关闭虚拟机
[root@idys1 /vm] virsh shutdown centos6.10
域 centos6.10 被关闭
- 磁盘回滚,直接回滚到某个快照点下
[root@idys1 /vm] qemu-img snapshot -l centos6-disk0.qcow2
Snapshot list:
ID TAG VM SIZE DATE VM CLOCK
1 snap-cent6.10-1 0 2020-10-27 00:41:18 00:00:00.000
[root@idys1 /vm] qemu-img snapshot -a snap-cent6.10-1 centos6-disk0.qcow2
此时已经回滚到
snap-cent6.10-1
这个tags
下
- 再次启动虚拟机
[root@idys1 /vm] virsh start centos6.10
域 centos6.10 已开始
- 此时再次查看
/tmp
目录下的文件信息,发现之前的文件又回来了
[root@idys1 /vm] ssh root@192.168.122.194 tree /tmp | head -20
root@192.168.122.194's password:
/tmp
├── dir1
│ ├── file1
│ ├── file10
│ ├── file2
│ ├── file3
│ ├── file4
│ ├── file5
│ ├── file6
│ ├── file7
│ ├── file8
│ └── file9
├── dir2
│ ├── file1
│ ├── file10
│ ├── file2
│ ├── file3
│ ├── file4
│ ├── file5
│ ├── file6
02. 存储池
2.1 存储池的基本概念
Libvirt
可以以存储池的形式对存储进行统一管理、简化操作对于虚拟机操作来说,存储池和卷并不是必需的
支持以下存储池
dir
:Filesystem Directory
disk
:Physical Disk Device
fs
:Pre-Formatted Block Device
gluster
:Gluster FileSystem
iscsi
:iSCSI Target
logical
:LVM Volume Group
mpath
:Multipath Device Enumerator
netfs
:Network Export Directory
rbd
:RADOS Block Device/Ceph
scsi
:SCSI Host Adapter
sheepdog
:Sheepdog FileSystem
存储池的配置文件
[root@idys1 /vm] ls /etc/libvirt/storage/
autostart default.xml iso.xml virtio_dir.xml vm.xml
- 查看某个存储池对应的配置文件
[root@idys1 /vm] cat /etc/libvirt/storage/iso.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 iso
or other application using the libvirt API.
--><pool type='dir'><name>iso</name><uuid>4dc4371a-754b-418c-9ae6-539ee3e09845</uuid><capacity unit='bytes'>0</capacity><allocation unit='bytes'>0</allocation><available unit='bytes'>0</available><source></source><target><path>/iso</path></target>
</pool>
- 查看
autostart
这个目录底下的文件
[root@idys1 /vm] ls -l /etc/libvirt/storage/autostart/
总用量 0
lrwxrwxrwx 1 root root 32 10月 21 04:03 default.xml -> /etc/libvirt/storage/default.xml
lrwxrwxrwx 1 root root 28 10月 21 19:07 iso.xml -> /etc/libvirt/storage/iso.xml
lrwxrwxrwx 1 root root 35 10月 23 18:28 virtio_dir.xml -> /etc/libvirt/storage/virtio_dir.xml
lrwxrwxrwx 1 root root 27 10月 22 00:10 vm.xml -> /etc/libvirt/storage/vm.xml
这个目录下的链接文件都是随
libvirt
的启动而启动的
virsh
中存储池相关命令
Storage Pool (help keyword 'pool')find-storage-pool-sources-as 找到潜在存储池源find-storage-pool-sources 发现潜在存储池源pool-autostart 自动启动某个池pool-build 建立池pool-create-as 从一组变量中创建一个池pool-create 从一个 XML 文件中创建一个池pool-define-as 在一组变量中定义池pool-define define an inactive persistent storage pool or modify an existing persistent one from an XML filepool-delete 删除池pool-destroy 销毁(删除)池pool-dumpxml XML 中的池信息pool-edit 为存储池编辑 XML 配置pool-info 存储池信息pool-list 列出池pool-name 将池 UUID 转换为池名称pool-refresh 刷新池pool-start 启动一个(以前定义的)非活跃的池pool-undefine 取消定义一个不活跃的池pool-uuid 把一个池名称转换为池 UUIDpool-event Storage Pool Events
- 编辑存储池
[root@idys1 /vm] virsh pool-edit iso
- 列举出所有的储存池
[root@idys1 /vm] virsh pool-list名称 状态 自动开始
-------------------------------------------default 活动 是 iso 活动 是 virtio_dir 活动 是 vm 活动 是
- 查看存储池的信息
[root@idys1 /vm] virsh pool-info default
名称: default
UUID: 2c143706-2402-4f0b-a78b-ee475a69a73a
状态: running
持久: 是
自动启动: 是
容量: 47.46 GiB
分配: 20.77 GiB
可用: 26.69 GiB[root@idys1 /vm] virsh pool-info vm
名称: vm
UUID: 1693104e-8164-4151-b9a6-602a5d5f848c
状态: running
持久: 是
自动启动: 是
容量: 78.62 GiB
分配: 4.41 GiB
可用: 74.21 GiB
- 查看
pool-autostart
这个命令的帮助信息
[root@idys1 /vm] virsh pool-autostart --helpNAMEpool-autostart - 自动启动某个池SYNOPSISpool-autostart <pool> [--disable]DESCRIPTION将某个池设置为在引导时自动启动。OPTIONS[--pool] <string> 池名或 uuid--disable 禁止自动启动
2.2 virsh中的存储卷相关命令
- 存储卷相关命令
[root@idys1 /] virsh help volumeStorage Volume (help keyword 'volume'):vol-clone 克隆卷。vol-create-as 从一组变量中创建卷vol-create 从一个 XML 文件创建一个卷vol-create-from 生成卷,使用另一个卷作为输入。vol-delete 删除卷vol-download 将卷内容下载到文件中vol-dumpxml XML 中的卷信息vol-info 存储卷信息vol-key 为给定密钥或者路径返回卷密钥vol-list 列出卷vol-name 为给定密钥或者路径返回卷名vol-path 为给定密钥或者路径返回卷路径vol-pool 为给定密钥或者路径返回存储池vol-resize 创新定义卷大小vol-upload 将文件内容上传到卷中vol-wipe 擦除卷
2.3 基于目录的存储池
- 准备目录:设置目录权限
chown root:root /guest_images/
chmod 700 /guest_images
通过
virt-manager
创建通过
virsh
创建
virsh pool-define-as guest_images dir --target "/guest_images"
- 演示
- 创建一个目录
[root@idys1 /] mkdir /guest_images
- 设置目录权限
[root@idys1 /] chown root:root /guest_images
[root@idys1 /] chmod 700 /guest_images
- 通过
virt-manage
创建存储池
[root@idys1 /] virt-manager
- 点击编辑
- 连接详情
- 存储
- 点击左下角的
+
按钮
- 输出名称后,点击前进
- 目标路径选择之前创建的目录
- 列出所有存储池
[root@idys1 /] virsh pool-list名称 状态 自动开始
-------------------------------------------default 活动 是 guest_images_dir 活动 是 iso 活动 是 virtio_dir 活动 是 vm 活动 是
- 查看某个存储池的详细信息
[root@idys1 /] virsh pool-info guest_images_dir
名称: guest_images_dir
UUID: c91c62a3-5a41-4f56-93ba-cb88b42c31ed
状态: running
持久: 是
自动启动: 是
容量: 47.46 GiB
分配: 20.77 GiB
可用: 26.69 GiB
- 查看存储池配置文件
[root@idys1 /] 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>c91c62a3-5a41-4f56-93ba-cb88b42c31ed</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>
- 先停止存储池,然后删除存储池
- 用
virsh
创建一个dir
类型的存储池,目前目录为一个不存在的目录
[root@idys1 ~] virsh pool-list --all # 先查看存储池名称 状态 自动开始
-------------------------------------------default 活动 是 iso 活动 是 virtio_dir 活动 是 vm 活动 是
[root@idys1 ~] virsh pool-define-as guest_images dir --target "/guest_images2" # 创建一个存储池,它的目标路径
定义池 guest_images
- 查看存储池状态
[root@idys1 ~] virsh pool-list --all | column -t
名称 状态 自动开始
-------------------------------------------
default 活动 是
guest_images 不活跃 否
iso 活动 是
virtio_dir 活动 是
vm 活动 是
[root@idys1 ~]
- 查看具体某个存储池的详细信息
[root@idys1 ~] virsh pool-info guest_images
名称: guest_images
UUID: 150f972f-59e2-480f-ae1f-fe019b80cce8
状态: 不活跃
持久: 是
自动启动: 否
- 查看存储池的配置文件
[root@idys1 ~] cat /etc/libvirt/storage/guest_images.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
or other application using the libvirt API.
--><pool type='dir'><name>guest_images</name><uuid>150f972f-59e2-480f-ae1f-fe019b80cce8</uuid><capacity unit='bytes'>0</capacity><allocation unit='bytes'>0</allocation><available unit='bytes'>0</available><source></source><target><path>/guest_images2</path></target>
</pool>
- 启动存储池:因为存储池对应的文件夹不存在,所有启动失败
[root@idys1 ~] virsh pool-start guest_images
错误:启动池 guest_images 失败
错误:cannot open directory '/guest_images2': 没有那个文件或目录
- 构造存储池
[root@idys1 ~] virsh pool-build guest_images
构建池 guest_images
- 因为前面,存储池构造了,那么我们现在来查看存储池的目录是否存在
[root@idys1 ~] ls /gue* # 可以发现 pool-bulid 之后,目录生成了
/guest_images:/guest_images2:
- 启动存储池,然后再来查看存储池的状态
[root@idys1 ~] virsh pool-start guest_images # 启动存储池
池 guest_images 已启动[root@idys1 ~] virsh pool-list # 查看存储池名称 状态 自动开始
-------------------------------------------default 活动 是 guest_images 活动 否 iso 活动 是 virtio_dir 活动 是 vm 活动 是
- 将存储池设置为自启动
[root@idys1 ~] virsh pool-autostart guest_images
池 guest_images 标记为自动启动[root@idys1 ~] virsh pool-list 名称 状态 自动开始
-------------------------------------------default 活动 是 guest_images 活动 是 iso 活动 是 virtio_dir 活动 是 vm 活动 是
- 终止存储池的运行
[root@idys1 ~] virsh pool-destroy guest_images
销毁池 guest_images[root@idys1 ~] ls /guest_images* # 查看目录
/guest_images:/guest_images2:
[root@idys1 ~] virsh pool-list --all | column -t # 查看存储池状态
名称 状态 自动开始
-------------------------------------------
default 活动 是
guest_images 不活跃 是
iso 活动 是
virtio_dir 活动 是
vm 活动 是
- 删除存储池
[root@idys1 ~] virsh pool-delete guest_images
池 guest_images 被删除
- 查看目录,存储池配置文件是否存在
[root@idys1 ~] ls -d /gue* # 目录以及消失
/guest_images
[root@idys1 ~] virsh pool-list --all # 但是内容信息还在名称 状态 自动开始
-------------------------------------------default 活动 是 guest_images 不活跃 是 iso 活动 是 virtio_dir 活动 是 vm 活动 是
[root@idys1 ~] ls /etc/libvirt/storage/guest_images.xml # 存储池配置文件也在
/etc/libvirt/storage/guest_images.xml
- 彻底删除存储池
[root@idys1 ~] virsh pool-undefine guest_images
池 guest_images 已经被取消定义[root@idys1 ~] virsh pool-list --all # 以及没有关于guest_images 的信息了名称 状态 自动开始
-------------------------------------------default 活动 是 iso 活动 是 virtio_dir 活动 是 vm 活动 是 [root@idys1 ~] ls /etc/libvirt/storage/ # 配置文件也已经消失了
autostart default.xml iso.xml virtio_dir.xml vm.xml
[root@idys1 ~] ls -d /gue*
/guest_images
2.4 基于分区的存储池:fs
libvirtd
会自动mount
分区- 准备分区并创建文件系统
fdisk /dev/sdc
mkfs.ext4 /dev/sdc1
- 创建
Source Path
:块设备名Target Path
:mount
到的目录名
virsh pool-define-as guest_images_fs fs --source-dev "/dev/sdc1" --target "/guest_images2"
- 在
vm
里面添加一块硬盘:虚拟机处于运行状态,直接插入硬盘
[root@idys1 ~] for i in {0..2};do echo "- - -" >> /sys/class/scsi_host/host$i/scan;done
# 重新扫描系统总线
[root@idys1 ~] fdisk -l # 可以看到插入的硬盘以及被检测
磁盘 /dev/sdd:85.9 GB, 85899345920 字节,167772160 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
- 为硬盘分区,为其分
40G
容量
[root@idys1 ~] fdisk /dev/sdd
欢迎使用 fdisk (util-linux 2.23.2)。更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。Device does not contain a recognized partition table
使用磁盘标识符 0x74008775 创建新的 DOS 磁盘标签。命令(输入 m 获取帮助):n
Partition type:p primary (0 primary, 0 extended, 4 free)e extended
Select (default p): p
分区号 (1-4,默认 1):1
起始 扇区 (2048-167772159,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-167772159,默认为 167772159):+40G
分区 1 已设置为 Linux 类型,大小设为 40 GiB命令(输入 m 获取帮助):p 磁盘 /dev/sdd:85.9 GB, 85899345920 字节,167772160 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x74008775设备 Boot Start End Blocks Id System
/dev/sdd1 2048 83888127 41943040 83 Linux命令(输入 m 获取帮助):w
The partition table has been altered!Calling ioctl() to re-read partition table.
正在同步磁盘。
- 查看分区信息是否写入
[root@idys1 ~] fdisk -l /dev/sdd磁盘 /dev/sdd:85.9 GB, 85899345920 字节,167772160 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x74008775设备 Boot Start End Blocks Id System
/dev/sdd1 2048 83888127 41943040 83 Linux
- 将分区格式化文件系统
[root@idys1 ~] mkfs.ext4 /dev/sdd1
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
2621440 inodes, 10485760 blocks
524288 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=2157969408
320 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
- 删除某个目录
[root@idys1 ~] ls -d /guest_image*
/guest_images
[root@idys1 ~] ls /guest_images/
[root@idys1 ~] rm -rf /guest_images/
- 用
virt-manager
创建基于分区的存储池
- 第一步
- 第二步
- 第三步
- 查看创建的信息
[root@idys1 ~] virsh pool-list 名称 状态 自动开始
-------------------------------------------default 活动 是 guest_images_fs 活动 是 iso 活动 是 virtio_dir 活动 是 vm 活动 是
[root@idys1 ~] virsh pool-info guest_images_fs
名称: guest_images_fs
UUID: 2a0c9588-e3bd-4d8d-b5af-59776de735c2
状态: running
持久: 是
自动启动: 是
容量: 39.25 GiB
分配: 48.02 MiB
可用: 39.20 GiB
- 查看新存储池的
xml
文档
[root@idys1 ~] cat /etc/libvirt/storage/guest_images_fs.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_fs
or other application using the libvirt API.
--><pool type='fs'><name>guest_images_fs</name><uuid>2a0c9588-e3bd-4d8d-b5af-59776de735c2</uuid><capacity unit='bytes'>0</capacity><allocation unit='bytes'>0</allocation><available unit='bytes'>0</available><source><device path='/dev/sdd1'/><format type='auto'/></source><target><path>/guest_images</path></target>
</pool>
- 查看文件夹是否存在和
mount
点是否挂载
[root@idys1 ~] mount | grep /dev/sdd1
/dev/sdd1 on /guest_images type ext4 (rw,nosuid,nodev,noexec,relatime,data=ordered)
- 将
libvirt
服务停止掉,查看是否mount
点的挂载会断开
[root@idys1 ~] systemctl stop libvirtd.service
[root@idys1 ~] ls /guest_images/ # 可以看到 mount 点仍然可以可以访问,没有断开
lost+found
[root@idys1 ~] umount /guest_images # 手动断开挂载点
[root@idys1 ~] ls /guest_images/ # 此时 /dev/sdd1 的内容已经无法访问
[root@idys1 ~]
- 启动
libvirt
服务
[root@idys1 ~] systemctl restart libvirtd.service
[root@idys1 ~] ls /guest_images/ # 可以发现 libvirt 又被自动挂载上去了
lost+found
- 用
virt-manager
关闭、删除这个存储池
- 再来查看这个存储池是否存在
[root@idys1 /] virsh pool-list 名称 状态 自动开始
-------------------------------------------default 活动 是 iso 活动 是 virtio_dir 活动 是 vm 活动 是
- 用
virsh
创建基于分区的存储池,目标文件夹为不存在的文件夹
[root@idys1 /] virsh pool-define-as guest_images_fs fs --source-dev "/dev/sdd1" --target "/guest_images2"
定义池 guest_images_fs
- 查看存储池信息
[root@idys1 /] virsh pool-list --all | column -t
名称 状态 自动开始
-------------------------------------------
default 活动 是
guest_images_fs 不活跃 否
iso 活动 是
virtio_dir 活动 是
vm 活动 是
- 启动存储池
[root@idys1 /] virsh pool-start guest_images_fs
错误:启动池 guest_images_fs 失败
错误:内部错误:子进程(/usr/bin/mount -t auto /dev/sdd1 /guest_images2 -o nodev,nosuid,noexec)意外 退出状态 32: mount: 挂载点 /guest_images2 不存在
因为目标文件夹不存在,所以报错
- 构建存储池
[root@idys1 /] virsh pool-build guest_images_fs
构建池 guest_images_fs
- 再来启动查看存储池
[root@idys1 /] virsh pool-build guest_images_fs
构建池 guest_images_fs[root@idys1 /] ls -d /guest_images* # 构建存储池之后,目录是存在的
/guest_images /guest_images2[root@idys1 /] virsh pool-start guest_images_fs
池 guest_images_fs 已启动[root@idys1 /] virsh pool-info guest_images_fs
名称: guest_images_fs
UUID: 73368013-781d-41f2-a581-46af051ea099
状态: running
持久: 是
自动启动: 否
容量: 39.25 GiB
分配: 48.02 MiB
可用: 39.20 GiB
- 设置存储池的自动启动
[root@idys1 /] virsh pool-autostart guest_images_fs
池 guest_images_fs 标记为自动启动
- 命令行删除存储池
[root@idys1 /] virsh pool-destroy guest_images_fs
销毁池 guest_images_fs[root@idys1 /] virsh pool-delete guest_images_fs
池 guest_images_fs 被删除[root@idys1 /] virsh pool-undefine guest_images_fs
池 guest_images_fs 已经被取消定义
2.5 基于磁盘的存储池
- 准备
xml
文件
vi /tmp/guest_images_disk.xml
<pool type='disk'><name>guest_images_disk</name><source><device path='/dev/sdc'><format type='gpt'></source><target><path>/dev</path></target>
</pool>
- 通过
virsh
创建
virsh pool-define /tmp/guest_images_disk.xml
- 删除之前创建的分区
[root@idys1 /] fdisk /dev/sdd
欢迎使用 fdisk (util-linux 2.23.2)。更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。命令(输入 m 获取帮助):d
已选择分区 1
分区 1 已删除命令(输入 m 获取帮助):p磁盘 /dev/sdd:85.9 GB, 85899345920 字节,167772160 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x74008775设备 Boot Start End Blocks Id System命令(输入 m 获取帮助):w
The partition table has been altered!Calling ioctl() to re-read partition table.
正在同步磁盘。
[root@idys1 /] partprobe
Warning: 无法以读写方式打开 /dev/sr0 (只读文件系统)。/dev/sr0 已按照只读方式打开。[root@idys1 /] fdisk -l /dev/sdd磁盘 /dev/sdd:85.9 GB, 85899345920 字节,167772160 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x74008775设备 Boot Start End Blocks Id System
- 修改
/dev/sdd
的磁盘类型为gpt
[root@idys1 /] parted /dev/sdd
GNU Parted 3.1
使用 /dev/sdd
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel
新的磁盘标签类型? gpt
警告: The existing disk label on /dev/sdd will be destroyed and all data on this disk will be lost. Do you want to continue?
是/Yes/否/No? yes
(parted) quit
信息: You may need to update /etc/fstab.
[root@idys1 /] fdisk -l /dev/sdd
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.磁盘 /dev/sdd:85.9 GB, 85899345920 字节,167772160 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:gpt
Disk identifier: F96CFC18-0055-40FD-B8EE-CEB407F8B888# Start End Size Type Name
- 定义
xml
文件
[root@idys1 /tmp] cat guest_images.xml
<pool type='disk'><name>guest_images_disk</name><source><device path='/dev/sdd'/><format type='gpt'/></source><target><path>/guest_images</path></target>
</pool>
- 基于
xml
文件定义存储池
[root@idys1 /tmp] virsh pool-define guest_images.xml
在 guest_images_disk 中定义池 guest_images.xml
- 查看所有存储池
[root@idys1 /tmp] virsh pool-list --all # 发现存储池定义成功名称 状态 自动开始
-------------------------------------------default 活动 是 guest_images_disk 不活跃 否 iso 活动 是 virtio_dir 活动 是 vm 活动 是
- 启动存储池,同时设置为自启动
[root@idys1 /tmp] virsh pool-start guest_images_disk
池 guest_images_disk 已启动[root@idys1 /tmp] virsh pool-autostart guest_images_disk
池 guest_images_disk 标记为自动启动
[root@idys1 /tmp] virsh pool-info guest_images_disk
名称: guest_images_disk
UUID: 3868dc6e-db23-48f5-8e2c-ea447a871460
状态: running
持久: 是
自动启动: 是
容量: 80.00 GiB
分配: 0.00 B
可用: 80.00 GiB
- 删除存储池
[root@idys1 /tmp] virsh pool-destroy guest_images_disk
销毁池 guest_images_disk
[root@idys1 /tmp] virsh pool-undefine guest_images_disk
池 guest_images_disk 已经被取消定义
2.6 基于 LVM的存储池
- 划分分区,类型为
lvm
[root@idys1 /tmp] fdisk /dev/sdd
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
欢迎使用 fdisk (util-linux 2.23.2)。更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。命令(输入 m 获取帮助):n
分区号 (1-128,默认 1):
第一个扇区 (34-167772126,默认 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-167772126,默认 167772126):+30G
已创建分区 1命令(输入 m 获取帮助):P磁盘 /dev/sdd:85.9 GB, 85899345920 字节,167772160 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:gpt
Disk identifier: F96CFC18-0055-40FD-B8EE-CEB407F8B888# Start End Size Type Name1 2048 62916607 30G Linux filesyste 命令(输入 m 获取帮助):t
已选择分区 1
分区类型(输入 L 列出所有类型):l1 EFI System C12A7328-F81F-11D2-BA4B-00A0C93EC93B2 MBR partition scheme 024DEE41-33E7-11D3-9D69-0008C781F39F3 Intel Fast Flash D3BFE2DE-3DAF-11DF-BA40-E3A556D895934 BIOS boot 21686148-6449-6E6F-744E-6565644546495 Sony boot partition F4019732-066E-4E12-8273-346C5641494F6 Lenovo boot partition BFBFAFE7-A34F-448A-9A5B-6213EB736C227 PowerPC PReP boot 9E1A2D38-C612-4316-AA26-8B49521E5A8B8 ONIE boot 7412F7D5-A156-4B13-81DC-8671749293259 ONIE config D4E6E2CD-4469-46F3-B5CB-1BFF57AFC14910 Microsoft reserved E3C9E316-0B5C-4DB8-817D-F92DF00215AE11 Microsoft basic data EBD0A0A2-B9E5-4433-87C0-68B6B72699C712 Microsoft LDM metadata 5808C8AA-7E8F-42E0-85D2-E1E90434CFB313 Microsoft LDM data AF9B60A0-1431-4F62-BC68-3311714A69AD14 Windows recovery environment DE94BBA4-06D1-4D40-A16A-BFD50179D6AC15 IBM General Parallel Fs 37AFFC90-EF7D-4E96-91C3-2D7AE055B17416 Microsoft Storage Spaces E75CAF8F-F680-4CEE-AFA3-B001E56EFC2D17 HP-UX data 75894C1E-3AEB-11D3-B7C1-7B03A000000018 HP-UX service E2A1E728-32E3-11D6-A682-7B03A000000019 Linux swap 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F20 Linux filesystem 0FC63DAF-8483-4772-8E79-3D69D8477DE421 Linux server data 3B8F8425-20E0-4F3B-907F-1A25A76F98E822 Linux root (x86) 44479540-F297-41B2-9AF7-D131D5F0458A23 Linux root (ARM) 69DAD710-2CE4-4E3C-B16C-21A1D49ABED324 Linux root (x86-64) 4F68BCE3-E8CD-4DB1-96E7-FBCAF984B70925 Linux root (ARM-64) B921B045-1DF0-41C3-AF44-4C6F280D3FAE26 Linux root (IA-64) 993D8D3D-F80E-4225-855A-9DAF8ED7EA9727 Linux reserved 8DA63339-0007-60C0-C436-083AC823090828 Linux home 933AC7E1-2EB4-4F13-B844-0E14E2AEF91529 Linux RAID A19D880F-05FC-4D3B-A006-743F0F84911E30 Linux extended boot BC13C2FF-59E6-4262-A352-B275FD6F717231 Linux LVM E6D6D379-F507-44C2-A23C-238F2A3DF92832 FreeBSD data 516E7CB4-6ECF-11D6-8FF8-00022D09712B33 FreeBSD boot 83BD6B9D-7F41-11DC-BE0B-001560B84F0F34 FreeBSD swap 516E7CB5-6ECF-11D6-8FF8-00022D09712B35 FreeBSD UFS 516E7CB6-6ECF-11D6-8FF8-00022D09712B36 FreeBSD ZFS 516E7CBA-6ECF-11D6-8FF8-00022D09712B37 FreeBSD Vinum 516E7CB8-6ECF-11D6-8FF8-00022D09712B38 Apple HFS/HFS+ 48465300-0000-11AA-AA11-00306543ECAC39 Apple UFS 55465300-0000-11AA-AA11-00306543ECAC40 Apple RAID 52414944-0000-11AA-AA11-00306543ECAC41 Apple RAID offline 52414944-5F4F-11AA-AA11-00306543ECAC42 Apple boot 426F6F74-0000-11AA-AA11-00306543ECAC43 Apple label 4C616265-6C00-11AA-AA11-00306543ECAC44 Apple TV recovery 5265636F-7665-11AA-AA11-00306543ECAC45 Apple Core storage 53746F72-6167-11AA-AA11-00306543ECAC46 Solaris boot 6A82CB45-1DD2-11B2-99A6-08002073663147 Solaris root 6A85CF4D-1DD2-11B2-99A6-08002073663148 Solaris /usr & Apple ZFS 6A898CC3-1DD2-11B2-99A6-08002073663149 Solaris swap 6A87C46F-1DD2-11B2-99A6-08002073663150 Solaris backup 6A8B642B-1DD2-11B2-99A6-08002073663151 Solaris /var 6A8EF2E9-1DD2-11B2-99A6-08002073663152 Solaris /home 6A90BA39-1DD2-11B2-99A6-08002073663153 Solaris alternate sector 6A9283A5-1DD2-11B2-99A6-08002073663154 Solaris reserved 1 6A945A3B-1DD2-11B2-99A6-08002073663155 Solaris reserved 2 6A9630D1-1DD2-11B2-99A6-08002073663156 Solaris reserved 3 6A980767-1DD2-11B2-99A6-08002073663157 Solaris reserved 4 6A96237F-1DD2-11B2-99A6-08002073663158 Solaris reserved 5 6A8D2AC7-1DD2-11B2-99A6-08002073663159 NetBSD swap 49F48D32-B10E-11DC-B99B-0019D187964860 NetBSD FFS 49F48D5A-B10E-11DC-B99B-0019D187964861 NetBSD LFS 49F48D82-B10E-11DC-B99B-0019D187964862 NetBSD concatenated 2DB519C4-B10E-11DC-B99B-0019D187964863 NetBSD encrypted 2DB519EC-B10E-11DC-B99B-0019D187964864 NetBSD RAID 49F48DAA-B10E-11DC-B99B-0019D187964865 ChromeOS kernel FE3A2A5D-4F32-41A7-B725-ACCC3285A30966 ChromeOS root fs 3CB8E202-3B7E-47DD-8A3C-7FF2A13CFCEC67 ChromeOS reserved 2E0A753D-9E48-43B0-8337-B15192CB1B5E68 MidnightBSD data 85D5E45A-237C-11E1-B4B3-E89A8F7FC3A769 MidnightBSD boot 85D5E45E-237C-11E1-B4B3-E89A8F7FC3A770 MidnightBSD swap 85D5E45B-237C-11E1-B4B3-E89A8F7FC3A771 MidnightBSD UFS 0394EF8B-237E-11E1-B4B3-E89A8F7FC3A772 MidnightBSD ZFS 85D5E45D-237C-11E1-B4B3-E89A8F7FC3A773 MidnightBSD Vinum 85D5E45C-237C-11E1-B4B3-E89A8F7FC3A774 Ceph Journal 45B0969E-9B03-4F30-B4C6-B4B80CEFF10675 Ceph Encrypted Journal 45B0969E-9B03-4F30-B4C6-5EC00CEFF10676 Ceph OSD 4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D77 Ceph crypt OSD 4FBD7E29-9D25-41B8-AFD0-5EC00CEFF05D78 Ceph disk in creation 89C57F98-2FE5-4DC0-89C1-F3AD0CEFF2BE79 Ceph crypt disk in creation 89C57F98-2FE5-4DC0-89C1-5EC00CEFF2BE80 OpenBSD data 824CC7A0-36A8-11E3-890A-952519AD3F6181 QNX6 file system CEF5A9AD-73BC-4601-89F3-CDEEEEE321A182 Plan 9 partition C91818F9-8025-47AF-89D2-F030D7000C2C分区类型(输入 L 列出所有类型):31
已将分区“Linux filesystem”的类型更改为“Linux LVM”命令(输入 m 获取帮助):p磁盘 /dev/sdd:85.9 GB, 85899345920 字节,167772160 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:gpt
Disk identifier: F96CFC18-0055-40FD-B8EE-CEB407F8B888# Start End Size Type Name1 2048 62916607 30G Linux LVM 命令(输入 m 获取帮助):w
The partition table has been altered!Calling ioctl() to re-read partition table.
正在同步磁盘。
- 创建
PV
[root@idys1 /tmp] pvcreate /dev/sdd1
WARNING: ext4 signature detected on /dev/sdd1 at offset 1080. Wipe it? [y/n]: yWiping ext4 signature on /dev/sdd1.Physical volume "/dev/sdd1" successfully created.
- 查看
PV
详情
[root@idys1 /tmp] pvscan PV /dev/sda2 VG centos lvm2 [<19.51 GiB / 0 free]PV /dev/sdc1 VG centos lvm2 [<50.00 GiB / <20.04 GiB free]PV /dev/sdb1 VG vmvg lvm2 [<80.00 GiB / 0 free]PV /dev/sdd1 lvm2 [30.00 GiB]Total: 4 [179.50 GiB] / in use: 3 [149.50 GiB] / in no VG: 1 [30.00 GiB]
[root@idys1 /tmp] pvdisplay /dev/sdd1"/dev/sdd1" is a new physical volume of "30.00 GiB"--- NEW Physical volume ---PV Name /dev/sdd1VG Name PV Size 30.00 GiBAllocatable NOPE Size 0 Total PE 0Free PE 0Allocated PE 0PV UUID qpoDjx-xKWj-FcY8-cbXc-dlmd-55Uc-ShlSrI
- 创建
VG
[root@idys1 /tmp] vgcreate guest_imagesNo command with matching syntax recognised. Run 'vgcreate --help' for more information.Correct command syntax is:vgcreate VG_new PV ...
- 查看
VG
[root@idys1 /tmp] vgscanReading volume groups from cache.Found volume group "guest_images_lvm" using metadata type lvm2Found volume group "centos" using metadata type lvm2Found volume group "vmvg" using metadata type lvm2
[root@idys1 /tmp] vgdisplay guest_images_lvm--- Volume group ---VG Name guest_images_lvmSystem ID Format lvm2Metadata Areas 1Metadata Sequence No 1VG Access read/writeVG Status resizableMAX LV 0Cur LV 0Open LV 0Max PV 0Cur PV 1Act PV 1VG Size <30.00 GiBPE Size 4.00 MiBTotal PE 7679Alloc PE / Size 0 / 0 Free PE / Size 7679 / <30.00 GiBVG UUID OOzbjM-chBX-ewwB-8zUT-5cu2-dWAI-331Pks
- 实验
virt-manager
创建基于lvm
的存储池
- 按照图中所示创建,点击完成
- 查看储存池
[root@idys1 /tmp] virsh pool-list 名称 状态 自动开始
-------------------------------------------default 活动 是 guest_images_lvm 活动 是 iso 活动 是 virtio_dir 活动 是 vm 活动 是 [root@idys1 /tmp] virsh pool-info guest_images_lvm
名称: guest_images_lvm
UUID: 8da1dca2-9c82-49fb-868d-086f25818aea
状态: running
持久: 是
自动启动: 是
容量: 30.00 GiB
分配: 0.00 B
可用: 30.00 GiB
可以看到创建成功
- 删除存储池
- 查看存储池,可与看到存储池已经不存在了
[root@idys1 /tmp] virsh pool-list --all名称 状态 自动开始
-------------------------------------------default 活动 是 iso 活动 是 virtio_dir 活动 是 vm 活动 是
- 删除
vg
、pv
,分区
[root@idys1 /tmp] vgremove guest_images_lvmVolume group "guest_images_lvm" successfully removed
[root@idys1 /tmp] pvscan PV /dev/sda2 VG centos lvm2 [<19.51 GiB / 0 free]PV /dev/sdc1 VG centos lvm2 [<50.00 GiB / <20.04 GiB free]PV /dev/sdb1 VG vmvg lvm2 [<80.00 GiB / 0 free]PV /dev/sdd1 lvm2 [30.00 GiB]Total: 4 [179.50 GiB] / in use: 3 [149.50 GiB] / in no VG: 1 [30.00 GiB]
[root@idys1 /tmp] pvremove /dev/sdd1Labels on physical volume "/dev/sdd1" successfully wiped.[root@idys1 /tmp] fdisk /dev/sdd
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
欢迎使用 fdisk (util-linux 2.23.2)。更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。命令(输入 m 获取帮助):d
已选择分区 1
分区 1 已删除命令(输入 m 获取帮助):p磁盘 /dev/sdd:85.9 GB, 85899345920 字节,167772160 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:gpt
Disk identifier: F96CFC18-0055-40FD-B8EE-CEB407F8B888# Start End Size Type Name命令(输入 m 获取帮助):w
The partition table has been altered!Calling ioctl() to re-read partition table.
正在同步磁盘。
既是没有创建分区、
pv
、vg
也可以直接构建首先使用
virt-manager
构建首先创建一个
LVM
分区
[root@idys1 /] fdisk /dev/sdd
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
欢迎使用 fdisk (util-linux 2.23.2)。更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。命令(输入 m 获取帮助):n
分区号 (1-128,默认 1):
第一个扇区 (34-167772126,默认 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-167772126,默认 167772126):+30G
已创建分区 1命令(输入 m 获取帮助):P磁盘 /dev/sdd:85.9 GB, 85899345920 字节,167772160 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:gpt
Disk identifier: F96CFC18-0055-40FD-B8EE-CEB407F8B888# Start End Size Type Name1 2048 62916607 30G Linux filesyste 命令(输入 m 获取帮助):T
已选择分区 1
分区类型(输入 L 列出所有类型):l1 EFI System C12A7328-F81F-11D2-BA4B-00A0C93EC93B2 MBR partition scheme 024DEE41-33E7-11D3-9D69-0008C781F39F3 Intel Fast Flash D3BFE2DE-3DAF-11DF-BA40-E3A556D895934 BIOS boot 21686148-6449-6E6F-744E-6565644546495 Sony boot partition F4019732-066E-4E12-8273-346C5641494F6 Lenovo boot partition BFBFAFE7-A34F-448A-9A5B-6213EB736C227 PowerPC PReP boot 9E1A2D38-C612-4316-AA26-8B49521E5A8B8 ONIE boot 7412F7D5-A156-4B13-81DC-8671749293259 ONIE config D4E6E2CD-4469-46F3-B5CB-1BFF57AFC14910 Microsoft reserved E3C9E316-0B5C-4DB8-817D-F92DF00215AE11 Microsoft basic data EBD0A0A2-B9E5-4433-87C0-68B6B72699C712 Microsoft LDM metadata 5808C8AA-7E8F-42E0-85D2-E1E90434CFB313 Microsoft LDM data AF9B60A0-1431-4F62-BC68-3311714A69AD14 Windows recovery environment DE94BBA4-06D1-4D40-A16A-BFD50179D6AC15 IBM General Parallel Fs 37AFFC90-EF7D-4E96-91C3-2D7AE055B17416 Microsoft Storage Spaces E75CAF8F-F680-4CEE-AFA3-B001E56EFC2D17 HP-UX data 75894C1E-3AEB-11D3-B7C1-7B03A000000018 HP-UX service E2A1E728-32E3-11D6-A682-7B03A000000019 Linux swap 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F20 Linux filesystem 0FC63DAF-8483-4772-8E79-3D69D8477DE421 Linux server data 3B8F8425-20E0-4F3B-907F-1A25A76F98E822 Linux root (x86) 44479540-F297-41B2-9AF7-D131D5F0458A23 Linux root (ARM) 69DAD710-2CE4-4E3C-B16C-21A1D49ABED324 Linux root (x86-64) 4F68BCE3-E8CD-4DB1-96E7-FBCAF984B70925 Linux root (ARM-64) B921B045-1DF0-41C3-AF44-4C6F280D3FAE26 Linux root (IA-64) 993D8D3D-F80E-4225-855A-9DAF8ED7EA9727 Linux reserved 8DA63339-0007-60C0-C436-083AC823090828 Linux home 933AC7E1-2EB4-4F13-B844-0E14E2AEF91529 Linux RAID A19D880F-05FC-4D3B-A006-743F0F84911E30 Linux extended boot BC13C2FF-59E6-4262-A352-B275FD6F717231 Linux LVM E6D6D379-F507-44C2-A23C-238F2A3DF92832 FreeBSD data 516E7CB4-6ECF-11D6-8FF8-00022D09712B33 FreeBSD boot 83BD6B9D-7F41-11DC-BE0B-001560B84F0F34 FreeBSD swap 516E7CB5-6ECF-11D6-8FF8-00022D09712B35 FreeBSD UFS 516E7CB6-6ECF-11D6-8FF8-00022D09712B36 FreeBSD ZFS 516E7CBA-6ECF-11D6-8FF8-00022D09712B37 FreeBSD Vinum 516E7CB8-6ECF-11D6-8FF8-00022D09712B38 Apple HFS/HFS+ 48465300-0000-11AA-AA11-00306543ECAC39 Apple UFS 55465300-0000-11AA-AA11-00306543ECAC40 Apple RAID 52414944-0000-11AA-AA11-00306543ECAC41 Apple RAID offline 52414944-5F4F-11AA-AA11-00306543ECAC42 Apple boot 426F6F74-0000-11AA-AA11-00306543ECAC43 Apple label 4C616265-6C00-11AA-AA11-00306543ECAC44 Apple TV recovery 5265636F-7665-11AA-AA11-00306543ECAC45 Apple Core storage 53746F72-6167-11AA-AA11-00306543ECAC46 Solaris boot 6A82CB45-1DD2-11B2-99A6-08002073663147 Solaris root 6A85CF4D-1DD2-11B2-99A6-08002073663148 Solaris /usr & Apple ZFS 6A898CC3-1DD2-11B2-99A6-08002073663149 Solaris swap 6A87C46F-1DD2-11B2-99A6-08002073663150 Solaris backup 6A8B642B-1DD2-11B2-99A6-08002073663151 Solaris /var 6A8EF2E9-1DD2-11B2-99A6-08002073663152 Solaris /home 6A90BA39-1DD2-11B2-99A6-08002073663153 Solaris alternate sector 6A9283A5-1DD2-11B2-99A6-08002073663154 Solaris reserved 1 6A945A3B-1DD2-11B2-99A6-08002073663155 Solaris reserved 2 6A9630D1-1DD2-11B2-99A6-08002073663156 Solaris reserved 3 6A980767-1DD2-11B2-99A6-08002073663157 Solaris reserved 4 6A96237F-1DD2-11B2-99A6-08002073663158 Solaris reserved 5 6A8D2AC7-1DD2-11B2-99A6-08002073663159 NetBSD swap 49F48D32-B10E-11DC-B99B-0019D187964860 NetBSD FFS 49F48D5A-B10E-11DC-B99B-0019D187964861 NetBSD LFS 49F48D82-B10E-11DC-B99B-0019D187964862 NetBSD concatenated 2DB519C4-B10E-11DC-B99B-0019D187964863 NetBSD encrypted 2DB519EC-B10E-11DC-B99B-0019D187964864 NetBSD RAID 49F48DAA-B10E-11DC-B99B-0019D187964865 ChromeOS kernel FE3A2A5D-4F32-41A7-B725-ACCC3285A30966 ChromeOS root fs 3CB8E202-3B7E-47DD-8A3C-7FF2A13CFCEC67 ChromeOS reserved 2E0A753D-9E48-43B0-8337-B15192CB1B5E68 MidnightBSD data 85D5E45A-237C-11E1-B4B3-E89A8F7FC3A769 MidnightBSD boot 85D5E45E-237C-11E1-B4B3-E89A8F7FC3A770 MidnightBSD swap 85D5E45B-237C-11E1-B4B3-E89A8F7FC3A771 MidnightBSD UFS 0394EF8B-237E-11E1-B4B3-E89A8F7FC3A772 MidnightBSD ZFS 85D5E45D-237C-11E1-B4B3-E89A8F7FC3A773 MidnightBSD Vinum 85D5E45C-237C-11E1-B4B3-E89A8F7FC3A774 Ceph Journal 45B0969E-9B03-4F30-B4C6-B4B80CEFF10675 Ceph Encrypted Journal 45B0969E-9B03-4F30-B4C6-5EC00CEFF10676 Ceph OSD 4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D77 Ceph crypt OSD 4FBD7E29-9D25-41B8-AFD0-5EC00CEFF05D78 Ceph disk in creation 89C57F98-2FE5-4DC0-89C1-F3AD0CEFF2BE79 Ceph crypt disk in creation 89C57F98-2FE5-4DC0-89C1-5EC00CEFF2BE80 OpenBSD data 824CC7A0-36A8-11E3-890A-952519AD3F6181 QNX6 file system CEF5A9AD-73BC-4601-89F3-CDEEEEE321A182 Plan 9 partition C91818F9-8025-47AF-89D2-F030D7000C2C分区类型(输入 L 列出所有类型):31
已将分区“Linux filesystem”的类型更改为“Linux LVM”命令(输入 m 获取帮助):w
The partition table has been altered!Calling ioctl() to re-read partition table.
正在同步磁盘。
- 查看存储池
[root@idys1 /] virsh pool-list --all名称 状态 自动开始
-------------------------------------------default 活动 是 guest_images_lvm2 活动 是 iso 活动 是 virtio_dir 活动 是 vm 活动 是 [root@idys1 /] virsh pool-info guest_images_lvm2
名称: guest_images_lvm2
UUID: 7ad5eed2-2b24-460a-8166-4e2aac7e3179
状态: running
持久: 是
自动启动: 是
容量: 30.00 GiB
分配: 0.00 B
可用: 30.00 GiB
- 查看
lvm
创建详情
[root@idys1 /] pvscan PV /dev/sda2 VG centos lvm2 [<19.51 GiB / 0 free]PV /dev/sdc1 VG centos lvm2 [<50.00 GiB / <20.04 GiB free]PV /dev/sdb1 VG vmvg lvm2 [<80.00 GiB / 0 free]PV /dev/sdd1 VG guest_images_lvm2 lvm2 [<30.00 GiB / <30.00 GiB free]Total: 4 [<179.50 GiB] / in use: 4 [<179.50 GiB] / in no VG: 0 [0 ]
[root@idys1 /] vgscan Reading volume groups from cache.Found volume group "centos" using metadata type lvm2Found volume group "vmvg" using metadata type lvm2Found volume group "guest_images_lvm2" using metadata type lvm2
- 继续删除存储池
[root@idys1 /] virsh pool-destroy guest_images_lvm2
销毁池 guest_images_lvm2[root@idys1 /] virsh pool-delete guest_images_lvm2
池 guest_images_lvm2 被删除[root@idys1 /] virsh pool-undefine guest_images_lvm2
池 guest_images_lvm2 已经被取消定义
- 删除分区
[root@idys1 /] fdisk /dev/sdd
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
欢迎使用 fdisk (util-linux 2.23.2)。更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。命令(输入 m 获取帮助):d
已选择分区 1
分区 1 已删除命令(输入 m 获取帮助):w
The partition table has been altered!Calling ioctl() to re-read partition table.
正在同步磁盘。
[root@idys1 /] fdisk -l /dev/sdd
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.磁盘 /dev/sdd:85.9 GB, 85899345920 字节,167772160 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:gpt
Disk identifier: F96CFC18-0055-40FD-B8EE-CEB407F8B888# Start End Size Type Name
- 利用命令行创建分区
# 前面已经创建过 /dev/sdd1 的lvm分区
[root@idys1 /] virsh pool-define-as guest_images_lvm logical --source-dev=/dev/sdd1 --source-name=libvirt_lvm --target=/guest_images_lvm
定义池 guest_images_lvm
[root@idys1 /] virsh pool-build guest_images_lvm
构建池 guest_images_lvm # 构建lvm存储池[root@idys1 /] virsh pool-start guest_images_lvm #启动lvm存储池
池 guest_images_lvm 已启动[root@idys1 /] virsh pool-autostart guest_images_lvm #设置存储池的自动启动
池 guest_images_lvm 标记为自动启动
--source-name=libvirt_lvm
代表vg
名称
- 查看存储池信息
[root@idys1 /] virsh pool-list --all名称 状态 自动开始
-------------------------------------------default 活动 是 guest_images_lvm 活动 是 iso 活动 是 virtio_dir 活动 是 vm 活动 是 [root@idys1 /] virsh pool-info guest_images_lvm
名称: guest_images_lvm
UUID: a994c0c3-0796-4df1-83ec-bbcf09b39265
状态: running
持久: 是
自动启动: 是
容量: 30.00 GiB
分配: 0.00 B
可用: 30.00 GiB
- 创建存储池
[root@idys1 /etc/yum.repos.d] virsh pool-destroy guest_images_lvm
销毁池 guest_images_lvm[root@idys1 /etc/yum.repos.d] virsh pool-delete guest_images_lvm
池 guest_images_lvm 被删除[root@idys1 /etc/yum.repos.d] virsh pool-undefine guest_images_lvm
池 guest_images_lvm 已经被取消定义[root@idys1 /etc/yum.repos.d] virsh pool-list 名称 状态 自动开始
-------------------------------------------default 活动 是 iso 活动 是 virtio_dir 活动 是 vm 活动 是 [root@idys1 /etc/yum.repos.d] pvscanPV /dev/sda2 VG centos lvm2 [<19.51 GiB / 0 free]PV /dev/sdc1 VG centos lvm2 [<50.00 GiB / <20.04 GiB free]PV /dev/sdb1 VG vmvg lvm2 [<80.00 GiB / 0 free]Total: 3 [149.50 GiB] / in use: 3 [149.50 GiB] / in no VG: 0 [0 ]
[root@idys1 /etc/yum.repos.d] vgscanReading volume groups from cache.Found volume group "centos" using metadata type lvm2Found volume group "vmvg" using metadata type lvm2
- 删除分区
[root@idys1 /etc/yum.repos.d] fdisk /dev/sdd
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
欢迎使用 fdisk (util-linux 2.23.2)。更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。命令(输入 m 获取帮助):d
已选择分区 1
分区 1 已删除命令(输入 m 获取帮助):p磁盘 /dev/sdd:85.9 GB, 85899345920 字节,167772160 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:gpt
Disk identifier: F96CFC18-0055-40FD-B8EE-CEB407F8B888# Start End Size Type Name命令(输入 m 获取帮助):w
The partition table has been altered!Calling ioctl() to re-read partition table.
正在同步磁盘。
[root@idys1 /etc/yum.repos.d] partprobe
Warning: 无法以读写方式打开 /dev/sr0 (只读文件系统)。/dev/sr0 已按照只读方式打开。
2.7 iscsi
存储池
2.7.1 基本概念
在
SAN
中,主机一般是Initator
,存储设备则是Target
Initiator
SCSI
会话的发起方- 向
Target
请求LUN
,并将数据的读写指令发送给Target
Target
- 接受
scsi
会话的一方 - 它接受来自
initiator
的指令,为Initiator
提供LUN
,并实现对LUN
的读写
- 接受
2.7.2 Linux-IO Target概述
http://linux-iscsi.org/wiki/Main Page
Linux-IO Target
在Linux
内核,用软件实现各种SCSI Target
前端
FC
、FCoE
、iSCSI
、1394
、InfiniBand
、USB
、vHost
后端:
SATA
、SAS
、SCSI
、SSD
、FLASH
、USB
、ramdisk
…
架构
- 支持
SSE4.2
高性能、多线程 - 支持
x86
、ia64
、Alpha
、Cell
、PPC
、ARM
、MIPS
等多种CPU
- 支持高可用,负载
- 支持
2.7.3 实验环境准备:安装linux的存储服务器
- 最小化安装的
linux
- 安装
targetcli
软件包
yum -y install targetcli
使用
targetcli
配置存储kickstart
应答文件配置
auth --enableshadow --passalgo=sha512
cdrom
text
firstboot --enable
ignoredisk --only-use=vda
keyboard --vckeymap=us --xlayouts='us'
lang en_US.UTF-8
network --onboot yes --bootproto dhcp --noipv6
network --hostname=idys3.com
rootpw 123456
firewall --disable
selinux --disable
timezone --utc Asia/Shanghai
bootloader --location=mbr --boot-drive=vda
autopart --type=lvm
clearpart --none --initlabel
reboot
@packages
@core
@base
net-tools
%end
- 系统详情
[root@idys1 ~] uname -a
Linux idys1.com 3.10.0-1127.19.1.el7.x86_64 #1 SMP Tue Aug 25 17:23:54 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
[root@idys1 ~] cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)
- 本地
yum
配置文件的基本编写
# vi CentOS-local.repo
[localcdrom]
name=CentOS-$releaserver - Local CDROM
baseurl=file://mnt/cdrom
gpgcheck=0
enabled=1 # 该项如果没有的话,默认就是 enabled=1
- 安装
targetcli
[root@idys1 /etc/yum.repos.d] yum -y install targetcli
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
软件包 targetcli-2.1.fb49-1.el7.noarch 已安装并且是最新版本
无须任何处理
- 进入
targetcli
的交互模式
[root@idys1 /etc/yum.repos.d] targetcli
Warning: Could not load preferences file /root/.targetcli/prefs.bin.
targetcli shell version 2.1.fb49
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'./> helpGENERALITIES
============
This is a shell in which you can create, delete and configure
configuration objects.The available commands depend on the current path or target
path you want to run a command in: different path have
different sets of available commands, i.e. a path pointing at
an iscsi target will not have the same availaible commands as,
say, a path pointing at a storage object.The prompt that starts each command line indicates your
current path. Alternatively (useful if the prompt displays
an abbreviated path to save space), you can run the
pwd command to display the complete current path.Navigating the tree is done using the cd command. Without
any argument, cd will present you with the full objects
tree. Just use arrows to select the destination path, and
enter will get you there. Please try help cd for navigation
tips.COMMAND SYNTAX
==============
Commands are built using the following syntax:[TARGET_PATH] COMMAND_NAME [OPTIONS]The TARGET_PATH indicates the path to run the command from.
If ommited, the command will be run from your current path.The OPTIONS depend on the command. Please use help
COMMAND to get more information.AVAILABLE COMMANDS
==================
The following commands are available in the
current path:- bookmarks action [bookmark] - cd [path] - clearconfig [confirm] - exit - get [group] [parameter...] - help [topic] - ls [path] [depth] - pwd - refresh - restoreconfig [savefile] [clear_existing] - saveconfig [savefile] - sessions [action] [sid] - set [group] [parameter=value...] - status - version
- 退出命令
/> exit
Global pref auto_save_on_exit=true
Configuration saved to /etc/target/saveconfig.json
- 查看目录树
/> ls
o- / ......................................................................................................................... [...]o- backstores .............................................................................................................. [...]| o- block .................................................................................................. [Storage Objects: 0]| o- fileio ................................................................................................. [Storage Objects: 0]| o- pscsi .................................................................................................. [Storage Objects: 0]| o- ramdisk ................................................................................................ [Storage Objects: 0]o- iscsi ............................................................................................................ [Targets: 0]o- loopback ......................................................................................................... [Targets: 0]
- 进入目录树查看
/> cd iscsi
/iscsi> ls
o- iscsi .............................................................................................................. [Targets: 0]
2.7.4 配置target
- 创建存储对象
- 创建块存储对象
create block1 dev=/dev/vdb1
- 创建
fileio
对象create fileio1 /foo.img 50M
- 创建
ramdisk
对象create ramdisk1 1M
- 创建块存储对象
- 创建
iSSCI Target
create iqn.2010-05.org.linuxplus.srv1:stor1
- 配置
target portal group(TPG)
- 配置
portals
- 配置
LUN
:添加块设备,ramdisk
、fileio
三个LUN
- 配置
ACL
- 查看
iSCSI initiator
查看其IQN
- 为每个
initiator
创建ACL
- 查看
- 配置
- 保存配置
- 设置
target
服务为自动启动 - 检查配置
- 为
/dev/sdd
设备创建分区
[root@idys1 /etc/yum.repos.d] fdisk /dev/sdd
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
欢迎使用 fdisk (util-linux 2.23.2)。更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。命令(输入 m 获取帮助):n
分区号 (1-128,默认 1):
第一个扇区 (34-167772126,默认 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-167772126,默认 167772126):
已创建分区 1命令(输入 m 获取帮助):p磁盘 /dev/sdd:85.9 GB, 85899345920 字节,167772160 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:gpt
Disk identifier: F96CFC18-0055-40FD-B8EE-CEB407F8B888# Start End Size Type Name1 2048 167772126 80G Linux filesyste 命令(输入 m 获取帮助):w
The partition table has been altered!Calling ioctl() to re-read partition table.
正在同步磁盘。
- 查看
/dev/sdd
这个硬盘
[root@idys1 /etc/yum.repos.d] fdisk -l /dev/sdd
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.磁盘 /dev/sdd:85.9 GB, 85899345920 字节,167772160 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:gpt
Disk identifier: F96CFC18-0055-40FD-B8EE-CEB407F8B888# Start End Size Type Name1 2048 167772126 80G Linux filesyste
- 使用
targetcli
进入到存储目录树里面
[root@idys1 /etc/yum.repos.d] targetcli
targetcli shell version 2.1.fb49
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'./iscsi> cd /
/> ls
o- / ......................................................................................................................... [...]o- backstores .............................................................................................................. [...]| o- block .................................................................................................. [Storage Objects: 0]| o- fileio ................................................................................................. [Storage Objects: 0]| o- pscsi .................................................................................................. [Storage Objects: 0]| o- ramdisk ................................................................................................ [Storage Objects: 0]o- iscsi ............................................................................................................ [Targets: 0]o- loopback ......................................................................................................... [Targets: 0]
/> cd backstores/
/backstores> ls
o- backstores ................................................................................................................ [...]o- block .................................................................................................... [Storage Objects: 0]o- fileio ................................................................................................... [Storage Objects: 0]o- pscsi .................................................................................................... [Storage Objects: 0]o- ramdisk .................................................................................................. [Storage Objects: 0]
/backstores> cd block
/backstores/block> ls
o- block ...................................................................................................... [Storage Objects: 0]
- 查看
create
帮助
/backstores/block> help createSYNTAX
======
create name dev [readonly] [wwn] DESCRIPTION
===========Creates an Block Storage object. dev is the path to the TYPE_DISK
block device to use.
- 使用
create
创建块设备存储
/backstores/block> create block1 dev=/dev/sdd1
Created block storage object block1 using /dev/sdd1.
/backstores/block> ls
o- block ...................................................................................................... [Storage Objects: 1]o- block1 ........................................................................... [/dev/sdd1 (80.0GiB) write-thru deactivated]o- alua ....................................................................................................... [ALUA Groups: 1]o- default_tg_pt_gp ........................................................................... [ALUA state: Active/optimized]
- 使用
filoio
作为存储
/backstores/block> cd /backstores/fileio
/backstores/fileio> ls
o- fileio ..................................................................................................... [Storage Objects: 0]
/backstores/fileio> create fileio1 /tmp/foo1.img 50M
Created fileio fileio1 with size 52428800
此时会在
/tmp/
目录下创建foo1.img
,大小为50M
- 查看文件是否存在
[root@idys1 ~] ls /tmp/foo1.img
/tmp/foo1.img
[root@idys1 ~] file /tmp/foo1.img # 查看文件类型
/tmp/foo1.img: data
- 可以查看文件实际占用大小可表面占用大小
[root@idys1 /tmp] ls -lhF foo1.img
-rw-r--r-- 1 root root 50M 10月 31 03:41 foo1.img
[root@idys1 /tmp] du -sh foo1.img
0 foo1.img
- 根据内存创建存储(
ramdisk
)
/backstores/ramdisk> create ramdisk1 1M # 创建 内存的存储 ,大小为 1M
Created ramdisk ramdisk1 with size 1M.
/backstores/ramdisk> ls
o- ramdisk .................................................................................................... [Storage Objects: 1]o- ramdisk1 ............................................................................................... [(1.0MiB) deactivated]o- alua ....................................................................................................... [ALUA Groups: 1]o- default_tg_pt_gp ........................................................................... [ALUA state: Active/optimized]
- 创建
iscsi Target
存储
/iscsi> create iqn.2020-10.com.idys.srv1:tomstor1
Created target iqn.2020-10.com.idys.srv1:tomstor1.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.
- 查看如何创建
portals
/iscsi> ls
o- iscsi .............................................................................................................. [Targets: 1]o- iqn.2020-10.com.idys.srv1:tomstor1 .................................................................................. [TPGs: 1]o- tpg1 ................................................................................................. [no-gen-acls, no-auth]o- acls ............................................................................................................ [ACLs: 0]o- luns ............................................................................................................ [LUNs: 0]o- portals ...................................................................................................... [Portals: 1]o- 0.0.0.0:3260 ....................................................................................................... [OK]
/iscsi> cd iqn.2020-10.com.idys.srv1:tomstor1/tpg1/portals/
/iscsi/iqn.20.../tpg1/portals> help createSYNTAX
======
create [ip_address] [ip_port] DESCRIPTION
===========Creates a Network Portal with specified ip_address and
ip_port. If ip_port is omitted, the default port for
the target fabric will be used. If ip_address is omitted,
INADDR_ANY (0.0.0.0) will be used.Choosing IN6ADDR_ANY (::0) will listen on all IPv6 interfaces
as well as IPv4, assuming IPV6_V6ONLY sockopt has not been
set.Note: Portals on Link-local IPv6 addresses are currently not
supported.SEE ALSO
========
delete
- 创建
luns
/iscsi/iqn.20...or1/tpg1/luns> create /backstores/block/block1
Created LUN 0.
/iscsi/iqn.20...or1/tpg1/luns> create /backstores/fileio/fileio1
Created LUN 1.
/iscsi/iqn.20...or1/tpg1/luns> create /backstores/ramdisk/ramdisk1
Created LUN 2.
基于前面的
block
、fileio
、ramdisk
创建LUN1
、LUN1
、LUN2
- 另外开启一台主机作为
initiator
,其ip
地址为192.168.1.150
,为其安装iscsi-initiator-utils
包
[root@master ~] yum -y install iscsi-initiator-utils
- 查看这台主机的
initiator
[root@master ~] cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.1994-05.com.redhat:2596a1841fd
- 设置
initiator
冒号后面的字段,让其更加有价值
[root@master ~] cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.1994-05.com.redhat:2596a1841fd
[root@master ~] vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.1994-05.com.redhat:tomkvm1
- 为
initiator
创建ACL
/iscsi/iqn.20...or1/tpg1/acls> create iqn.1994-05.com.redhat:tomkvm1 # 为其赋予 访问 LUN1 LUN2 LUN0 的访问权限
Created Node ACL for iqn.1994-05.com.redhat:tomkvm1
Created mapped LUN 2.
Created mapped LUN 1.
Created mapped LUN 0.
- 保存配置
/iscsi/iqn.20...or1/tpg1/acls> cd /
/> saveconfig
Configuration saved to /etc/target/saveconfig.json
- 设置开机自启动
[root@idys1 /etc/yum.repos.d] systemctl enable target.service
Created symlink from /etc/systemd/system/multi-user.target.wants/target.service to /usr/lib/systemd/system/target.service.
- 重启服务
[root@idys1 /etc/yum.repos.d] systemctl restart target.service
- 看重启服务之后,配置是否存在
/> ls
o- / ......................................................................................................................... [...]o- backstores .............................................................................................................. [...]| o- block .................................................................................................. [Storage Objects: 1]| | o- block1 ......................................................................... [/dev/sdd1 (80.0GiB) write-thru activated]| | o- alua ................................................................................................... [ALUA Groups: 1]| | o- default_tg_pt_gp ....................................................................... [ALUA state: Active/optimized]| o- fileio ................................................................................................. [Storage Objects: 1]| | o- fileio1 .................................................................... [/tmp/foo1.img (50.0MiB) write-back activated]| | o- alua ................................................................................................... [ALUA Groups: 1]| | o- default_tg_pt_gp ....................................................................... [ALUA state: Active/optimized]| o- pscsi .................................................................................................. [Storage Objects: 0]| o- ramdisk ................................................................................................ [Storage Objects: 1]| o- ramdisk1 ............................................................................................. [(1.0MiB) activated]| o- alua ................................................................................................... [ALUA Groups: 1]| o- default_tg_pt_gp ....................................................................... [ALUA state: Active/optimized]o- iscsi ............................................................................................................ [Targets: 1]| o- iqn.2020-10.com.idys.srv1:tomstor1 ................................................................................ [TPGs: 1]| o- tpg1 ............................................................................................... [no-gen-acls, no-auth]| o- acls .......................................................................................................... [ACLs: 1]| | o- iqn.1994-05.com.redhat:tomkvm1 ....................................................................... [Mapped LUNs: 3]| | o- mapped_lun0 ................................................................................ [lun0 block/block1 (rw)]| | o- mapped_lun1 .............................................................................. [lun1 fileio/fileio1 (rw)]| | o- mapped_lun2 ............................................................................ [lun2 ramdisk/ramdisk1 (rw)]| o- luns .......................................................................................................... [LUNs: 3]| | o- lun0 .................................................................... [block/block1 (/dev/sdd1) (default_tg_pt_gp)]| | o- lun1 .............................................................. [fileio/fileio1 (/tmp/foo1.img) (default_tg_pt_gp)]| | o- lun2 ............................................................................ [ramdisk/ramdisk1 (default_tg_pt_gp)]| o- portals .................................................................................................... [Portals: 1]| o- 0.0.0.0:3260 ..................................................................................................... [OK]o- loopback ......................................................................................................... [Targets: 0]
2.7.5 实验: Initiator连接 Target
- 发现
Target
[root@master ~] iscsiadm --mode discovery --type sendtargets --portal 192.168.1.170
192.168.1.170:3260,1 iqn.2020-10.com.idys.srv1:tomstor1
- 连接
Target
[root@master ~] iscsiadm -d2 -m node --login
iscsiadm: Max file limits 1024 4096
iscsiadm: default: Creating session 1/1
Logging in to [iface: default, target: iqn.2020-10.com.idys.srv1:tomstor1, portal: 192.168.1.170,3260] (multiple)
Login to [iface: default, target: iqn.2020-10.com.idys.srv1:tomstor1, portal: 192.168.1.170,3260] successful.
- 在
Initiator
查看存储
[root@master ~] fdisk -lDisk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0009dd53Device Boot Start End Blocks Id System
/dev/sda1 * 2048 411647 204800 83 Linux
/dev/sda2 411648 42354687 20971520 83 Linux
/dev/sda3 42354688 44451839 1048576 82 Linux swap / SolarisDisk /dev/sdb: 85.9 GB, 85898280448 bytes, 167770079 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 4194304 bytesDisk /dev/sdc: 1 MB, 1048576 bytes, 2048 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/sdd: 52 MB, 52428800 bytes, 102400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 4194304 bytes
- 断开与
Target
的连接
[root@master ~] iscsiadm -d2 -m node --logout
iscsiadm: Max file limits 1024 4096
Logging out of session [sid: 1, target: iqn.2020-10.com.idys.srv1:tomstor1, portal: 192.168.1.170,3260]
Logout of [sid: 1, target: iqn.2020-10.com.idys.srv1:tomstor1, portal: 192.168.1.170,3260] successful.
2.7.6 参考资料
http://linux-iscsi.org/wiki/Target
http://linux-iscsi.org/wiki/ISCSI
http://en.wikipedia.org/wiki/SCSI initiator and Target
2.7.7 基于iSCSI的存储池 iscsi: iSCSI Target
- 使用图形界面做
iscsi
存储池
- 下面的图片里面
- 主机名选择
Target
端的主机名或者ip
地址 - 源
IQN
选择,Target
的IQN
initiator IQN
顾名思义- 主机名填写
target
的主机名
- 主机名选择
- 在另外一个系统添加一块硬盘,在不关机的情况下扫描硬盘,检测出硬盘
[root@master ~] for i in {0..3};do echo "- - -" >/sys/class/scsi_host/host$i/scan;done
- 对检测出来的硬盘进程分区
[root@master ~] fdisk /dev/sde
Welcome to fdisk (util-linux 2.23.2).Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x593b96fa.Command (m for help): n
Partition type:p primary (0 primary, 0 extended, 4 free)e extended
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-167772159, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-167772159, default 167772159):
Using default value 167772159
Partition 1 of type Linux and of size 80 GiB is setCommand (m for help): pDisk /dev/sde: 85.9 GB, 85899345920 bytes, 167772160 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x593b96faDevice Boot Start End Blocks Id System
/dev/sde1 2048 167772159 83885056 83 LinuxCommand (m for help): w
The partition table has been altered!Calling ioctl() to re-read partition table.
Syncing disks.
- 对分区进行检测,让系统检测出分区
[root@master ~] partprobe
Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.
- 查看创建的存储池
[root@idys1 /] virsh pool-list # 查看之前创建的 iSCSI 存储池名称 状态 自动开始
-------------------------------------------default 活动 是 iso 活动 是 storm1 活动 是 virtio_dir 活动 是 vm 活动 是 [root@idys1 /] virsh pool-info storm1
名称: storm1
UUID: 9d705861-7847-4eb9-840d-998b5416f7b3
状态: running
持久: 是
自动启动: 是
容量: 80.15 GiB
分配: 80.15 GiB
可用: 0.00 B
- 查看存储池的文件
[root@idys1 /] cat /etc/libvirt/storage/storm1.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 storm1
or other application using the libvirt API.
--><pool type='iscsi'><name>storm1</name><uuid>9d705861-7847-4eb9-840d-998b5416f7b3</uuid><capacity unit='bytes'>0</capacity><allocation unit='bytes'>0</allocation><available unit='bytes'>0</available><source><host name='192.168.1.150'/><device path='iqn.2020-10.com.idys1.srv2:torage1'/><initiator><iqn name='iqn.1994-05.com.redhat:idysstor'/></initiator></source><target><path>/dev/disk/by-path</path></target>
</pool>
- 通过
virsh
创建iSCSI
存储池
[root@idys1 /] virsh pool-define-as --name stor2 --type=iscsi --source-host 192.168.1.150 --source-dev iqn.2020-10.com.idys1.srv2:torage1 --target /dev/disk/by-path
定义池 stor2
记得把
target
端的3260
端口对initiator
端打开
- 设置启动和启动重启
[root@idys1 /] virsh pool-start stor2
池 stor2 已启动[root@idys1 /] virsh pool-autostart stor2
池 stor2 标记为自动启动
2.8 基于NFS的存储池
- 首先在存储端安装
NFS
[root@master ~] yum -y install nfs-utils
- 创建目录,并且配置访问权限
[root@master ~] mkdir /nfsshare
[root@master ~] vi /etc/exports
/nfsshare *(rw)
- 开启
rpcbind
和nfs
服务
[root@master ~] systemctl start rpcbind
[root@master ~] systemctl start nfs
- 查看挂载列表
[root@idys1 /] showmount -e 192.168.1.150
Export list for 192.168.1.150:
/nfsshare *
- 使用
virt-manager
挂载nfs
存储池 - 主机名为
nfs
存储端的主机名或者ip
地址 - 源路径为
nfs
分享出来的的目录
- 查看挂载,此时可以看到它会自动的做一些挂载
mount
操作,当你创建存储池后就无需挂载了
[root@idys1 /] mount | grep 192.168
192.168.1.150:/nfsshare on /var/lib/libvirt/images/nfs1 type nfs4 (rw,nosuid,nodev,noexec,relatime,vers=4.1,rsize=262144,wsize=262144,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=192.168.1.170,local_lock=none,addr=192.168.1.150)
- 查看存储池信息
[root@idys1 /] cat /etc/libvirt/storage/nfs1.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 nfs1
or other application using the libvirt API.
--><pool type='netfs'><name>nfs1</name><uuid>e3da613a-3685-4129-a05c-84d3a81266ff</uuid><capacity unit='bytes'>0</capacity><allocation unit='bytes'>0</allocation><available unit='bytes'>0</available><source><host name='192.168.1.150'/><dir path='/nfsshare'/><format type='auto'/></source><target><path>/var/lib/libvirt/images/nfs1</path></target>
</pool>[root@idys1 /] virsh pool-info nfs1
名称: nfs1
UUID: e3da613a-3685-4129-a05c-84d3a81266ff
状态: running
持久: 是
自动启动: 是
容量: 19.99 GiB
分配: 4.61 GiB
可用: 15.38 GiB
- 使用
virsh
创建nfs
存储池
[root@idys1 /] virsh pool-define-as --name nfs1 --type netfs --source-host 192.168.1.150 --source-path /nfsshare --target /var/lib/libvirt/images/nfs1
定义池 nfs1
- 因为本地的存储路径不存在,所以需要构建路径
[root@idys1 /] virsh pool-build nfs1
构建池 nfs1
- 启动存储池,同时设置自启动
[root@idys1 /] virsh pool-start nfs1
池 nfs1 已启动
[root@idys1 /] virsh pool-autostart nfs1
池 nfs1 标记为自动启动
- 停止,删除存储池
[root@idys1 /] virsh pool-destroy nfs1
销毁池 nfs1[root@idys1 /] ls /var/lib/libvirt/images/nfs1/
[root@idys1 /] virsh pool-delete nfs1
池 nfs1 被删除[root@idys1 /] ls /var/lib/libvirt/images/nfs1/
ls: 无法访问/var/lib/libvirt/images/nfs1/: 没有那个文件或目录
[root@idys1 /] virsh pool-undefine nfs1
池 nfs1 已经被取消定义
03. 存储卷
3.1 存储卷概述
存储池被分割为存储卷(
storage volume
)存储卷
- 文件
- 块设备(如物理分区、LVM逻辑卷)
libvirt
管理的其他类型存储的抽象
virsh
存储卷管理命令
[root@idys1 /] virsh help volumeStorage Volume (help keyword 'volume'):vol-clone 克隆卷。vol-create-as 从一组变量中创建卷vol-create 从一个 XML 文件创建一个卷vol-create-from 生成卷,使用另一个卷作为输入。vol-delete 删除卷vol-download 将卷内容下载到文件中vol-dumpxml XML 中的卷信息vol-info 存储卷信息vol-key 为给定密钥或者路径返回卷密钥vol-list 列出卷vol-name 为给定密钥或者路径返回卷名vol-path 为给定密钥或者路径返回卷路径vol-pool 为给定密钥或者路径返回存储池vol-resize 创新定义卷大小vol-upload 将文件内容上传到卷中vol-wipe 擦除卷
3.2 存储卷管理
- 创建
- 克隆
- 删除
- 移动
- 修改大小
vol-create
的参数信息
[root@idys1 /] virsh vol-create-as --helpNAMEvol-create-as - 从一组变量中创建卷SYNOPSISvol-create-as <pool> <name> <capacity> [--allocation <string>] [--format <string>] [--backing-vol <string>] [--backing-vol-format <string>] [--prealloc-metadata] [--print-xml]DESCRIPTION创建一个卷。OPTIONS[--pool] <string> 卷名称[--name] <string> 卷的名称[--capacity] <string> 卷大小,以整数计(默认为字节)--allocation <string> 初始化分配大小,以整数计(默认为 KiB)--format <string> 文件格式类型:raw、bochs、qcow、qcow2、qed、vmdk--backing-vol <string> 提取快照时的后端卷--backing-vol-format <string> 提取快照时的后端卷格式--prealloc-metadata 预先分配的元数据(用于 qcow2 而不是整个分配)--print-xml 打印 XML 文档,但不能定义/创建
3.3 存储卷管理
- 基于目录的存储池中的存储卷管理
- 基于
LVM
的存储池中的存储卷管理
3.3.1 基于目录的存储池中的存储卷管理
- 查看存储池信息
[root@idys1 /] virsh pool-list 名称 状态 自动开始
-------------------------------------------default 活动 是 iso 活动 是 stor2 活动 是 virtio_dir 活动 是 vm 活动 是 [root@idys1 /] virsh pool-info vm
名称: vm
UUID: 1693104e-8164-4151-b9a6-602a5d5f848c
状态: running
持久: 是
自动启动: 是
容量: 78.62 GiB
分配: 4.45 GiB
可用: 74.16 GiB[root@idys1 /] virsh pool-dumpxml vm
<pool type='dir'><name>vm</name><uuid>1693104e-8164-4151-b9a6-602a5d5f848c</uuid><capacity unit='bytes'>84412882944</capacity><allocation unit='bytes'>4780724224</allocation><available unit='bytes'>79632158720</available><source></source><target><path>/vm</path><permissions><mode>0755</mode><owner>0</owner><group>0</group></permissions></target>
</pool>
- 查看存储池中的存储卷有那些
[root@idys1 /] virsh vol-list vm名称 路径
------------------------------------------------------------------------------back_img /vm/back_img base-centos6-disk0.qcow2 /vm/base-centos6-disk0.qcow2 CentOS-disk1.qcow2 /vm/CentOS-disk1.qcow2 centos6-disk0.qcow2 /vm/centos6-disk0.qcow2 erp-disk0.qcow2 /vm/erp-disk0.qcow2 lost+found /vm/lost+found oa-disk0.qcow2 /vm/oa-disk0.qcow2 win32-disk2 /vm/win32-disk2
- 在存储池当中创建存储卷
[root@idys1 /] virsh vol-create-as vm test_vol.qcow2 2G --format qcow2
创建卷 test_vol.qcow2
- 列举存储池里面的存储卷
[root@idys1 /] virsh vol-list vm名称 路径
------------------------------------------------------------------------------back_img /vm/back_img base-centos6-disk0.qcow2 /vm/base-centos6-disk0.qcow2 CentOS-disk1.qcow2 /vm/CentOS-disk1.qcow2 centos6-disk0.qcow2 /vm/centos6-disk0.qcow2 erp-disk0.qcow2 /vm/erp-disk0.qcow2 lost+found /vm/lost+found oa-disk0.qcow2 /vm/oa-disk0.qcow2 test_vol.qcow2 /vm/test_vol.qcow2 win32-disk2 /vm/win32-disk2
- 查看存储卷信息
[root@idys1 /] virsh vol-info /vm/test_vol.qcow2
名称: test_vol.qcow2
类型: 文件
容量: 2.00 GiB
分配: 196.00 KiB
[root@idys1 /] virsh vol-info test_vol.qcow2 --pool vm
名称: test_vol.qcow2
类型: 文件
容量: 2.00 GiB
分配: 196.00 KiB
3.3.2 基于LVM
的存储池中的存储卷管理
- 查看存储池信息
[root@idys1 /] virsh pool-list --all名称 状态 自动开始
-------------------------------------------default 活动 是 iso 活动 是 stor2 活动 是 virtio_dir 活动 是 vm 活动 是
- 在
vmware
里面再加一块盘,然后重新扫描系统总线,对添加的硬盘检测
[root@idys1 /] for i in {0..2};do echo "- - -" > /sys/class/scsi_host/host$i/scan;done
[root@idys1 /] echo "- - -" > /sys/class/scsi_host/host7/scan
[root@idys1 /] fdisk -l /dev/sdh # 此时可以看到硬盘检测出来了磁盘 /dev/sdh:53.7 GB, 53687091200 字节,104857600 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
- 基于
lvm
构建存储池
[root@idys1 /] virsh pool-define-as guest_images_lvm logical --source-dev=/dev/sdh --target=/dev/vg_libvirt
定义池 guest_images_lvm[root@idys1 /] virsh pool-build guest_images_lvm
构建池 guest_images_lvm
- 启动存储池,设置存储池开机自启动
[root@idys1 /] virsh pool-start guest_images_lvm
池 guest_images_lvm 已启动[root@idys1 /] virsh pool-autostart guest_images_lvm
池 guest_images_lvm 标记为自动启动
- 查看
pv
和vg
[root@idys1 /] pvscan PV /dev/sda2 VG centos lvm2 [<19.51 GiB / 0 free]PV /dev/sdc1 VG centos lvm2 [<50.00 GiB / 0 free]PV /dev/sdb1 VG vmvg lvm2 [<80.00 GiB / 0 free]PV /dev/sdh VG guest_images_lvm lvm2 [<50.00 GiB / <50.00 GiB free]Total: 4 [<199.50 GiB] / in use: 4 [<199.50 GiB] / in no VG: 0 [0 ]
[root@idys1 /] vgscan Reading volume groups from cache.Found volume group "centos" using metadata type lvm2Found volume group "vmvg" using metadata type lvm2Found volume group "guest_images_lvm" using metadata type lvm2
- 基于
lvm
的存储池,创建三个存储卷lv
[root@idys1 /] virsh vol-create-as guest_images_lvm lvvol1 1G
创建卷 lvvol1 [root@idys1 /] virsh vol-create-as guest_images_lvm lvvol2 2G
创建卷 lvvol2 [root@idys1 /] virsh vol-create-as guest_images_lvm lvvol3 3G
创建卷 lvvol3 [root@idys1 /] virsh vol-list guest_images_lvm 名称 路径
------------------------------------------------------------------------------lvvol1 /dev/guest_images_lvm/lvvol1 lvvol2 /dev/guest_images_lvm/lvvol2 lvvol3 /dev/guest_images_lvm/lvvol3
- 查看
lv
,发现已经自动创建了三个lv
逻辑卷
[root@idys1 /] lvscanACTIVE '/dev/centos/swap' [2.00 GiB] inheritACTIVE '/dev/centos/root' [67.50 GiB] inheritACTIVE '/dev/vmvg/lvvm1' [<80.00 GiB] inheritACTIVE '/dev/guest_images_lvm/lvvol1' [1.00 GiB] inheritACTIVE '/dev/guest_images_lvm/lvvol2' [2.00 GiB] inheritACTIVE '/dev/guest_images_lvm/lvvol3' [3.00 GiB] inherit
- 查看
vg
[root@idys1 /] vgdisplay guest_images_lvm --- Volume group ---VG Name guest_images_lvmSystem ID Format lvm2Metadata Areas 1Metadata Sequence No 4VG Access read/writeVG Status resizableMAX LV 0Cur LV 3Open LV 0Max PV 0Cur PV 1Act PV 1VG Size <50.00 GiBPE Size 4.00 MiBTotal PE 12799Alloc PE / Size 1536 / 6.00 GiBFree PE / Size 11263 / <44.00 GiBVG UUID ynUxcB-jtXu-8bve-7U69-9ebg-HdA8-ZobNoQ
- 克隆存储卷
[root@idys1 /] virsh vol-clone test_vol.qcow2 test_vol1.qcow2 --pool vm
使用 test_vol1.qcow2 克隆的卷 test_vol.qcow2
[root@idys1 /] virsh vol-list vm # 再次查看存储卷,发现 test_vol.qcow2 已经存在名称 路径
------------------------------------------------------------------------------back_img /vm/back_img base-centos6-disk0.qcow2 /vm/base-centos6-disk0.qcow2 CentOS-disk1.qcow2 /vm/CentOS-disk1.qcow2 centos6-disk0.qcow2 /vm/centos6-disk0.qcow2 erp-disk0.qcow2 /vm/erp-disk0.qcow2 lost+found /vm/lost+found oa-disk0.qcow2 /vm/oa-disk0.qcow2 test_vol.qcow2 /vm/test_vol.qcow2 test_vol1.qcow2 /vm/test_vol1.qcow2 win32-disk2 /vm/win32-disk2
- 查看克隆卷信息
[root@idys1 /] virsh vol-info test_vol1.qcow2 --pool vm
名称: test_vol1.qcow2
类型: 文件
容量: 2.00 GiB
分配: 196.00 KiB
- 基于
lvm
卷克隆
[root@idys1 /] virsh vol-clone lvvol2 lvvol4 guest_images_lvm
使用 lvvol4 克隆的卷 lvvol2
- 再来查看
lvm
的卷
[root@idys1 /] virsh vol-list guest_images_lvm 名称 路径
------------------------------------------------------------------------------lvvol1 /dev/guest_images_lvm/lvvol1 lvvol2 /dev/guest_images_lvm/lvvol2 lvvol3 /dev/guest_images_lvm/lvvol3 lvvol4 /dev/guest_images_lvm/lvvol4
- 删除
lvm
存储卷里面的存储池
[root@idys1 /] for i in {1..4};do virsh vol-delete lvvol$i --pool guest_images_lvm ;done
卷 lvvol1 被删除卷 lvvol2 被删除卷 lvvol3 被删除卷 lvvol4 被删除
- 查看
vg
信息
[root@idys1 /] vgdisplay guest_images_lvm --- Volume group ---VG Name guest_images_lvmSystem ID Format lvm2Metadata Areas 1Metadata Sequence No 9VG Access read/writeVG Status resizableMAX LV 0Cur LV 0Open LV 0Max PV 0Cur PV 1Act PV 1VG Size <50.00 GiBPE Size 4.00 MiBTotal PE 12799Alloc PE / Size 0 / 0 Free PE / Size 12799 / <50.00 GiBVG UUID ynUxcB-jtXu-8bve-7U69-9ebg-HdA8-ZobNoQ
- 删除
lvm
存储池
[root@idys1 /] virsh pool-destroy guest_images_lvm
销毁池 guest_images_lvm[root@idys1 /] virsh pool-delete guest_images_lvm
池 guest_images_lvm 被删除[root@idys1 /] virsh pool-undefine guest_images_lvm
池 guest_images_lvm 已经被取消定义
- 再来查看
pv
和vg
,发现他们已经不存在了
[root@idys1 /] pvscan PV /dev/sda2 VG centos lvm2 [<19.51 GiB / 0 free]PV /dev/sdc1 VG centos lvm2 [<50.00 GiB / 0 free]PV /dev/sdb1 VG vmvg lvm2 [<80.00 GiB / 0 free]Total: 3 [149.50 GiB] / in use: 3 [149.50 GiB] / in no VG: 0 [0 ]
[root@idys1 /] vgscan Reading volume groups from cache.Found volume group "centos" using metadata type lvm2Found volume group "vmvg" using metadata type lvm2
- 删除
dir
存储池里面的存储卷
[root@idys1 /] virsh vol-delete /vm/test_vol1.qcow2
卷 /vm/test_vol1.qcow2 被删除
3.3.3 向虚拟机添加卷
attach-device
- 通过
XML
添加新的设备
- 通过
<disk type='file' device='disk'><driver name='qemu' type='raw' cache='none' /><source file='/vm/testdisk1.img' /><target dev='vdb' />
</disk>
- 另外
<disk type='file' device='cdrom'><driver name='qemu' type='raw' cache='none' /><source file='/iso/CentOS.iso' /><readonly /><target dev='hdc' />
</disk>
attach-disk
virsh attach-disk --domin VM1 --source=/vm/t2.img --target=vdb --cache=none
- 创建一个表面大小50M,实际大小
0
M的稀疏文件
[root@idys1 /vm] dd if=/dev/zero of=./mytest1.raw bs=1024k count=0 seek=50
记录了0+0 的读入
记录了0+0 的写出
0字节(0 B)已复制,0.00011147 秒,0.0 kB/秒
- 用
qemu-img
创建稀疏文件
[root@idys1 /vm] qemu-img create -f qcow2 mytest2 2G
Formatting 'mytest2', fmt=qcow2 size=2147483648 encryption=off cluster_size=65536 lazy_refcounts=off
- 用
virsh vol-create
创建
[root@idys1 /vm] virsh vol-create-as vm mytest3.qcow2 60G --format=qcow2
创建卷 mytest3.qcow2
[root@idys1 /vm] qemu-img info mytest3.qcow2
image: mytest3.qcow2
file format: qcow2
virtual size: 60G (64424509440 bytes)
disk size: 196K
cluster_size: 65536
Format specific information:compat: 0.10
[root@idys1 /vm] virsh vol-info mytest3.qcow2 vm
名称: mytest3.qcow2
类型: 文件
容量: 60.00 GiB
分配: 196.00 KiB
- 编辑文件
[root@idys1 /vm] vim /tmp/vdbxml
<disk type='file' device='disk'><driver name='qemu' type='qcow2' cache='none' /><source file='/vm/testdisk1.qcow2' /><target dev='vdb' />
</disk>
- 列举虚拟机的块设备文件
[root@idys1 /vm] virsh domblklist win2k3a
目标 源
------------------------------------------------
vda /var/lib/libvirt/images/win2k3a.qcow2
hdb /iso/virtio_stable/virtio-win-0.1.185.iso
- 创建磁盘文件
[root@idys1 /vm] qemu-img create -f qcow2 testdisk1.qcow2 60G
Formatting 'testdisk1.qcow2', fmt=qcow2 size=64424509440 encryption=off cluster_size=65536 lazy_refcounts=off
- 永久挂接设备
[root@idys1 /vm] virsh attach-device win2k3a /tmp/vdbxml --persistent
成功附加设备
- 查看挂接设备
[root@idys1 /vm] virsh domblklist win2k3a
目标 源
------------------------------------------------
vda /var/lib/libvirt/images/win2k3a.qcow2
vdb /vm/testdisk1.qcow2
hdb /iso/virtio_stable/virtio-win-0.1.185.iso
- 再次挂接磁盘
[root@idys1 /vm] virsh attach-disk win2k3a --source=/vm/test_vol.qcow2 --target=vdc #这次使用的是命令行
成功附加磁盘
- 创建
lvm
存储池,并且设置为自启动
[root@idys1 /vm] virsh pool-define-as lvm_test logical --source-dev=/dev/sdh --target=/dev/vg_libvirt
定义池 lvm_test[root@idys1 /vm] virsh pool-build lvm_test
构建池 lvm_test[root@idys1 /vm] virsh pool-start lvm_test
池 lvm_test 已启动[root@idys1 /vm] virsh pool-autostart lvm_test
池 lvm_test 标记为自动启动
- 在
lvm
存储池里面创建lv
卷
[root@idys1 /vm] virsh vol-create-as lvm_test lvtest 30G
创建卷 lvtest
- 查看
lv
卷
[root@idys1 /vm] lvscan ACTIVE '/dev/lvm_test/lvtest' [30.00 GiB] inherit
- 将
lvm
存储卷作为虚拟机的磁盘
[root@idys1 /vm] virsh attach-disk --domain win2k3a --source=/dev/lvm_test/lvtest --target=vdd
成功附加磁盘
写在最后的话:
- 无论每个知识点的难易程度如何,我都会尽力将它描绘得足够细致
- 欢迎关注我的CSDN博客,IDYS’BLOG
- 持续更新内容:
linux基础 | 数据通信(路由交换,WLAN) | Python基础 | 云计算 - 如果你有什么疑问,或者是难题。欢迎评论或者私信我。你若留言,我必回复!
- 虽然我现在还很渺小,但我会做好每一篇内容。谢谢关注!
虚拟机磁盘与qemu-img、存储池、存储卷相关推荐
- 【3】KVM虚拟化存储 | 虚拟机磁盘挂载
目录 [概念] 一.存储池管理 1.创建基于文件夹的存储池(目录) 2.定义存储池与其目录 3.创建已定义的存储池 4.激活并自动启动已定义的存储池 5.在存储池中创建虚拟机存储卷 6.存储池相关管理 ...
- 【HCIA-cloud】【4】服务器虚拟化之存储资源管理:存储资源类型说明、存储配置模式说明【普通、精简、延迟置零】、虚拟机磁盘类型说明、FusionCompute中操作添加存储
目录一览 说明 存储资源类型 存储虚拟化与华为云计算存储对比 FusionCompute存储资源与存储资源使用对比 FusionCompute中的存储资源类型 物理磁盘 SATA盘 SAS盘 NL-S ...
- 虚拟机磁盘类型_虚拟机存储类型分为哪些种类
存储类型主要分为三个类别: SAN使用主机总线适配器(HBA)--这是最传统的SAN类型.支持的类型包括光纤通道和串行连接SCSI(SAS).光纤通道往往更昂贵,但比SAS提供更快的性能. SAN ...
- virsh存储池,存储卷的管理
目录 一.存储池 1. 查看存储池 2.创建物理卷,卷组 3.编写存储池xml 4.创建存储池 5.启动 6.查看 7.扩容 8.删除 二.存储卷 1. 创建存储池 2.创建存储卷 3.查看存储路径 ...
- linux虚拟磁盘管理pe大小6,Linux下磁盘的高级管理——LVM逻辑卷管理
文章目录 逻辑卷是什么 逻辑卷的原理 逻辑卷的优点 lv的管理 lv的建立 xfs格式下lvm的拉伸 ext4下lvm的拉伸和缩减 lvm快照 lvm快照的原理和作用 快照的建立 lvm的删除 逻辑卷 ...
- kvm qcow2和ceph rbd虚拟机磁盘加密
微信公众号:运维开发故事,作者:wanger kvm qcow2磁盘加密 关于luks加密 LUKS 实现了一种独立于平台的标准磁盘格式,用于各种工具.LUKS 用于加密块设备.加密设备的内容是任意的 ...
- 云原生存储详解:容器存储与 K8s 存储卷
作者 | 阚俊宝 阿里云技术专家 导读:云原生存储详解系列文章将从云原生存储服务的概念.特点.需求.原理.使用及案例等方面,和大家一起探讨云原生存储技术新的机遇与挑战.本文为该系列文章的第二篇,会对容 ...
- k8s挂载目录_云原生存储详解:容器存储与 K8s 存储卷
作者 | 阚俊宝 阿里云技术专家 导读:云原生存储详解系列文章将从云原生存储服务的概念.特点.需求.原理.使用及案例等方面,和大家一起探讨云原生存储技术新的机遇与挑战.本文为该系列文章的第二篇,会对容 ...
- docker修改镜像的存储位置_云原生存储详解:容器存储与 K8s 存储卷(内含赠书福利)...
作者 | 阚俊宝 阿里巴巴技术专家 参与文末留言互动,即有机会获得赠书福利! 导读:云原生存储详解系列文章将从云原生存储服务的概念.特点.需求.原理.使用及案例等方面,和大家一起探讨云原生存储技术新 ...
最新文章
- 浮动元素会引起的问题和你的解决办法
- 编辑模式下,控制对象移动
- 华为汪涛:无线网络未来十年十大趋势
- Okhttp3-网络请求流程解析
- 引用头文件报错 .pch引用不了其他的.h文件
- 我又踩坑了!如何为 HttpClient 请求设置 Content-Type 标头?
- 卸载mysql数据库命令,值得推荐!
- EverNote 极致的免费笔记资料管理软件 (数据网络同步、支持PC、Mac与手机多平台) 转自:http://www.iplaysoft.com/evernote.html
- 单片机通信接口:UART、I2C、SPI、TTL、RS232、RS422、RS485、CAN、USB
- 【2021-09-22 修订】【梳理】计算机网络:自顶向下方法 第二章 应用层(docx)
- 数据结构与算法(java):线性表(链表-双向链表)
- 贝叶斯法则与先验后验概率以及似然度的关系
- AI大军已经兵临城下,我们离失业还有多远?
- 第十八届深圳文博会今日开幕,江苏馆携手卓易紫砂街数字文化惊艳亮相!
- 软件测试颗粒度,测试用例之度——系列之颗粒度(上)
- linux批处理模式,巧用linux-top的批处理模式
- Docker Note [vaynexiao]
- 5个文献免费下载神器
- python列表推导式是什么
- 【KV260】利用XADC生成芯片温度曲线图
热门文章
- 头条服务器维护更新公告,【更新公告】《第五人格》2021年8月12日维护公告
- GET /socket.io/?EIO=3transport=websocket
- 北京VI设计公司总结关于vi设计提案中的窍门
- 使用python统计改善提案
- vue动态换肤(自定义主题)
- JavaScript:打印一个等腰梯形
- cdr文件用什么打开?(cdr文件打开方式汇总)
- 数字型字符串万位加万字_把整万的数改写成用万作单位的数时,将万位后面的4个0去掉,添上一个万字,中间用什么连结...
- 多分类经典语录微信小程序源码下载支持一键复制带壁纸,王者改名等功能
- 【翻译】什么是职业倦怠?定义、症状以及组织和个人可以做什么