cinder是openstack中提供块存储服务的组件,主要是为虚拟机实例提供虚拟磁盘。mysql
经过某种协议(SAS,SCSI,SAN,iSCSI等)挂接裸硬盘,而后分区、格式化建立的文件,或者直接使用裸硬盘存储数据的方式叫作块存储,每一个裸硬盘一般也叫作Volume(卷)。算法
经过nfs,cifs等协议,须要挂载的远程文件系统,叫作文件系统存储。sql
cinder流程数据库
1)用户 向 API 发送请求
api
2)api对请求作一些必要的处理后,向messaging(rabbitmq)发送信息,让scheduler建立一个volumebash
3) scheduler从messaging获取到api发送的消息,而后执行调度算法,从若干存储节点选出节点Adom
4) scheduler向messaging发送一条消息,让存储节点建立volumeide
5)存储节点的volume 从messaging中获取到scheduler发给它的消息,而后经过driver在volume provider上建立volumememcached
cinder配置url
在控制节点上建立数据库,并受权用户,参考命令
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