1、概述
块存储服务(cinder)为访客实例提供块存储设备。存储设置和消耗的方法由块存储驱动程序或多后端配置的驱动程序确定。有各种可用的驱动程序:NAS / SAN,NFS,iSCSI,Ceph等。
Block Storage API和调度程序服务通常在控制器节点上运行。根据使用的驱动程序,卷服务可以在控制器节点,计算节点或独立存储节点上运行。
OpenStack Block Storage服务(cinder)将持久存储添加到虚拟机。Block Storage提供了管理卷的基础架构,并与OpenStack Compute交互以提供实例的卷。该服务还可以管理卷快照和卷类型。
块存储服务由以下组件组成:
接受API请求,并将其路由到
cinder-volume
操作。
cinder-volume
直接与块存储服务,以及诸如过程相互作用
cinder-scheduler
。它还通过消息队列与这些进程交互。该
cinder-volume
服务响应发送到块存储服务的读取和写入请求以维护状态。它可以通过驱动程序架构与各种存储提供商进行交互。
cinder-scheduler守护进程
选择要在其上创建卷的最佳存储提供者节点。类似的组件
nova-scheduler
。
cinder-backup守护进程
该
cinder-backup
服务为备份存储提供商提供任何类型的备份卷。与
cinder-volume
服务一样,它可以通过驱动程序架构与各种存储提供商进行交互。
2、环境(创建数据库,服务凭据和API端点)
2.1、创建数据库
2.1.1、连接数据库
# mysql -u root -p
2.1.2、创建cinder
数据库
MariaDB [(none)]> CREATE DATABASE cinder;
Query OK, 1 row affected (0.00 sec)
2.1.3、授予对cinder
数据库的正确访问权限
MariaDB [(none)]> grant all privileges on cinder .* to 'cinder'@'localhost' identified by 'CINDER_DBPASS';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all privileges on cinder .* to 'cinder'@'%' identified by 'CINDER_DBPASS';
Query OK, 0 rows affected (0.00 sec)
2.2、引入admin
凭据以访问仅管理CLI命令
# source admin-openrc
2.3、创建服务凭据
2.3.1、创建cinder
用户
# openstack user create --domain default --password-prompt cinder
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | 388242c3d5ab429083b81ce3837b21f2 |
| name | cinder |
| password_expires_at | None |
+---------------------+----------------------------------+
2.3.2、将admin
角色添加到cinder
用户
# openstack role add --project service --user cinder admin
2.3.3、创建cinder
和cinderv2
服务实体
# openstack service create --name cinder \
> --description "OpenStack Block Storage" volume
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Block Storage |
| enabled | True |
| id | b385143b55fe466b9ae0a4a3ba7b090c |
| name | cinder |
| type | volume |
+-------------+----------------------------------+
# openstack service create --name cinderv2 \
> --description "OpenStack Block Storage" volumev2
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Block Storage |
| enabled | True |
| id | 593856d323cf4f04b4fe40f8c70bda9a |
| name | cinderv2 |
| type | volumev2 |
+-------------+----------------------------------+
块存储服务需要两个服务实体。
2.4、创建块存储服务API端点
# openstack endpoint create --region RegionOne \
> volume public http://controller:8776/v1/%\(tenant_id\)s
+--------------+-----------------------------------------+
| Field | Value |
+--------------+-----------------------------------------+
| enabled | True |
| id | 12b79d81eb8d4eb0af9fc24fe1c81ef2 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | b385143b55fe466b9ae0a4a3ba7b090c |
| service_name | cinder |
| service_type | volume |
| url | http://controller:8776/v1/%(tenant_id)s |
+--------------+-----------------------------------------+
# openstack endpoint create --region RegionOne \
> volume internal http://controller:8776/v1/%\(tenant_id\)s
+--------------+-----------------------------------------+
| Field | Value |
+--------------+-----------------------------------------+
| enabled | True |
| id | a0a8b045020a4470b3b26b10f8f19b06 |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | b385143b55fe466b9ae0a4a3ba7b090c |
| service_name | cinder |
| service_type | volume |
| url | http://controller:8776/v1/%(tenant_id)s |
+--------------+-----------------------------------------+
# openstack endpoint create --region RegionOne \
> volume admin http://controller:8776/v1/%\(tenant_id\)s
+--------------+-----------------------------------------+
| Field | Value |
+--------------+-----------------------------------------+
| enabled | True |
| id | 6e00beeceee54f599eab586d956521c6 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | b385143b55fe466b9ae0a4a3ba7b090c |
| service_name | cinder |
| service_type | volume |
| url | http://controller:8776/v1/%(tenant_id)s |
+--------------+-----------------------------------------+
v2
# openstack endpoint create --region RegionOne \
> volumev2 public http://controller:8776/v2/%\(tenant_id\)s
+--------------+-----------------------------------------+
| Field | Value |
+--------------+-----------------------------------------+
| enabled | True |
| id | cc38622a0a534900b6af568487594f3b |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 593856d323cf4f04b4fe40f8c70bda9a |
| service_name | cinderv2 |
| service_type | volumev2 |
| url | http://controller:8776/v2/%(tenant_id)s |
+--------------+-----------------------------------------+
# openstack endpoint create --region RegionOne \
> volumev2 internal http://controller:8776/v2/%\(tenant_id\)s
+--------------+-----------------------------------------+
| Field | Value |
+--------------+-----------------------------------------+
| enabled | True |
| id | 6992adee3fe2409f930124d3205a58ec |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 593856d323cf4f04b4fe40f8c70bda9a |
| service_name | cinderv2 |
| service_type | volumev2 |
| url | http://controller:8776/v2/%(tenant_id)s |
+--------------+-----------------------------------------+
# openstack endpoint create --region RegionOne \
> volumev2 admin http://controller:8776/v2/%\(tenant_id\)s
+--------------+-----------------------------------------+
| Field | Value |
+--------------+-----------------------------------------+
| enabled | True |
| id | 908c6c87e5714680a678eac7710a7e78 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 593856d323cf4f04b4fe40f8c70bda9a |
| service_name | cinderv2 |
| service_type | volumev2 |
| url | http://controller:8776/v2/%(tenant_id)s |
+--------------+-----------------------------------------+
3、安装和配置组件
3.1、安装软件包
# yum install openstack-cinder
3.2、配置组件(/etc/cinder/cinder.conf)
3.2.1、在[database]
节中,配置数据库访问
[database]
...
connection = mysql+pymysql://cinder:CINDER_DBPASS@controller/cinder
3.2.2、在[DEFAULT]
节中,配置RabbitMQ
消息队列访问
[DEFAULT]
...
transport_url = rabbit://openstack:RABBIT_PASS@controller
Notice:不要配置在其他节点上去了
3.2.3、在[DEFAULT]
和[keystone_authtoken]
部分,配置身份服务访问
[DEFAULT]
...
auth_strategy = keystone
[keystone_authtoken]
...
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = cinder
password = CINDER_PASS
3.2.4、在[DEFAULT]
节中,配置my_ip
选项以使用控制器节点的管理接口IP地址
[DEFAULT]
...
my_ip = 10.0.0.11
3.2.5、在[oslo_concurrency]
部分中,配置锁定路径
[oslo_concurrency]
...
lock_path = /var/lib/cinder/tmp
4、填充Block Storage数据库
su -s /bin/sh -c "cinder-manage db sync" cinder
5、配置计算使用块存储(/etc/nova/nova.conf)
[cinder]
os_region_name = RegionOne
6、完成安装
6.1、重新启动Compute API服务
# systemctl restart openstack-nova-api.service
6.2、启动Block Storage服务并将其配置为在系统启动时启动
# systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service
# systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service
以下在 存储节点 上操作
以下为块存储服务安装和配置存储节点。该服务使用LVM驱动程序提供此设备上的 逻辑卷,并通过iSCSI传输将其提供给实例。
7、环境准备
7.1、在存储节点上安装 支持实用程序包
# yum install lvm2
7.2、启动LVM元数据服务并将其配置为在系统启动时启动
# systemctl enable lvm2-lvmetad.service
# systemctl start lvm2-lvmetad.service
7.3、创建LVM物理卷/dev/sdb
# pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created
Notice:使用fdisk -l查看磁盘名称
7.4、创建LVM卷组cinder-volumes
# vgcreate cinder-volumes /dev/vdb
Volume group "cinder-volumes" successfully created
块存储服务在此卷组中创建逻辑卷。
7.5、只有实例可以访问块存储卷。但是,底层操作系统管理与卷关联的设备。默认情况下,LVM卷扫描工具会扫描/dev
包含卷的块存储设备的 目录。如果项目在其卷上使用LVM,则扫描工具会检测这些卷并尝试缓存它们,这可能会导致底层操作系统和项目卷的各种问题。您必须重新配置LVM以仅扫描包含cinder-volumes
卷组的设备。(/etc/lvm/lvm.conf)
7.5.1、在devices
节中,添加一个接受/dev/sdb
设备并拒绝所有其他设备的过滤 器
devices {
...
filter = [ "a/sdb/", "r/.*/"]
过滤器阵列中的每个项目以a
for accept或 r
for reject开头,并包含设备名称的正则表达式。阵列必须结束r/.*/
以拒绝任何剩余的设备。您可以使用vgs -vvvv命令来测试过滤器。
Notice:如果存储节点在操作系统磁盘上使用LVM,则还必须将关联的设备添加到过滤器。例如,如果/dev/sda
设备包含操作系统:
filter = [ "a/sda/", "a/sdb/", "r/.*/"]
同样,如果您的计算节点在操作系统磁盘上使用LVM,则还必须修改/etc/lvm/lvm.conf
这些节点上的文件中的过滤器, 以仅包括操作系统磁盘。例如,如果/dev/sda
设备包含操作系统:
filter = [ "a/sda/", "r/.*/"]
8、安装和配置组件
8.1、安装软件包
# yum install openstack-cinder targetcli python-keystone
8.2、配置组件(/etc/cinder/cinder.conf)
8.2.1、在[database]
节中,配置数据库访问
[database]
...
connection = mysql+pymysql://cinder:CINDER_DBPASS@controller/cinder
8.2.2、在[DEFAULT]
节中,配置RabbitMQ
消息队列访问
[DEFAULT]
...
transport_url = rabbit://openstack:RABBIT_PASS@controller
Notice:注意在DEFAULT节下,wu
8.2.3、在[DEFAULT]
和[keystone_authtoken]
部分,配置身份服务访问
[DEFAULT]
...
auth_strategy = keystone
[keystone_authtoken]
...
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = cinder
password = CINDER_PASS
8.2.4、在[DEFAULT]
节中,配置my_ip
选项
[DEFAULT]
...
my_ip = MANAGEMENT_INTERFACE_IP_ADDRESS
Notice:配置管理IP地址
8.2.5、在[lvm]
节中,使用LVM驱动程序,cinder-volumes
卷组,iSCSI协议和适当的iSCSI服务配置LVM后端。如果该[lvm]
部分不存在,请创建它
[lvm]
volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
volume_group = cinder-volumes
iscsi_protocol = iscsi
iscsi_helper = lioadm
8.2.6、在[DEFAULT]
节中,启用LVM后端
[DEFAULT]
...
enabled_backends = lvm
8.2.7、在[DEFAULT]
节中,配置Image Service API的位置
[DEFAULT]
...
glance_api_servers = http://controller:9292
8.2.8、在[oslo_concurrency]
部分中,配置锁定路径
[oslo_concurrency]
...
lock_path = /var/lib/cinder/tmp
9、完成安装
9.1、启动Block Storage卷服务,包括其依赖关系,并将其配置为在系统引导时启动
# systemctl enable openstack-cinder-volume.service target.service
# systemctl start openstack-cinder-volume.service target.service
10、验证操作(在控制节点上)
10.1、导入admin
凭据以访问仅管理CLI命令
# source admin-openrc
10.2、列出服务组件,以验证每个进程的成功启动
# openstack volume service list
+------------------+-----------------+------+---------+-------+----------------------------+
| Binary | Host | Zone | Status | State | Updated At |
+------------------+-----------------+------+---------+-------+----------------------------+
| cinder-scheduler | controller | nova | enabled | up | 2017-07-23T10:50:13.000000 |
| cinder-volume | blockstorge@lvm | nova | enabled | up | 2017-07-23T10:50:14.000000 |
+------------------+-----------------+------+---------+-------+----------------------------+
11、问题
11.1、10.2中验证发现无blockstorge@lvm连接?
a、查看/var/log/cinder/volume.log日志显示:
2017-07-23 06:49:36.475 4840 ERROR cinder.cmd.volume DBConnectionError:
(pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on
'controller' ([Errno -2] Name or service not known)")
SQL连接无法找到主机(controller)
处理:添加hosts文件中控制节点信息