本文主要是介绍Cinder对接NFS文件系统实验详解,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
2、对接NFS(Network File System:网络文件系统)实验
实验前的准备:
完整克隆一台虚拟机作为Cinder的后端存储(IP为192.168.100.40)
Cinder节点作为服务端,把Controller作为客户端
Controller节点对接NFS
在Cinder节点添加一个30G的磁盘,分区为30G的sdb1然后进行格式化为xfs文件系统
(1)安装NFS服务,查看NFS是否已经安装,若已经安装了,直接启动nfs-server.service服务并设置开机自己即可。若没有安装,执行yum install -y nfs-utils即可
(2)关闭防火墙及SELINUX
(3)创建共享目录/nfs_server,并把已经格式化好的sdb1挂载到/nfs_server,因为是作为共享的目录所以权限为777
(4)修改/etc/exports配置文件,增加一行参数,/nfs_share 192.168.100.0/24(rw),表示共享服务器的/nfs_server目录下只能192.168.100这个网段的主机才能访问,且拥有读写权限
(5)修改完成配置文件,重启服务systemctl restart nfs-server.service
(6)在客户端(在本实验中,也就是我的controller节点)测试挂载操作。先查看有没有安装nfs-utils,若已经安装直接启动。若没有安装,就先安装再启动
(7)创建一个挂载目录/nfs_test,目录名随意,并把服务端(cinder节点)挂载的目录,挂载到客户端(controller),并存入文件测试。无论在客户端还是服务端,写入的文件都会互相共享
注意:如果卸载文件系统时出现device is busy,执行fuser -m /nfs_test查询进程号,结束掉,或者重启nfs服务
控制节点配置NFS共享,对接后端存储
(8)创建文件/etc/cinder/NFS_share,并写入内容192.168.100.40:/nfs_server,表示把服务端的已经挂载的磁盘挂载到本机上,并把该文件的拥有任何拥有组修改成root:cinder,文件权限为640
(9)增加NFS的后端参数(在/etc/cinder/cinder.conf的配置文件中,找到lvm,在后面加上nfs的配置内容)
662 enabled_backends=lvm,nfs //表示启动的后端存储为lvm和nfs [lvm] iscsi_helper=lioadm volume_group=cinder-volumes iscsi_ip_address=192.168.100.10 volume_driver=cinder.volume.drivers.lvm.LVMISCSIDriver volume_backend_name=lvm [nfs] //中括号里面的nfs可以修改,但是需要和662行的enabled_backends=lvm,nfs保持一致 nfs_shares_config = /etc/cinder/NFS_share //表示nfs的共享文件 volume_driver = cinder.volume.drivers.nfs.NfsDriver //表示volume的驱动 volume_backend_name = nfs_backend //表示后端存储的名称,后面需要和类型进行关联
(10)配置完成,重启cinder的所有服务
[root@controller cinder(keystone_wm)]# openstack-service restart cinder
(11)创建云硬盘类型(注意:要用openstack的admin身份创建,可通过help查看要接的具体参数)
[root@controller cinder(keystone_admin)]# cinder type-create nfs_type +--------------------------------------+----------+ | ID | Name | +--------------------------------------+----------+ | 81aa71bc-5428-45e5-8b5f-a36e31e59909 | nfs_type | +--------------------------------------+----------+ [root@controller cinder(keystone_admin)]# cinder type-list +--------------------------------------+----------+ | ID | Name | +--------------------------------------+----------+ | 81aa71bc-5428-45e5-8b5f-a36e31e59909 | nfs_type | | dec12709-630a-41cc-90b1-88281a3b17ce | iscsi | +--------------------------------------+----------+
(12)将存储类型和volume关联(其中volume_backend_name=nfs_backend是山面的nfs中的参数)
[root@controller ~(keystone_admin)]#cinder type-key nfs_type set volume_backend_name=nfs_backend
(13)使用NFS类型创建云硬盘
[root@controller ~(keystone_wm)]# cinder type-list +--------------------------------------+----------+ | ID | Name | +--------------------------------------+----------+ | 81aa71bc-5428-45e5-8b5f-a36e31e59909 | nfs_type | | dec12709-630a-41cc-90b1-88281a3b17ce | iscsi | +--------------------------------------+----------+ [root@controller ~(keystone_wm)]# cinder create --display-name evs001 --volume-type nfs_type 2 //表示创建一个名称为evfs001,类型为nfs_type ,大小为2G的云硬盘 +---------------------+--------------------------------------+ | Property | Value | +---------------------+--------------------------------------+ | attachments | [] | | availability_zone | nova | | bootable | false | | created_at | 2022-09-15T20:38:10.906141 | | display_description | None | | display_name | evs001 | | encrypted | False | | id | 527d6296-0d62-4fcd-b9f4-340011c7ab1f | | metadata | {} | | size | 2 | | snapshot_id | None | | source_volid | None | | status | creating | | volume_type | nfs_type | +---------------------+--------------------------------------+
(14)尝试挂载给虚拟机
[root@controller ~(keystone_wm)]# nova list +--------------------------------------+------+---------+------------+-------------+------------------------------------------+ | ID | Name | Status | Task State | Power State | Networks | +--------------------------------------+------+---------+------------+-------------+------------------------------------------+ | 567ac18f-22c4-43ab-967a-7aee9dcd17d7 | LUN1 | SHUTOFF | - | Shutdown | private1=192.168.66.202, 192.168.100.203 | +--------------------------------------+------+---------+------------+-------------+------------------------------------------+ [root@controller ~(keystone_wm)]# cinder list +--------------------------------------+-----------+--------------+------+-------------+----------+--------------------------------------+ | ID | Status | Display Name | Size | Volume Type | Bootable | Attached to | +--------------------------------------+-----------+--------------+------+-------------+----------+--------------------------------------+ | 527d6296-0d62-4fcd-b9f4-340011c7ab1f | available | evs001 | 2 | nfs_type | false | | | fadda155-4300-4698-b0ba-1da5659d3f5b | in-use | meme1 | 2 | iscsi | false | 567ac18f-22c4-43ab-967a-7aee9dcd17d7 | +--------------------------------------+-----------+--------------+------+-------------+----------+--------------------------------------+ [root@controller ~(keystone_wm)]# nova volume-attach LUN1 527d6296-0d62-4fcd-b9f4-340011c7ab1f +----------+--------------------------------------+ | Property | Value | +----------+--------------------------------------+ | device | /dev/vdc | | id | 527d6296-0d62-4fcd-b9f4-340011c7ab1f | | serverId | 567ac18f-22c4-43ab-967a-7aee9dcd17d7 | | volumeId | 527d6296-0d62-4fcd-b9f4-340011c7ab1f | +----------+--------------------------------------+
(15)完成创建
这篇关于Cinder对接NFS文件系统实验详解的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!