一、cinder 介紹:
-
通過某種協議(SAS,SCSI,SAN,iSCSI 等) 掛接裸硬盤,然后分區、格式化、創建文件系統;或者直接使用裸硬盤存儲數據(數據庫)
-
通過 NFS、CIFS 等 協議,mount 遠程的文件系統
-
提供 REST API 使用戶能夠查詢和管理 volume、volume snapshot 以及 volume type
-
提供 scheduler 調度 volume 創建請求,合理優化存儲資源的分配
-
通過 driver 架構支持多種 back-end(后端)存儲方式,包括 LVM,NFS,Ceph 和其他諸如 EMC、IBM 等商業存儲產品和方案
Cinder 架構

客戶端可以將請求發送到 endponits 指定的地址,向 cinder-api 請求操作。 當然,作為最終用戶的我們不會直接發送 Rest API 請求。OpenStack CLI,Dashboard 和其他需要跟 Cinder 交換的組件會使用這些 API。
cinder-api 接受哪些請求呢?簡單的說,只要是 Volume 生命周期相關的操作,cinder-api 都可以響應。大部分操作都可以在 Dashboard 上看到。
cinder-volume
通過 Driver 架構支持多種 Volume Provider
接着的問題是:現在市面上有這么多塊存儲產品和方案(volume provider),cinder-volume 如何與它們配合呢?
通過的 Driver 架構。 cinder-volume 為這些 volume provider 定義了統一的接口,volume provider 只需要實現這些接口,就可以 Driver 的形式即插即用到 OpenStack 系統中。
定期向 OpenStack 報告計算節點的狀態
cinder-volume 會定期向 Cinder 報告存儲節點的空閑容量來做篩選啟動volume
實現 volume 生命周期管理
Cinder 對 volume 的生命周期的管理最終都是通過 cinder-volume 完成的,包括 volume 的 create、extend、attach、snapshot、delete 等。
cinder-scheduler
volume provider
Message Queue
Database Cinder




二、 Cinder 的設計思想

-
客戶(可以是 OpenStack 最終用戶,也可以是其他程序) 向 API(cinder-api)發送請求:“幫我創建一個 volume”
-
API 對請求做一些必要處理后,向 Messaging(RabbitMQ)發送了一條消息:“ 讓 Scheduler 創建一個 volume”
-
Scheduler(cinder-scheduler)從 Messaging 獲取到 API 發給它的消息,然后 執行調度算法,從若干計存儲點中選出節點 A
-
Scheduler 向 Messaging 發送了一條消息:“讓存儲節點 A 創建這個 volume”
-
存儲節點 A 的 Volume(cinder-volume)從 Messaging 中獲取到 Scheduler 發給它的消息,然后 通過 driver 在 volume provider 上創建 volume。
-
對外提供統一接口,隱藏實現細節
-
API 提供 REST 標准調用服務,便於與第三方系統集成
-
可以 通過運行多個 API 服務實例輕松實現 API 的高可用,比如運行多個 cinder-api 進程
Scheduler 調度服務
Driver 框架


三、cinder部署
controller節點
點擊Block Storage service——Install and configure controller
1)創建cinder數據庫並授權
MariaDB [(none)]> CREATE DATABASE cinder; MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' \ IDENTIFIED BY 'CINDER_DBPASS'; MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' \ IDENTIFIED BY 'CINDER_DBPASS';
2)創建用戶cinder
openstack user create --domain default --password-prompt cinder
3)給cinder用戶授予管理員權限
openstack role add --project service --user cinder admin
4)創建cinderv2和cinderv3服務
openstack service create --name cinderv2 \ --description "OpenStack Block Storage" volumev2
openstack service create --name cinderv3 \ --description "OpenStack Block Storage" volumev3
5)再分別創建cinderv2和cinderv3的服務端點
openstack endpoint create --region RegionOne \ volumev2 public http://controller:8776/v2/%\(project_id\)s openstack endpoint create --region RegionOne \ volumev2 internal http://controller:8776/v2/%\(project_id\)s openstack endpoint create --region RegionOne \ volumev2 admin http://controller:8776/v2/%\(project_id\)s openstack endpoint create --region RegionOne \ volumev3 public http://controller:8776/v3/%\(project_id\)s openstack endpoint create --region RegionOne \ volumev3 internal http://controller:8776/v3/%\(project_id\)s openstack endpoint create --region RegionOne \ volumev3 admin http://controller:8776/v3/%\(project_id\)s
6)下載openstack-cinder安裝
yum install openstack-cinder
7)編輯cinder配置文件
[lvm] volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver volume_group = cinder-volumes #volumes_dir = $state_path/volumes iscsi_protocol = iscsi iscsi_helper = lioadm #iscsi_ip_address = 192.168.253.135 #本機ip
8)同步數據庫
su -s /bin/sh -c "cinder-manage db sync" cinder
9)編輯nova數據庫,取消下面注釋
[cinder]
os_region_name = RegionOne
10)重啟相關服務
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
11)查看是否部署成功
openstack volume service list
| Binary | Host | Zone | Status | State | Updated At | +------------------+-------------+------+---------+-------+----------------------------+ | cinder-scheduler | controller | nova | enabled | up | 2019-06-06T08:59:35.000000 | +------------------+-------------+------+---------+-------+----------------------------
storage節點
點進Install and configure a storage node
1)安裝lvm安裝包
openstack-cinder targetcli python-keystone lvm2
2)創建物理卷/卷組和邏輯卷
pvcreate /dev/sdb
vgcreate cinder-volumes /dev/sdb
3)編輯配置文件/etc/lvm/lvm.conf(315行后面添加,注意不要超出大括號)
devices { ... filter = [ "a/sdb/", "r/.*/"]
4)配置cinder配置文件,下面是需要修改的地方
vim /etc/lvm/lvm.conf
[lvm]
volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
volume_group = cinder-volumes
iscsi_protocol = iscsi
iscsi_helper = lioadm
5)重啟lvm和cinder服務
# systemctl enable openstack-cinder-volume.service target.service # systemctl start openstack-cinder-volume.service target.service
6)控制節點查看是否部署成功
openstack volume service list