Configure NFS network storage as the back-end storage of cinder

Install cinder and nfs

yum install -y openstack-cinder
yum install cifs-utils

Configuring nfs on the controller node

[root@controller ~]# mkdir -p /data/nfs  #Create a directory to share mount resources
[root@controller ~]# cat /etc/exports
/data/nfs *(rw,sync,root_squash) #The configuration file of NFS service program is / etc / exports sync, which writes data to memory and hard disk at the same time, ensuring no loss of data. rw reads and writes no root. When NFS client is accessed as root administrator, it is mapped as root administrator of NFS server

Start and enable the NFS server. Before using NFS service for file sharing, RPC (Remote Procedure Call) service is needed to send the IP address and port number of NFS server to the client. Therefore, before starting the NFS service, you need to restart and enable the rpcbind service program, and add both services to the boot entry

[root@controller ~]# systemctl resatrt rpcbind
[root@controller ~]# systemctl enable rpcbind
[root@controller ~]# systemctl start nfs-server
[root@controller ~]# systemctl enable nfs-server

Using the showmount command to query the remote share information of NFS server

[root@controller ~]# showmount -e 192.168.100.10
Export list for 192.168.100.10:
/data/nfs *

Test mount

[root@compute ~]# mount 192.168.100.10:/data/nfs /mnt/
192.168.100.10:/data/nfs nfs4      197G   19G  169G  10% /mnt
#Mount successfully
[root@compute ~]# umount /mnt/
[root@compute ~]# df -Th
Filesystem              Type      Size  Used Avail Use% Mounted on
/dev/mapper/centos-root ext4      2.9T  1.8G  2.8T   1% /
devtmpfs                devtmpfs  7.8G     0  7.8G   0% /dev
tmpfs                   tmpfs     7.8G     0  7.8G   0% /dev/shm
tmpfs                   tmpfs     7.8G   17M  7.8G   1% /run
tmpfs                   tmpfs     7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/md126p2            xfs       495M  129M  367M  27% /boot
tmpfs                   tmpfs     1.6G     0  1.6G   0% /run/user/0

Configuring nfs as a cinder backend storage

[root@controller ~]# vi /etc/cinder/cinder.conf 
[DEFAULT]
volume_driver = cinder.volume.drivers.nfs.NfsDriver
nfs_shares_config = /etc/cinder/nfs.conf

To create the file / etc/cinder/nfs.conf

[root@controller ~]# vi /etc/cinder/nfs.conf
192.168.100.10:/data/nfs

Restart service nfs backend storage auto mount

[root@controller ~]# systemctl restart openstack-cinder-api.service
[root@controller ~]# systemctl restart openstack-cinder-volume.service
[root@controller ~]# systemctl restart openstack-cinder-scheduler.service
[root@controller ~]# df -Th
Filesystem               Type      Size  Used Avail Use% Mounted on
/dev/mapper/centos-root  ext4      197G   19G  169G  10% /
devtmpfs                 devtmpfs  7.8G     0  7.8G   0% /dev
tmpfs                    tmpfs     7.8G     0  7.8G   0% /dev/shm
tmpfs                    tmpfs     7.8G  8.7M  7.8G   1% /run
tmpfs                    tmpfs     7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/sda1                xfs       494M  126M  368M  26% /boot
/dev/loop0               iso9660   4.1G  4.1G     0 100% /opt/centos
/dev/loop1               iso9660   2.7G  2.7G     0 100% /opt/iaas
tmpfs                    tmpfs     1.6G     0  1.6G   0% /run/user/0
192.168.100.10:/data/nfs nfs4      197G   19G  169G  10% /var/lib/cinder/mnt/cfee723fff086429eb82121076ac5407

Create volume test

[root@controller ~]# cinder create --display-name 'volume' 1
+--------------------------------+--------------------------------------+
|            Property            |                Value                 |
+--------------------------------+--------------------------------------+
|          attachments           |                  []                  |
|       availability_zone        |                 nova                 |
|            bootable            |                false                 |
|      consistencygroup_id       |                 None                 |
|           created_at           |      2019-04-24T15:36:11.000000      |
|          description           |                 None                 |
|           encrypted            |                False                 |
|               id               | d259218e-45ec-4d31-a97c-b7e006cf957e |
|            metadata            |                  {}                  |
|        migration_status        |                 None                 |
|          multiattach           |                False                 |
|              name              |                volume                |
|     os-vol-host-attr:host      |                 None                 |
| os-vol-mig-status-attr:migstat |                 None                 |
| os-vol-mig-status-attr:name_id |                 None                 |
|  os-vol-tenant-attr:tenant_id  |   89b7ee9ffd73479b9446a3bf296bacbb   |
|       replication_status       |               disabled               |
|              size              |                  1                   |
|          snapshot_id           |                 None                 |
|          source_volid          |                 None                 |
|             status             |               creating               |
|           updated_at           |                 None                 |
|            user_id             |   3469ea43ec3345d2a29606c4566cd43a   |
|          volume_type           |                 None                 |
+--------------------------------+--------------------------------------+
[root@controller ~]# openstack volume list
+--------------------------------------+--------------+--------+------+-------------+
| ID                                   | Display Name | Status | Size | Attached to |
+--------------------------------------+--------------+--------+------+-------------+
| d259218e-45ec-4d31-a97c-b7e006cf957e | volume       | error  |    1 |             |
+--------------------------------------+--------------+--------+------+-------------+

#volume status erros to view the log

[root@controller cinder]# tail -f volume.log 
2019-04-24 11:36:13.359 461 ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/cinder/utils.py", line 148, in execute
2019-04-24 11:36:13.359 461 ERROR oslo_messaging.rpc.dispatcher     return processutils.execute(*cmd, **kwargs)
2019-04-24 11:36:13.359 461 ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/oslo_concurrency/processutils.py", line 389, in execute
2019-04-24 11:36:13.359 461 ERROR oslo_messaging.rpc.dispatcher     cmd=sanitized_cmd)
2019-04-24 11:36:13.359 461 ERROR oslo_messaging.rpc.dispatcher ProcessExecutionError: Unexpected error while running command.
2019-04-24 11:36:13.359 461 ERROR oslo_messaging.rpc.dispatcher Command: truncate -s 1G /var/lib/cinder/mnt/cfee723fff086429eb82121076ac5407/volume-d259218e-45ec-4d31-a97c-b7e006cf957e
2019-04-24 11:36:13.359 461 ERROR oslo_messaging.rpc.dispatcher Exit code: 1
2019-04-24 11:36:13.359 461 ERROR oslo_messaging.rpc.dispatcher Stdout: u''
2019-04-24 11:36:13.359 461 ERROR oslo_messaging.rpc.dispatcher Stderr: 'truncate: cannot open \xe2\x80\x98/var/lib/cinder/mnt/cfee723fff086429eb82121076ac5407/volume-d259218e-45ec-4d31-a97c-b7e006cf957e\xe2\x80\x99 for writing: Permission denied\n'
2019-04-24 11:36:13.359 461 ERROR oslo_messaging.rpc.dispatcher 

No permission for failure reason

[root@controller ~]# ls /data/nfs/ -ld
drwxr-xr-x. 2 root root 4096 Apr 24 10:19 /data/nfs/
[root@controller ~]# chmod o+w /data/nfs/
[root@controller ~]# ls /data/nfs/ -ld   
drwxr-xrwx. 2 root root 4096 Apr 24 10:19 /data/nfs/

Recreate volume test

[root@controller ~]# cinder create --display-name 'volume' 1
+--------------------------------+--------------------------------------+
|            Property            |                Value                 |
+--------------------------------+--------------------------------------+
|          attachments           |                  []                  |
|       availability_zone        |                 nova                 |
|            bootable            |                false                 |
|      consistencygroup_id       |                 None                 |
|           created_at           |      2019-04-24T15:41:56.000000      |
|          description           |                 None                 |
|           encrypted            |                False                 |
|               id               | 16b0c969-c71f-47e0-b898-1c2098e41338 |
|            metadata            |                  {}                  |
|        migration_status        |                 None                 |
|          multiattach           |                False                 |
|              name              |                volume                |
|     os-vol-host-attr:host      |                 None                 |
| os-vol-mig-status-attr:migstat |                 None                 |
| os-vol-mig-status-attr:name_id |                 None                 |
|  os-vol-tenant-attr:tenant_id  |   89b7ee9ffd73479b9446a3bf296bacbb   |
|       replication_status       |               disabled               |
|              size              |                  1                   |
|          snapshot_id           |                 None                 |
|          source_volid          |                 None                 |
|             status             |               creating               |
|           updated_at           |                 None                 |
|            user_id             |   3469ea43ec3345d2a29606c4566cd43a   |
|          volume_type           |                 None                 |
+--------------------------------+--------------------------------------+
[root@controller ~]# cinder list
+--------------------------------------+-----------+--------+------+-------------+----------+-------------+
|                  ID                  |   Status  |  Name  | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+--------+------+-------------+----------+-------------+
| 16b0c969-c71f-47e0-b898-1c2098e41338 | available | volume |  1   |      -      |  false   |             |
+--------------------------------------+-----------+--------+------+-------------+----------+-------------+

volume status available

[root@controller ~]# ls /data/nfs/
volume-16b0c969-c71f-47e0-b898-1c2098e41338
#volume is written to nfs as back-end storage

Tags: OpenStack CentOS yum Permission denied

Posted on Sat, 23 Nov 2019 11:41:57 -0500 by ksimpkins