openstack核心组件——cinder存储服务(11)
-
通过某种协议(SAS,SCSI,SAN,iSCSI 等)挂接裸硬盘,然后分区、格式化、创建文件系统;或者直接使用裸硬盘存储数据(数据库)
-
通过 NFS、CIFS 等 协议,mount 远程的文件系统
-
提供 REST API 使用户能够查询和管理 volume、volume snapshot 以及 volume type
-
提供 scheduler 调度 volume 创建请求,合理优化存储资源的分配
-
通过 driver 架构支持多种 back-end(后端)存储方式,包括 LVM,NFS,Ceph 和其他诸如 EMC、IBM 等商业存储产品和方案
![http://7xo6kd.com1.z0.glb.clouddn.com/upload-ueditor-image-20160610-1465514561994059446.png](http://learn.yunwei.edu/openstack-learn/cinder_files/640.jpg)
客户端可以将请求发送到 endponits 指定的地址,向 cinder-api 请求操作。 当然,作为最终用户的我们不会直接发送 Rest API 请求。OpenStack CLI,Dashboard 和其他需要跟 Cinder 交换的组件会使用这些 API。
cinder-api 接受哪些请求呢?简单的说,只要是 Volume 生命周期相关的操作,cinder-api 都可以响应。大部分操作都可以在 Dashboard 上看到。
通过 Driver 架构支持多种 Volume Provider
接着的问题是:现在市面上有这么多块存储产品和方案(volume provider),cinder-volume 如何与它们配合呢?
通过的 Driver 架构。 cinder-volume 为这些 volume provider 定义了统一的接口,volume provider 只需要实现这些接口,就可以 Driver 的形式即插即用到 OpenStack 系统中。
定期向 OpenStack 报告计算节点的状态
cinder-volume 会定期向 Cinder 报告存储节点的空闲容量来做筛选启动volume
实现 volume 生命周期管理
Cinder 对 volume 的生命周期的管理最终都是通过 cinder-volume 完成的,包括 volume 的 create、extend、attach、snapshot、delete 等。
![](http://learn.yunwei.edu/openstack-learn/cinder_files/Image%20[1].png)
![http://7xo6kd.com1.z0.glb.clouddn.com/upload-ueditor-image-20160610-1465514562079057922.png](http://learn.yunwei.edu/openstack-learn/cinder_files/640.png)
![](http://learn.yunwei.edu/openstack-learn/cinder_files/Image%20[2].png)
![](http://learn.yunwei.edu/openstack-learn/cinder_files/Image%20[3].png)
![](http://learn.yunwei.edu/openstack-learn/cinder_files/Image%20[4].png)
-
客户(可以是 OpenStack 最终用户,也可以是其他程序)向 API(cinder-api)发送请求:“帮我创建一个 volume”
-
API 对请求做一些必要处理后,向 Messaging(RabbitMQ)发送了一条消息:“让 Scheduler 创建一个 volume”
-
Scheduler(cinder-scheduler)从 Messaging 获取到 API 发给它的消息,然后执行调度算法,从若干计存储点中选出节点 A
-
Scheduler 向 Messaging 发送了一条消息:“让存储节点 A 创建这个 volume”
-
存储节点 A 的 Volume(cinder-volume)从 Messaging 中获取到 Scheduler 发给它的消息,然后通过 driver 在 volume provider 上创建 volume。
-
对外提供统一接口,隐藏实现细节
-
API 提供 REST 标准调用服务,便于与第三方系统集成
-
可以通过运行多个 API 服务实例轻松实现 API 的高可用,比如运行多个 cinder-api 进程
![](http://learn.yunwei.edu/openstack-learn/cinder_files/Image%20[5].png)
![](http://learn.yunwei.edu/openstack-learn/cinder_files/Image%20[6].png)
[DEFAULT] my_ip = 172.16.254.63 glance_api_servers = http://controller:9292 auth_strategy = keystone enabled_backends = lvm transport_url = rabbit://openstack:admin@controller [backend] [barbican] [brcd_fabric_example] [cisco_fabric_example] [coordination] [cors] [cors.subdomain] [database] connection = mysql+pymysql://cinder:CINDER_DBPASS@controller/cinder [fc-zone-manager] [healthcheck] [key_manager] [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 [matchmaker_redis] [oslo_concurrency] lock_path = /var/lib/cinder/tmp [oslo_messaging_amqp] [oslo_messaging_kafka] [oslo_messaging_notifications] [oslo_messaging_rabbit] [oslo_messaging_zmq] [oslo_middleware] [oslo_policy] [oslo_reports] [oslo_versionedobjects] [profiler] [ssl] [lvm] volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver volume_group = cinder-vg volumes_dir = $state_path/volumes iscsi_protocol = iscsi iscsi_helper = lioadm iscsi_ip_address = 172.16.254.63
cinder 控制节点部署
块存储,类似于磁盘
第一步:创建cinder的数据库和用户
[root@zxw6 ~]# mysql -uroot -p123
create database cinder;
grant all on cinder.* to cinder@'localhost' identified by 'zxw6';
Query OK, 0 rows affected (0.02 sec)
grant all on cinder.* to cinder@'%' identifiied by 'zxw6';
Query OK, 0 rows affected (0.00 sec)
登录到openstack
[root@zxw6 ~]# source openrc
第二步:创建openstack的cinder用户
[root@zxw6 ~]# openstack user create --domain default --password=zxw6 cinder
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | c6d19459b0354931a4e281bfc52b9a88 |
| name | cinder |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
第四步:在service项目把cinder用户加入到admin角色
[root@zxw6 ~]# openstack role add --project service --user cinder admin
第五步:创建service项目cinderv2,cinderv3
[root@zxw6 ~]# openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Block Storage |
| enabled | True |
| id | d51dc5280e584c7b8a50f018a0041724 |
| name | cinderv2 |
| type | volumev2 |
+-------------+----------------------------------+
[root@zxw6 ~]# openstack service create --name cinderv3 --description "OpenStack Block Storage" volumev3
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Block Storage |
| enabled | True |
| id | c67f72e6c80942ef9baacc123feae8da |
| name | cinderv3 |
| type | volumev3 |
+-------------+----------------------------------+
第六步:创建服务v2,v3端点8776
openstack endpoint create --region RegionOne volumev2 public http://zxw6:8776/v2/%\(project_id\)s
openstack endpoint create --region RegionOne volumev2 internal http://zxw6:8776/v2/%\(project_id\)s
openstack endpoint create --region RegionOne volumev2 admin http://zxw6:8776/v2/%\(project_id\)s
openstack endpoint create --region RegionOne volumev3 public http://zxw6:8776/v3/%\(project_id\)s
openstack endpoint create --region RegionOne volumev3 internal http://zxw6:8776/v3/%\(project_id\)s
openstack endpoint create --region RegionOne volumev3 admin http://zxw6:8776/v3/%\(project_id\)s
第七步:下载cinder服务
[root@zxw6 ~]# yum install openstack-cinder -y
第八步:编辑配置文件cinder
vim /etc/cinder/cinder.conf
root@zxw6 cinder]# egrep -v '(#|^$)' cinder.conf
[DEFAULT]
my_ip = 192.168.126.6
transport_url = rabbit://openstack:zxw6@zxw6
auth_strategy = keystone
[backend]
[barbican]
[brcd_fabric_example]
[cisco_fabric_example]
[coordination]
[cors]
[cors.subdomain]
[database]
connection = mysql+pymysql://cinder:zxw6@zxw6/cinder
[fc-zone-manager]
[healthcheck]
[key_manager]
[keystone_authtoken]
auth_uri = http://zxw6:5000
auth_url = http://zxw6:35357
memcached_servers = zxw6:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = cinder
password = zxw6
[matchmaker_redis]
[oslo_concurrency]
lock_path = /var/lib/cinder/tmp
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_messaging_zmq]
[oslo_middleware]
[oslo_policy]
[oslo_reports]
[oslo_versionedobjects]
[profiler]
[ssl]
第九步:导入cinder数据库
[root@zxw6 ~]# su -s /bin/sh -c "cinder-manage db sync" cinder
第十步:编辑nova服务
[root@zxw6 ~]# vim /etc/nova/nova.conf
[cinder]
os_region_name = RegionOne
第十一步:重启nova-api服务
[root@zxw6 ~]# systemctl restart openstack-nova-api.service
第十二步 :启动cinder服务并开机自启
[root@zxw6 ~]# systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service
[root@zxw6 ~]# systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service
cinder存储节点部署
环境前部署添加一块新的硬盘
第一步:下载逻辑卷服务
[root@zxw8 ~]# yum install lvm2 -y
第二步:启动lvm服务
[root@zxw8 ~]# systemctl start lvm2-lvmetad.service
[root@zxw8 ~]# systemctl enable lvm2-lvmetad.service
第三步:创建pv物理卷
[root@zxw8 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 19G 0 part
├─cl-root 253:0 0 17G 0 lvm /
└─cl-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 10G 0 disk
sr0 11:0 1 4.1G 0 rom /mnt
您在 /var/spool/mail/root 中有新邮件
[root@zxw8 ~]# pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created.
第四步:创建卷宗组
[root@zxw8 ~]# vgcreate vg_cinder /dev/sdb
Volume group "vg_cinder" successfully created
第五步:修改lvm的配置文件
devices {
filter = [ "a/sdb/", "r/.*/" ]
第六步:下载cinder存储
[root@zxw8 cinder]# yum install openstack-cinder targetcli python-keystone -y
第七步:配置cinder文件
[root@zxw8 cinder]# egrep -v '(#|^$)' cinder.conf
[DEFAULT] my_ip = 172.16.254.63 glance_api_servers = http://controller:9292 auth_strategy = keystone enabled_backends = lvm transport_url = rabbit://openstack:admin@controller [backend] [barbican] [brcd_fabric_example] [cisco_fabric_example] [coordination] [cors] [cors.subdomain] [database] connection = mysql+pymysql://cinder:CINDER_DBPASS@controller/cinder [fc-zone-manager] [healthcheck] [key_manager] [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 [matchmaker_redis] [oslo_concurrency] lock_path = /var/lib/cinder/tmp [oslo_messaging_amqp] [oslo_messaging_kafka] [oslo_messaging_notifications] [oslo_messaging_rabbit] [oslo_messaging_zmq] [oslo_middleware] [oslo_policy] [oslo_reports] [oslo_versionedobjects] [profiler] [ssl] [lvm] volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver volume_group = cinder-vg volumes_dir = $state_path/volumes iscsi_protocol = iscsi iscsi_helper = lioadm iscsi_ip_address = 172.16.254.63
第八步:启动服务。并开机自启
[root@zxw8 ~]# systemctl start openstack-cinder-volume.service target.service
[root@zxw8 ~]# systemctl enable openstack-cinder-volume.service target.service
访问
查看服务是否启动
[root@zxw6 ~]# cinder service-list
+------------------+----------+------+---------+-------+----------------------------+-----------------+
| Binary | Host | Zone | Status | State | Updated_at | Disabled Reason |
+------------------+----------+------+---------+-------+----------------------------+-----------------+
| cinder-scheduler | zxw6 | nova | enabled | up | 2019-08-03T01:25:14.000000 | - |
| cinder-volume | zxw8@lvm | nova | enabled | up | 2019-08-03T01:25:11.000000 | - |
+------------------+----------+------+---------+-------+----------------------------+-----------------+
查看卷
[root@zxw6 ~]# cinder list
+----+--------+------+------+-------------+----------+-------------+
| ID | Status | Name | Size | Volume Type | Bootable | Attached to |
+----+--------+------+------+-------------+----------+-------------+