云计算|OpenStack|社区版OpenStack安装部署文档(八--- 存储服务cinder的安装部署---Rocky版)

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介: 云计算|OpenStack|社区版OpenStack安装部署文档(八--- 存储服务cinder的安装部署---Rocky版)

Cinder概述

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技术,后面会详细讲解。

一,

在控制节点(本例是192.168.123.130)上操作,安装部署cinder服务

1,

创建相关数据库

登陆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;

2,

在keystone上注册cinder服务

创建用户,绑定到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

3,

创建cinder的服务实例

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   |
+----------------------------------+-----------+-----------+

4,

创建cinder服务的检查点(六个)

###注:仍然使用的是控制节点的主机名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                   |
+----------------------------------+-----------+--------------+--------------+---------+-----------+------------------------------------------+

5,

yum安装cinder

yum install openstack-cinder -y

6,

快速修改cinder配置

###注:这里仍然是使用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

7,

同步cinder数据库(共计新增35张表)

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

9,重启nova-api服务和启动cinder服务以及将cinder服务加入自启

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 |
+------------------+------------+------+---------+-------+----------------------------+

二,

在storage存储节点操作

该虚拟机新增了一个100G的硬盘,IP地址是192.168.123.132

 

1,

环境准备

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

2,

配置过滤器,防止系统出错

# 默认只会有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来测试过滤器。

3,

在存储节点安装配置cinder组件

yum install openstack-cinder targetcli python-keystone -y

4,

在存储节点快速修改cinder配置

###注:仍然是使用控制节点的主机名,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

5,

存储节点启动cinder服务并加入自启

# 需要启动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服务就完成了

三,

验证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服务。

相关实践学习
基于EBS部署高性能的MySQL服务
如果您通常是通过ECS实例部署MySQL来使用数据库服务,您可以参考本实验操作来搭建高性能的MySQL服务。本实验为您演示如何通过EBS ESSD云盘部署一个高性能的MySQL服务。
目录
相关文章
|
4月前
|
存储 数据管理 云计算
云计算——存储虚拟化功能
云计算——存储虚拟化功能
88 0
|
4月前
|
存储 数据管理 虚拟化
云计算——存储虚拟化简介 与 存储模式及方法
云计算——存储虚拟化简介 与 存储模式及方法
158 0
|
4月前
|
IDE Linux KVM
云计算|OpenStack|社区版OpenStack---基本概念科普(kvm的驱动类别和安装)
云计算|OpenStack|社区版OpenStack---基本概念科普(kvm的驱动类别和安装)
87 0
|
4月前
|
Ubuntu Linux 网络安全
云计算|OpenStack|社区版OpenStack(实务操作---cloud-init的使用)
云计算|OpenStack|社区版OpenStack(实务操作---cloud-init的使用)
142 0
|
4月前
|
云计算 数据安全/隐私保护 虚拟化
云计算|OpenStack|社区版OpenStack安装部署文档(十一--- 如何获取镜像---Rocky版)
云计算|OpenStack|社区版OpenStack安装部署文档(十一--- 如何获取镜像---Rocky版)
59 0
|
4月前
|
IDE Linux KVM
云计算|OpenStack|社区版OpenStack安装部署文档(十二--- openstack的网络模型解析---Rocky版)
云计算|OpenStack|社区版OpenStack安装部署文档(十二--- openstack的网络模型解析---Rocky版)
76 0
|
2月前
|
弹性计算 运维 安全
阿里云轻量应用服务器:一款高效、稳定、安全的云计算服务
阿里云服务器ECS和轻量应用服务器有什么区别?轻量和ECS优缺点对比,云服务器ECS是明星级云产品,适合企业专业级的使用场景,轻量应用服务器是在ECS的基础上推出的轻量级云服务器,适合个人开发者单机应用访问量不高的网站博客、云端学习测试环境等,阿里云服务器网从从使用场景、适用人群、计费方式、系统镜像、网络带宽、运维管理等多方面来详细说下二者区别及如何选择
96 1
|
2月前
|
存储 安全 文件存储
云计算基础-存储基础
什么是存储: 存储就是根据不同的应用程序环境,通过采取合理、安全、有效的方式将数据保存到某些介质上,并能保证有效的访问,存储的本质是记录信息的载体。
37 2
|
2月前
|
存储 缓存 固态存储
云计算基础-存储虚拟化(深信服aSAN分布式存储)
每秒钟的IOPS数,该指标主要用于评价小块IO性能,体现存储系统的IO延时能力和并发能力。业界一般默认IOPS指的是4K块大小的IO性能,该值越大说明性能越好。
53 1
|
4月前
|
存储 运维 调度
云计算——ACA学习 阿里云云计算服务概述
云计算——ACA学习 阿里云云计算服务概述
91 1