您好,登錄后才能下訂單哦!
小編給大家分享一下如何配置sheepdog作為openstack Cinder的存儲后端,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
Cinder是Openstack的Software Defined Storage(SDS)開源方案,支持多種存儲后端。其中就包括sheepdog,一種分布式的開源塊設備。具有具有零配置、Thin-Provision、高可靠、智能節點管理、容量線性擴展、虛擬機感知(底層支持冷熱遷移和快照、克隆等)、支持計算與存儲混合架構的特點等,可擴展到上千級別的物理節點。
1. Openstack環境說明
開始研究openstack的第一步當然是安裝openstack。 對于一般用戶來說,最方便的獲取openstack環境就是直接使用各大linux 發行版的openstack package。Ubuntu,Fedora/Centos/RHEL, SUSE都已經作了大量打包工作。
例如 Redhat的PDO: http://openstack.redhat.com/Quickstart
http://docs.openstack.org/trunk/install-guide/install/yum/content/
對于開發者開說,最好是使用devstack,它是一整套的BASH腳本,從源碼一步步的部署好openstack 開發環境,因此升級到最新代碼相當方便。
2. 安裝sheepdog
參考官方wiki: https://github.com/sheepdog/sheepdog/wiki/Getting-Started
sheepdog和qemu項目高度集成,可以直接支持qemu的后端存儲。
例如:
qemu-system-x86_64 -drive file=sheepdog:192.168.10.2:7000:Alice
意思是啟動一個虛擬機,后端的文件位于192.168.10.2這臺sheepdog cluster node上的Alice VDI
因為sheepdog沒有自己開發集群管理,依賴的是corosync。所以務必安裝wiki的說明源碼安裝,并保證服務啟動。
否則sheepdog daemon會啟動不了
[root@fedora ~]# cat /var/log/sheepdog/sheep.log Mar 25 22:56:53 INFO [main] md_add_disk(337) /var/log/sheepdog/obj, vdisk nr 68, total disk 1 Mar 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(867) failed to create sheepdog cluster
3. Congiure Cinder use sheepdog as back-end storage driver
修改Cinder的配置文件,默認的比如“/etc/cinder/cinder.conf”
volume_driver=cinder.volume.drivers.sheepdog.SheepdogDriver
修改后,重啟cinder服務 openstack-service restart cinder
4. 創建一個Cinder volume
我這里測試的是把一個glance image轉化成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
以上步驟結束之后,我們就可以在系統中看到創建好的cinder volume。 我在操作過程實際上碰到一個問題。
從glance image創建volume沒有成功,打開cinder的log文件,會看到具體的錯誤信息:
2014-03-26 22:51: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:142 2014-03-26 22:51:14.414 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:142 2014-03-26 22:51: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 <open GreenPipe '<fd:16>', mode 'w+b' at 0x341c7a0> sheepdog:volume-c1cb8b40-82fa-4722-9424-2368ac5dc187 execute /usr/lib/python2.7/site-packages/cinder/openstack/common/processutils.py:142 2014-03-26 22:51: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:167 2014-03-26 22:51: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 protocol qemu-img: Could not open '<open GreenPipe '<fd:16>', mode 'w+b' at 0x341c7a0>': No such file or directory qemu-img: Could not open '<open GreenPipe '<fd:16>', mode 'w+b' at 0x341c7a0>'
從log顯示來看,cinder創建volume的過程對應的代碼位于 volume/drivers/sheepdog.py 中的 copy_image_to_volume函數。
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 image 104 conversion_dir = CONF.image_conversion_dir 105 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) 110 111 # remove the image created by import before this function. 112 # see volume/drivers/manager.py:_create_volume 113 self._delete(volume) 114 # convert and store into sheepdog 115 image_utils.convert_image(tmp, 'sheepdog:%s' % volume['name'], 116 'raw') 117 self._resize(volume)
解釋下就是這么寫步驟:
1. 從glance 下載image到本地目錄。cinder有對應的下載目錄配置:
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
2. 下載到目錄之后,用qemu-img info 命令取回image disk的信息,主要是檢查cinder輸入的volume szie參數,應當不能小于image disk的大小。這你懂的,不然不能夠。。。
image/image_utils.py:fetch_verify_image
238 # NOTE(xqueralt): If the image virtual size doesn't fit in the 239 # requested volume there is no point on resizing it because it will 240 # 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.") % params 245 raise exception.ImageUnacceptable(image_id=image_id, reason=reason)
3. 到了這一步就要用qemu-img convert 把image 轉化成sheepdog VDI。 正確的命令是:
qemu-img convert -O raw /var/log/conversion/tmpf9sUFs sheepdog:volume-1e3eb4f2-c60c-4eeb-9bc0-41f1afe7c911
成功的話,就會在sheepdog系統中create一個名字是“volume-1e3eb4f2-c60c-4eeb-9bc0-41f1afe7c911”的VDI。 結果代碼有個bug,實際生成的命令如上面錯誤log顯示:
qemu-img convert -O raw <open GreenPipe '<fd:16>', mode 'w+b' at 0x341c7a0> sheepdog:volume-c1cb8b40-82fa-4722-9424-2368ac5dc187
這里明顯是參數傳錯了,應該傳入的是下載到本地目錄的image 文件名。在tempfile.NamedTemporaryFile 這個context中,tmp就是tempfile的object instance。 改成tmp.name就ok了。
115 image_utils.convert_image(tmp.name, 'sheepdog:%s' % volume['name'], 116 'raw'
修改后,重新操作,成功后的log:
2014-03-26 22:55: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:142 2014-03-26 22:55:51.710 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:142 2014-03-26 22:55: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:142 2014-03-26 22:55: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:142 2014-03-26 22:55: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:1383 2014-03-26 22:55: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:1323 2014-03-26 22:55:53.839 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:1286 2014-03-26 22:55: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': u'bare', 'min_ram': 0, 'disk_format': u'qcow2', 'image_name': u'CirrOS 0.3.1', 'image_id': u'285ac2bf-e2d4-4bbd-b438-f2fa4f24bb27', 'checksum': u'd972013792949d0d3ba628fbe8685bce', 'min_disk': 0, 'size': 13147648} _capture_volume_image_metadata /usr/lib/python2.7/site-packages/cinder/volume/flows/create_volume/__init__.py:1420 2014-03-26 22:55: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
至于為什么tempfile.NamedTemporaryFile 拋出來的異常顯示是<open GreenPipe '<fd:16>', mode 'w+b' at 0x341c7a0>。 主要是因為openstack代碼中使用了Greenlet python庫來啟動進程跑本地命令。
以上是“如何配置sheepdog作為openstack Cinder的存儲后端”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。