Attaching external NFS storage
The Generic NFS Reference Driver allows you to mount multiple NFS shares to your compute cluster and use them as external NFS storages.
To attach an external NFS storage
Use the following command:
vinfra service compute storage add <storage_name> --nfs --params nas_host=<nas_ip_address>,nas_share_path=<share_path>
[--nfs-mount-options <options>] --enable
Where:
<storage_name>is a custom name of your external storage. The name may only contain letters, numbers, and underscores, and must be 3 to 64 characters long.nas_host=<nas_ip_address>is the IP address of the external storage to connect to.nas_share_path=<share_path>is the root export path of the NFS share.-
--nfs-mount-options <options>is a comma-separated list of mount options for NFS compute storages, with additional flags separated by spaces. For example:lookupcache=none,nfsvers=4,minorversion=0,timeo=150,retrans=3 -m -s. To see a full list of mount options, refer to themountandnfsman pages.Note that if
nfs_shares_configis used, these mount options are applied to every share listed in the configuration file, unless they are overwritten in the configuration file.Setting the
lookupcachepolicy toallis not recommended as it leads to issues with accessing volume.infofiles.
When the --nfs option is specified, it automatically sets the following parameters required for NFS storage:
volume_backend_nameto the external storage name specified by<storage_name>.volume_driverto the name of the OpenStack volume driver, which iscinder.volume.drivers.nfs.NfsDriver.nfs_mount_optionstolookupcache=posto ensure that the NFS client revalidates negative entries in the directory entry cache.nfs_mount_point_baseto the directory to mount the NFS share to, which is /mnt/compute/storages.nas_secure_file_permissionstoFalseto create volumes with open permissions.nfs_qcow2_volumestoTrueto create volumes as QCOW2 files.nfs_snapshot_supporttoTrueandnas_secure_file_operationstoFalseto enable support for snapshots.nfs_sparsed_volumestoTrueto create volumes as sparsed files, which take no space.
For example, to add the external storage nfs_storage with the IP address 10.10.10.12 and the share path /myshare, run:
# vinfra service compute storage add nfs_storage --nfs --params nas_host=10.10.10.12,nas_share_path=/myshare --enable
Ensure that the data specified is valid. An incorrectly configured storage will lead to the critical state of the cinder-volume service and the node itself. However, all other operations on the node will not be affected.
The added external storage will appear in the vinfra service compute storage list output:
# vinfra service compute storage list +-------------+----------------------------------------------------+---------------+---------+------------+ | name | params | secret_params | enabled | configured | +-------------+----------------------------------------------------+---------------+---------+------------+ | nfs_storage | nas_host: 10.10.10.12 | | True | True | | | nas_secure_file_operations: 'False' | | | | | | nas_secure_file_permissions: 'False' | | | | | | nas_share_path: /myshare | | | | | | nfs_mount_options: lookupcache=pos | | | | | | nfs_mount_point_base: /mnt/compute/storages | | | | | | nfs_qcow2_volumes: 'True' | | | | | | nfs_snapshot_support: 'True' | | | | | | nfs_sparsed_volumes: 'True' | | | | | | volume_backend_name: nfs-storage | | | | | | volume_driver: cinder.volume.drivers.nfs.NfsDriver | | | | +-------------+----------------------------------------------------+---------------+---------+------------+