CentOS 7
Sponsored Link

OpenStack Mitaka : Use Cinder Storage (NFS)2016/05/08

 
It's possible to use Virtual Storages provided by Cinder if an Instance needs more disks.
Configure Virtual storage with NFS backend on here.
                                      +------------------+
                             10.0.0.50| [ Storage Node ] |
+------------------+            +-----+   Cinder-Volume  |
| [ Control Node ] |            | eth0|                  |           +--------------+
|     Keystone     |10.0.0.30   |     +------------------+  10.0.0.40|              |
|      Glance      |------------+------------------------------------+  NFS Server  |
|     Nova API     |eth0        |     +------------------+       eth0|              |
|    Cinder API    |            | eth0| [ Compute Node ] |           +--------------+
+------------------+            +-----+   Nova Compute   |
                             10.0.0.51|                  |
                                      +------------------+

[1]
NFS server is required to be running on your LAN, refer to here.
On this example, configure "/storage" directory on "nfs.srv.world" as a shared directory.
[2] Configure Storage Node.
[root@storage ~]#
yum -y install nfs-utils
[root@storage ~]#
vi /etc/idmapd.conf
# line 5: uncomment and change to the own domain name

Domain =
srv.world
[root@storage ~]#
systemctl start rpcbind

[root@storage ~]#
systemctl enable rpcbind
[root@storage ~]#
vi /etc/cinder/cinder.conf
# add follows in the [DEFAULT] section

enabled_backends = nfs
# add follows to the end

[nfs]
volume_driver = cinder.volume.drivers.nfs.NfsDriver
nfs_shares_config = /etc/cinder/nfs_shares
nfs_mount_point_base = $state_path/mnt
[root@storage ~]#
vi /etc/cinder/nfs_shares
# create new : specify NFS shared directory

nfs.srv.world:/storage
[root@storage ~]#
chmod 640 /etc/cinder/nfs_shares

[root@storage ~]#
chgrp cinder /etc/cinder/nfs_shares

[root@storage ~]#
systemctl restart openstack-cinder-volume

[root@storage ~]#
chown -R cinder. /var/lib/cinder/mnt

[3] Change Nova settings to mount NFS.
[root@node01 ~]#
yum -y install nfs-utils
[root@node01 ~]#
vi /etc/idmapd.conf
# line 5: uncomment and change to the own domain name

Domain =
srv.world
[root@node01 ~]#
systemctl start rpcbind

[root@node01 ~]#
systemctl enable rpcbind
[root@node01 ~]#
vi /etc/nova/nova.conf
# add follows in the [DEFAULT] section

volume_api_class = nova.volume.cinder.API
[root@node01 ~]#
systemctl restart openstack-nova-compute

[4] For example, create a virtual disk "disk01" with 10GB. It's OK to work on any node. (This example is on Control Node)
# set environment variable first

[root@dlp ~(keystone)]#
echo "export OS_VOLUME_API_VERSION=2" >> ~/keystonerc

[root@dlp ~(keystone)]#
source ~/keystonerc
[root@dlp ~(keystone)]#
cinder create --display_name disk01 10

+--------------------------------+--------------------------------------+
|            Property            |                Value                 |
+--------------------------------+--------------------------------------+
|          attachments           |                  []                  |
|       availability_zone        |                 nova                 |
|            bootable            |                false                 |
|      consistencygroup_id       |                 None                 |
|           created_at           |      2016-05-09T14:46:33.000000      |
|          description           |                 None                 |
|           encrypted            |                False                 |
|               id               | bfb88906-30d8-42b3-8c02-29583491e2d0 |
|            metadata            |                  {}                  |
|        migration_status        |                 None                 |
|          multiattach           |                False                 |
|              name              |                disk01                |
|     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  |   7a160aeddebd4e398fd22e6491f10baa   |
|       replication_status       |               disabled               |
|              size              |                  10                  |
|          snapshot_id           |                 None                 |
|          source_volid          |                 None                 |
|             status             |               creating               |
|           updated_at           |                 None                 |
|            user_id             |   f9c0838d5fcf4a87ba2e0b1653faa6d0   |
|          volume_type           |                 None                 |
+--------------------------------+--------------------------------------+

[root@dlp ~(keystone)]#
cinder list

+--------------------------------------+-----------+--------+------+-------------+----------+-------------+
|                  ID                  |   Status  |  Name  | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+--------+------+-------------+----------+-------------+
| bfb88906-30d8-42b3-8c02-29583491e2d0 | available | disk01 |  10  |      -      |  false   |             |
+--------------------------------------+-----------+--------+------+-------------+----------+-------------+
[5] Attach the virtual disk to an Instance.
For the example below, the disk is connected as "/dev/vdb". It's possible to use it as a storage to create a file system on it.
[root@dlp ~(keystone)]#
nova list

+-----------+----------+---------+------------+-------------+-----------------------------------+
| ID        | Name     | Status  | Task State | Power State | Networks                          |
+-----------+----------+---------+------------+-------------+-----------------------------------+
| 4e232450- | CentOS_7 | SHUTOFF | -          | Shutdown    | int_net=192.168.100.3, 10.0.0.201 |
+-----------+----------+---------+------------+-------------+-----------------------------------+

[root@dlp ~(keystone)]#
nova volume-attach CentOS_7 bfb88906-30d8-42b3-8c02-29583491e2d0 auto

+----------+--------------------------------------+
| Property | Value                                |
+----------+--------------------------------------+
| device   | /dev/vdb                             |
| id       | bfb88906-30d8-42b3-8c02-29583491e2d0 |
| serverId | 4e232450-4cae-47ba-a19a-1c59e3cbc91b |
| volumeId | bfb88906-30d8-42b3-8c02-29583491e2d0 |
+----------+--------------------------------------+

# the status of attached disk turns "in-use" like follows

[root@dlp ~(keystone)]#
cinder list

+--------------------------------------+--------+--------+------+-------------+----------+--------------------------------------+
|                  ID                  | Status |  Name  | Size | Volume Type | Bootable |             Attached to              |
+--------------------------------------+--------+--------+------+-------------+----------+--------------------------------------+
| bfb88906-30d8-42b3-8c02-29583491e2d0 | in-use | disk01 |  10  |      -      |  false   | 4e232450-4cae-47ba-a19a-1c59e3cbc91b |
+--------------------------------------+--------+--------+------+-------------+----------+--------------------------------------+
Matched Content