前置條件
HBlock服務已經正確配置,且可以正常啟動。
正確安裝OpenStack,支持的OpenStack版本詳見環境要求。
正確安裝OpenStack的接入插件,且功能正常。
說明
在使用Stor Cinder進行鏡像創建卷的場景下,它支持采用克隆方式進行底層處理。當鏡像文件較大時,利用克隆方式可以快速高效地完成卷的創建任務,大大提升了操作效率和用戶體驗。使用此方式的前提條件是:
Glance配置了HBlock存儲。
cinder.conf中配置:allowed_direct_url_schemes=cinder,配置位置在[DEFAULT]標簽下,否則不生效。
glance-api.conf中配置:glance-api.conf: show_image_direct_url = True,配置位置在[DEFAULT]標簽下,否則不生效。
對應的image必須是基于下列條件創建的:HBlock的卷,格式為raw,容器為bare。
使用方法
修改Glance的配置文件/etc/glance/glance-api.conf,修改enabled_backends,支持使用Cinder作為Glance的后端存儲,同時通過cinder_volume_type來指定卷類型。
[DEFAULT] show_image_direct_url = True enabled_backends="file:file,cinder-a:cinder,cinder-b:cinder" [glance_store] stores=file,cinder-a,cinder-b default_backend=file [file] filesystem_store_datadir = /opt/stack/data/glance/images/ [os_glance_tasks_store] filesystem_store_datadir = /opt/stack/data/glance/tasks_work_dir [os_glance_staging_store] filesystem_store_datadir = /opt/stack/data/glance/staging [cinder-a] cinder_os_region_name=RegionOne cinder_store_auth_address=//10.179.32.198:5000/v3 cinder_store_user_name=cinder cinder_store_password=nomoresecret cinder_store_project_name=service cinder_volume_type=hblocka cinder_enforce_multipath=True cinder_use_multipath=True rootwrap_config = /etc/cinder/rootwrap.conf [cinder-b] cinder_os_region_name=RegionOne cinder_store_auth_address=//10.179.32.198:5000/v3 cinder_store_user_name=cinder cinder_store_password=nomoresecret cinder_store_project_name=service cinder_volume_type=hblockb cinder_enforce_multipath=True cinder_use_multipath=True rootwrap_config = /etc/cinder/rootwrap.conf部分參數描述,具體詳細參數請參考OpenStack官網。
參數 描述 show_image_direct_url 是否允許通過直接url的方式表示鏡像。
取值:
True。
False。
說明
在使用Stor Cinder進行鏡像創建卷的場景下,支持采用克隆方式進行底層處理。如果使用克隆進行底層處理,必須配置此項,且該項取值為True。
enabled_backends 存儲標識符和存儲類型。配置形式為key:value。value的合法值為file、rbd、http、swift、cinder。key為default_backend的值。
說明
可以一次配置多個key:value,以英文逗號隔開,如key1:value1,key1:value2。enabled_backends中的每一個key都需要有一個單獨的一個配置組[key],配置組中需要配置該配置的所有詳細配置項。
default_backend 必須為enabled_backends中的key。 cinder_os_region_name 從服務目錄中查找cinder服務的區域名稱。 cinder_store_auth_address Openstack實際的identity服務url,對應的賬戶密碼需找管理員獲取。在PackStack部署模式下,此值為類似的地址: //10.179.32.198:5000/v3。 cinder_store_user_name OpenStack鑒權賬戶名。 cinder_store_password OpenStack鑒權密碼。 cinder_store_project_name 鏡像卷存儲在Cinder中的項目名稱。 cinder_volume_type 在Cinder中創建卷的卷類型。 cinder_enforce_multipath 如果它被設置為True,則當Multipathd未運行時,鏡像傳輸的卷附加將中止。
取值:
- True。
- False。
說明
如果HBlock集群版,需要配置為True,如果HBlock單機版,配置為False。僅在cinder_use_multipath設置為True時,才將此字段設置為True。
cinder_use_multipath 在部署中支持用于識別Mutipath的標記。
如果不支持多路徑,則將其設置為False。
- True:Cinder使用多路徑。
- False:Cinder不使用多路徑。
說明
如果HBlock集群版,需要配置為True,如果HBlock單機版,配置為False。
rootwrap_config 用于以root用戶身份運行命令的rootwrap配置文件的路徑。
Cinder存儲需要root特權才能運行鏡像卷(用于連接到 iSCSI/FC 卷以及讀/寫卷數據等)。配置文件應允許cinder store和os-brick庫所需的命令。
注意
注意:以下僅為示例,請按照實際的OpenStack環境信息進行填寫。
[DEFAULT] show_image_direct_url = True enabled_backends="file:file,cinder:cinder,cinder-stor8:cinder" [glance_store] stores=file,cinder default_backend=file [file] filesystem_store_datadir = /opt/stack/data/glance/images/ [os_glance_tasks_store] filesystem_store_datadir = /opt/stack/data/glance/tasks_work_dir [os_glance_staging_store] filesystem_store_datadir = /opt/stack/data/glance/staging [cinder] cinder_os_region_name=RegionOne cinder_store_auth_address=//10.179.32.198:5000/v3 # cinder_store_auth_address為openstack實際的identity服務url, 對應的賬戶密碼需找管理員獲取。 cinder_store_user_name=cinder cinder_store_password=nomoresecret cinder_store_project_name=service cinder_volume_type=stor cinder_enforce_multipath=True cinder_use_multipath=True rootwrap_config = /etc/cinder/rootwrap.conf [cinder-stor8] cinder_os_region_name=RegionOne cinder_store_auth_address=//10.179.32.198:5000/v3 cinder_store_user_name=admin cinder_store_password=0ac3ffd8157c4692 cinder_store_project_name=admin cinder_volume_type=stor8 cinder_enforce_multipath=False cinder_use_multipath=False rootwrap_config = /etc/cinder/rootwrap.conf命令行創建images。
[root@controller gw(keystone_admin)]# glance image-create --name centos-instance-test1 --visibility public --disk-format raw --container-format bare --file /home/gw/output.raw --store cinder-stor8 +------------------+----------------------------------------------------------------------------------+ | Property | Value | +------------------+----------------------------------------------------------------------------------+ | checksum | 56730d3091a764d5f8b38feeef0bfcef | | container_format | bare | | created_at | 2025-05-09T06:15:25Z | | direct_url | cinder://cinder-stor8/313eaedf-3e11-4da3-b5ca-0723fc356c14 | | disk_format | raw | | id | 12072d0b-b47d-435b-a5c4-cc77f9ed9742 | | min_disk | 0 | | min_ram | 0 | | name | centos-instance-test1 | | os_hash_algo | sha512 | | os_hash_value | 34f5709bc2363eafe857ba1344122594a90a9b8cc9d80047c35f7e34e8ac28ef1e14e2e3c13d55a4 | | | 3b841f533435e914b01594f2c14dd597ff9949c8389e3006 | | os_hidden | False | | owner | 97be599dfa1f4d2584719a2511b82207 | | protected | False | | size | 41126400 | | status | active | | stores | cinder-stor8 | | tags | [] | | updated_at | 2025-05-09T06:15:30Z | | virtual_size | 41126400 | | visibility | public | +------------------+----------------------------------------------------------------------------------+ [root@controller gw(keystone_admin)]# glance image-create --name centos-instance-test2 --visibility public --disk-format qcow2 --container-format bare --file /home/gw/cirros-0.3.4-x86_64-disk.img --store cinder-stor8 +------------------+----------------------------------------------------------------------------------+ | Property | Value | +------------------+----------------------------------------------------------------------------------+ | checksum | ee1eca47dc88f4879d8a229cc70a07c6 | | container_format | bare | | created_at | 2025-05-09T08:02:01Z | | direct_url | cinder://cinder-stor8/4c3d3910-4fbf-4a01-b434-2ce65263f02c | | disk_format | qcow2 | | id | c1995b47-d3a8-4d34-9bd0-d904388d88ae | | min_disk | 0 | | min_ram | 0 | | name | centos-instance-test2 | | os_hash_algo | sha512 | | os_hash_value | 1b03ca1bc3fafe448b90583c12f367949f8b0e665685979d95b004e48574b953316799e23240f4f7 | | | 39d1b5eb4c4ca24d38fdc6f4f9d8247a2bc64db25d6bbdb2 | | os_hidden | False | | owner | 97be599dfa1f4d2584719a2511b82207 | | protected | False | | size | 13287936 | | status | active | | stores | cinder-stor8 | | tags | [] | | updated_at | 2025-05-09T08:02:04Z | | virtual_size | 41126400 | | visibility | public | +------------------+----------------------------------------------------------------------------------+檢查創建的images。
[root@controller gw(keystone_admin)]# glance image-list +--------------------------------------+------------------------+ | ID | Name | +--------------------------------------+------------------------+ | 12072d0b-b47d-435b-a5c4-cc77f9ed9742 | centos-instance-test1 | | c1995b47-d3a8-4d34-9bd0-d904388d88ae | centos-instance-test2 | +--------------------------------------+------------------------+創建卷。
[root@controller gw(keystone_admin)]# cinder create --name stor8-test3 --image-id 12072d0b-b47d-435b-a5c4-cc77f9ed9742 --volume-type stor8 100 +--------------------------------+--------------------------------------+ | Property | Value | +--------------------------------+--------------------------------------+ | attachments | [] | | availability_zone | nova | | bootable | false | | cluster_name | None | | consistencygroup_id | None | | consumes_quota | True | | created_at | 2025-05-09T08:48:00.000000 | | description | None | | encrypted | False | | group_id | None | | id | d4f7fa8a-4090-4b34-8084-cde24755a56b | | metadata | {} | | migration_status | None | | multiattach | False | | name | stor8-test3 | | 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 | 97be599dfa1f4d2584719a2511b82207 | | provider_id | None | | replication_status | None | | service_uuid | None | | shared_targets | True | | size | 100 | | snapshot_id | None | | source_volid | None | | status | creating | | updated_at | None | | user_id | d60fa5458fda4f96bbf581bf6c2dd63e | | volume_type | stor8 | | volume_type_id | 997c4eb1-4473-4c0a-a1f6-4f4967fd2c3a | +--------------------------------+--------------------------------------+