2012-10-10 20:22:47 +00:00
|
|
|
|
=============================
|
|
|
|
|
Block Devices and OpenStack
|
|
|
|
|
=============================
|
2012-09-18 20:00:58 +00:00
|
|
|
|
|
2013-06-14 23:57:48 +00:00
|
|
|
|
.. index:: Ceph Block Device; OpenStack
|
|
|
|
|
|
|
|
|
|
You may use Ceph Block Device images with OpenStack through ``libvirt``, which
|
2012-10-10 20:22:47 +00:00
|
|
|
|
configures the QEMU interface to ``librbd``. Ceph stripes block device images as
|
2013-06-14 23:57:48 +00:00
|
|
|
|
objects across the cluster, which means that large Ceph Block Device images have
|
2012-10-10 20:22:47 +00:00
|
|
|
|
better performance than a standalone server!
|
2012-09-18 20:00:58 +00:00
|
|
|
|
|
2013-06-14 23:57:48 +00:00
|
|
|
|
To use Ceph Block Devices with OpenStack, you must install QEMU, ``libvirt``,
|
2013-10-31 00:21:14 +00:00
|
|
|
|
and OpenStack first. We recommend using a separate physical node for your
|
2012-10-10 20:22:47 +00:00
|
|
|
|
OpenStack installation. OpenStack recommends a minimum of 8GB of RAM and a
|
|
|
|
|
quad-core processor. The following diagram depicts the OpenStack/Ceph
|
|
|
|
|
technology stack.
|
2012-09-18 20:00:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.. ditaa:: +---------------------------------------------------+
|
|
|
|
|
| OpenStack |
|
2012-10-09 21:06:40 +00:00
|
|
|
|
+---------------------------------------------------+
|
2012-09-18 20:00:58 +00:00
|
|
|
|
| libvirt |
|
2012-10-09 21:06:40 +00:00
|
|
|
|
+------------------------+--------------------------+
|
|
|
|
|
|
|
|
|
|
|
| configures
|
|
|
|
|
v
|
|
|
|
|
+---------------------------------------------------+
|
|
|
|
|
| QEMU |
|
2012-09-18 20:00:58 +00:00
|
|
|
|
+---------------------------------------------------+
|
|
|
|
|
| librbd |
|
|
|
|
|
+---------------------------------------------------+
|
2012-10-01 21:53:57 +00:00
|
|
|
|
| librados |
|
2012-09-26 00:19:50 +00:00
|
|
|
|
+------------------------+-+------------------------+
|
|
|
|
|
| OSDs | | Monitors |
|
|
|
|
|
+------------------------+ +------------------------+
|
2012-06-18 21:29:04 +00:00
|
|
|
|
|
2013-06-14 23:57:48 +00:00
|
|
|
|
.. important:: To use Ceph Block Devices with OpenStack, you must have
|
|
|
|
|
access to a running Ceph Storage Cluster.
|
2012-06-18 21:29:04 +00:00
|
|
|
|
|
2012-10-10 20:22:47 +00:00
|
|
|
|
Two parts of OpenStack integrate with Ceph's block devices:
|
2012-09-18 20:00:58 +00:00
|
|
|
|
|
2012-10-10 20:22:47 +00:00
|
|
|
|
- **Images**: OpenStack Glance manages images for VMs. Images
|
|
|
|
|
are immutable. OpenStack treats images as binary blobs and
|
|
|
|
|
downloads them accordingly.
|
2012-10-01 18:39:54 +00:00
|
|
|
|
|
2012-10-10 20:22:47 +00:00
|
|
|
|
- **Volumes**: Volumes are block devices. OpenStack uses volumes
|
2013-10-31 00:21:14 +00:00
|
|
|
|
to boot VMs, or to attach volumes to running VMs. OpenStack manages
|
|
|
|
|
volumes using Cinder services.
|
2012-10-01 18:39:54 +00:00
|
|
|
|
|
2013-10-31 00:44:24 +00:00
|
|
|
|
You can use OpenStack Glance to store images in a Ceph Block Device, and you
|
2013-10-31 00:21:14 +00:00
|
|
|
|
can use Cinder to boot a VM using a copy-on-write clone of an image.
|
2012-10-10 20:22:47 +00:00
|
|
|
|
|
2013-10-31 00:21:14 +00:00
|
|
|
|
The instructions below detail the setup for Glance and Cinder, although
|
2012-10-10 20:22:47 +00:00
|
|
|
|
they do not have to be used together. You may store images in Ceph block devices
|
|
|
|
|
while running VMs using a local disk, or vice versa.
|
2012-06-18 21:29:04 +00:00
|
|
|
|
|
2013-10-31 00:44:24 +00:00
|
|
|
|
.. tip:: This document describes using Ceph Block Devices with OpenStack Havana.
|
|
|
|
|
For earlier versions of OpenStack see
|
|
|
|
|
`Block Devices and OpenStack (Dumpling)`_.
|
|
|
|
|
|
2013-06-14 23:57:48 +00:00
|
|
|
|
.. index:: pools; OpenStack
|
|
|
|
|
|
2012-06-18 21:29:04 +00:00
|
|
|
|
Create a Pool
|
2012-09-18 20:00:58 +00:00
|
|
|
|
=============
|
|
|
|
|
|
2012-10-10 20:22:47 +00:00
|
|
|
|
By default, Ceph block devices use the ``rbd`` pool. You may use any available
|
2013-10-31 00:21:14 +00:00
|
|
|
|
pool. We recommend creating a pool for Cinder and a pool for Glance. Ensure
|
2012-10-10 20:22:47 +00:00
|
|
|
|
your Ceph cluster is running, then create the pools. ::
|
2012-06-18 21:29:04 +00:00
|
|
|
|
|
2012-11-12 20:01:07 +00:00
|
|
|
|
ceph osd pool create volumes 128
|
|
|
|
|
ceph osd pool create images 128
|
2012-09-18 20:00:58 +00:00
|
|
|
|
|
2012-10-10 20:22:47 +00:00
|
|
|
|
See `Create a Pool`_ for detail on specifying the number of placement groups for
|
|
|
|
|
your pools, and `Placement Groups`_ for details on the number of placement
|
2012-10-01 18:39:54 +00:00
|
|
|
|
groups you should set for your pools.
|
|
|
|
|
|
2012-12-03 20:22:37 +00:00
|
|
|
|
.. _Create a Pool: ../../rados/operations/pools#createpool
|
|
|
|
|
.. _Placement Groups: ../../rados/operations/placement-groups
|
2012-10-01 18:39:54 +00:00
|
|
|
|
|
2012-10-10 20:22:47 +00:00
|
|
|
|
|
|
|
|
|
Configure OpenStack Ceph Clients
|
2012-10-01 18:39:54 +00:00
|
|
|
|
================================
|
|
|
|
|
|
2013-10-31 00:21:14 +00:00
|
|
|
|
The nodes running ``glance-api`` and ``cinder-volume`` act as Ceph clients. Each
|
|
|
|
|
requires the ``ceph.conf`` file::
|
2012-10-01 18:39:54 +00:00
|
|
|
|
|
2012-10-10 20:22:47 +00:00
|
|
|
|
ssh {your-openstack-server} sudo tee /etc/ceph/ceph.conf </etc/ceph/ceph.conf
|
2012-10-01 18:39:54 +00:00
|
|
|
|
|
|
|
|
|
Install Ceph client packages
|
|
|
|
|
----------------------------
|
|
|
|
|
|
2013-10-31 00:21:14 +00:00
|
|
|
|
On the ``glance-api`` node and on the ``cinder-volume`` node, you'll need the
|
|
|
|
|
Python bindings for ``librbd``::
|
2012-10-01 18:39:54 +00:00
|
|
|
|
|
|
|
|
|
sudo apt-get install python-ceph
|
2013-10-31 00:21:14 +00:00
|
|
|
|
sudo yum install python-ceph
|
2012-10-01 18:39:54 +00:00
|
|
|
|
|
2013-10-31 00:21:14 +00:00
|
|
|
|
On the ``cinder-volume`` node, use the client command line tools::
|
2012-10-01 18:39:54 +00:00
|
|
|
|
|
|
|
|
|
sudo apt-get install ceph-common
|
2013-10-31 00:21:14 +00:00
|
|
|
|
sudo yum install ceph
|
2012-10-01 18:39:54 +00:00
|
|
|
|
|
2012-10-10 20:22:47 +00:00
|
|
|
|
|
|
|
|
|
Setup Ceph Client Authentication
|
2012-10-01 18:39:54 +00:00
|
|
|
|
--------------------------------
|
|
|
|
|
|
2012-11-13 16:14:09 +00:00
|
|
|
|
If you have `cephx authentication`_ enabled, create a new user for Nova/Cinder
|
2013-10-31 00:21:14 +00:00
|
|
|
|
and Glance. Execute the following::
|
2012-12-30 07:57:01 +00:00
|
|
|
|
|
|
|
|
|
ceph auth get-or-create client.volumes mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=volumes, allow rx pool=images'
|
|
|
|
|
ceph auth get-or-create client.images mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=images'
|
2012-11-13 16:14:09 +00:00
|
|
|
|
|
2013-03-12 21:25:44 +00:00
|
|
|
|
Add the keyrings for ``client.volumes`` and ``client.images`` to the appropriate
|
2013-10-31 00:21:14 +00:00
|
|
|
|
nodes and change their ownership::
|
2012-10-01 18:39:54 +00:00
|
|
|
|
|
2012-10-10 20:22:47 +00:00
|
|
|
|
ceph auth get-or-create client.images | ssh {your-glance-api-server} sudo tee /etc/ceph/ceph.client.images.keyring
|
|
|
|
|
ssh {your-glance-api-server} sudo chown glance:glance /etc/ceph/ceph.client.images.keyring
|
|
|
|
|
ceph auth get-or-create client.volumes | ssh {your-volume-server} sudo tee /etc/ceph/ceph.client.volumes.keyring
|
|
|
|
|
ssh {your-volume-server} sudo chown cinder:cinder /etc/ceph/ceph.client.volumes.keyring
|
2012-06-18 21:29:04 +00:00
|
|
|
|
|
2013-10-31 00:21:14 +00:00
|
|
|
|
Nodes running ``nova-compute`` do not need the keyring. Instead, they
|
|
|
|
|
store the secret key in ``libvirt``. Create a temporary copy of the secret
|
|
|
|
|
key on the nodes running ``nova-compute``::
|
2012-09-18 20:00:58 +00:00
|
|
|
|
|
2013-10-31 00:21:14 +00:00
|
|
|
|
ceph auth get-key client.volumes | ssh {your-compute-node} tee client.volumes.key
|
2012-06-18 21:29:04 +00:00
|
|
|
|
|
2013-10-31 00:21:14 +00:00
|
|
|
|
Then, on the compute nodes, add the secret key to ``libvirt`` and remove the
|
2013-03-12 21:25:44 +00:00
|
|
|
|
temporary copy of the key::
|
2012-06-18 21:29:04 +00:00
|
|
|
|
|
2012-10-01 18:39:54 +00:00
|
|
|
|
cat > secret.xml <<EOF
|
|
|
|
|
<secret ephemeral='no' private='no'>
|
|
|
|
|
<usage type='ceph'>
|
|
|
|
|
<name>client.volumes secret</name>
|
|
|
|
|
</usage>
|
|
|
|
|
</secret>
|
|
|
|
|
EOF
|
|
|
|
|
sudo virsh secret-define --file secret.xml
|
|
|
|
|
<uuid of secret is output here>
|
|
|
|
|
sudo virsh secret-set-value --secret {uuid of secret} --base64 $(cat client.volumes.key) && rm client.volumes.key secret.xml
|
2012-09-18 20:00:58 +00:00
|
|
|
|
|
2012-10-10 20:22:47 +00:00
|
|
|
|
Save the uuid of the secret for configuring ``nova-compute`` later.
|
2012-09-18 20:00:58 +00:00
|
|
|
|
|
2012-12-03 20:22:37 +00:00
|
|
|
|
.. _cephx authentication: ../../rados/operations/authentication
|
2012-10-09 20:53:37 +00:00
|
|
|
|
|
2012-10-01 18:39:54 +00:00
|
|
|
|
|
2012-10-10 20:22:47 +00:00
|
|
|
|
Configure OpenStack to use Ceph
|
|
|
|
|
===============================
|
2012-10-01 18:39:54 +00:00
|
|
|
|
|
|
|
|
|
Configuring Glance
|
|
|
|
|
------------------
|
2012-10-10 20:22:47 +00:00
|
|
|
|
|
|
|
|
|
Glance can use multiple back ends to store images. To use Ceph block devices by
|
2012-10-01 18:39:54 +00:00
|
|
|
|
default, edit ``/etc/glance/glance-api.conf`` and add::
|
|
|
|
|
|
|
|
|
|
default_store=rbd
|
|
|
|
|
rbd_store_user=images
|
|
|
|
|
rbd_store_pool=images
|
|
|
|
|
|
2013-10-31 00:44:24 +00:00
|
|
|
|
If you’re using Folsom and want to enable copy-on-write cloning of images into
|
|
|
|
|
volumes, also add::
|
|
|
|
|
|
|
|
|
|
show_image_direct_url=True
|
|
|
|
|
|
|
|
|
|
Note that this exposes the back end location via Glance’s API, so the endpoint
|
|
|
|
|
with this option enabled should not be publicly accessible.
|
|
|
|
|
|
2012-10-10 20:22:47 +00:00
|
|
|
|
|
2013-10-31 00:21:14 +00:00
|
|
|
|
Configuring Cinder
|
|
|
|
|
------------------
|
2012-10-10 20:22:47 +00:00
|
|
|
|
|
|
|
|
|
OpenStack requires a driver to interact with Ceph block devices. You must also
|
2013-10-31 00:21:14 +00:00
|
|
|
|
specify the pool name for the block device. On your OpenStack node,
|
|
|
|
|
edit ``/etc/cinder/cinder.conf`` by adding::
|
2013-05-30 21:17:35 +00:00
|
|
|
|
|
|
|
|
|
volume_driver=cinder.volume.drivers.rbd.RBDDriver
|
|
|
|
|
rbd_pool=volumes
|
|
|
|
|
glance_api_version=2
|
2012-06-18 21:29:04 +00:00
|
|
|
|
|
2012-10-01 18:39:54 +00:00
|
|
|
|
If you're using `cephx authentication`_, also configure the user and
|
2013-10-31 00:21:14 +00:00
|
|
|
|
uuid of the secret you added to ``libvirt`` earlier::
|
2012-10-01 18:39:54 +00:00
|
|
|
|
|
|
|
|
|
rbd_user=volumes
|
|
|
|
|
rbd_secret_uuid={uuid of secret}
|
2012-09-18 20:00:58 +00:00
|
|
|
|
|
2012-11-13 16:14:09 +00:00
|
|
|
|
|
2012-10-10 20:22:47 +00:00
|
|
|
|
|
2012-09-26 00:21:52 +00:00
|
|
|
|
Restart OpenStack
|
2012-09-18 20:00:58 +00:00
|
|
|
|
=================
|
|
|
|
|
|
2012-10-10 20:22:47 +00:00
|
|
|
|
To activate the Ceph block device driver and load the block device pool name
|
|
|
|
|
into the configuration, you must restart OpenStack. Navigate the directory where
|
|
|
|
|
you installed OpenStack, and execute the following::
|
2012-06-18 21:29:04 +00:00
|
|
|
|
|
|
|
|
|
./rejoin-stack.sh
|
|
|
|
|
|
2012-10-09 20:53:37 +00:00
|
|
|
|
If you have OpenStack configured as a service, you can also execute
|
2013-10-31 00:21:14 +00:00
|
|
|
|
these commands on the appropriate nodes::
|
2012-06-18 21:29:04 +00:00
|
|
|
|
|
2012-10-09 20:53:37 +00:00
|
|
|
|
sudo service glance-api restart
|
|
|
|
|
sudo service nova-compute restart
|
|
|
|
|
sudo service cinder-volume restart
|
2012-06-18 21:29:04 +00:00
|
|
|
|
|
|
|
|
|
Once OpenStack is up and running, you should be able to create a volume with
|
2012-10-10 20:22:47 +00:00
|
|
|
|
OpenStack on a Ceph block device.
|
|
|
|
|
|
2012-10-01 18:39:54 +00:00
|
|
|
|
|
2012-10-10 20:22:47 +00:00
|
|
|
|
Booting from a Block Device
|
|
|
|
|
===========================
|
2012-10-01 18:39:54 +00:00
|
|
|
|
|
2013-10-31 00:21:14 +00:00
|
|
|
|
You can create a volume from an image using the Cinder command line tool::
|
2012-10-01 18:39:54 +00:00
|
|
|
|
|
|
|
|
|
cinder create --image-id {id of image} --display-name {name of volume} {size of volume}
|
|
|
|
|
|
2012-10-24 23:19:21 +00:00
|
|
|
|
Note that image must be raw format. You can use `qemu-img`_ to convert
|
|
|
|
|
from one format to another, i.e.::
|
|
|
|
|
|
|
|
|
|
qemu-img convert -f qcow2 -O raw precise-cloudimg.img precise-cloudimg.raw
|
|
|
|
|
|
2013-10-31 00:21:14 +00:00
|
|
|
|
When Glance and Cinder are both using Ceph block devices, the image is a
|
2012-10-01 18:39:54 +00:00
|
|
|
|
copy-on-write clone, so volume creation is very fast.
|
|
|
|
|
|
2012-10-10 20:22:47 +00:00
|
|
|
|
In the OpenStack dashboard you can then boot from that volume by launching a new
|
|
|
|
|
instance, choosing the image that you created the volume from, and selecting
|
|
|
|
|
'boot from volume' and the volume you created.
|
2012-10-24 23:19:21 +00:00
|
|
|
|
|
|
|
|
|
.. _qemu-img: ../qemu-rbd/#running-qemu-with-rbd
|
2013-10-31 00:44:24 +00:00
|
|
|
|
.. _Block Devices and OpenStack (Dumpling): http://ceph.com/docs/dumpling/rbd/rbd-openstack
|