glusterfs块存储应用与实践
glusterfs提供块存储方式
目前glusterfs 提供块存储主要有:
- 通过fuse客户端或api+iSCSI LUNs (project:gluster-block)
- 通过fuse客户端挂载到vm宿主机提供local disk images
- 通过glusterfs api 形式提供 qemu disk images
这3种方式都可以实现给虚拟机提供块存储,区别在于第1种io栈要多经过iscsi 协议栈和第2种要经过fuse内核模块,glusterfs api 形式 qemu driver 可以直接通过api 访问网络存储,绕开了宿主机内核和iscsi 协议栈。所以理论上第3种是效率最高的。
qemu glusterfs api driver 实践
安装
qemu 2.x版本已经支持glusterfs,即centos7 用centos6的话需要自己编译。但是centos7 目前用的qemu 2.10版本还是glusterfs3.4 版本的api,所以如果要使用高版本api 的一些新特性,就需要自己去编译。
1.安装你目前使用的glusterfs 版本(必须包含api 包)。
2.编译qemu。
configure 文件:
可以看到每个glusterfs版本都支持了一些新功能。
- 安装依赖yum install zlib-devel glib2-devel -y
- ./configure --enable-glusterfs
- make -j 6
- make install
测试
- 创建volume testvol (gluster volume set volname performance.client-io-threads off 这个io-thread 层会出现 执行 seek 操作 core dump)
- 创建qcow2 格式镜像文件qemu-img create -f qcow2 gluster://localhost/testvol/test.img 20,这个时候在testvol 卷下面根目录下生成了一个test.img 文件。(添加的时候可能有以西错误日志不用管,只要echo $? 为0 就是正确的)
- 给虚拟机vm-1(这是提前创建好的虚机),virsh attach-device vm-1 d.xml --subdriver=qcow2
cat d.xml:
这个时候到虚机里面fdisk -l能看到 就能看到设备/dev/vdb 。
io 对比测试
读:
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-NAyXxhjd-1597915735581)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20200729102947773.png)]
写:
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-TppwOc37-1597915735588)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20200729103125489.png)]
参考:
https://www.qemu.org/docs/master/system/qemu-block-drivers.html#iscsi-luns
http://wiki.stoney-cloud.org/wiki/Libvirt_external_snapshot_with_GlusterFS
ey-cloud.org/wiki/Libvirt_external_snapshot_with_GlusterFS