您的位置:首页 > 运维架构

Openstack之cinder磁盘挂载

2017-08-09 00:00 1381 查看
参考:http://happylab.blog.51cto.com/1730296/1736562/

1.概述

openstack的cinder项目负责volume的服务,即虚拟机的外挂存储,cinder作为管理存储的工具,可以支持LVM,glusterfs,ceph,sleepdog等开源的存储方案,同时也提供了对HP,IBM,huawei等商业存储的支持,配置完cinder之后,即可对虚拟机分配存储空间,如下给虚拟机分配cinder存储空间为例,讲述cinder的使用方法。

2.磁盘挂载

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
[root@controller~]#novalist|grep10.16.6.52
|1809ae2e-7e29-4203-930b-494de426bf8e|Dev_20151201_01|ACTIVE|-|Running|vmPrivate=10.16.6.52|ChuangYiYuan_10_16_2_13|
[root@controller~]#cindercreate--display-name"storage_10.16.6.52"20#划分一个20G的磁盘
+---------------------+--------------------------------------+
|Property|Value|
+---------------------+--------------------------------------+
|attachments|[]|
|availability_zone|nova|
|bootable|false|
|created_at|2016-01-19T08:58:29.819663|
|display_description|None|
|display_name|storage_10.16.6.52|
|encrypted|False|
|id|e5ef5ad4-ddc4-4675-95bf-726473c4c62d|#获取cinder-volume的id号码,用于和instance关联
|metadata|{}|
|size|20|
|snapshot_id|None|
|source_volid|None|
|status|creating|
|volume_type|None|
+---------------------+--------------------------------------+

将cinder和虚拟机关联
[root@controller~]#novavolume-attach1809ae2e-7e29-4203-930b-494de426bf8ee5ef5ad4-ddc4-4675-95bf-726473c4c62d
+----------+--------------------------------------+
|Property|Value|
+----------+--------------------------------------+
|device|/dev/vdc|#虚拟机将会识别为vdc设备
|id|e5ef5ad4-ddc4-4675-95bf-726473c4c62d|
|serverId|1809ae2e-7e29-4203-930b-494de426bf8e|
|volumeId|e5ef5ad4-ddc4-4675-95bf-726473c4c62d|
+----------+--------------------------------------+

查看cinder的情况
[root@controller~]#cindershowe5ef5ad4-ddc4-4675-95bf-726473c4c62d
+--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
|Property|Value|
+--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
|attachments|[{u'device':u'/dev/vdc',u'server_id':u'1809ae2e-7e29-4203-930b-494de426bf8e',u'id':u'e5ef5ad4-ddc4-4675-95bf-726473c4c62d',u'host_name':None,u'volume_id':u'e5ef5ad4-ddc4-4675-95bf-726473c4c62d'}]|
|availability_zone|nova|
|bootable|false|
|created_at|2016-01-19T08:58:29.000000|
|display_description|None|
|display_name|storage_10.16.6.52|
|encrypted|False|
|id|e5ef5ad4-ddc4-4675-95bf-726473c4c62d|
|metadata|{u'readonly':u'False',u'attached_mode':u'rw'}|
|os-vol-host-attr:host|ChuangYiYuan_10_16_2_7|
|os-vol-mig-status-attr:migstat|None|
|os-vol-mig-status-attr:name_id|None|
|os-vol-tenant-attr:tenant_id|842ab3268a2c47e6a4b0d8774de805ae|
|size|20|
|snapshot_id|None|
|source_volid|None|
|status|in-use|
|volume_type|None|
+--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
3.格式化磁盘

查看系统识别的disk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[root@localhost~]#ipaddr
1:lo:<LOOPBACK,UP,LOWER_UP>mtu16436qdiscnoqueuestateUNKNOWN
link/loopback00:00:00:00:00:00brd00:00:00:00:00:00
inet127.0.0.1/8scopehostlo
2:eth0:<BROADCAST,MULTICAST,UP,LOWER_UP>mtu1500qdiscpfifo_faststateUPqlen1000
link/etherfa:16:3e:d5:e1:4ebrdff:ff:ff:ff:ff:ff
inet10.16.6.52/23brd10.16.7.255scopeglobaleth0
[root@localhost~]#dmesg|tail-10
pci0000:00:07.0:usingdefaultPCIsettings
virtio-pci0000:00:07.0:enablingdevice(0000->0003)
virtio-pci0000:00:07.0:PCIINTA->Link[LNKC]->GSI10(level,high)->IRQ10
allocirq_descfor31onnode-1
allockstat_irqsonnode-1
virtio-pci0000:00:07.0:irq31forMSI/MSI-X
allocirq_descfor32onnode-1
allockstat_irqsonnode-1
virtio-pci0000:00:07.0:irq32forMSI/MSI-X
vdc:unknownpartitiontable#磁盘识别为vdc
2.分区与格式化

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
[root@Dev_10_16_6_52~]#fdisk/dev/vdc#磁盘分区
DevicecontainsneitheravalidDOSpartitiontable,norSun,SGIorOSFdisklabel
BuildinganewDOSdisklabelwithdiskidentifier0x115a4ff3.
Changeswillremaininmemoryonly,untilyoudecidetowritethem.
Afterthat,ofcourse,thepreviouscontentwon'tberecoverable.

Warning:invalidflag0x0000ofpartitiontable4willbecorrectedbyw(rite)

Command(mforhelp):n
Commandaction
eextended
pprimarypartition(1-4)
p
Partitionnumber(1-4):1
Firstsector(2048-41943039,default2048):
Usingdefaultvalue2048
Lastsector,+sectorsor+size{K,M,G}(2048-41943039,default41943039):
Usingdefaultvalue41943039

Command(mforhelp):w
Thepartitiontablehasbeenaltered!

Callingioctl()tore-readpartitiontable.
Syncingdisks.
[root@Dev_10_16_6_52~]#partprobe/dev/vdc
[root@Dev_10_16_6_52~]#mkfs.ext4/dev/vdc1#格式化
mke2fs1.41.12(17-May-2010)
Filesystemlabel=
OStype:Linux
Blocksize=4096(log=2)
Fragmentsize=4096(log=2)
Stride=0blocks,Stripewidth=0blocks
1310720inodes,5242624blocks
262131blocks(5.00%)reservedforthesuperuser
Firstdatablock=0
Maximumfilesystemblocks=4294967296
160blockgroups
32768blockspergroup,32768fragmentspergroup
8192inodespergroup
Superblockbackupsstoredonblocks:
32768,98304,163840,229376,294912,819200,884736,1605632,2654208,
4096000

Writinginodetables:done
Creatingjournal(32768blocks):done
Writingsuperblocksandfilesystemaccountinginformation:done

Thisfilesystemwillbeautomaticallycheckedevery38mountsor
180days,whichevercomesfirst.Usetune2fs-cor-itooverride.
3.挂载使用

1
2
3
4
5
[root@localhost~]#mkdir/data2
[root@localhost~]#mount/dev/vdc1/data2/
[root@localhost~]#df-h/data2/
FilesystemSizeUsedAvailUse%Mountedon
/dev/vdc120G172M19G1%/data2
4.总结

cinder作为一种外挂的存储,在openstack中用于数据存储有非常关键的作用,并且在openstack中,使用cinder非常方便,创建和关联,轻松就可以实现任意大小磁盘的分配,实现高效的管理。

5.附录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
[root@controller~]#cinder-h
usage:cinder[--version][--debug][--os-username<auth-user-name>]
[--os-password<auth-password>]
[--os-tenant-name<auth-tenant-name>]
[--os-tenant-id<auth-tenant-id>][--os-auth-url<auth-url>]
[--os-region-name<region-name>]
[--os-auth-system<auth-system>][--service-type<service-type>]
[--service-name<service-name>]
[--volume-service-name<volume-service-name>]
[--endpoint-type<endpoint-type>]
[--os-volume-api-version<volume-api-ver>]
[--os-cacert<ca-certificate>][--retries<retries>]
<subcommand>...
Command-lineinterfacetotheOpenStackCinderAPI.
Positionalarguments:
<subcommand>
absolute-limitsPrintalistofabsolutelimitsforauser
availability-zone-list
Listalltheavailabilityzones.
backup-createCreatesabackup.#备份相关
backup-deleteRemoveabackup.
backup-listListallthebackups.
backup-restoreRestoreabackup.
backup-showShowdetailsaboutabackup.
createAddanewvolume.
credentialsShowusercredentialsreturnedfromauth.
deleteRemovevolume(s).
encryption-type-create#加密盘相关
Createanewencryptiontypeforavolumetype(Admin
Only).
encryption-type-delete
Deletetheencryptiontypeforavolumetype(Admin
Only).
encryption-type-list
Listencryptiontypeinformationforallvolumetypes
(AdminOnly).
encryption-type-show
Showtheencryptiontypeinformationforavolumetype
(AdminOnly).
endpointsDiscoverendpointsthatgetreturnedfromthe
authenticateservices.
extendAttempttoextendthesizeofanexistingvolume.
extra-specs-listPrintalistofcurrent'volumetypesandextraspecs'
(AdminOnly).
force-deleteAttemptforcedremovalofvolume(s),regardlessofthe
state(s).
listListallthevolumes.
metadataSetorDeletemetadataonavolume.
metadata-showShowmetadataofgivenvolume.
metadata-update-all
Updateallmetadataofavolume.
migrateMigratethevolumetothenewhost.#qos相关
qos-associateAssociateqosspecswithspecificvolumetype.
qos-createCreateanewqosspecs.
qos-deleteDeleteaspecificqosspecs.
qos-disassociateDisassociateqosspecsfromspecificvolumetype.
qos-disassociate-all
Disassociateqosspecsfromallofitsassociations.
qos-get-association
Getallassociationsofspecificqosspecs.
qos-keySetorunsetspecificationsforaqosspec.
qos-listGetfulllistofqosspecs.
qos-showGetaspecificqosspecs.
quota-class-showListthequotasforaquotaclass.#磁盘配额相关
quota-class-updateUpdatethequotasforaquotaclass.
quota-defaultsListthedefaultquotasforatenant.
quota-deleteDeletethequotasforatenant.
quota-showListthequotasforatenant.
quota-updateUpdatethequotasforatenant.
quota-usageListthequotausageforatenant.
rate-limitsPrintalistofratelimitsforauser
readonly-mode-update
Updatevolumeread-onlyaccessmoderead_only.
renameRenameavolume.
reset-stateExplicitlyupdatethestateofavolume.#服务管理相关
service-disableDisabletheservice.
service-enableEnabletheservice.
service-listListalltheservices.Filterbyhost&service
binary.
showShowdetailsaboutavolume.
snapshot-createAddanewsnapshot.快照相关
snapshot-deleteRemoveoneormoresnapshots.
snapshot-listListallthesnapshots.
snapshot-metadataSetorDeletemetadataofasnapshot.
snapshot-metadata-show
Showmetadataofgivensnapshot.
snapshot-metadata-update-all
Updateallmetadataofasnapshot.
snapshot-renameRenameasnapshot.
snapshot-reset-state
Explicitlyupdatethestateofasnapshot.
snapshot-showShowdetailsaboutasnapshot.
transfer-acceptAcceptsavolumetransfer.
transfer-createCreatesavolumetransfer.
transfer-deleteUndoatransfer.
transfer-listListallthetransfers.
transfer-showShowdetailsaboutatransfer.
type-createCreateanewvolumetype.cindertype相关
type-deleteDeleteaspecificvolumetype.
type-keySetorunsetextra_specforavolumetype.
type-listPrintalistofavailable'volumetypes'.
upload-to-imageUploadvolumetoimageserviceasimage.
bash-completionPrintargumentsforbash_completion.
helpDisplayhelpaboutthisprogramoroneofits
subcommands.
list-extensionsListalltheos-apiextensionsthatareavailable.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: