Cinder組件詳解


一、Cinder組件介紹

Cinder前身是 Nova 中的 nova-volume 服務,在 Folsom 版本發布時,從 Nova 中剝離作為一個獨立的 Openstack 項目存在。

Cinder 類似 Amazon 的 EBS(Elastic Block Storage),為虛擬機提供持久化的塊存儲能力,實現虛擬機存儲卷(Volume)的創建、掛載、卸載、快照(snapshot)等生命周期管理。

1、概念

cinder組件作用:

  1. 塊存儲服務,為運行實例提供穩定的數據塊存儲服務。
  2. 塊存儲服務,提供對 volume 從創建到刪除整個生命周期的管理。

塊存儲(Block Storage):“塊”是指存儲系統采用一整塊的存儲設備。塊存儲可虛擬出整塊硬盤給雲主機使用。

文件存儲(File Storage):依靠文件系統來存儲文件,文件直接存儲在文件系統中,通過FTP、NFS等服務進行訪問。

2、核心架構

Cinder主要由 cinder-api、cinder-scheduler、cinder-volume、volume-provider、volume-backup幾個服務所組成,它們之間通過 AMQP消息隊列進行通信。

blockchain

3、核心組件

在塊存儲中,裸硬盤通常被稱為卷(Volume),Cinder的任務就是管理卷,包括卷的創建、刪除等操作。

模塊名 功能說明
cinder-api 用於接收和響應外部請求,也是外部可用於管理Cinder的唯一入口。
cinder-volume 對卷管理的模塊,運行在存儲節點上管理具體存儲設備的存儲空間。
cinder-scheduler 負責通過調度算法從多個存儲節點中選擇合適的節點來處理用戶請求(創建卷)。
volume-provider 負責通過驅動調用具體的卷管理系統實現對卷的具體操作。支持多種卷管理系統:LVM、NFS、Ceph等
volume-backup 為卷提供備份服務
message queue 各個子服務通過消息隊列實現進程間通信和相互協作。
database cinder 存儲數據文件的數據庫。

4、工作流程

Cinder各個模塊分工合作的大致流程如下(注意模塊之間的通信都是通過消息隊列傳遞的)。

  1. “cinder-api”接收到用戶通過管理界面或命令行發起的卷創建請求后,完成必要處理后將其發送到消息隊列中。
  2. “cinder-scheduler”從消息隊列獲得請求和數據以后,從若干存儲節點中選出一個能存放該卷的節點。然后又將信息發送到消息隊列。
  3. “cinder-volume”從消息隊列獲取請求后,通過“volume-provider”調用具體的卷管理系統在存儲設備上創建卷。

blockchain

二、常用操作

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,如下圖所示:
blockchain

再創建雲硬盤時狀態改為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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM