赞
踩
cinder服务可以提供云磁盘(卷),类似阿里云云盘
OpenStack块存储服务(cinder)为虚拟机添加持久的存储,块存储提供一个基础设施为了管理卷,以及和OpenStack计算服务交互,为实例提供卷。此服务也会激活管理卷的快照和卷类型的功能。
块存储服务通常包含下列组件:
1)cinder-api
接受API请求,并将其路由到``cinder-volume``执行。
2)cinder-volume
与块存储服务和例如``cinder-scheduler``的进程进行直接交互。它也可以与这些进程通过一个消息队列进行交互。``cinder-volume``服务响应送到块存储服务的读写请求来维持状态。它也可以和多种存储提供者在驱动架构下进行交互。
3)cinder-scheduler守护进程
选择最优存储提供节点来创建卷。其与``nova-scheduler``组件类似。
4)cinder-backup守护进程
``cinder-backup``服务提供任何种类备份卷到一个备份存储提供者。就像``cinder-volume``服务,它与多种存储提供者在驱动架构下进行交互。
5)消息队列
在块存储的进程之间路由信息。
那么,cinder的部署和其它服务也基本差不多的,需要在控制节点部署,也需要在一个单独的storage存储服务器部署,本例中由于都是在虚拟机中部署,因此,storage节点增加一个100G的硬盘。
该服务的底层是使用的iscsi技术,后面会详细讲解。
登陆mariadb,执行以下SQL语句:
- CREATE DATABASE cinder;
- GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY 'cinder';
- GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' IDENTIFIED BY 'cinder';
- flush privileges;
创建用户,绑定到admin角色并加入service项目:
- openstack user create --domain default --password=cinder cinder
- openstack role add --project service --user cinder admin
输出入下,第二个命令无输出表示正确:
- [root@openstack1 ~]# openstack user create --domain default --password=cinder cinder
- +---------------------+----------------------------------+
- | Field | Value |
- +---------------------+----------------------------------+
- | domain_id | default |
- | enabled | True |
- | id | e4dab5daa52b4da783370824566697eb |
- | name | cinder |
- | options | {} |
- | password_expires_at | None |
- +---------------------+----------------------------------+
- [root@openstack1 ~]# openstack role add --project service --user cinder admin
- openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2
- openstack service create --name cinderv3 --description "OpenStack Block Storage" volumev3
输出如下:
- [root@openstack1 ~]# openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2
- +-------------+----------------------------------+
- | Field | Value |
- +-------------+----------------------------------+
- | description | OpenStack Block Storage |
- | enabled | True |
- | id | ef9ec02eecf84560a1a3a498a968312a |
- | name | cinderv2 |
- | type | volumev2 |
- +-------------+----------------------------------+
- [root@openstack1 ~]# openstack service create --name cinderv3 --description "OpenStack Block Storage" volumev3
- +-------------+----------------------------------+
- | Field | Value |
- +-------------+----------------------------------+
- | description | OpenStack Block Storage |
- | enabled | True |
- | id | dbb637bc998544b89e7feb6d60759f5a |
- | name | cinderv3 |
- | type | volumev3 |
- +-------------+----------------------------------+
- [root@openstack1 ~]# openstack service list
- +----------------------------------+-----------+-----------+
- | ID | Name | Type |
- +----------------------------------+-----------+-----------+
- | 629d817aa28d4579b08663529efc63e4 | placement | placement |
- | 7aa0d862c3dc4ae884e7f02551b07630 | glance | image |
- | 83721cda2dd94e8bbfad43e34657a6da | nova | compute |
- | c187cea7ed9c46668a229a3278b1e434 | keystone | identity |
- | dbb637bc998544b89e7feb6d60759f5a | cinderv3 | volumev3 |
- | ef9ec02eecf84560a1a3a498a968312a | cinderv2 | volumev2 |
- | fed6374c1cdd453a8d26c4e33d664b5d | neutron | network |
- +----------------------------------+-----------+-----------+
###注:仍然使用的是控制节点的主机名openstack1
- openstack endpoint create --region RegionOne volumev2 public http://openstack1:8776/v2/%\(project_id\)s
- openstack endpoint create --region RegionOne volumev2 internal http://openstack1:8776/v2/%\(project_id\)s
- openstack endpoint create --region RegionOne volumev2 admin http://openstack1:8776/v2/%\(project_id\)s
-
- openstack endpoint create --region RegionOne volumev3 public http://openstack1:8776/v3/%\(project_id\)s
- openstack endpoint create --region RegionOne volumev3 internal http://openstack1:8776/v3/%\(project_id\)s
- openstack endpoint create --region RegionOne volumev3 admin http://openstack1:8776/v3/%\(project_id\)s
输出如下:
- [root@openstack1 ~]# openstack endpoint list
- +----------------------------------+-----------+--------------+--------------+---------+-----------+------------------------------------------+
- | ID | Region | Service Name | Service Type | Enabled | Interface | URL |
- +----------------------------------+-----------+--------------+--------------+---------+-----------+------------------------------------------+
- | 010363cc3b224811ab1c45d67f56d475 | RegionOne | placement | placement | True | public | http://openstack1:8778 |
- | 09b682984f4d446b9624de291b27ba43 | RegionOne | keystone | identity | True | internal | http://openstack1:5000/v3/ |
- | 133422327e074eb7af3cdd47f0cb8002 | RegionOne | cinderv2 | volumev2 | True | public | http://openstack1:8776/v2/%(project_id)s |
- | 168e152a5ecd471183d5772b0d582039 | RegionOne | glance | image | True | public | http://openstack1:9292 |
- | 1d267eb74ab245958730f80b75c1abf3 | RegionOne | nova | compute | True | internal | http://openstack1:8774/v2.1 |
- | 38a8f28889e147aebea59251589fe9af | RegionOne | cinderv3 | volumev3 | True | internal | http://openstack1:8776/v3/%(project_id)s |
- | 4cbde990b9ac4e5d8cb58ecea6591361 | RegionOne | placement | placement | True | admin | http://openstack1:8778 |
- | 5080d68d4d094baab6246608fd7d277d | RegionOne | neutron | network | True | admin | http://openstack1:9696 |
- | 51ce1bfdca11488f8851c0ad6c77873d | RegionOne | cinderv3 | volumev3 | True | public | http://openstack1:8776/v3/%(project_id)s |
- | 632410fddc98491496f54d93a9d13a96 | RegionOne | keystone | identity | True | public | http://openstack1:5000/v3/ |
- | 63cf103027204a5d845c9da6a08f36e0 | RegionOne | nova | compute | True | public | http://openstack1:8774/v2.1 |
- | 8bbfa274e32f4a069b172976a0e209e4 | RegionOne | placement | placement | True | internal | http://openstack1:8778 |
- | 9f46fdd5d8a7498d8a12b047f21095ab | RegionOne | glance | image | True | admin | http://openstack1:9292 |
- | a1c8d96d44154cbc85f32e5d9ff8e54e | RegionOne | neutron | network | True | internal | http://openstack1:9696 |
- | a3610b51395e49d8898463136d24cec3 | RegionOne | nova | compute | True | admin | http://openstack1:8774/v2.1 |
- | a57efb7be1664e9bae2ad823bef3ea5a | RegionOne | glance | image | True | internal | http://openstack1:9292 |
- | a9e0562e0f5241b49c9106dadcf88db7 | RegionOne | keystone | identity | True | admin | http://openstack1:5000/v3/ |
- | b4a929d14a0d432eb0a554357fa66d33 | RegionOne | cinderv2 | volumev2 | True | internal | http://openstack1:8776/v2/%(project_id)s |
- | b6ec4e7f40eb4cedbf18a94883173654 | RegionOne | cinderv2 | volumev2 | True | admin | http://openstack1:8776/v2/%(project_id)s |
- | dedb5defaefc41ddaf3eae3e470af2dc | RegionOne | cinderv3 | volumev3 | True | admin | http://openstack1:8776/v3/%(project_id)s |
- | e69de8adfe8042369e05652e6961503e | RegionOne | neutron | network | True | public | http://openstack1:9696 |
- +----------------------------------+-----------+--------------+--------------+---------+-----------+------------------------------------------+
yum install openstack-cinder -y
###注:这里仍然是使用130的主机名,注意,rabbitmq的密码不要写错了
- openstack-config --set /etc/cinder/cinder.conf database connection mysql+pymysql://cinder:cinder@openstack1/cinder
- openstack-config --set /etc/cinder/cinder.conf DEFAULT transport_url rabbit://openstack:RABBIT_PASS@openstack1
- openstack-config --set /etc/cinder/cinder.conf DEFAULT auth_strategy keystone
- openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_uri http://openstack1:5000
- openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_url http://openstack1:5000
- openstack-config --set /etc/cinder/cinder.conf keystone_authtoken memcached_servers openstack1:11211
- openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_type password
- openstack-config --set /etc/cinder/cinder.conf keystone_authtoken project_domain_name default
- openstack-config --set /etc/cinder/cinder.conf keystone_authtoken user_domain_name default
- openstack-config --set /etc/cinder/cinder.conf keystone_authtoken project_name service
- openstack-config --set /etc/cinder/cinder.conf keystone_authtoken username cinder
- openstack-config --set /etc/cinder/cinder.conf keystone_authtoken password cinder
- openstack-config --set /etc/cinder/cinder.conf DEFAULT my_ip 192.168.123.130
- openstack-config --set /etc/cinder/cinder.conf oslo_concurrency lock_path /var/lib/nova/tmp
配置文件的内容:
- [root@openstack1 ~]# grep ^[a-z] /etc/cinder/cinder.conf
- transport_url = rabbit://openstack:RABBIT_PASS@openstack1
- auth_strategy = keystone
- my_ip = 192.168.123.130
- connection = mysql+pymysql://cinder:cinder@openstack1/cinder
- auth_uri = http://openstack1:5000
- auth_url = http://openstack1:5000
- memcached_servers = openstack1:11211
- auth_type = password
- project_domain_name = default
- user_domain_name = default
- project_name = service
- username = cinder
- password = cinder
- lock_path = /var/lib/nova/tmp
su -s /bin/sh -c "cinder-manage db sync" cinder
输出如下:
###注:这个警告可以忽略
- [root@openstack1 ~]# su -s /bin/sh -c "cinder-manage db sync" cinder
- Deprecated: Option "logdir" from group "DEFAULT" is deprecated. Use option "log-dir" from group "DEFAULT".
- [root@openstack1 ~]# mysql -ucinder -pcinder -e "use cinder;show tables" |wc -l
- 36
8,配置nova调用cinder服务
openstack-config --set /etc/nova/nova.conf cinder os_region_name RegionOne
- 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
此时,在dashboard里可以看到多出了一个卷管理界面:
此时,查看卷存储的服务是只能看到一个调度服务的:
- [root@openstack1 ~]# openstack volume service list
- +------------------+------------+------+---------+-------+----------------------------+
- | Binary | Host | Zone | Status | State | Updated At |
- +------------------+------------+------+---------+-------+----------------------------+
- | cinder-scheduler | openstack1 | nova | enabled | up | 2023-02-03T04:01:49.000000 |
- +------------------+------------+------+---------+-------+----------------------------+
该虚拟机新增了一个100G的硬盘,IP地址是192.168.123.132
- yum install lvm2 device-mapper-persistent-data -y
- systemctl enable lvm2-lvmetad.service
- systemctl start lvm2-lvmetad.service
- systemctl status lvm2-lvmetad.service
- [root@openstack3 ~]# lsblk
- NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
- sda 8:0 0 100G 0 disk
- └─sda1 8:1 0 100G 0 part /
- sdb 8:16 0 100G 0 disk
- sr0 11:0 1 4.2G 0 rom
- [root@openstack3 ~]# pvcreate /dev/sdb
- Physical volume "/dev/sdb" successfully created.
- [root@openstack3 ~]# vgcreate cinder-volumes /dev/sdb
- Volume group "cinder-volumes" successfully created
-
# 默认只会有openstack实例访问块存储卷组,不过,底层的操作系统也会管理这些设备并尝试将逻辑卷与系统关联。
# 默认情况下LVM卷扫描工具会扫描整个/dev目录,查找所有包含lvm卷的块存储设备。如果其他项目在某个磁盘设备sda,sdc等上使用了lvm卷,那么扫描工具检测到这些卷时会尝试缓存这些lvm卷,可能导致底层操作系统或者其他服务无法正常调用他们的lvm卷组,从而产生各种问题,需要手动配置LVM,让LVM卷扫描工具只扫描包含"cinder-volume"卷组的设备/dev/sdb,我这边磁盘分区都是格式化的手工分区,目前不存在这个问题,以下是配置演示:
- vim /etc/lvm/lvm.conf
- -----------------------------
- devices {
- filter = [ "a/sdb/", "r/.*/"]
- }
# 配置规则:
# 每个过滤器组中的元素都以a开头accept接受,或以 r 开头reject拒绝,后面连接设备名称的正则表达式规则。 # 过滤器组必须以"r/.*/"结束,过滤所有保留设备。 # 可以使用命令:vgs -vvvv来测试过滤器。
yum install openstack-cinder targetcli python-keystone -y
###注:仍然是使用控制节点的主机名,my_ip是本机IP
- openstack-config --set /etc/cinder/cinder.conf database connection mysql+pymysql://cinder:cinder@openstack1/cinder
- openstack-config --set /etc/cinder/cinder.conf DEFAULT transport_url rabbit://openstack:RABBIT_PASS@openstack1
- openstack-config --set /etc/cinder/cinder.conf DEFAULT auth_strategy keystone
- openstack-config --set /etc/cinder/cinder.conf keystone_authtoken www_authenticate_uri http://openstack1:5000
- openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_url http://openstack1:5000
- openstack-config --set /etc/cinder/cinder.conf keystone_authtoken memcached_servers openstack1:11211
- openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_type password
- openstack-config --set /etc/cinder/cinder.conf keystone_authtoken project_domain_name default
- openstack-config --set /etc/cinder/cinder.conf keystone_authtoken user_domain_name default
- openstack-config --set /etc/cinder/cinder.conf keystone_authtoken project_name service
- openstack-config --set /etc/cinder/cinder.conf keystone_authtoken username cinder
- openstack-config --set /etc/cinder/cinder.conf keystone_authtoken password cinder
- openstack-config --set /etc/cinder/cinder.conf DEFAULT my_ip 192.168.123.132
- openstack-config --set /etc/cinder/cinder.conf lvm volume_driver cinder.volume.drivers.lvm.LVMVolumeDriver
- openstack-config --set /etc/cinder/cinder.conf lvm volume_group cinder-volumes
- openstack-config --set /etc/cinder/cinder.conf lvm iscsi_protocol iscsi
- openstack-config --set /etc/cinder/cinder.conf lvm iscsi_helper lioadm
- openstack-config --set /etc/cinder/cinder.conf DEFAULT enabled_backends lvm
- openstack-config --set /etc/cinder/cinder.conf DEFAULT glance_api_servers http://openstack1:9292
- openstack-config --set /etc/cinder/cinder.conf oslo_concurrency lock_path /var/lib/cinder/tmp
配置文件修改的内容:
- [root@openstack3 ~]# grep ^[a-z] /etc/cinder/cinder.conf
- transport_url = rabbit://openstack:RABBIT_PASS@openstack1
- auth_strategy = keystone
- my_ip = 192.168.123.132
- enabled_backends = lvm
- glance_api_servers = http://openstack1:9292
- connection = mysql+pymysql://cinder:cinder@openstack1/cinder
- www_authenticate_uri = http://openstack1:5000
- auth_url = http://openstack1:5000
- memcached_servers = openstack1:11211
- auth_type = password
- project_domain_name = default
- user_domain_name = default
- project_name = service
- username = cinder
- password = cinder
- lock_path = /var/lib/cinder/tmp
- volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
- volume_group = cinder-volumes
- iscsi_protocol = iscsi
- iscsi_helper = lioadm
# 需要启动2个服务
- systemctl enable openstack-cinder-volume.service target.service
- systemctl start openstack-cinder-volume.service target.service
- systemctl status openstack-cinder-volume.service target.service
# 至此,在存储节点安装cinder服务就完成了
- [root@openstack1 ~]# openstack volume service list
- +------------------+----------------+------+---------+-------+----------------------------+
- | Binary | Host | Zone | Status | State | Updated At |
- +------------------+----------------+------+---------+-------+----------------------------+
- | cinder-scheduler | openstack1 | nova | enabled | up | 2023-02-03T05:26:30.000000 |
- | cinder-volume | openstack3@lvm | nova | enabled | up | 2023-02-03T05:26:23.000000 |
可以看到两个service,cinder-volume的host自动打上了lvm的标签。
cinder服务其实只算完成了一部分,还有一个备份服务没有安装,但此备份服务依赖于对象存储服务Swift,因此,在讲Swift服务安装完毕后,在补充backup服务。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。