CentOS 6
Sponsored Link

OpenStack Havana - Use Virtual Storage(NFS)2013/10/27

 
It's possible to use Virtual Storage provided by Cinder for Virtual Machine Instance.
This example shows to set to use NFS for Virtual Storage. If you've already set LVM for Virtual Storage, unset it first.
[1]
Configure NFS Server in your LAN first.
This example uses a shared directory "/storage" provided by NFS on "nfs.srv.world".
[2] Configure idmapd
[root@dlp ~(keystone)]#
vi /etc/idmapd.conf
# line 5: uncomment and chnage your domain name

Domain =
srv.world
[root@dlp ~(keystone)]#
/etc/rc.d/init.d/rpcidmapd restart

Stopping RPC idmapd: [ OK ]
Starting RPC idmapd: [ OK ]
[3] Configure Cinder
[root@dlp ~(keystone)]#
vi /etc/cinder/cinder.conf
# line 1384: uncomment

nfs_shares_config=/etc/cinder/nfs_shares

# line 1403: uncomment and change

nfs_mount_point_base=
/var/lib/cinder/mnt
# line 1757: uncomment and change

volume_driver=cinder.volume.drivers.
nfs.NfsDriver
[root@dlp ~(keystone)]#
vi /etc/nova/nova.conf
# line 2014: uncomment

libvirt_volume_drivers=iscsi=nova.virt.libvirt.volume.LibvirtISCSIVolumeDriver,i
ser=nova.virt.libvirt.volume.LibvirtISERVolumeDriver,local=nova.virt.libvirt.vol
ume.LibvirtVolumeDriver,fake=nova.virt.libvirt.volume.LibvirtFakeVolumeDriver,rb
d=nova.virt.libvirt.volume.LibvirtNetVolumeDriver,sheepdog=nova.virt.libvirt.vol
ume.LibvirtNetVolumeDriver,nfs=nova.virt.libvirt.volume.LibvirtNFSVolumeDriver,a
oe=nova.virt.libvirt.volume.LibvirtAOEVolumeDriver,glusterfs=nova.virt.libvirt.v
olume.LibvirtGlusterfsVolumeDriver,fibre_channel=nova.virt.libvirt.volume.Libvir
tFibreChannelVolumeDriver,scality=nova.virt.libvirt.volume.LibvirtScalityVolumeD
river

# line 2172: uncomment and change

nfs_mount_point_base=
/var/lib/cinder/mnt
[root@dlp ~(keystone)]#
vi /etc/cinder/nfs_shares
# create new : specify NFS shared directory

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

[root@dlp ~(keystone)]#
chgrp cinder /etc/cinder/nfs_shares

[root@dlp ~(keystone)]#
mkdir /var/lib/cinder/mnt

[root@dlp ~(keystone)]#
chown cinder. /var/lib/cinder/mnt

[root@dlp ~(keystone)]#
/etc/rc.d/init.d/openstack-cinder-volume restart

Stopping openstack-cinder-volume: [ OK ]
Starting openstack-cinder-volume: [ OK ]
[root@dlp ~(keystone)]#
/etc/rc.d/init.d/openstack-nova-compute restart

Stopping openstack-nova-compute: [ OK ]
Starting openstack-nova-compute: [ OK ]
[4] For example, create a volume named "disk01", 10GB.
[root@dlp ~(keystone)]#
cinder create --display_name disk01 10

+---------------------+--------------------------------------+
|       Property      |                Value                 |
+---------------------+--------------------------------------+
|     attachments     |                  []                  |
|  availability_zone  |                 nova                 |
|       bootable      |                false                 |
|      created_at     |      2013-10-28T06:57:15.176400      |
| display_description |                 None                 |
|     display_name    |                disk01                |
|          id         | 344ed806-d34e-4a6d-aeee-4a188082681b |
|       metadata      |                  {}                  |
|         size        |                  10                  |
|     snapshot_id     |                 None                 |
|     source_volid    |                 None                 |
|        status       |               creating               |
|     volume_type     |                 None                 |
+---------------------+--------------------------------------+

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

+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
|                  ID                  |   Status  | Display Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| 344ed806-d34e-4a6d-aeee-4a188082681b | available |    disk01    |  10  |     None    |  false   |             |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
[5] Attach the volume just created to Instance.
The following example just attached to the Instance as "/dev/vdb".
[root@dlp ~(keystone)]#
nova list

+--------------------------------------+-----------+---------+------------+-------------+--------------------+
| ID                                   | Name      | Status  | Task State | Power State | Networks           |
+--------------------------------------+-----------+---------+------------+-------------+--------------------+
| 7dc735d8-5206-4b0f-8016-41c5e1fe2381 | CentOS_64 | SHUTOFF | None       | Shutdown    | network01=10.1.0.2 |
+--------------------------------------+-----------+---------+------------+-------------+--------------------+

[root@dlp ~(keystone)]#
nova volume-attach CentOS_64 344ed806-d34e-4a6d-aeee-4a188082681b auto

+----------+--------------------------------------+
| Property | Value                                |
+----------+--------------------------------------+
| device   | /dev/vdb                             |
| serverId | 7dc735d8-5206-4b0f-8016-41c5e1fe2381 |
| id       | 344ed806-d34e-4a6d-aeee-4a188082681b |
| volumeId | 344ed806-d34e-4a6d-aeee-4a188082681b |
+----------+--------------------------------------+
Matched Content