接受 API 请求,并将其路由到 "cinder-volume" 执行。
与块存储服务和例如 "cinder-scheduler" 的进程进行直接交互。它也可以与这些进程通过一个消息队列进行交互。"cinder-volume" 服务响应送到块存储服务的读写请求来维持状态,它也可以和多种存储提供者在驱动架构下进行交互。
选择最优存储提供节点来创建卷。其与 "nova-scheduler" 组件类似。
"cinder-backup" 服务提供任何种类备份卷到一个备份存储提供者,就像 "cinder-volume" 服务它与种存储提供者在驱动架构下进行交互。
注:cinder 不是必须需要的服务,看公司需求,因为是通过挂载 NFS 等一系列文件服务器来做存储,网络是一个很大的瓶颈,但是做了 cinder 可以扩容磁盘大小,以及云主机的热迁移
- 1 #安装cinder
- 2 [root@linux-node1 ~]# yum install openstack-cinder -y
- 1 #登录数据库
- 2 [root@linux-node1 ~]# mysql -uroot -p
- 3 #创建cinder库
- 4 MariaDB [(none)]> create database cinder;
- 5 #给cinder用户授权
- 6 MariaDB [(none)]> grant all privileges on cinder.* to 'cinder'@'localhost' identified by 'cinder';
- 7 Query OK, 0 rows affected (0.05 sec)
- 8 MariaDB [(none)]> grant all privileges on cinder.* to 'cinder'@'%' identified by 'cinder';
- 9 Query OK, 0 rows affected (0.00 sec)
- 1 #创建cinder用户,密码cinder
- 2 [root@linux-node1 ~]# openstack user create --domain default --password-prompt cinder
- 3 #将cinder用户加入到service项目并且赋予admin角色
- 4 [root@linux-node1 ~]# openstack role add --project service --user cinder admin
- 1 #创建cinder实体服务
- 2 [root@linux-node1 ~]# openstack service create --name cinder \
- 3 --description "OpenStack Block Storage" volume
- +-------------+----------------------------------+
- | Field | Value |
- +-------------+----------------------------------+
- | description | OpenStack Block Storage |
- | enabled | True |
- | id | 0dae8b9c2a434c7a82ad1ad56b53d8d0 |
- | name | cinder |
- | type | volume |
- +-------------+----------------------------------+
- 4 #创建cinderv2实体服务
- 5 [root@linux-node1 ~]# openstack service create --name cinderv2 \
- 6 --description "OpenStack Block Storage" volumev2
- +-------------+----------------------------------+
- | Field | Value |
- +-------------+----------------------------------+
- | description | OpenStack Block Storage |
- | enabled | True |
- | id | 30998a4da9c04e2a9e3a3e247311f09b |
- | name | cinderv2 |
- | type | volumev2 |
- +-------------+----------------------------------+
- 7 #创建API端点(cinder)
- 8 [root@linux-node1 ~]# openstack endpoint create --region RegionOne \
- 9 volume public http://192.168.56.11:8776/v1/%\(tenant_id\)s
- +--------------+--------------------------------------------+
- | Field | Value |
- +--------------+--------------------------------------------+
- | enabled | True |
- | id | 67a154e432de4efaa568f1e8c7a0050e |
- | interface | public |
- | region | RegionOne |
- | region_id | RegionOne |
- | service_id | 0dae8b9c2a434c7a82ad1ad56b53d8d0 |
- | service_name | cinder |
- | service_type | volume |
- | url | http://192.168.56.11:8776/v1/%(tenant_id)s |
- +--------------+--------------------------------------------+
- 10 [root@linux-node1 ~]# openstack endpoint create --region RegionOne \
- 11 volume internal http://192.168.56.11:8776/v1/%\(tenant_id\)s
- +--------------+--------------------------------------------+
- | Field | Value |
- +--------------+--------------------------------------------+
- | enabled | True |
- | id | 0052499eb61e454ab280d9ac689c463e |
- | interface | internal |
- | region | RegionOne |
- | region_id | RegionOne |
- | service_id | 0dae8b9c2a434c7a82ad1ad56b53d8d0 |
- | service_name | cinder |
- | service_type | volume |
- | url | http://192.168.56.11:8776/v1/%(tenant_id)s |
- +--------------+--------------------------------------------+
- 12 [root@linux-node1 ~]# openstack endpoint create --region RegionOne \
- 13 volume admin http://192.168.56.11:8776/v1/%\(tenant_id\)s
- +--------------+--------------------------------------------+
- | Field | Value |
- +--------------+--------------------------------------------+
- | enabled | True |
- | id | 5765c91142874d2584d6ea7464900732 |
- | interface | admin |
- | region | RegionOne |
- | region_id | RegionOne |
- | service_id | 0dae8b9c2a434c7a82ad1ad56b53d8d0 |
- | service_name | cinder |
- | service_type | volume |
- | url | http://192.168.56.11:8776/v1/%(tenant_id)s |
- +--------------+--------------------------------------------+
- 14 #创建API端点(cinderv2)
- 15 [root@linux-node1 ~]# openstack endpoint create --region RegionOne \
- 16 volumev2 public http://192.168.56.11:8776/v2/%\(tenant_id\)s
- +--------------+--------------------------------------------+
- | Field | Value |
- +--------------+--------------------------------------------+
- | enabled | True |
- | id | 35da6dd734e44bee817fd3712f01b126 |
- | interface | public |
- | region | RegionOne |
- | region_id | RegionOne |
- | service_id | 30998a4da9c04e2a9e3a3e247311f09b |
- | service_name | cinderv2 |
- | service_type | volumev2 |
- | url | http://192.168.56.11:8776/v2/%(tenant_id)s |
- +--------------+--------------------------------------------+
- 17 [root@linux-node1 ~]# openstack endpoint create --region RegionOne \
- 18 volumev2 internal http://192.168.56.11:8776/v2/%\(tenant_id\)s
- +--------------+--------------------------------------------+
- | Field | Value |
- +--------------+--------------------------------------------+
- | enabled | True |
- | id | 5c046a3dc07c4c26b642e01f2f5b1be0 |
- | interface | internal |
- | region | RegionOne |
- | region_id | RegionOne |
- | service_id | 30998a4da9c04e2a9e3a3e247311f09b |
- | service_name | cinderv2 |
- | service_type | volumev2 |
- | url | http://192.168.56.11:8776/v2/%(tenant_id)s |
- +--------------+--------------------------------------------+
- 19 [root@linux-node1 ~]# openstack endpoint create --region RegionOne \
- 20 volumev2 admin http://192.168.56.11:8776/v2/%\(tenant_id\)s
- +--------------+--------------------------------------------+
- | Field | Value |
- +--------------+--------------------------------------------+
- | enabled | True |
- | id | 5d86cf81628c42e8847a7bb8373df0a6 |
- | interface | admin |
- | region | RegionOne |
- | region_id | RegionOne |
- | service_id | 30998a4da9c04e2a9e3a3e247311f09b |
- | service_name | cinderv2 |
- | service_type | volumev2 |
- | url | http://192.168.56.11:8776/v2/%(tenant_id)s |
- +--------------+--------------------------------------------+
- 1 [root@linux-node1 ~]# su -s /bin/sh -c "cinder-manage db sync" cinder
- 1 [root@linux-node1 ~]# mysql -ucinder -pcinder -h192.168.56.11 -e "use cinder;show tables;"
- +----------------------------+
- | Tables_in_cinder |
- +----------------------------+
- | backups |
- | cgsnapshots |
- | clusters |
- | consistencygroups |
- | driver_initiator_data |
- | encryption |
- | group_snapshots |
- | group_type_projects |
- | group_type_specs |
- | group_types |
- | group_volume_type_mapping |
- | groups |
- | image_volume_cache_entries |
- | messages |
- | migrate_version |
- | quality_of_service_specs |
- | quota_classes |
- | quota_usages |
- | quotas |
- | reservations |
- | services |
- | snapshot_metadata |
- | snapshots |
- | transfers |
- | volume_admin_metadata |
- | volume_attachment |
- | volume_glance_metadata |
- | volume_metadata |
- | volume_type_extra_specs |
- | volume_type_projects |
- | volume_types |
- | volumes |
- | workers |
- +----------------------------+
- 1 #重启nova-api服务
- 2 [root@linux-node1 ~]# systemctl restart openstack-nova-api.service
- 3 #允许开机自启动
- 4 [root@linux-node1 ~]# systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service
- 5 #启动cinder服务及其组件
- 6 [root@linux-node1 ~]# systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service
- 7 #允许lvm2服务开机自启
- 8 [root@linux-node1 ~]# systemctl enable lvm2-lvmetad.service
- 9 #启动lvm2服务
- 10 [root@linux-node1 ~]# systemctl start lvm2-lvmetad.service
因为环境只有两台服务器,所以将存储节点也装在控制节点上
- 1 #安装lvm2
- 2 [root@linux-node1 ~]# yum install lvm2 -y
- 3 #安装cinder及其组件
- 4 [root@linux-node1 ~]# yum install openstack-cinder targetcli python-keystone
- 1 #允许lvm2开机自启
- 2 [root@linux-node1 ~]# systemctl enable lvm2-lvmetad.service
- 3 #启动lvm2
- 4 [root@linux-node1 ~]# systemctl start lvm2-lvmetad.service
- 1 [root@linux-node1 ~]# pvcreate /dev/sdb
- 2 Physical volume "/dev/sdb" successfully created.
- 1 [root@linux-node1 ~]# vgcreate cinder-volumes /dev/sdb
- 2 Volume group "cinder-volumes" successfully created
只有实例可以访问块存储卷组。但是,底层的操作系统管理着与这些卷相关联的设备。默认情况下,LVM 卷扫描工具会扫描 ``/dev`` 目录,查找包含卷的块存储设备。如果项目在他们的卷上使用了 LVM,扫描工具便会在检测到这些卷时尝试缓存它们,这可能会在底层操作系统和项目卷上产生各种问题。所以您必须重新配置 LVM,让它扫描仅包含 ``cinder-volume`` 卷组的设备。编辑 ``/etc/lvm/lvm.conf`` 文件并完成下面的操作:
在 devices 部分,添加一个过滤器,只接受 /dev/sdb 设备,拒绝其他所有设备:
- 1 [root@linux-node1 ~]# vim /etc/lvm/lvm.conf
- 2 filter = [ "a/sda/", "a/sdb/", "r/.*/"]
- 1 #允许开机自启
- 2 [root@linux-node1 ~]# systemctl enable openstack-cinder-volume.service target.service
- 3 #启动服务
- 4 [root@linux-node1 ~]# systemctl start openstack-cinder-volume.service target.service
#新创建一个云主机,然后连接卷
- 1 #磁盘格式化
- 2 [root@web-node1 ~]# mkfs.xfs /dev/vdc
- 3 #创建data目录
- 4 [root@web-node1 ~]# mkdir /data
- 5 #挂载磁盘
- 6 [root@web-node1 ~]# mount /dev/vdc /data
注:后端存储,不仅可以用 ISCSI,还可以用 NFS、GFS 等等,后期会更新如何用 NFS 做后端存储,敬请期待。
【开源是一种精神,分享是一种美德】
— By GoodCook
— 笔者 QQ:253097001
— 欢迎大家随时来交流
—原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。
来源: http://www.cnblogs.com/goodcook/p/6491269.html