openstack中Cinder组件简解
作者:@郑琰
本文转载请注明出处!:https://www.cnblogs.com/zhengyan6/p/16204536.html
一,Cinder组件介绍
概念
cinder组件作用:
- 块存储服务,为运行实例提供稳定的数据块存储服务
- 块存储服务,提供对 volume 从创建到删除整个生命周期的管理
二,常用操作
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> # a.修改卷状态为available [root@controller ~]# cinder reset-state --state available test-volume-01 # b.查看(创建)卷类型 [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 | +--------------------------------------+------+-------------+-----------+ # c.修改为对应的类型 [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管理
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='2022-1-1' +-------------+-------------+ | Property | Value | +-------------+-------------+ | function | Backup data | | update-date | 2022-1-1 | +-------------+-------------+ # 删除快照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>
分类:
OpenStack
标签:
OpenStack·
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)