当前位置: 首页 > 工具软件 > Cinder > 使用案例 >

openstack之cinder命令存储

翟修明
2023-12-01

说明

cinder volumes的配置项,添加一个backend_host 目的是在cind volumes在不同控制节点上切换时,从直接点主机名称不一致,导致不能管理之前控制节点上时创建的cinder卷;该配置项就时统一这个控制节点的名称问题;
同理 fc的存储也需要用一个配置项 backend_host=fc:volumes;
iSCSi的存储也需要用一个配置项backend_host=iscsi:volumes

cinder命令初学:

1、cinder help

获得帮助信息,列出所有命令。

2、cinder absolute-limits

[root@wi115-10 ~]# cinder absolute-limits 
     +-------------------------+-------+
     |           Name          | Value |
     +-------------------------+-------+
     | maxTotalVolumeGigabytes |  1000 |
     |     maxTotalVolumes     |   10  |
     +-------------------------+-------+

列出当前用户的所有资源(Print a list of absolute limits for a user),此用户能够用的磁盘总大小为1000G,volume个数最大为10个。

3、cinder create --display_name cin01 10

[root@wi115-10 ~]# cinder create --display_name cin01 10
  +---------------------+--------------------------------------+
  |       Property      |                Value                 |
  +---------------------+--------------------------------------+
  |     attachments     |                  []                  |
  |  availability_zone  |                 nova                 |
  |      created_at     |      2012-12-18T07:03:08.490263      |
  | display_description |                 None                 |
  |     display_name    |                cin01                 |
  |          id         | 93b42627-f4db-4e70-8531-5687b30cc32a |
  |       metadata      |                  {}                  |
  |         size        |                  10                  |
  |     snapshot_id     |                 None                 |
  |        status       |               creating               |
  |     volume_type     |                 None                 |
  +---------------------+--------------------------------------+

创建一个volume,后还可以接其他参数,如:–volume_type <type_name>

4、cinder list

[root@wi115-10 ~]# cinder list
  +--------------------------------------+-----------+--------------+------+-------------+-------------+
  |                  ID                  |   Status  | Display Name | Size | Volume Type | Attached to |
  +--------------------------------------+-----------+--------------+------+-------------+-------------+
  | 65d23a41-b13f-4345-ab65-918a4b8a6fe6 | available |      qt      |  10  |     None    |             |
  | 93b42627-f4db-4e70-8531-5687b30cc32a |   error   |    cin01     |  10  |     None    |             |
  +--------------------------------------+-----------+--------------+------+-------------+-------------+

列出所有的volume(刚刚创建的那个error了T_T。。。。),与cinder没有独立出来之前的 # nova volume-list命令功能相同。

5、 cinder delete ID(cinder list 查看)

[root@wi115-10 ~]# cinder delete 93b42627-f4db-4e70-8531-5687b30cc32a
  [root@wi115-10 ~]# cinder list
  +--------------------------------------+-----------+--------------+------+-------------+-------------+
  |                  ID                  |   Status  | Display Name | Size | Volume Type | Attached to |
  +--------------------------------------+-----------+--------------+------+-------------+-------------+
  | 65d23a41-b13f-4345-ab65-918a4b8a6fe6 | available |      qt      |  10  |     None    |             |
  +--------------------------------------+-----------+--------------+------+-------------+-------------+

删除一个volume,#cinder delete <volume_id or volume_name>,与cinder没有独立出来之前的 # nova volume-delete <volume_id or volume_name>命令功能相同。

6、cinder credentials

帮助里的解释是:“Discover endpoints that get returned from the authenticate services.”,这条命令的具体用途我不是很清楚,但是看列出来的类容,是将openstack的几个独立模块的authority信息给列出来了。

[root@wi115-10 ~]# cinder credentials
  +------------------+----------------------------------------------------------------------------------------+
  | User Credentials |                                         Value                                          |
  +------------------+----------------------------------------------------------------------------------------+
  |        id        |                            2f98c94b6e2149c984a09c738ef815da                            |
  |       name       |                                         admin                                          |
  |      roles       | [{u'name': u'admin'}, {u'name': u'KeystoneServiceAdmin'}, {u'name': u'KeystoneAdmin'}] |
  |   roles_links    |                                           []                                           |
  |     username     |                                         admin                                          |
  +------------------+----------------------------------------------------------------------------------------+
  +---------+---------------------------------------------------------------------------------------------------------+
  |  Token  |                                                  Value                                                  |
  +---------+---------------------------------------------------------------------------------------------------------+
  | expires |                                           2012-12-19T07:14:14Z                                          |
  |    id   |                                     17d0550c8e154e439a61051505237328                                    |
  |  tenant | {u'enabled': True, u'id': u'74b0e15f70414b7ea8c43a08ba3211f1', u'name': u'admin', u'description': None} |
  +---------+---------------------------------------------------------------------------------------------------------+

列出当前用户的keystone认证信息。

7、cinder show ID(cinder list 查看)

[root@wi115-10 ~]# cinder show  65d23a41-b13f-4345-ab65-918a4b8a6fe6
  +---------------------+--------------------------------------+
  |       Property      |                Value                 |
  +---------------------+--------------------------------------+
  |     attachments     |                  []                  |
  |  availability_zone  |                 nova                 |
  |      created_at     |      2012-12-18T06:21:45.000000      |
  | display_description |                 None                 |
  |     display_name    |                  qt                  |
  |          id         | 65d23a41-b13f-4345-ab65-918a4b8a6fe6 |
  |       metadata      |                  {}                  |
  |         size        |                  10                  |
  |     snapshot_id     |                 None                 |
  |        status       |              available               |
  |     volume_type     |                 None                 |
  +---------------------+--------------------------------------+

显示出指定volume的详细信息,与与cinder没有独立出来之前的 # nova volume-show <volume_id or volume_name>命令功能相同。

8、cinder snapshot-create --display_name qt-snap ID(cinder list 查看)

[root@wi115-10 ~]# cinder snapshot-create --display_name qt-snap 65d23a41-b13f-4345-ab65-918a4b8a6fe6 
  +---------------------+--------------------------------------+
  |       Property      |                Value                 |
  +---------------------+--------------------------------------+
  |      created_at     |      2012-12-18T07:33:36.105541      |
  | display_description |                 None                 |
  |     display_name    |               qt-snap                |
  |          id         | e95506af-2bc6-48ea-a218-8e8c943262c7 |
  |         size        |                  10                  |
  |        status       |               creating               |
  |      volume_id      | 65d23a41-b13f-4345-ab65-918a4b8a6fe6 |
  +---------------------+--------------------------------------+

创建 一个volume快照。

9、cinder snapshot-list

[root@wi115-10 ~]# cinder snapshot-list
  +--------------------------------------+--------------------------------------+--------+--------------+------+
  |                  ID                  |              Volume ID               | Status | Display Name | Size |
  +--------------------------------------+--------------------------------------+--------+--------------+------+
  | e95506af-2bc6-48ea-a218-8e8c943262c7 | 65d23a41-b13f-4345-ab65-918a4b8a6fe6 | error  |   qt-snap    |  10  |
  +--------------------------------------+--------------------------------------+--------+--------------+------+

列出volume快照。

10、cinder snapshot-show ID(cinder list 查看)

[root@wi115-10 ~]# cinder snapshot-show e95506af-2bc6-48ea-a218-8e8c943262c7
  +--------------------------------------------+--------------------------------------+
  |                  Property                  |                Value                 |
  +--------------------------------------------+--------------------------------------+
  |                 created_at                 |      2012-12-18T07:33:36.000000      |
  |            display_description             |                 None                 |
  |                display_name                |               qt-snap                |
  |                     id                     | e95506af-2bc6-48ea-a218-8e8c943262c7 |
  |  os-extended-snapshot-attributes:progress  |                  0%                  |
  | os-extended-snapshot-attributes:project_id |   74b0e15f70414b7ea8c43a08ba3211f1   |
  |                    size                    |                  10                  |
  |                   status                   |                error                 |
  |                 volume_id                  | 65d23a41-b13f-4345-ab65-918a4b8a6fe6 |
  +--------------------------------------------+--------------------------------------+

列出快照的详细信息。

11、cinder snapshot-delete ID(cinder list 查看)

[root@wi115-10 ~]# cinder snapshot-delete e95506af-2bc6-48ea-a218-8e8c943262c7
  [root@wi115-10 ~]# cinder snapshot-list

  [root@wi115-10 ~]#
  删除一个volume快照。
12、cinder type-create AP
[root@wi115-10 ~]# cinder type-create AP
  +----+------+
  | ID   | Name |
  +----+------+
  | 1    |  AP    |
  +----+------+

创建一个volume类型,这样在创建volume的时候就可以加上类型:

 [root@wi115-10 ~]# cinder create --display_name ss --volume_type AP 2
  +---------------------+--------------------------------------+
  |       Property      |                Value                 |
  +---------------------+--------------------------------------+
  |     attachments     |                  []                  |
  |  availability_zone  |                 nova                 |
  |      created_at     |      2012-12-18T07:51:30.034858      |
  | display_description |                 None                 |
  |     display_name    |                  ss                  |
  |          id         | b2ea409b-3b4d-44bb-8b4c-0d5ef6200985 |
  |       metadata      |                  {}                  |
  |         size        |                  2                   |
  |     snapshot_id     |                 None                 |
  |        status       |               creating               |
  |     volume_type     |                  1                   |
  +---------------------+--------------------------------------+
  [root@wi115-10 ~]# cinder list
  +--------------------------------------+-----------+--------------+------+-------------+-------------+
  |                  ID                  |   Status  | Display Name | Size | Volume Type | Attached to |
  +--------------------------------------+-----------+--------------+------+-------------+-------------+
  | 65d23a41-b13f-4345-ab65-918a4b8a6fe6 | available |      qt      |  10  |     None    |             |
  | b2ea409b-3b4d-44bb-8b4c-0d5ef6200985 | available |      ss      |  2   |      AP     |             |
  +--------------------------------------+-----------+--------------+------+-------------+-------------+

13、cinder type-list

[root@wi115-10 ~]# cinder type-list
  +----+------+
  | ID | Name |
  +----+------+
  | 1  |  AP  |
  +----+------+

列出所有的volume type。

14、 cinder type-delete 1

[root@wi115-10 ~]# cinder type-delete 1
  [root@wi115-10 ~]# cinder type-list

  [root@wi115-10 ~]#

删除指定的volume type。不知道是什么原因,之前在测试创建有类型的volume时,–volume_type后只能接type的名字,而在删除type时,只能接type的ID。
另外,cinder还有几个关于quato的命令,目前没有研究有什么作用,待进一步学习。

 类似资料: