cinder是openstack中提供塊存儲服務的組件,主要是為虛擬機實例提供虛擬磁盤。
通過某種協議(SAS,SCSI,SAN,iSCSI等)掛接裸硬盤,然后分區、格式化創建的文件,或者直接使用裸硬盤存儲數據的方式叫做塊存儲,每個裸硬盤通常也叫做Volume(卷)。
通過nfs,cifs等協議,需要掛載的遠程文件系統,叫做文件系統存儲。
cinder流程
1)用戶 向 API 發送請求
2)api對請求做一些必要的處理后,向messaging(rabbitmq)發送信息,讓scheduler創建一個volume
3) scheduler從messaging獲取到api發送的消息,然后執行調度算法,從若干存儲節點選出節點A
4) scheduler向messaging發送一條消息,讓存儲節點創建volume
5)存儲節點的volume 從messaging中獲取到scheduler發給它的消息,然后通過driver在volume provider上創建volume
以下部分在controller節點進行配置
cinder暫時只做了controller節點部分
在安裝和配置Block Storage 服務之前,必須創建數據庫,服務憑證,和API節點並授予合適的權限:
cinder配置
在控制節點上創建數據庫,並授權用戶,參考命令
MariaDB [(none)]> CREATE DATABASE cinder;
為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'; 'CINDER_DBPASS' 設置自己的密碼
取得管理員憑據,以訪問僅管理員的CLI命令:
$ . admin-openrc 這是個腳本文件,你之前需要添加的所有系統環境變量 沒有可以新建一個
創建一個cinder用戶
$ openstack user create --domain default --password-prompt cinder User Password: Repeat User Password: +---------------------+----------------------------------+ | Field | Value | +---------------------+----------------------------------+ | domain_id | default | | enabled | True | | id | 9d7e33de3e1a498390353819bc7d245d | | 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 | eb9fd245bdbc414695952e93f29fe3ac | | name | cinderv2 | | type | volumev2 | +-------------+----------------------------------
$ openstack service create --name cinderv3 \ --description "OpenStack Block Storage" volumev3 +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Block Storage | | enabled | True | | id | ab3bbbef780845a1a283490d281e7fda | | name | cinderv3 | | type | volumev3 | +-------------+----------------------------------+
Note:
塊存儲服務需要兩個服務實體。
創建塊存儲服務API端點:
$ openstack endpoint create --region RegionOne \ volumev2 public http://controller:8776/v2/%\(project_id\)s +--------------+------------------------------------------+ | Field | Value | +--------------+------------------------------------------+ | enabled | True | | id | 513e73819e14460fb904163f41ef3759 | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | eb9fd245bdbc414695952e93f29fe3ac | | service_name | cinderv2 | | service_type | volumev2 | | url | http://controller:8776/v2/%(project_id)s | +--------------+------------------------------------------+ $ openstack endpoint create --region RegionOne \ volumev2 internal http://controller:8776/v2/%\(project_id\)s +--------------+------------------------------------------+ | Field | Value | +--------------+------------------------------------------+ | enabled | True | | id | 6436a8a23d014cfdb69c586eff146a32 | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | eb9fd245bdbc414695952e93f29fe3ac | | service_name | cinderv2 | | service_type | volumev2 | | url | http://controller:8776/v2/%(project_id)s | +--------------+------------------------------------------+ $ openstack endpoint create --region RegionOne \ volumev2 admin http://controller:8776/v2/%\(project_id\)s +--------------+------------------------------------------+ | Field | Value | +--------------+------------------------------------------+ | enabled | True | | id | e652cf84dd334f359ae9b045a2c91d96 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | eb9fd245bdbc414695952e93f29fe3ac | | service_name | cinderv2 | | service_type | volumev2 | | url | http://controller:8776/v2/%(project_id)s | +--------------+------------------------------------------+
volumev3:
$ openstack endpoint create --region RegionOne \ volumev3 public http://controller:8776/v3/%\(project_id\)s +--------------+------------------------------------------+ | Field | Value | +--------------+------------------------------------------+ | enabled | True | | id | 03fa2c90153546c295bf30ca86b1344b | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | ab3bbbef780845a1a283490d281e7fda | | service_name | cinderv3 | | service_type | volumev3 | | url | http://controller:8776/v3/%(project_id)s | +--------------+------------------------------------------+ $ openstack endpoint create --region RegionOne \ volumev3 internal http://controller:8776/v3/%\(project_id\)s +--------------+------------------------------------------+ | Field | Value | +--------------+------------------------------------------+ | enabled | True | | id | 94f684395d1b41068c70e4ecb11364b2 | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | ab3bbbef780845a1a283490d281e7fda | | service_name | cinderv3 | | service_type | volumev3 | | url | http://controller:8776/v3/%(project_id)s | +--------------+------------------------------------------+ $ openstack endpoint create --region RegionOne \ volumev3 admin http://controller:8776/v3/%\(project_id\)s +--------------+------------------------------------------+ | Field | Value | +--------------+------------------------------------------+ | enabled | True | | id | 4511c28a0f9840c78bacb25f10f62c98 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | ab3bbbef780845a1a283490d281e7fda | | 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_DBPASS@controller/cinder CINDER_DBPASS改為cinder數據庫的密碼
在【DEFAULT】節點,配置RabbitMQ消息隊列訪問
[DEFAULT] # ... transport_url = rabbit://openstack:RABBIT_PASS@controller openstack:RABBIT_PASS 改為消息隊列里創建的用戶名和密碼
在[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_id = default user_domain_id = default project_name = service username = cinder password = CINDER_PASS //改為cinder的密碼
在[DEFAULT]部分中,配置my_ip選項以使用控制器節點的管理接口IP地址:
[DEFAULT] # ... my_ip = 10.0.0.11 //controller節點IP
在[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