一、Block Storage Service? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Block Storage Servicet 提供對 volume 從創(chuàng)建到刪除整個生命周期的管理。從 instance 的角度看,掛載的每一個 Volume 都是一塊硬盤。? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?OpenStack 提供 Block Storage Service 的是 Cinder,其具體功能是:???????????????????? ??
1、提供 REST API 使用戶能夠查詢和管理 volume、volume snapshot 以及 volume type? ? ?
2、提供 scheduler 調(diào)度 volume 創(chuàng)建請求,合理優(yōu)化存儲資源的分配? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
3、通過 driver 架構支持多種 back-end(后端)存儲方式,包括 LVM,NFS,Ceph 和其他? ? ? ? 諸如 EMC、IBM 等商業(yè)存儲產(chǎn)品和方案
二、cinder組? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?1、cinder-api:接收API請求,調(diào)用cinder-volume,所有的cinder請求都是要通過cinder-? ? ? ? ? ?api來處理的。? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?cinder-api 對接收到的 HTTP API 請求會做如下處理:??????????????????????????????????????? ? ? ? ? ? ? ? ? ? ? ? ? ?1)檢查客戶端傳入的參數(shù)是否合法有效? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 2)調(diào)用 cinder 其他子服務的處理客戶端請求? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 3)將 cinder 其他子服務返回的結果序列號并返回給客戶端? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
2、cinder-volume:管理volume服務,與volume provider協(xié)調(diào)工作,管理volume的生命? ? ? ? ? ? 周期,cinder-volume是運行在存儲節(jié)點上。? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?OpenStack 對 Volume 的操作,最后都是交給 cinder-volume 來完成的。cinder-volume? ? ? ? ?自身并不管理真正的存儲設備,存儲設備是由?volume provider?管理的。cinder-volume? ? ? ? ?與 volume provider 一起實現(xiàn) volume 生命周期的管理。? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
3、cinder-scheduler? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? scheduler 通過調(diào)度算法選擇最合適的存儲節(jié)點創(chuàng)建 volume。?創(chuàng)建 Volume 時,cinder-? ? ? ? scheduler 會基于容量、Volume Type 等條件選擇出最合適的存儲節(jié)點,然后讓其創(chuàng)建? ? ? ? ? Volume? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
4、volume provider????????????????????????????????????????????????????????????????????????? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 數(shù)據(jù)的存儲設備,為 volume 提供物理存儲空間。 cinder-volume 支持多種 volume? ? ? ? ? ? ? ? provider,每種 volume provider 通過自己的 driver 與cinder-volume 協(xié)調(diào)工作。? ? ? ? ? ? ? ??Cinder 的服務會部署在兩類節(jié)點上,控制節(jié)點和存儲節(jié)點
三、設計思想

客戶(可以是 OpenStack 最終用戶,也可以是其他程序)向 API(cinder-api)發(fā)送請求:“幫我創(chuàng)建一個 volume”
1、API 對請求做一些必要處理后,向 Messaging(RabbitMQ)發(fā)送了一條消息:“讓 Scheduler 創(chuàng)建一個 volume”
2、Scheduler(cinder-scheduler)從 Messaging 獲取到 API 發(fā)給它的消息,然后執(zhí)行調(diào)度算法,從若干計存儲點中選出節(jié)點 A
3、Scheduler 向 Messaging 發(fā)送了一條消息:“讓存儲節(jié)點 A 創(chuàng)建這個 volume”
4、存儲節(jié)點 A 的 Volume(cinder-volume)從 Messaging 中獲取到 Scheduler 發(fā)給它的消息,然后通過 driver 在 volume provider 上創(chuàng)建 volume。