Cinder组件详解
一、Cinder组件介绍
Cinder前身是 Nova 中的 nova-volume 服务,在 Folsom 版本发布时,从 Nova 中剥离作为一个独立的 Openstack 项目存在。
Cinder 类似 Amazon 的 EBS(Elastic Block Storage),为虚拟机提供持久化的块存储能力
,实现虚拟机存储卷(Volume)的创建、挂载、卸载、快照(snapshot)等生命周期管理。
1、概念
cinder组件作用:
- 块存储服务,为运行实例提供稳定的数据块存储服务。
- 块存储服务,提供对
volume
从创建到删除整个生命周期的管理。
块存储(Block Storage):“块”是指存储系统采用一整块的存储设备。块存储可虚拟出整块硬盘给云主机使用。
文件存储(File Storage):依靠文件系统来存储文件,文件直接存储在文件系统中,通过FTP、NFS等服务进行访问。
2、核心架构
Cinder主要由 cinder-api、cinder-scheduler、cinder-volume、volume-provider、volume-backup几个服务所组成,它们之间通过 AMQP消息队列进行通信。
3、核心组件
在块存储中,裸硬盘通常被称为卷(Volume),Cinder的任务就是管理卷,包括卷的创建、删除等操作。
模块名 | 功能说明 |
---|---|
cinder-api | 用于接收和响应外部请求,也是外部可用于管理Cinder的唯一入口。 |
cinder-volume | 对卷管理的模块,运行在存储节点上管理具体存储设备的存储空间。 |
cinder-scheduler | 负责通过调度算法从多个存储节点中选择合适的节点来处理用户请求(创建卷)。 |
volume-provider | 负责通过驱动调用具体的卷管理系统实现对卷的具体操作。支持多种卷管理系统:LVM、NFS、Ceph等 |
volume-backup | 为卷提供备份服务 |
message queue | 各个子服务通过消息队列实现进程间通信和相互协作。 |
database cinder | 存储数据文件的数据库。 |
4、工作流程
Cinder各个模块分工合作的大致流程如下(注意模块之间的通信都是通过消息队列传递的)。
- “cinder-api”接收到用户通过管理界面或命令行发起的卷创建请求后,完成必要处理后将其发送到消息队列中。
- “cinder-scheduler”从消息队列获得请求和数据以后,从若干存储节点中选出一个能存放该卷的节点。然后又将信息发送到消息队列。
- “cinder-volume”从消息队列获取请求后,通过“volume-provider”调用具体的卷管理系统在存储设备上创建卷。
二、常用操作
1、Volume管理
# 卷列表查看
[root@controller ~]# cinder list
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
| ID | Status | Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
| 9f9022f5-1b11-447e-bc0c-d3889712120a | available | test2 | 1 | - | false | |
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
# 卷详情查看
[root@controller ~]# cinder show test2
+--------------------------------+--------------------------------------+
| Property | Value |
+--------------------------------+--------------------------------------+
| attachments | [] |
| availability_zone | nova |
| bootable | false |
| consistencygroup_id | None |
| created_at | 2021-11-14T02:16:13.000000 |
| description | None |
| encrypted | False |
| id | 9f9022f5-1b11-447e-bc0c-d3889712120a |
| metadata | {} |
| migration_status | None |
| multiattach | False |
| name | test2 |
| os-vol-host-attr:host | compute@lvm#LVM |
| os-vol-mig-status-attr:migstat | None |
| os-vol-mig-status-attr:name_id | None |
| os-vol-tenant-attr:tenant_id | 386dbfcf77e444c7872e4e23d5829fcc |
| replication_status | disabled |
| size | 1 |
| snapshot_id | None |
| source_volid | None |
| status | available |
| updated_at | 2021-11-14T02:16:14.000000 |
| user_id | 0f217182b5af448c988f5464c706a337 |
| volume_type | None |
+--------------------------------+--------------------------------------+
# 卷创建
# size只能是整数
cinder create [--name <name>, --volume-type <type>] <size(GB)>
[root@controller ~]# cinder create --name test --description 'new volume' --availability-zone nova 2
+--------------------------------+--------------------------------------+
| Property | Value |
+--------------------------------+--------------------------------------+
| attachments | [] |
| availability_zone | nova |
| bootable | false |
| consistencygroup_id | None |
| created_at | 2021-11-14T02:54:52.000000 |
| description | new volume |
| encrypted | False |
| id | 8190367e-4874-4e5e-86f7-0a3c4e2ae4cc |
| metadata | {} |
| migration_status | None |
| multiattach | False |
| name | test |
| os-vol-host-attr:host | None |
| os-vol-mig-status-attr:migstat | None |
| os-vol-mig-status-attr:name_id | None |
| os-vol-tenant-attr:tenant_id | 386dbfcf77e444c7872e4e23d5829fcc |
| replication_status | disabled |
| size | 2 |
| snapshot_id | None |
| source_volid | None |
| status | creating |
| updated_at | None |
| user_id | 0f217182b5af448c988f5464c706a337 |
| volume_type | None |
+--------------------------------+--------------------------------------+
# 卷删除
cinder delete <volume>
[root@controller ~]# cinder delete test
Request to delete volume test has been accepted.
# 卷更新
# 1.重命名
cinder rename <volume> <name>
[root@controller ~]# cinder rename test test-volume-01
[root@controller ~]# cinder list
+--------------------------------------+-----------+----------------+------+-------------+----------+-------------+
| ID | Status | Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+----------------+------+-------------+----------+-------------+
| 5b117210-9f6e-4d2c-94f4-66c2e3953584 | available | test-volume-01 | 2 | - | false | |
+--------------------------------------+-----------+----------------+------+-------------+----------+-------------+
# 2.修改状态
# 可修改的状态:"available", "error", "creating", "deleting", "in-use", "attaching", "detaching", "error_deleting" and "maintenance".
# 附加状态:"attached" , "detached". 默认状态为:None.
cinder reset-state [--state <state>,--attach-status <attach-status>,--reset-migration-status] <volume>
[root@controller ~]# cinder reset-state --state deleting test-volume-01
[root@controller ~]# cinder list
+--------------------------------------+----------+----------------+------+-------------+----------+-------------+
| ID | Status | Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+----------+----------------+------+-------------+----------+-------------+
| 5b117210-9f6e-4d2c-94f4-66c2e3953584 | deleting | test-volume-01 | 2 | - | false | |
+--------------------------------------+----------+----------------+------+-------------+----------+-------------+
# 3.修改类型
# 注意:改状态卷状态必须是available状态
cinder retype <volume> <volume_type>
# 1)修改卷状态为available
[root@controller ~]# cinder reset-state --state available test-volume-01
# 2)查看(创建)卷类型
[root@controller ~]# cinder type-create lvm
+--------------------------------------+------+-------------+-----------+
| ID | Name | Description | Is_Public |
+--------------------------------------+------+-------------+-----------+
| b16ab5aa-f9d2-4402-89a8-1a72e9c51914 | lvm | - | True |
+--------------------------------------+------+-------------+-----------+
[root@controller ~]# cinder type-list
+--------------------------------------+------+-------------+-----------+
| ID | Name | Description | Is_Public |
+--------------------------------------+------+-------------+-----------+
| 5780bda0-0ac4-4f5a-a8c4-807980c28aaa | 性能 | | True |
| b16ab5aa-f9d2-4402-89a8-1a72e9c51914 | lvm | - | True |
+--------------------------------------+------+-------------+-----------+
# 3)修改为对应的类型
[root@controller ~]# cinder retype test-volume-01 5780bda0-0ac4-4f5a-a8c4-807980c28aaa
[root@controller ~]# cinder show test-volume-01
+--------------------------------+--------------------------------------+
| Property | Value |
+--------------------------------+--------------------------------------+
| attachments | [] |
| availability_zone | nova |
| bootable | false |
| consistencygroup_id | None |
| created_at | 2021-11-14T02:56:04.000000 |
| description | new volume |
| encrypted | False |
| id | 5b117210-9f6e-4d2c-94f4-66c2e3953584 |
| metadata | {} |
| migration_status | None |
| multiattach | False |
| name | test-volume-01 |
| os-vol-host-attr:host | compute@lvm#LVM |
| os-vol-mig-status-attr:migstat | None |
| os-vol-mig-status-attr:name_id | None |
| os-vol-tenant-attr:tenant_id | 386dbfcf77e444c7872e4e23d5829fcc |
| replication_status | disabled |
| size | 2 |
| snapshot_id | None |
| source_volid | None |
| status | available |
| updated_at | 2021-11-14T03:00:07.000000 |
| user_id | 0f217182b5af448c988f5464c706a337 |
| volume_type | 性能 |
+--------------------------------+--------------------------------------+
# 4.扩容
# 注意:可以从小改大,但是不可以从大改小。
# 注意:卷大小只能设置为整数值。
cinder extend <volume> <new size>
[root@controller ~]# cinder extend test-volume-01 5
[root@controller ~]# cinder list
+--------------------------------------+-----------+----------------+------+-------------+----------+-------------+
| ID | Status | Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+----------------+------+-------------+----------+-------------+
| 5b117210-9f6e-4d2c-94f4-66c2e3953584 | available | test-volume-01 | 5 | 性能 | false | |
+--------------------------------------+-----------+----------------+------+-------------+----------+-------------+
# 5.迁移
# 迁移一个卷到特定的主机,在请求体中指定 os-migrate_volume action。
# 一般不推荐对处于in-use状态,且挂载在多个虚机上的卷进行迁移。
# 默认只有管理员用户有迁移的权限,但是可以通过policy.json文件进行权限的设置。
cinder migrate <volume> <host>
2、Type管理
type-create Creates a volume type. # 类型创建
type-default List the default volume type.
type-delete Deletes a volume type. # 类型删除
type-key Sets or unsets extra_spec for a volume type.
type-list Lists available 'volume types'. (Admin only will see
private types) # 类型列表查看
type-show Show volume type details. # 类型详情查看
type-update Updates volume type name, description, and/or
is_public. # 类型更新
# 查看类型
cinder type-list
[root@controller ~]# cinder type-list
+--------------------------------------+------+-------------+-----------+
| ID | Name | Description | Is_Public |
+--------------------------------------+------+-------------+-----------+
| 5780bda0-0ac4-4f5a-a8c4-807980c28aaa | 性能 | | True |
| b16ab5aa-f9d2-4402-89a8-1a72e9c51914 | lvm | - | True |
+--------------------------------------+------+-------------+-----------+
# 创建类型
cinder type-create [ --description <description>, --is-public <is-public>] <name>
Positional arguments:
<name> Name of new volume type.
Optional arguments:
--description <description>
Description of new volume type.
--is-public <is-public>
Make type accessible to the public (default true).
[root@controller ~]# cinder type-create sata-hb-project
+--------------------------------------+-----------------+-------------+-----------+
| ID | Name | Description | Is_Public |
+--------------------------------------+-----------------+-------------+-----------+
| ac57dcb7-d157-419f-bd63-3ea0eb6ff940 | sata-hb-project | - | True |
+--------------------------------------+-----------------+-------------+-----------+
# 删除类型
# 注意:必须使用卷类型的id
cinder type-delete <type_id>
[root@controller ~]# cinder type-delete lvm
ERROR: Volume type lvm could not be found. (HTTP 404) (Request-ID: req-6144d4f5-61ee-4b83-b45d-f11ac54b8229)
[root@controller ~]# cinder type-delete ac57dcb7-d157-419f-bd63-3ea0eb6ff940
[root@controller ~]# cinder type-list
+--------------------------------------+------+-------------+-----------+
| ID | Name | Description | Is_Public |
+--------------------------------------+------+-------------+-----------+
| 5780bda0-0ac4-4f5a-a8c4-807980c28aaa | 性能 | | True |
| b16ab5aa-f9d2-4402-89a8-1a72e9c51914 | lvm | - | True |
+--------------------------------------+------+-------------+-----------+
# 修改类型
cinder type-update [--name <name>,--description <description>,--is-public <is-public>] <type_id>
[root@controller ~]# cinder type-update b16ab5aa-f9d2-4402-89a8-1a72e9c51914 --name ssd --description 'best of all'
+--------------------------------------+------+-------------+-----------+
| ID | Name | Description | Is_Public |
+--------------------------------------+------+-------------+-----------+
| b16ab5aa-f9d2-4402-89a8-1a72e9c51914 | ssd | best of all | False |
+--------------------------------------+------+-------------+-----------+
3、Snapshot快照管理
(1)openstack命令行格式案例
# 语法
openstack
server image create Create a new server disk image from an existing server # 为已存在的服务器创建一个新的硬盘镜像
volume snapshot create Create new volume snapshot # 创建新的卷快照
volume snapshot delete Delete volume snapshot(s) # 删除卷快照
volume snapshot list List volume snapshots # 查看卷快照列表
volume snapshot set Set volume snapshot properties # 修改卷快照属性
volume snapshot show Display volume snapshot details # 查看卷快照详情
volume snapshot unset Unset volume snapshot properties # 取消卷快照修改设置
# 对云主机拍摄快照生成镜像,可用来还原云主机或创建新云主机
# 语法:
openstack server image create [--name <image-name>] [--wait] <server>
# 为云主机拍快照,生成镜像
[root@controller ~]# openstack server image create hqs01 --name vmSnapshot
[root@controller ~]# openstack image list
+--------------------------------------+------------------+--------+
| ID | Name | Status |
+--------------------------------------+------------------+--------+
| 356cdc45-ad0b-493c-a0ba-cf3a889ec23b | centos7.2 | active |
| 1eb75af5-43ef-44e0-9367-83681181312a | centos7.5-docker | active |
| 7096885c-0a58-4086-8014-b92affceb0e8 | cirros | active |
| 26a9da63-b975-4512-ac1a-9432c31a8f0d | vmSnapshot | active |
+--------------------------------------+------------------+--------+
# 操作前置——有卷volume存在
[root@controller ~]# openstack volume list
# 创建卷快照
openstack volume snapshot create [--options] <snapshot-name>
--volume <volume> Volume to snapshot (name or ID) (default is <snapshot-
name>) # 指定要快照的卷
--description <description> # 描述快照
Description of the snapshot
--force Create a snapshot attached to an instance. Default is
False # 强制拍快照,默认只有available的卷可以快照
--property <key=value> # 设置快照的属性
Set a property to this snapshot (repeat option to set
multiple properties)
--remote-source <key=value> # 远程快照属性?
The attribute(s) of the exsiting remote volume
snapshot (admin required)
[root@controller ~]# openstack volume snapshot create --description 'test snapshot' --volume 87d595dd-3089-4d37-b8e4-bc0a597c92c7 --force hqs01_backup
+-------------+--------------------------------------+
| Field | Value |
+-------------+--------------------------------------+
| created_at | 2022-12-09T12:01:21.472986 |
| description | test snapshot |
| id | d23fb39f-7078-46ef-9148-be9f42145838 |
| name | hqs01_backup |
| properties | |
| size | 10 |
| status | creating |
| updated_at | None |
| volume_id | 87d595dd-3089-4d37-b8e4-bc0a597c92c7 |
+-------------+--------------------------------------+
# 查看卷快照列表(包含openstack server image create创的)
[root@controller ~]# openstack volume snapshot list
+--------------------------------------+-------------------------+---------------+-----------+------+
| ID | Name | Description | Status | Size |
+--------------------------------------+-------------------------+---------------+-----------+------+
| d23fb39f-7078-46ef-9148-be9f42145838 | hqs01_backup | test snapshot | available | 10 |
| f6829d63-9ac6-419e-91df-8fb2cb489bbb | snapshot for vmSnapshot | | available | 10 |
+--------------------------------------+-------------------------+---------------+-----------+------+
# 查看卷快照详情
[root@controller ~]# openstack volume snapshot show hqs01_backup
+--------------------------------------------+--------------------------------------+
| Field | Value |
+--------------------------------------------+--------------------------------------+
| created_at | 2022-12-09T12:01:21.000000 |
| description | test snapshot |
| id | d23fb39f-7078-46ef-9148-be9f42145838 |
| name | hqs01_backup |
| os-extended-snapshot-attributes:progress | 100% |
| os-extended-snapshot-attributes:project_id | 4188570a34464b938ed3fa7e08681df8 |
| properties | |
| size | 10 |
| status | available |
| updated_at | 2022-12-09T12:01:22.000000 |
| volume_id | 87d595dd-3089-4d37-b8e4-bc0a597c92c7 |
+--------------------------------------------+--------------------------------------+
# 删除卷快照
[root@controller ~]# openstack volume snapshot delete hqs01_backup
(2)cinder命令行格式案例
# 语法
cinder
snapshot-create Creates a snapshot.
snapshot-delete Removes one or more snapshots.
snapshot-list Lists all snapshots.
snapshot-show Shows snapshot details.
snapshot-rename Renames a snapshot.
snapshot-reset-state
Explicitly updates the snapshot state.
snapshot-manage Manage an existing snapshot.
snapshot-unmanage Stop managing a snapshot.
snapshot-metadata Sets or deletes snapshot metadata.
snapshot-metadata-show
Shows snapshot metadata.
snapshot-metadata-update-all
Updates snapshot metadata.
# 创建快照
cinder snapshot-create [--name <name>,--force [<True|False>],--description <description>,--metadata [<key=value> [<key=value> ...]]] <volume>
[root@controller keystone]# cinder snapshot-create --name snapshot-01 --description 'test snapshot of a volume' 92ad953c-a7a1-4ef7-8929-85835143cb26
+-------------+--------------------------------------+
| Property | Value |
+-------------+--------------------------------------+
| created_at | 2021-11-04T15:17:24.382623 |
| description | test snapshot of a volume |
| id | b360d2c0-9a32-4d5b-afe3-112f6cd0e215 |
| metadata | {} |
| name | snapshot-01 |
| size | 2 |
| status | creating |
| updated_at | None |
| volume_id | 92ad953c-a7a1-4ef7-8929-85835143cb26 |
+-------------+--------------------------------------+
# 查看快照列表
cinder snapshot-list
[root@controller keystone]# cinder snapshot-list
+--------------------------------------+--------------------------------------+-----------+-------------+------+
| ID | Volume ID | Status | Name | Size |
+--------------------------------------+--------------------------------------+-----------+-------------+------+
| b360d2c0-9a32-4d5b-afe3-112f6cd0e215 | 92ad953c-a7a1-4ef7-8929-85835143cb26 | available | snapshot-01 | 2 |
+--------------------------------------+--------------------------------------+-----------+-------------+------+
# 查看快照详情
cinder snapshot-show <snapshot>
[root@controller keystone]# cinder snapshot-show snapshot-01
+--------------------------------------------+--------------------------------------+
| Property | Value |
+--------------------------------------------+--------------------------------------+
| created_at | 2021-11-04T15:17:24.000000 |
| description | test snapshot of a volume |
| id | b360d2c0-9a32-4d5b-afe3-112f6cd0e215 |
| metadata | {} |
| name | snapshot-01 |
| os-extended-snapshot-attributes:progress | 100% |
| os-extended-snapshot-attributes:project_id | 386dbfcf77e444c7872e4e23d5829fcc |
| size | 2 |
| status | available |
| updated_at | 2021-11-04T15:17:24.000000 |
| volume_id | 92ad953c-a7a1-4ef7-8929-85835143cb26 |
+--------------------------------------------+--------------------------------------+
# 删除快照
cinder snapshot-delete <snapshot>
[root@controller keystone]# cinder snapshot-delete snapshot-01
[root@controller keystone]# cinder snapshot-list
+----+-----------+--------+------+------+
| ID | Volume ID | Status | Name | Size |
+----+-----------+--------+------+------+
+----+-----------+--------+------+------+
# 快照改名
cinder snapshot-rename [--description <description>] <snapshot> [<name>]
[root@controller keystone]# cinder snapshot-rename --description 'You Have Only One Life' snapshot-01 new-test-snapshot
[root@controller keystone]# cinder snapshot-show snapshot-01
ERROR: No snapshot with a name or ID of 'snapshot-01' exists.
[root@controller keystone]# cinder snapshot-show new-test-snapshot
+--------------------------------------------+--------------------------------------+
| Property | Value |
+--------------------------------------------+--------------------------------------+
| created_at | 2021-11-04T15:19:39.000000 |
| description | You Have Only One Life |
| id | a54e8e02-911c-482f-bc49-fac2060ad7c3 |
| metadata | {} |
| name | new-test-snapshot |
| os-extended-snapshot-attributes:progress | 100% |
| os-extended-snapshot-attributes:project_id | 386dbfcf77e444c7872e4e23d5829fcc |
| size | 2 |
| status | available |
| updated_at | 2021-11-04T15:36:26.000000 |
| volume_id | 92ad953c-a7a1-4ef7-8929-85835143cb26 |
+--------------------------------------------+--------------------------------------+
# 更新快照状态
# 可更新的状态:"available", "error", "creating", "deleting", and "error_deleting".
cinder snapshot-reset-state [--state <state>] <snapshot> [<snapshot> ...]
[root@controller keystone]# cinder snapshot-reset-state --state error new-test-snapshot
[root@controller keystone]# cinder snapshot-show new-test-snapshot
+--------------------------------------------+--------------------------------------+
| Property | Value |
+--------------------------------------------+--------------------------------------+
| created_at | 2021-11-04T15:19:39.000000 |
| description | You Have Only One Life |
| id | a54e8e02-911c-482f-bc49-fac2060ad7c3 |
| metadata | {} |
| name | new-test-snapshot |
| os-extended-snapshot-attributes:progress | 100% |
| os-extended-snapshot-attributes:project_id | 386dbfcf77e444c7872e4e23d5829fcc |
| size | 2 |
| status | error |
| updated_at | 2021-11-04T15:39:40.000000 |
| volume_id | 92ad953c-a7a1-4ef7-8929-85835143cb26 |
+--------------------------------------------+--------------------------------------+
# 管理快照
cinder snapshot-manage [--id-type <id-type>,--name <name>,--description <description>,] [--name <name>,--metadata [<key=value> [<key=value> ...]]]
<volume> <identifier>
[root@controller keystone]# cinder snapshot-manage test2 new-test-snapshot
+--------------------------------------------+--------------------------------------+
| Property | Value |
+--------------------------------------------+--------------------------------------+
| created_at | 2021-11-04T15:46:23.000000 |
| description | None |
| id | 26efb6e5-ff02-47c0-bb1c-6a36718bd68a |
| metadata | {} |
| name | None |
| os-extended-snapshot-attributes:progress | 0% |
| os-extended-snapshot-attributes:project_id | 386dbfcf77e444c7872e4e23d5829fcc |
| size | 2 |
| status | creating |
| updated_at | None |
| volume_id | 456a40c6-65c4-41ee-9958-63bae91ec189 |
+--------------------------------------------+--------------------------------------+
# 停止管理快照
[root@controller keystone]# cinder snapshot-unmanage 26efb6e5-ff02-47c0-bb1c-6a36718bd68a
[root@controller keystone]# cinder snapshot-list
+--------------------------------------+--------------------------------------+-----------+-------------------+------+
| ID | Volume ID | Status | Name | Size |
+--------------------------------------+--------------------------------------+-----------+-------------------+------+
| a54e8e02-911c-482f-bc49-fac2060ad7c3 | 92ad953c-a7a1-4ef7-8929-85835143cb26 | available | new-test-snapshot | 2 |
+--------------------------------------+--------------------------------------+-----------+-------------------+------+
# 设置或删除快照的meta数据
cinder snapshot-metadata <snapshot> <action> <key=value>
[<key=value> ...]
Positional arguments:
<snapshot> ID of snapshot for which to update metadata.
<action> The action. Valid values are "set" or "unset."
<key=value> Metadata key and value pair to set or unset. For unset, specify
only the key.
# 设置快照meta
[root@controller keystone]# cinder snapshot-metadata a54e8e02-911c-482f-bc49-fac2060ad7c3 set function='Backup data'
+----------+-------------+
| Property | Value |
+----------+-------------+
| function | Backup data |
+----------+-------------+
[root@controller keystone]# cinder snapshot-metadata a54e8e02-911c-482f-bc49-fac2060ad7c3 set update-date='2021-11-24'
+-------------+-------------+
| Property | Value |
+-------------+-------------+
| function | Backup data |
| update-date | 2021-11-24 |
+-------------+-------------+
# 删除快照meta
[root@controller keystone]# cinder snapshot-metadata a54e8e02-911c-482f-bc49-fac2060ad7c3 unset update-date='2021-11-24'
[root@controller keystone]# cinder snapshot-metadata-show a54e8e02-911c-482f-bc49-fac2060ad7c3
+-------------------+-------------+
| Metadata-property | Value |
+-------------------+-------------+
| function | Backup data |
+-------------------+-------------+
# 查看快照meta数据
[root@controller keystone]# cinder snapshot-metadata-show a54e8e02-911c-482f-bc49-fac2060ad7c3
+-------------------+-------------+
| Metadata-property | Value |
+-------------------+-------------+
| function | Backup data |
| update-date | 2021-11-24 |
+-------------------+-------------+
# 更新快照meta数据
cinder snapshot-metadata-update-all <snapshot> <key=value>
[<key=value> ...]
[root@controller keystone]# cinder snapshot-metadata-update-all a54e8e02-911c-482f-bc49-fac2060ad7c3 create-date='2021-11-1 12:00:11' update-date='2021/11/24 17:24:15' function='tank T-54'
+----------+------------------------------------------------------------------------------------------------------------+
| Property | Value |
+----------+------------------------------------------------------------------------------------------------------------+
| metadata | {u'function': u'tank T-54', u'update-date': u'2021/11/24 17:24:15', u'create-date': u'2021-11-1 12:00:11'} |
+----------+------------------------------------------------------------------------------------------------------------+
[root@controller keystone]# cinder snapshot-metadata-show a54e8e02-911c-482f-bc49-fac2060ad7c3
+-------------------+---------------------+
| Metadata-property | Value |
+-------------------+---------------------+
| create-date | 2021-11-1 12:00:11 |
| function | tank T-54 |
| update-date | 2021/11/24 17:24:15 |
+-------------------+---------------------+
4、Backup管理
# 开启卷备份服务
systemctl restart openstack-cinder-backup
# 查看备份列表
cinder backup-list
# 查看备份详情
cinder backup-show <backup>
# 创建备份
cinder backup-create --name <name> [--container <container>] <volume>
# 删除备份
cinder backup-delete <backup>
# 恢复备份
cinder backup-restore [--volume <volume>] <backup>
# 备份导出
cinder backup-export <backup>
# 备份导入
cinder backup-import <backup_service> <backup_url>
三、高级操作
1、Qos管理
2、Transfer管理
3、Service管理
4、Consisgroup管理
5、Encryption管理
四、故障处理
1、cinder创建云硬盘状态错误
错误情况:创建一个云硬盘后,查询硬盘时显示error
[root@controller ~]# cinder create 1 --name test2
+--------------------------------+--------------------------------------+
| Property | Value |
+--------------------------------+--------------------------------------+
| attachments | [] |
| availability_zone | nova |
| bootable | false |
| consistencygroup_id | None |
| created_at | 2021-11-14T02:01:12.000000 |
| description | None |
| encrypted | False |
| id | dfad6645-73d3-4d0f-bd83-f8e50c48cb7b |
| metadata | {} |
| migration_status | None |
| multiattach | False |
| name | test2 |
| os-vol-host-attr:host | None |
| os-vol-mig-status-attr:migstat | None |
| os-vol-mig-status-attr:name_id | None |
| os-vol-tenant-attr:tenant_id | 386dbfcf77e444c7872e4e23d5829fcc |
| replication_status | disabled |
| size | 1 |
| snapshot_id | None |
| source_volid | None |
| status | creating |
| updated_at | None |
| user_id | 0f217182b5af448c988f5464c706a337 |
| volume_type | None |
+--------------------------------+--------------------------------------+
[root@controller ~]# cinder list
+--------------------------------------+--------+-------+------+-------------+----------+-------------+
| ID | Status | Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+--------+-------+------+-------------+----------+-------------+
| dfad6645-73d3-4d0f-bd83-f8e50c48cb7b | error | test2 | 1 | - | false | |
+--------------------------------------+--------+-------+------+-------------+----------+-------------+
查询块存储服务日志,找到报错信息:
[root@controller cinder]# vi /var/log/cinder/scheduler.log
2021-11-13 20:54:38.708 1268 ERROR cinder.scheduler.flows.create_volume [req-afe87e8b-cc3a-4275-8e58-fb0034da8be7 0f217182b5af448c988f5464c706a337 386dbfcf77e444c7872e4e23d5829fcc - - -]
Failed to run task cinder.scheduler.flows.create_volume.ScheduleCreateVolumeTask;
volume:create: No valid host was found. No weighed hosts available
计算节点上查看openstack的组件服务状态:
[root@compute ~]# openstack-status
== Cinder services ==
openstack-cinder-api: inactive (disabled on boot)
openstack-cinder-scheduler: inactive (disabled on boot)
openstack-cinder-volume: active
openstack-cinder-backup: inactive (disabled on boot)
确保cinder显示active,正常启动。
本次错误原因:两个节点的系统时间不同,导致计算节点的openstack-cinder-volume服务down掉了。需要在计算节点做如下操作:
[root@compute ~]# ntpdate 192.168.16.10
13 Nov 21:00:18 ntpdate[3689]: step time server 192.168.16.10 offset -324038.658500 sec
[root@compute ~]# date
Sat Nov 13 21:00:21 EST 2021
[root@compute ~]# systemctl restart openstack-cinder-volume
执行如上操作后问题解决,可查看dashboard上的系统信息cinder-volume服务从down改为up,如下图所示:
再创建云硬盘时状态改为availability:
[root@controller ~]# cinder create 1 --name test2
+--------------------------------+--------------------------------------+
| Property | Value |
+--------------------------------+--------------------------------------+
| attachments | [] |
| availability_zone | nova |
| bootable | false |
| consistencygroup_id | None |
| created_at | 2021-11-14T02:16:13.000000 |
| description | None |
| encrypted | False |
| id | 9f9022f5-1b11-447e-bc0c-d3889712120a |
| metadata | {} |
| migration_status | None |
| multiattach | False |
| name | test2 |
| os-vol-host-attr:host | None |
| os-vol-mig-status-attr:migstat | None |
| os-vol-mig-status-attr:name_id | None |
| os-vol-tenant-attr:tenant_id | 386dbfcf77e444c7872e4e23d5829fcc |
| replication_status | disabled |
| size | 1 |
| snapshot_id | None |
| source_volid | None |
| status | creating |
| updated_at | None |
| user_id | 0f217182b5af448c988f5464c706a337 |
| volume_type | None |
+--------------------------------+--------------------------------------+
[root@controller ~]# cinder list
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
| ID | Status | Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
| 9f9022f5-1b11-447e-bc0c-d3889712120a | available | test2 | 1 | - | false | |
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
2、openstack平台重启虚拟机创建失败
计算节点服务down掉处理:
systemctl restart openstack-cinder-volume
systemctl restart openstack-nova-compute
service neutron-metadata-agent restart
service neutron-openvswitch-agent restart