cinder是openstack中提供块存储服务的组件,主要是为虚拟机实例提供虚拟磁盘。

 

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

通过某种协议(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

 cinder安装与配置 Cloud

 

如果出现上述结果,属于正常。

 

配置计算服务以使用块存储

编辑/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
扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄