Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure sheepdog as the storage backend of openstack Cinder

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

Editor to share with you how to configure sheepdog as the storage backend of openstack Cinder, I believe most people do not know much about it, so share this article for your reference. I hope you will learn a lot after reading this article. Let's learn about it together.

Cinder is Openstack's Software Defined Storage (SDS) open source solution that supports a variety of storage backends. These include sheepdog, a distributed open source block device. With zero configuration, Thin-Provision, high reliability, smart node management, linear expansion of capacity, virtual machine awareness (underlying support for hot and cold migration and snapshots, cloning, etc.), support for hybrid computing and storage architecture, etc., can scale to thousands of physical nodes.

1. Openstack environment description

The first step in starting to study openstack is, of course, to install openstack. For ordinary users, the most convenient access to openstack environment is to directly use the major linux distributions of openstack package. Both Ubuntu,Fedora/Centos/RHEL and SUSE have done a lot of packing work.

For example, Redhat's PDO: http://openstack.redhat.com/Quickstart

Http://docs.openstack.org/trunk/install-guide/install/yum/content/

For developers, it's best to use devstack, which is a complete set of BASH scripts that deploy the openstack development environment step by step from the source code, so it's easy to upgrade to the latest code.

two。 Install sheepdog

Refer to the official wiki: https://github.com/sheepdog/sheepdog/wiki/Getting-Started

Sheepdog and qemu projects are highly integrated and can directly support qemu's back-end storage.

For example:

Qemu-system-x86_64-drive file=sheepdog:192.168.10.2:7000:Alice

It means to start a virtual machine, and the back-end file is located in Alice VDI on the 192.168.10.2 sheepdog cluster node.

Because sheepdog does not develop its own cluster management, it relies on corosync. So be sure to install the wiki instructions for source code installation, and ensure that the service starts.

Otherwise, sheepdog daemon will not start.

[root@fedora] # cat / var/log/sheepdog/sheep.log Mar 25 22:56:53 INFO [main] md_add_disk / var/log/sheepdog/obj, vdisk nr 68, total disk 1Mar 25 22:56:55 ERROR [main] corosync_init (733) failed to initialize cpg (6)-is corosync running?Mar 25 22:56:55 ERROR [main] main

3. Congiure Cinder use sheepdog as back-end storage driver

Modify the configuration file of Cinder, such as "/ etc/cinder/cinder.conf" by default

Volume_driver=cinder.volume.drivers.sheepdog.SheepdogDriver

After modification, restart the cinder service openstack-service restart cinder

4. Create a Cinder volume

What I'm testing here is converting a glance image into bootable volume.

[ray@fedora cinder] $cinder create-- image-id 285ac2bf-e2d4-4bbd-b438-f2fa4f24bb27-- display-name CirrosBootVol 2-- Property | Value | +- -+-+ | attachments | [] | availability_zone | nova | | bootable | false | | created_at | 2014-03-26T14:55:50.631075 | | display_description | None | | display_name | CirrosBootVol | | id | 1e3eb4f2-c60c-4eeb-9bc0-41f1afe7c911 | | image_id | 285ac2bf-e2d4-4bbd-b438-f2fa4f24bb27 | | metadata | | | {} | size | 2 | | snapshot_id | None | | source_volid | None | | status | creating | | | volume_type | None | +-+-+ [ray@fedora post] $cinder list+- | -+- -+ | ID | Status | Display Name | Size | Volume Type | Bootable | Attached to | +-- +-- -+-+ | 1e3eb4f2-c60c-4eeb-9bc0-41f1afe7c911 | available | CirrosBootVol | 2 | None | true | | | c1dfc42c-32c1-4104-a7cc-effc4ce86385 | in-use | Vdisk3G | 3 | None | false | b358aa2e-a8e9-4cb8-9f2a-e7c6e4d4f477 | +-- +-- -+-- + # use dog or collie command to show [ray@fedora post] $collie vdi list Name Id Size Used Shared Creation time VDI id Copies Tag volume-c1dfc42c-32c1 -4104-a7cc-effc4ce86385 0 3.0 GB 1.2 GB 0.0 MB 2014-03-25 23:28 31433a 1 volume-1e3eb4f2-c60c-4eeb-9bc0-41f1afe7c911 0 2.0 GB 32 MB 0.0 MB 2014-03-26 22:55 cd4679 1

After the above steps are completed, we can see the created cinder volume in the system. I actually encountered a problem during the operation.

The creation of volume from glance image is not successful. If you open the log file of cinder, you will see a specific error message:

2014-03-26 22 45d4 51 9f2b-9bf535d5446b 44d5eb0d5b1d4c4189affed764b24c60 b738ad4284ed466f91e677af13e71815 14.335 5821 DEBUG cinder.openstack.common.processutils [req-1e55cd8c-d4b4-45d4-9f2b-9bf535d5446b 44d5eb0d5b1d4c4189affed764b24c60 b738ad4284ed466f91e677af13e71815] Running cmd (subprocess): sudo cinder-rootwrap / etc/cinder/rootwrap.conf env LC_ALL=C qemu-img info / var/log/conversion/tmpqXIy_Y execute / usr/lib/python2.7/site-packages/cinder/openstack/common/processutils.py:1422014-03-26 22 22 15 14 5821 DEBUG cinder.openstack.common.processutils [req- 1e55cd8c-d4b4-45d4-9f2b-9bf535d5446b 44d5eb0d5b1d4c4189affed764b24c60 b738ad4284ed466f91e677af13e71815] Running cmd (subprocess): collie vdi delete volume-c1cb8b40-82fa-4722-9424-2368ac5dc187 execute / usr/lib/python2.7/site-packages/cinder/openstack/common/processutils.py:1422014-03-26 22 22 9f2b-9bf535d5446b 44d5eb0d5b1d4c4189affed764b24c60 b738ad4284ed466f91e677af13e71815 519f2b-9bf535d5446b 44d5eb0d5b1d4c4189affed764b24c60 b738ad4284ed466f91e677af13e71815 14.597 5821 DEBUG cinder.openstack.common.processutils [req-1e55cd8c-d4b4-45d4-9f2b-9bf535d5446b 44d5eb0d5b1d4c4189affed764b24c60 b738ad4284ed466f91e677af13e71815] Running cmd (subprocess): sudo cinder-rootwrap / etc/cinder/rootwrap.conf qemu-img convert-O raw sheepdog:volume -c1cb8b40-82fa-4722-9424-2368ac5dc187 execute / usr/lib/python2.7/site-packages/cinder/openstack/common/processutils.py:1422014-03-26 22 2368ac5dc187 execute 51 usr/lib/python2.7/site-packages/cinder/openstack/common/processutils.py:1422014 14.682 5821 DEBUG cinder.openstack.common.processutils [req-1e55cd8c-d4b4-45d4-9f2b-9bf535d5446b 44d5eb0d5b1d4c4189affed764b24c60 b738ad4284ed466f91e677af13e71815] Result was 1 execute / usr/lib/python2.7/site-packages/cinder/openstack/common/processutils.py:1672014-03-26 22 22 15 51 Fringe 14.686 5821 ERROR cinder.volume.flows.create_volume [req-1e55cd8c-d4b4-45d4-9f2b-9bf535d5446b 44d5eb0d5b1d4c4189affed764b24c60 b738ad4284ed466f91e677af13e71815] Failed to copy image 285ac2bf-e2d4-4bbd-b438-f2fa4f24bb27 to volume: c1cb8b40-82fa-4722-9424-2368ac5dc187 Error: qemu-img: Unknown protocolqemu-img: Could not open': No such file or directoryqemu-img: Could not open''

From the log display, the code corresponding to cinder's process of creating the volume is located in the copy_image_to_volume function in volume/drivers/sheepdog.py.

102 def copy_image_to_volume (self, context, volume, image_service Image_id): 103 # use the image_conversion_dir as a temporary place to save the image104 conversion_dir = CONF.image_conversion_dir105 self._ensure_dir_exists (conversion_dir) 106 with tempfile.NamedTemporaryFile (dir=conversion_dir) as tmp:107 # (wenhao): we don't need to convert to raw for sheepdog.108 image_utils.fetch_verify_image (context, image_service 109 image_id, tmp.name) 110111 # remove the image created by import before this function.112 # see volume/drivers/manager.py:_create_volume113 self._delete (volume) 114 # convert and store into sheepdog115 image_utils.convert_image (tmp, 'sheepdog:%s'% volume [' name'] 116' raw') 117 self._resize (volume)

Explain how to write the steps like this:

1. Download image from glance to your local directory. Cinder has a corresponding download directory configuration:

486 # 487 # Options defined in cinder.image.image_utils 488 # 489 490 # Directory used for temporary storage during image conversion 491 # (string value) 492 image_conversion_dir=/var/log/conversion

two。 After downloading to the directory, use the qemu-img info command to retrieve the information of image disk, mainly to check the volume szie parameter entered by cinder, which should not be less than the size of image disk. You know that, otherwise you can't.

Image/image_utils.py:fetch_verify_image

238 # NOTE (xqueralt): If the image virtual size doesn't fit in the239 # requested volume there is no point on resizing it because it will240 # generate an unusable image.241 if size is not None and data.virtual_size > size:242 params = {'image_size': data.virtual_size 'volume_size': size} 243 reason= _ ("Size is% (image_size) dGB and doesn't fit in a" 244 "volume of size% (volume_size) dGB.")% params245 raise exception.ImageUnacceptable (image_id=image_id, reason=reason)

3. At this point, you need to use qemu-img convert to convert image into sheepdog VDI. The correct command is:

Qemu-img convert-O raw / var/log/conversion/tmpf9sUFs sheepdog:volume-1e3eb4f2-c60c-4eeb-9bc0-41f1afe7c911

If successful, a VDI named "volume-1e3eb4f2-c60c-4eeb-9bc0-41f1afe7c911" will be create in the sheepdog system. The resulting code has a bug, and the actual generated command is shown in error log above:

Qemu-img convert-O raw sheepdog:volume-c1cb8b40-82fa-4722-9424-2368ac5dc187

It is obvious that the parameter is passed incorrectly, and the name of the image file downloaded to the local directory should be passed in. In the context of tempfile.NamedTemporaryFile, tmp is the object instance of tempfile. Change it to tmp.name and ok it.

115 image_utils.convert_image (tmp.name, 'sheepdog:%s'% volume [' name'], 116' raw'

After modification, rerun the operation, and the successful log:

2014-03-26 22 008b230acb45 44d5eb0d5b1d4c4189affed764b24c60 b738ad4284ed466f91e677af13e71815 55 DEBUG cinder.openstack.common.processutils 51.628 10137 DEBUG cinder.openstack.common.processutils [req-2e51dcbc-af6a-4a5f-9a92-008b230acb45 44d5eb0d5b1d4c4189affed764b24c60 b738ad4284ed466f91e677af13e71815] Running cmd (subprocess): sudo cinder-rootwrap / etc/cinder/rootwrap.conf env LC_ALL=C qemu-img info / var/log/conversion/tmpf9sUFs execute / usr/lib/python2.7/site-packages/cinder/openstack/common/processutils.py:1422014-03-26 22 22 15 15 51 10 10137 DEBUG cinder.openstack.common.processutils [req-2e51dcbc- Af6a-4a5f-9a92-008b230acb45 44d5eb0d5b1d4c4189affed764b24c60 b738ad4284ed466f91e677af13e71815] Running cmd (subprocess): collie vdi delete volume-1e3eb4f2-c60c-4eeb-9bc0-41f1afe7c911 execute / usr/lib/python2.7/site-packages/cinder/openstack/common/processutils.py:1422014-03-26 22 22 Running cmd 55 af6a-4a5f-9a92 52.036 10137 DEBUG cinder.openstack.common.processutils [req-2e51dcbc-af6a-4a5f-9a92-008b230acb45 44d5eb0d5b1d4c4189affed764b24c60 b738ad4284ed466f91e677af13e71815] Running cmd (subprocess): sudo cinder-rootwrap / etc/cinder/rootwrap.conf qemu-img convert-O raw / var/log/ Conversion/tmpf9sUFs sheepdog:volume-1e3eb4f2-c60c-4eeb-9bc0-41f1afe7c911 execute / usr/lib/python2.7/site-packages/cinder/openstack/common/processutils.py:1422014-03-26 2222 DEBUG cinder.openstack.common.processutils 5515 53.729 10137 DEBUG cinder.openstack.common.processutils [req-2e51dcbc-af6a-4a5f-9a92-008b230acb45 44d5eb0d5b1d4c4189affed764b24c60 b738ad4284ed466f91e677af13e71815] Running cmd (subprocess): collie vdi resize volume-1e3eb4f2-c60c-4eeb-9bc0-41f1afe7c911 2147483648 execute / usr/lib/python2.7/site-packages/cinder/openstack/common/processutils.py : 1422014-03-26 22 008b230acb45 44d5eb0d5b1d4c4189affed764b24c60 b738ad4284ed466f91e677af13e71815 55 008b230acb45 44d5eb0d5b1d4c4189affed764b24c60 b738ad4284ed466f91e677af13e71815 53.751 10137 DEBUG cinder.volume.flows.create_volume [req-2e51dcbc-af6a-4a5f-9a92-008b230acb45 44d5eb0d5b1d4c4189affed764b24c60 b738ad4284ed466f91e677af13e71815] Downloaded image 285ac2bf-e2d4-4bbd-b438-f2fa4f24bb27 ((None None) to volume 1e3eb4f2-c60c-4eeb-9bc0-41f1afe7c911 successfully _ copy_image_to_volume / usr/lib/python2.7/site-packages/cinder/volume/flows/create_volume/__init__.py:13832014-03-26 22 purl 55 purl 53.752 10137 DEBUG cinder.volume.flows.create_volume [req-2e51dcbc-af6a-4a5f-9a92-008b230acb45 44d5eb0d5b1d4c4189affed764b24c60 b738ad4284ed466f91e677af13e71815] Marking volume 1e3eb4f2-c60c-4eeb-9bc0-41f1afe7c911 as bootable_ enable_bootable_flag / usr/lib/python2.7/ Site-packages/cinder/volume/flows/create_volume/__init__.py:13232014-03-26 22 req-2e51dcbc-af6a-4a5f-9a92 55 req-2e51dcbc-af6a-4a5f-9a92 10137 DEBUG cinder.volume.flows.create_volume [req-2e51dcbc-af6a-4a5f-9a92-008b230acb45 44d5eb0d5b1d4c4189affed764b24c60 b738ad4284ed466f91e677af13e71815] Copying metadata from image 285ac2bf-e2d4-4bbd-b438-f2fa4f24bb27 to 1e3eb4f2-c60c-4eeb-9bc0-41f1afe7c911 _ handle_bootable_volume_glance_meta / usr/lib/python2.7/site-packages/cinder/volume/flows/create_volume/__init_ _ .py:12862014-03-26 2222 req-2e51dcbc-af6a-4a5f-9a92 5540 53.840 10137 DEBUG cinder.volume.flows.create_volume [req-2e51dcbc-af6a-4a5f-9a92-008b230acb45 44d5eb0d5b1d4c4189affed764b24c60 b738ad4284ed466f91e677af13e71815] Creating volume glance metadata for volume 1e3eb4f2-c60c-4eeb-9bc0-41f1afe7c911 backed by image 285ac2bf-e2d4-4bbd-b438-f2fa4f24bb27 with: {'container_format': uplink' 'min_ram': 0,' disk_format': upright qcow2, 'image_name': u'CirrOS 0.3.1,' image_id': u'285ac2bf-e2d4-4bbdmurb438, f2fa4f24bb27, 'checksum': uplid972013792949d0d3ba628fbe8685bcephaly,' min_disk': 0 'size': 13147648} _ capture_volume_image_metadata / usr/lib/python2.7/site-packages/cinder/volume/flows/create_volume/__init__.py:14202014-03-26 2222 purl 54.441 10137 DEBUG cinder.volume.flows.create_volume [req-2e51dcbc-af6a-4a5f-9a92-008b230acb45 44d5eb0d5b1d4c4189affed764b24c60 b738ad4284ed466f91e677af13e71815] Volume 1e3eb4f2-c60c-4eeb-9bc0-41f1afe7c911: creating export _ _ call__ / usr/lib/python2.7/site-packages/cinder/volume / flows/create_volume/__init__.py:1519

As to why the exception thrown by tempfile.NamedTemporaryFile shows. This is mainly because the Greenlet python library is used in the openstack code to start the process and run local commands.

The above is all the contents of the article "how to configure sheepdog as the storage backend of openstack Cinder". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report