cinder运维

1:在cinder中裸磁盘通常为卷,所以就是对于卷的管理,创建,删除,更改之类的操作

一:volume管理

cinder来操作

1:创建卷

格式:

cinder create --name volume1 --description  "new volume"  --volume-type size  c

创建了一个大小为2G的卷

[root@controller /]# cinder create --name volume1 --availabilitye nova 2

 

2:卷更新

1:重命名

格式:

cinder rename 旧卷名 新卷名

将volume1更改为test1

[root@controller /]# cinder rename volume1 test1
查看卷
[root@controller /]# cinder list
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
| ID                                   | Status    | Name  | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
| 656460cf-1d1d-4fbb-81e1-d34e065ab340 | available | test1 | 2    | __DEFAULT__ | false    |             |
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
[root@controller /]# 

2:修改状态

可修改的状态有以下几种

available,error,createing,deleting,in-use,attaching,detaching ,error_deleting,maintenance

附加的状态:atached,detached,默认状态为none

格式:

cinder reset-state --state  状态 卷名

 

将test1的状态改为deleting的状态

[root@controller /]# cinder reset-state --state deleting test1
[root@controller /]# cinder list
+--------------------------------------+----------+-------+------+-------------+----------+-------------+
| ID                                   | Status   | Name  | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+----------+-------+------+-------------+----------+-------------+
| 656460cf-1d1d-4fbb-81e1-d34e065ab340 | deleting | test1 | 2    | __DEFAULT__ | false    |             |
+--------------------------------------+----------+-------+------+-------------+----------+-------------+
[root@controller /]# 

 

3:修改类型

修改类型之前这个卷的状态必须是available状态才能修改卷的类型

先将之前的test1的状态修改成可用的

[root@controller /]# cinder reset-state --state available test1
[root@controller /]# cinder list
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
| ID                                   | Status    | Name  | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
| 656460cf-1d1d-4fbb-81e1-d34e065ab340 | available | test1 | 2    | __DEFAULT__ | false    |             |
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
[root@controller /]# 

 

成功将状态修改成available的状态

格式:

cinder retype 卷名 卷的类型

 

将test1的卷类型修改成lvm类型

[root@controller /]# cinder list
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
| ID                                   | Status    | Name  | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
| 656460cf-1d1d-4fbb-81e1-d34e065ab340 | available | test1 | 2    | __DEFAULT__ | false    |             |
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
[root@controller /]# cinder type-list
+--------------------------------------+-------------+---------------------+-----------+
| ID                                   | Name        | Description         | Is_Public |
+--------------------------------------+-------------+---------------------+-----------+
| 28550d3d-30cd-4c52-8d1a-c135ec2eee7f | __DEFAULT__ | Default Volume Type | True      |
| 6d590030-c967-4590-ac5f-9fc0cb72e7e4 | lvm         | -                   | True      |
+--------------------------------------+-------------+---------------------+-----------+
[root@controller /]# cinder retype test1 6d590030-c967-4590-ac5f-9fc0cb72e7e4 
[root@controller /]# cinder list
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
| ID                                   | Status    | Name  | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
| 656460cf-1d1d-4fbb-81e1-d34e065ab340 | available | test1 | 2    | lvm         | false    |             |
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
[root@controller /]# 

  

4:扩容的操作

可以从小改到大,但是不能从大改成小

格式:

cinder extend 卷名  size

 

将test1的空间增加到5

[root@controller /]# cinder extend test1 5
[root@controller /]# cinder list
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
| ID                                   | Status    | Name  | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
| 656460cf-1d1d-4fbb-81e1-d34e065ab340 | available | test1 | 5    | lvm         | false    |             |
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
[root@controller /]# 

  

  

5:迁移

就是移动到特定的主机上面

 

openstack命令来操作

1:创建卷

[root@controller ~]# openstack volume create --help
usage: openstack volume create [-h] [-f {json,shell,table,value,yaml}]
                               [-c COLUMN] [--max-width <integer>]
                               [--fit-width] [--print-empty] [--noindent]
                               [--prefix PREFIX] [--size <size>]
                               [--type <volume-type>]
                               [--image <image> | --snapshot <snapshot> | --source <volume>]
                               [--description <description>]
                               [--availability-zone <availability-zone>]
                               [--consistency-group consistency-group>]
                               [--property <key=value>] [--hint <key=value>]
                               [--bootable | --non-bootable]
                               [--read-only | --read-write]
                               <name>

#创建一个2G的卷
[root@controller ~]# openstack volume create --size 2 v1

#查看卷
[root@controller ~]# openstack volume list
+--------------------------------------+------+-----------+------+-------------+
| ID                                   | Name | Status    | Size | Attached to |
+--------------------------------------+------+-----------+------+-------------+
| 78174f85-8306-42fa-b453-fbe3504eab25 | v1   | available |    2 |             |
+--------------------------------------+------+-----------+------+-------------+
[root@controller ~]# 

 

2:修改卷

[root@controller ~]# openstack volume set --help
usage: openstack volume set [-h] [--name <name>] [--size <size>]
                            [--description <description>] [--no-property]
                            [--property <key=value>]
                            [--image-property <key=value>] [--state <state>]
                            [--attached | --detached] [--type <volume-type>]
                            [--retype-policy <retype-policy>]
                            [--bootable | --non-bootable]
                            [--read-only | --read-write]
                            <volume>

#修改卷的名字
[root@controller ~]# openstack volume set --name v2 v1

#修改卷的大小(只能扩容,不能缩容)
[root@controller ~]# openstack volume set --size 3 v2

#修改卷的类型
#没有这个类型,可以创建一个
[root@controller ~]# openstack volume set --type 11 v2

#查看卷
[root@controller ~]# openstack volume list
+--------------------------------------+------+-----------+------+-------------+
| ID                                   | Name | Status    | Size | Attached to |
+--------------------------------------+------+-----------+------+-------------+
| 78174f85-8306-42fa-b453-fbe3504eab25 | v2   | available |    3 |             |
+--------------------------------------+------+-----------+------+-------------+
[root@controller ~]# 

#修改卷的状态
[root@controller ~]# openstack volume set --state in-use v2
[root@controller ~]# openstack volume list
+--------------------------------------+------+--------+------+-------------+
| ID                                   | Name | Status | Size | Attached to |
+--------------------------------------+------+--------+------+-------------+
| 78174f85-8306-42fa-b453-fbe3504eab25 | v2   | in-use |    3 |             |
+--------------------------------------+------+--------+------+-------------+
[root@controller ~]# 

 

  

  

二:type类型的管理

cinder命令

类型管理的语句

type-create 类型的创建
type-default 类型默认
type-delete 类型删除
type-key 
type-list 类型列表的查看
type-show 类型详情的查看
type-update 类型的更新

 

1:查看类型和创建类型

查看类型
[root@controller /]# cinder type-list
+--------------------------------------+-------------+---------------------+-----------+
| ID                                   | Name        | Description         | Is_Public |
+--------------------------------------+-------------+---------------------+-----------+
| 28550d3d-30cd-4c52-8d1a-c135ec2eee7f | __DEFAULT__ | Default Volume Type | True      |
| 46067585-3e65-4802-927b-b3cd80aaa6ce | none        | -                   | True      |
| 6d590030-c967-4590-ac5f-9fc0cb72e7e4 | lvm         | -                   | True      |
+--------------------------------------+-------------+---------------------+-----------+
[root@controller /]# 

创建类型
[root@controller /]# cinder type-create qqq
+--------------------------------------+------+-------------+-----------+
| ID                                   | Name | Description | Is_Public |
+--------------------------------------+------+-------------+-----------+
| 1c7ba5f4-764e-4295-9a99-09aa69fabcf5 | qqq  | -           | True      |
+--------------------------------------+------+-------------+-----------+
[root@controller /]# 

 

2:删除类型,必须使用id来删除

[root@controller /]# cinder type-list
+--------------------------------------+-------------+---------------------+-----------+
| ID                                   | Name        | Description         | Is_Public |
+--------------------------------------+-------------+---------------------+-----------+
| 28550d3d-30cd-4c52-8d1a-c135ec2eee7f | __DEFAULT__ | Default Volume Type | True      |
| 46067585-3e65-4802-927b-b3cd80aaa6ce | none        | -                   | True      |
| 6d590030-c967-4590-ac5f-9fc0cb72e7e4 | lvm         | -                   | True      |
+--------------------------------------+-------------+---------------------+-----------+
[root@controller /]# cinder type-delete 46067585-3e65-4802-927b-b3cd80aaa6ce
Request to delete volume type 46067585-3e65-4802-927b-b3cd80aaa6ce has been accepted.
[root@controller /]# cinder type-list
+--------------------------------------+-------------+---------------------+-----------+
| ID                                   | Name        | Description         | Is_Public |
+--------------------------------------+-------------+---------------------+-----------+
| 28550d3d-30cd-4c52-8d1a-c135ec2eee7f | __DEFAULT__ | Default Volume Type | True      |
| 6d590030-c967-4590-ac5f-9fc0cb72e7e4 | lvm         | -                   | True      |
+--------------------------------------+-------------+---------------------+-----------+
[root@controller /]# 

  

3:修改类型

主要修改卷类型的名字,卷的描述,这个类型是否公共的

格式:

cinder type-update 类型 --name --description 

 

将lvm这个类型名字改为none这个名字

[root@controller /]# cinder type-update 6d590030-c967-4590-ac5f-9fc0cb72e7e4  --name none
+--------------------------------------+------+-------------+-----------+
| ID                                   | Name | Description | Is_Public |
+--------------------------------------+------+-------------+-----------+
| 6d590030-c967-4590-ac5f-9fc0cb72e7e4 | none | -           | True      |
+--------------------------------------+------+-------------+-----------+
[root@controller /]# cinder list
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
| ID                                   | Status    | Name  | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
| 656460cf-1d1d-4fbb-81e1-d34e065ab340 | available | test1 | 5    | none        | false    |             |
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
[root@controller /]# 

  

openstack命令  

  

 

 

 

 

  

 

 

  

  

 

  

  

  

 

 

 

  

 

posted @ 2023-12-06 14:07  q_7  阅读(51)  评论(0编辑  收藏  举报