这几天学习了openstack的cinder存储,做了几个实验,这是几个实验之一。原先使用的openstack有4个节点,一个控制节点,一个网络节点和两个计算节点。其中控制节点兼做存储节点,使用的是LVM后端存储,现在是想要新加一个nfs后端存储。使用一台新的服务器做nfs服务(但存储节点,即运行cinder-volume服务的节点还是只有控制节点,新的nfs服务器不运行cinder volume服务。)
1、新安装一台服务器,这里面是192.168.23.80
2、在192.168.23.80上安装NFS服务
yum install -y nfs-utils nfs-utils-lib
创建共享目录
mkdir -p /nfs_volume/cinder_volume
编辑NFS配置文件 /etc/exports:
/nfs_volume/cinder_volume 192.168.23.0/24(rw,sync,no_root_squash,no_subtree_check)
启动NFS服务:
exportfs -a
systemctl start nfs-server
3、在控制节点上配置NFS后端存储
先安装nfs客户端
yum install -y nfs-utils
修改cinder配置文件
vim /etc/cinder/cinder.conf
enabled_backends=lvm,nfs # 添加NFS后端存储
nfs
volume_driver = cinder.volume.drivers.nfs.NfsDriver
volume_backend_name =nfs # 指定NFS后端存储的名称
nfs_shares_config = /etc/cinder/nfs_shares
nfs_mount_point_base = /var/lib/cinder/nfs
nfs_sparsed_volumes = true
nfs_mount_options = vers=4.1
nfs_used_ratio = 0.95
nfs_oversub_ratio = 1.0
nas_secure_file_operations = auto
nas_secure_file_permissions = auto
创建NFS共享文件 /etc/cinder/nfs_shares:
192.168.23.80:/nfs_volume/cinder_volume
创建挂载点基础目录
mkdir -p /var/lib/cinder/nfs
chown -R cinder:cinder /var/lib/cinder/nfs
重启Cinder服务
systemctl restart openstack-cinder-*
创建类型
cinder type-create nfs
cinder type-key nfs set volume_backend_name=nfs
查看当前存储服务
cinder service-list
+------------------+----------------+------+---------+-------+----------------------------+-----------------+
| Binary | Host | Zone | Status | State | Updated_at | Disabled Reason |
+------------------+----------------+------+---------+-------+----------------------------+-----------------+
| cinder-backup | controller | nova | enabled | up | 2026-01-21T10:22:37.000000 | - |
| cinder-scheduler | controller | nova | enabled | up | 2026-01-21T10:22:32.000000 | - |
| cinder-volume | controller@lvm | nova | enabled | up | 2026-01-21T10:22:36.000000 | - |
| cinder-volume | controller@nfs | nova | enabled | up | 2026-01-21T10:22:36.000000 | - |
+------------------+----------------+------+---------+-------+----------------------------+-----------------+
注意@后面的内容就是[nfs]括号里面的内容
查看类型
cinder type-list
+--------------------------------------+-------+-------------+-----------+
| ID | Name | Description | Is_Public |
+--------------------------------------+-------+-------------+-----------+
| 082b2a5b-62d0-4a2e-a50c-7794b1998ad8 | iscsi | - | True |
| baec423a-f817-4925-a3cf-1d0cd816ab54 | nfs | - | True |
+--------------------------------------+-------+-------------+-----------+
查看存储池
cinder get-pools --detail
+-----------------------------+--------------------------------------------------+
| Property | Value |
+-----------------------------+--------------------------------------------------+
| QoS_support | False |
| allocated_capacity_gb | 7 |
| backend_state | up |
| driver_version | 3.0.0 |
| filter_function | None |
| free_capacity_gb | 189.73 |
| goodness_function | None |
| location_info | LVMVolumeDriver:controller:cinder-volumes:thin:0 |
| max_over_subscription_ratio | 20.0 |
| multiattach | True |
| name | controller@lvm#lvm |
| pool_name | lvm |
| provisioned_capacity_gb | 7.0 |
| reserved_percentage | 0 |
| storage_protocol | iSCSI |
| thick_provisioning_support | False |
| thin_provisioning_support | True |
| timestamp | 2026-01-22T01:23:16.630088 |
| total_capacity_gb | 190.0 |
| total_volumes | 8 |
| vendor_name | Open Source |
| volume_backend_name | lvm |
+-----------------------------+--------------------------------------------------+
+-----------------------------+----------------------------+
| Property | Value |
+-----------------------------+----------------------------+
| QoS_support | False |
| allocated_capacity_gb | 1 |
| driver_version | 1.4.0 |
| filter_function | None |
| free_capacity_gb | 99.9013671875 |
| goodness_function | None |
| max_over_subscription_ratio | 20.0 |
| name | controller@nfs#nfs |
| provisioned_capacity_gb | 1.0 |
| reserved_percentage | 0 |
| sparse_copy_volume | True |
| storage_protocol | nfs |
| thick_provisioning_support | False |
| thin_provisioning_support | True |
| timestamp | 2026-01-22T01:22:48.939648 |
| total_capacity_gb | 99.9503173828 |
| vendor_name | Open Source |
| volume_backend_name | nfs |
+-----------------------------+----------------------------+
4、在计算节点安装客户端
yum install -y nfs-utils
5、测试
注意直接创建实例用的是默认的iscsi类型,这个类型对应的volume_backend_name为lvm所以要先创建一个卷
在卷这一项创建一个类型为nfs的卷
确保卷可用,然后创建一个实例接入该卷