cinder塊存儲服務概述
OpenStack 塊存儲服務(cinder)將持久存儲添加到虛擬機。塊存儲提供用於管理卷的基礎結構,並與 OpenStack Compute 進行交互,以提供實例的卷。該服務還支持管理卷快照和卷類型。
塊存儲服務由以下組件組成:
-
cinder-api
接受 API 請求,並將它們路由到 操作。
cinder-volume
-
cinder-volume
直接與塊存儲服務和進程(如 )進行交互。它還通過消息隊列與這些進程進行交互。該服務響應發送到塊存儲服務的讀取和寫入請求以維護狀態。它可以通過驅動程序體系結構與各種存儲提供程序進行交互。
cinder-scheduler
cinder-volume
-
cinder-scheduler daemon
選擇要在其中創建卷的最佳存儲提供程序節點。與 類似的組件。
nova-scheduler
-
cinder-backup daemon
該服務向備份存儲提供程序提供任何類型的備份卷。與服務一樣,它可以通過驅動程序體系結構與各種存儲提供程序進行交互。
cinder-backup
cinder-volume
-
Messaging queue
在塊存儲進程之間路由信息。
安裝和配置控制器節點
本節介紹如何在控制器節點上安裝和配置塊存儲服務,代號爲block。此服務至少需要一個額外的存儲節點,該節點向實例提供卷。
先決條件¶
在安裝和配置塊存儲服務之前,必須創建數據庫、服務憑據和 API 終結點。
-
若要創建數據庫,請完成以下步驟:
-
使用數據庫訪問客戶端以用戶方式連接到數據庫服務器:
root
$ mysql -u root -p
-
創建數據庫:
cinder
MariaDB [(none)]> CREATE DATABASE cinder;
-
授予對數據庫的適當訪問權限:
cinder
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY 'cinder'; MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' IDENTIFIED BY 'cinder';
替換爲合適的密碼。
CINDER_DBPASS
- 退出數據庫訪問客戶端。
-
-
源憑據以訪問僅管理員 CLI 命令:
admin
$ . admin-openrc
-
若要創建服務憑據,請完成以下步驟:
-
創建用戶:
cinder
$ openstack user create --domain default --password-prompt cinder User Password: Repeat User Password: +---------------------+----------------------------------+ | Field | Value | +---------------------+----------------------------------+ | domain_id | default | | enabled | True | | id | 40361f373b0d48e4a7189df45ac78410 | | name | cinder | | options | {} | | password_expires_at | None | +---------------------+----------------------------------+
-
將角色添加到用戶:
admin``cinder
$ openstack role add --project service --user cinder admin
注意
此命令不提供輸出。
-
創建 和服務實體:
cinderv2
cinderv3
$ openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2 +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Block Storage | | enabled | True | | id | 6d4a9e3b739a4a78bce91910a41c3054 | | name | cinderv2 | | type | volumev2 | +-------------+----------------------------------+
$ openstack service create --name cinderv3 --description "OpenStack Block Storage" volumev3 +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Block Storage | | enabled | True | | id | b15215fcf7364e728b24c65f2f50d0b2 | | name | cinderv3 | | type | volumev3 | +-------------+----------------------------------+
注意
塊存儲服務需要兩個服務實體。
-
-
創建塊存儲服務 API 終結點:
[root@controller ~]# openstack endpoint create --region RegionOne volumev2 public http://controller:8776/v2/%\(project_id\)s +--------------+------------------------------------------+ | Field | Value | +--------------+------------------------------------------+ | enabled | True | | id | 404b00216d784b4c8557914fe21b2cd6 | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | 6d4a9e3b739a4a78bce91910a41c3054 | | service_name | cinderv2 | | service_type | volumev2 | | url | http://controller:8776/v2/%(project_id)s | +--------------+------------------------------------------+ [root@controller ~]# openstack endpoint create --region RegionOne volumev2 internal http://controller:8776/v2/%\(project_id\)s [root@controller ~]# openstack endpoint create --region RegionOne volumev2 admin http://controller:8776/v2/%\(project_id\)s +--------------+------------------------------------------+ | Field | Value | +--------------+------------------------------------------+ | enabled | True | | id | e1f2f38033574041ab3047db3452abef | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | 6d4a9e3b739a4a78bce91910a41c3054 | | service_name | cinderv2 | | service_type | volumev2 | | url | http://controller:8776/v2/%(project_id)s | +--------------+------------------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne volumev3 public http://controller:8776/v3/%\(project_id\)s +--------------+------------------------------------------+ | Field | Value | +--------------+------------------------------------------+ | enabled | True | | id | adde633c1f3f49578cf532982587a380 | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | b15215fcf7364e728b24c65f2f50d0b2 | | service_name | cinderv3 | | service_type | volumev3 | | url | http://controller:8776/v3/%(project_id)s | +--------------+------------------------------------------+ [root@controller ~]# openstack endpoint create --region RegionOne volumev3 internal http://controller:8776/v3/%\(project_id\)s +--------------+------------------------------------------+ | Field | Value | +--------------+------------------------------------------+ | enabled | True | | id | a5e8507d8b894bd2a9a145781f86ca18 | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | b15215fcf7364e728b24c65f2f50d0b2 | | service_name | cinderv3 | | service_type | volumev3 | | url | http://controller:8776/v3/%(project_id)s | +--------------+------------------------------------------+ [root@controller ~]# openstack endpoint create --region RegionOne volumev3 admin http://controller:8776/v3/%\(project_id\)s +--------------+------------------------------------------+ | Field | Value | +--------------+------------------------------------------+ | enabled | True | | id | 1b2874ea8ac1490eb0a1fd6facbcb77b | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | b15215fcf7364e728b24c65f2f50d0b2 | | service_name | cinderv3 | | service_type | volumev3 | | url | http://controller:8776/v3/%(project_id)s |
注意
塊存儲服務需要每個服務實體的終結點。
安裝和配置組件¶
-
安裝包:
# yum install openstack-cinder
-
編輯文件並完成以下操作:
/etc/cinder/cinder.conf
-
在 本節中,配置數據庫訪問:
[database]
[database] # ... connection = mysql+pymysql://cinder:cinder@controller/cinder
替換爲爲塊存儲數據庫選擇的密碼。
CINDER_DBPASS
-
在 部分中,配置消息隊列訪問:
[DEFAULT]``RabbitMQ
[DEFAULT] # ... transport_url = rabbit://openstack:openstack@controller
替換爲爲 帳戶選擇的密碼。
RABBIT_PASS``openstack``RabbitMQ
-
在 和 部分中,配置標識服務訪問:
[DEFAULT]``[keystone_authtoken]
[DEFAULT] # ... auth_strategy = keystone [keystone_authtoken] # ... www_authenticate_uri = http://controller:5000 auth_url = http://controller:5000 memcached_servers = controller:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = cinder password = cinder
替換爲"標識"服務中爲用戶選擇的密碼。
CINDER_PASS
cinder
注意
註釋掉或刪除部分中任何其他選項。
[keystone_authtoken]
-
在 本節中,配置使用控制器節點的管理接口 IP 地址的選項:
[DEFAULT]``my_ip
[DEFAULT] # ... my_ip = 172.16.30.30
-
-
在 本節中,配置鎖定路徑:
[oslo_concurrency]
[oslo_concurrency] # ... lock_path = /var/lib/cinder/tmp
-
填充塊存儲數據庫:
# su -s /bin/sh -c "cinder-manage db sync" cinder
注意
忽略此輸出中的任何棄用消息。
將計算配置爲使用塊存儲¶
-
編輯該文件並添加以下內容:
/etc/nova/nova.conf
[cinder] os_region_name = RegionOne
完成安裝¶
-
重新啓動計算 API 服務:
# systemctl restart openstack-nova-api.service
-
啓動塊存儲服務並將其配置爲在系統啓動時啓動:
# systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service # systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service
安裝和配置存儲節點
先決條件¶
在存儲節點上安裝和配置塊存儲服務之前,必須準備存儲設備。
在存儲節點上執行這些步驟。
-
安裝支持實用程序包:
-
安裝 LVM 軟件包:
# yum install lvm2 device-mapper-persistent-data
-
啓動 LVM 元數據服務並將其配置爲在系統啓動時啓動:
# systemctl enable lvm2-lvmetad.service # systemctl start lvm2-lvmetad.service
注意
默認情況下,某些發行版包括 LVM。
-
-
創建 LVM 物理卷:
/dev/sdb
# pvcreate /dev/sdb Physical volume "/dev/sdb" successfully created
-
創建 LVM 卷組:
cinder-volumes
# vgcreate cinder-volumes /dev/sdb Volume group "cinder-volumes" successfully created
塊存儲服務在此卷組中創建邏輯卷。
-
只有實例可以訪問塊存儲卷。但是,基礎操作系統管理與卷關聯的設備。默認情況下,LVM 卷掃描工具掃描目錄中包含卷的塊存儲設備。如果項目在捲上使用 LVM,掃描工具將檢測這些卷並嘗試緩存它們,這可能會導致基礎操作系統和項目卷出現各種問題。您必須重新配置 LVM 以僅掃描包含卷組的設備。編輯文件並完成以下操作:
/dev
cinder-volumes
/etc/lvm/lvm.conf
-
在 本節中,添加接受設備並拒絕所有其他設備的篩選器:
devices
/dev/sdb
devices { ... filter = [ "a/sdb/", "r/.*/"]
篩選器數組中的每一項都從接受或拒絕開始,幷包括設備名稱的正則表達式。陣列必須以拒絕任何剩餘設備結束。您可以使用vgs -vv 命令來測試篩選器。
a
r
r/.*/
警告
如果存儲節點在操作系統磁盤上使用 LVM,則還必須將關聯的設備添加到篩選器中。例如,如果設備包含操作系統:
/dev/sda
filter = [ "a/sda/", "a/sdb/", "r/.*/"]
同樣,如果計算節點在操作系統磁盤上使用 LVM,則還必須修改這些節點上文件中的篩選器,以僅包括操作系統磁盤。例如,如果設備包含操作系統:
/etc/lvm/lvm.conf``/dev/sda
filter = [ "a/sda/", "r/.*/"]
-
安裝和配置組件¶
-
安裝包:
# yum install openstack-cinder targetcli python-keystone
-
編輯文件並完成以下操作:
/etc/cinder/cinder.conf
-
在 本節中,配置數據庫訪問:
[database]
[database] # ... connection = mysql+pymysql://cinder:cinder@controller/cinder
替換爲爲塊存儲數據庫選擇的密碼。
CINDER_DBPASS
-
在 部分中,配置消息隊列訪問:
[DEFAULT]
RabbitMQ
[DEFAULT] # ... transport_url = rabbit://openstack:openstack@controller
替換爲爲 帳戶選擇的密碼。
RABBIT_PASS
openstack
RabbitMQ
-
在 和 部分中,配置標識服務訪問:
[DEFAULT]
[keystone_authtoken]
[DEFAULT] # ... auth_strategy = keystone [keystone_authtoken] # ... www_authenticate_uri = http://controller:5000 auth_url = http://controller:5000 memcached_servers = controller:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = cinder password = cinder
替換爲"標識"服務中爲用戶選擇的密碼。
CINDER_PASS
cinder
注意
註釋掉或刪除部分中任何其他選項。
[keystone_authtoken]
-
在 本節中,配置選項:
[DEFAULT]``my_ip
[DEFAULT] # ... my_ip = 172.16.2.2
替換爲存儲節點上管理網絡接口的 IP 地址,通常爲示例體系結構中第一個節點的 10.0.0.41。
MANAGEMENT_INTERFACE_IP_ADDRESS
-
在本節中,使用 LVM 驅動程序、卷組、iSCSI 協議和相應的 iSCSI 服務配置 LVM endpoint。如果該節不存在,請創建它:
[lvm]
cinder-volumes
[lvm]
[lvm] volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver volume_group = cinder-volumes target_protocol = iscsi target_helper = lioadm
-
在本節中,啓用 LVM 端:
[DEFAULT]
[DEFAULT] # ... enabled_backends = lvm
注意
端端名稱是任意的。例如,本指南使用驅動程序的名稱作爲端名。
-
在 本節中,配置影像服務 API 的位置:
[DEFAULT]
[DEFAULT] # ... glance_api_servers = http://controller:9292
-
在 本節中,配置鎖定路徑:
[oslo_concurrency]
[oslo_concurrency] # ... lock_path = /var/lib/cinder/tmp
-
完成安裝¶
-
啓動塊存儲卷服務(包括其依賴項)並將其配置爲在系統啓動時啓動:
# systemctl enable openstack-cinder-volume.service target.service # systemctl start openstack-cinder-volume.service target.service
驗證 cinder 操作
驗證塊存儲服務的操作。
注意
在控制器節點上執行這些命令。
-
源憑據以訪問僅管理員 CLI 命令:
admin
$ . admin-openrc
-
列出服務組件以驗證每個進程是否成功啓動:
$ openstack volume service list +------------------+------------+------+---------+-------+----------------------------+ | Binary | Host | Zone | Status | State | Updated At | +------------------+------------+------+---------+-------+----------------------------+ | cinder-scheduler | controller | nova | enabled | up | 2020-12-10T09:36:49.000000 | | cinder-volume | cinder@lvm | nova | enabled | up | 2020-12-10T09:36:42.000000 | +------------------+------------+------+---------+-------+----------------------------+