首页 资讯 社群 我的社区 搜索

[管理篇]VMWare搭建Openstack——Cinder完成对云硬盘的扩容

chinagissoft
2018-09-30 08:13:38

前面提到了,如果创建更多的时候,或者你的大小过大(X GB),系统也会提示失败,失败信息包括:Stderr: u'  Volume group "cinder-volumes" has insufficient free space (255 extents): 256 required.n' to caller

解决方法也提了,就是扩容相关的VG。

这里面首先要理解Linux的磁盘管理的知识。

  • PV(physical volume):物理卷在逻辑卷管理系统最底层,可为整个物理硬盘或实际物理硬盘上的分区。
  • VG(volume group):卷组建立在物理卷上,一卷组中至少要包括一物理卷,卷组建立后可动态的添加卷到卷组中,一个逻辑卷管理系统工程中可有多个卷组。
  • LV(logical volume):逻辑卷建立在卷组基础上,卷组中未分配空间可用于建立新的逻辑卷,逻辑卷建立后可以动态扩展和缩小空间。
  • PE(physical extent):物理区域是物理卷中可用于分配的最小存储单元,物理区域大小在建立卷组时指定,一旦确定不能更改,同一卷组所有物理卷的物理区域大小需一致,新的pv加入到vg后,pe的大小自动更改为vg中定义的pe大小。
  • LE(logical extent):逻辑区域是逻辑卷中可用于分配的最小存储单元,逻辑区域的大小取决于逻辑卷所在卷组中的物理区域的大小。
  • 卷组描述区域:卷组描述区域存在于每个物理卷中,用于描述物理卷本身、物理卷所属卷组、卷组中逻辑卷、逻辑卷中物理区域的分配等所有信息,它是在使用pvcreate建立物理卷时建立的。


还记得我们在对Cinder存储节点的时候,其中有一个步骤

# pvcreate /dev/sdb1
# vgcreate cinder-volumes /dev/sdb1


当时创建的/dev/sdb1为10GB,事实证明,并没有真正达到10GB。我们可以查看系统已有的VG信息

  1. sm@cinder:~$ sudo vgdisplay
  2. --- Volume group ---
  3. VG Name cinder-volumes
  4. System ID
  5. Format lvm2
  6. Metadata Areas 1
  7. Metadata Sequence No 36
  8. VG Access read/write
  9. VG Status resizable
  10. MAX LV 0
  11. Cur LV 6
  12. Open LV 1
  13. Max PV 0
  14. Cur PV 1
  15. Act PV 1
  16. VG Size 10.00 GiB
  17. PE Size 4.00 MiB
  18. Total PE 2559
  19. Alloc PE / Size 2304 / 9.00 GiB
  20. Free PE / Size 255 / 1020.00 MiB
  21. VG UUID 1arTMX-41HP-Q0RQ-JBpC-Fah4-5mrU-l07jIb
我们可以看到,VG名称为cinder-volumes大小为10GB,其中PE占用了4MB,所以,系统只有10GB-4MB的大小,我们已经创建了9GB的云硬盘,剩下不足1GB(1020MB),而且对于在Horizon界面创建的云硬盘默认大于1GB,所以无法再创建新的云硬盘。

我们查看已有的云硬盘信息

  1. +--------------------------------------+-----------+--------------+------+-------------+----------+--------------------------------------+
  2. | ID | Status | Display Name | Size | Volume Type | Bootable | Attached to |
  3. +--------------------------------------+-----------+--------------+------+-------------+----------+--------------------------------------+
  4. | 121b6509-08e2-4551-8f1d-74cda0eab1f6 | available | myVolume2 | 4 | None | false | |
  5. | 36a81215-50e0-4dbd-90a2-cb1bbde8c5f6 | available | ff | 1 | ceshi | false | |
  6. | 5360873f-b02a-4380-bc20-96fac7ffb340 | in-use | myVolume | 1 | None | false | 614a2641-1e8d-4442-9704-6ab62e3f39d5 |
  7. | b142da28-da38-4688-8990-9a7e844c0c70 | available | qcow2 | 1 | ceshi | true | |
  8. | b61e1c17-1f23-43f1-8141-5c96e0352c34 | available | raw | 1 | ceshi | true | |
  9. | c4abfd3f-c66a-43cc-9e40-91a70f049e9c | available | iso | 1 | ceshi | true | |
  10. +--------------------------------------+-----------+--------------+------+-------------+----------+--------------------------------------+

里面包含将近9GB的云硬盘,但是再创建新的云硬盘,系统就会报错。


1、我们添加一块硬盘 /dev/sdd

2、对新硬盘进行分区,将近/dev/sdd1,大小10GB

  1. sm@cinder:~$ sudo fdisk /dev/sdd
  2. Command (m for help): n
  3. Partition type:
  4. p primary (0 primary, 0 extended, 4 free)
  5. e extended
  6. Select (default p):
  7. Using default response p
  8. Partition number (1-4, default 1): 1
  9. First sector (2048-41943039, default 2048): 10240
  10. Last sector, +sectors or +size{K,M,G} (10240-41943039, default 41943039):
  11. Using default value 41943039
  12. Command (m for help): w
  13. The partition table has been altered!
  14. Calling ioctl() to re-read partition table.
  15. Syncing disks.

3、创建pv

  1. sm@cinder:~$ sudo pvcreate /dev/sdd1
  2. Physical volume "/dev/sdd1" successfully created
如果出现无法找到/dev/sdd1,可以修改/etc/lvm/lvm.conf
filter = [ "a/sdb1/","a/sdb2/","a/sdc1/","a/sdd1/", "r/.*/"]


4、扩展已有VG容量

  1. sm@cinder:~$ sudo vgextend cinder-volumes /dev/sdd1
  2. Volume group "cinder-volumes" successfully extended

5、查看扩展后的VG容量信息

  1. sm@cinder:~$ sudo vgdisplay
  2. --- Volume group ---
  3. VG Name cinder-volumes
  4. System ID
  5. Format lvm2
  6. Metadata Areas 2
  7. Metadata Sequence No 37
  8. VG Access read/write
  9. VG Status resizable
  10. MAX LV 0
  11. Cur LV 6
  12. Open LV 1
  13. Max PV 0
  14. Cur PV 2
  15. Act PV 2
  16. VG Size 29.99 GiB
  17. PE Size 4.00 MiB
  18. Total PE 7677
  19. Alloc PE / Size 2304 / 9.00 GiB
  20. Free PE / Size 5373 / 20.99 GiB
  21. VG UUID 1arTMX-41HP-Q0RQ-JBpC-Fah4-5mrU-l07jIb

6、重启一下service cinder-volume restart服务

7、然后再次创建云硬盘即可

  1. sm@controller:~$ cinder list
  2. +--------------------------------------+-----------+--------------+------+-------------+----------+--------------------------------------+
  3. | ID | Status | Display Name | Size | Volume Type | Bootable | Attached to |
  4. +--------------------------------------+-----------+--------------+------+-------------+----------+--------------------------------------+
  5. | 121b6509-08e2-4551-8f1d-74cda0eab1f6 | available | myVolume2 | 4 | None | false | |
  6. | 36a81215-50e0-4dbd-90a2-cb1bbde8c5f6 | available | ff | 1 | ceshi | false | |
  7. | 5360873f-b02a-4380-bc20-96fac7ffb340 | in-use | myVolume | 1 | None | false | 614a2641-1e8d-4442-9704-6ab62e3f39d5 |
  8. | 6dabd902-8ce4-4cdb-a63d-d58c13299f27 | available | q1 | 1 | ceshi | false | |
  9. | b142da28-da38-4688-8990-9a7e844c0c70 | available | qcow2 | 1 | ceshi | true | |
  10. | b61e1c17-1f23-43f1-8141-5c96e0352c34 | available | raw | 1 | ceshi | true | |
  11. | c4abfd3f-c66a-43cc-9e40-91a70f049e9c | available | iso | 1 | ceshi | true | |
  12. +--------------------------------------+-----------+--------------+------+-------------+----------+--------------------------------------+

我们看到q1就是我新创建的云硬盘。


其实我们根据开头介绍的磁盘管理可以对比一下,我们的每一个云硬盘就是通过卷组进行的逻辑LV.


通过查看系统的lv信息也可以看到,每一个云硬盘就是一个逻辑卷

  1. sm@cinder:~$ sudo lvdisplay
  2. --- Logical volume ---
  3. LV Path /dev/cinder-volumes/volume-5360873f-b02a-4380-bc20-96fac7ffb340
  4. LV Name volume-5360873f-b02a-4380-bc20-96fac7ffb340
  5. VG Name cinder-volumes
  6. LV UUID verxee-wYiv-ECK2-OHY2-n0pL-c6uR-RQ5MoO
  7. LV Write Access read/write
  8. LV Creation host, time cinder, 2015-06-14 22:20:18 +0800
  9. LV Status available
  10. # open 1
  11. LV Size 1.00 GiB
  12. Current LE 256
  13. Segments 1
  14. Allocation inherit
  15. Read ahead sectors auto
  16. - currently set to 256
  17. Block device 252:0
  18. --- Logical volume ---
  19. LV Path /dev/cinder-volumes/volume-121b6509-08e2-4551-8f1d-74cda0eab1f6
  20. LV Name volume-121b6509-08e2-4551-8f1d-74cda0eab1f6
  21. VG Name cinder-volumes
  22. LV UUID Px9RSh-nD45-cu50-iph7-IdRM-0t73-3KkZdc
  23. LV Write Access read/write
  24. LV Creation host, time cinder, 2015-06-14 22:21:04 +0800
  25. LV Status available
  26. # open 0
  27. LV Size 4.00 GiB
  28. Current LE 1024
  29. Segments 1
  30. Allocation inherit
  31. Read ahead sectors auto
  32. - currently set to 256
  33. Block device 252:1
  34. --- Logical volume ---
  35. LV Path /dev/cinder-volumes/volume-b61e1c17-1f23-43f1-8141-5c96e0352c34
  36. LV Name volume-b61e1c17-1f23-43f1-8141-5c96e0352c34
  37. VG Name cinder-volumes
  38. LV UUID ykeTF2-3QZo-SLYr-QUcn-H4fl-91s0-2nncJO
  39. LV Write Access read/write
  40. LV Creation host, time cinder, 2015-06-14 23:13:20 +0800
  41. LV Status available
  42. # open 0
  43. LV Size 1.00 GiB
  44. Current LE 256
  45. Segments 1
  46. Allocation inherit
  47. Read ahead sectors auto
  48. - currently set to 256
  49. Block device 252:2
  50. --- Logical volume ---
  51. LV Path /dev/cinder-volumes/volume-b142da28-da38-4688-8990-9a7e844c0c70
  52. LV Name volume-b142da28-da38-4688-8990-9a7e844c0c70
  53. VG Name cinder-volumes
  54. LV UUID 2cfHLk-37z3-XpsW-KB4y-OAp9-hLki-FLfXJp
  55. LV Write Access read/write
  56. LV Creation host, time cinder, 2015-06-14 23:31:17 +0800
  57. LV Status available
  58. # open 0
  59. LV Size 1.00 GiB
  60. Current LE 256
  61. Segments 1
  62. Allocation inherit
  63. Read ahead sectors auto
  64. - currently set to 256
  65. Block device 252:3
  66. --- Logical volume ---
  67. LV Path /dev/cinder-volumes/volume-c4abfd3f-c66a-43cc-9e40-91a70f049e9c
  68. LV Name volume-c4abfd3f-c66a-43cc-9e40-91a70f049e9c
  69. VG Name cinder-volumes
  70. LV UUID TbQYCn-nJzJ-3nAY-beKh-U6Hk-1p7B-fQNEIE
  71. LV Write Access read/write
  72. LV Creation host, time cinder, 2015-06-14 23:33:07 +0800
  73. LV Status available
  74. # open 0
  75. LV Size 1.00 GiB
  76. Current LE 256
  77. Segments 1
  78. Allocation inherit
  79. Read ahead sectors auto
  80. - currently set to 256
  81. Block device 252:4
  82. --- Logical volume ---
  83. LV Path /dev/cinder-volumes/volume-6dabd902-8ce4-4cdb-a63d-d58c13299f27
  84. LV Name volume-6dabd902-8ce4-4cdb-a63d-d58c13299f27
  85. VG Name cinder-volumes
  86. LV UUID ALtF8Q-4S2r-oeR9-PZo5-EVi3-niJq-JmzLrB
  87. LV Write Access read/write
  88. LV Creation host, time cinder, 2015-06-15 01:30:37 +0800
  89. LV Status available
  90. # open 0
  91. LV Size 1.00 GiB
  92. Current LE 256
  93. Segments 1
  94. Allocation inherit
  95. Read ahead sectors auto
  96. - currently set to 256
  97. Block device 252:5
  98. --- Logical volume ---
  99. LV Path /dev/cinder-volumes/volume-36a81215-50e0-4dbd-90a2-cb1bbde8c5f6
  100. LV Name volume-36a81215-50e0-4dbd-90a2-cb1bbde8c5f6
  101. VG Name cinder-volumes
  102. LV UUID dR3V81-zY6C-uRlY-JsHZ-wTNH-ssOT-8i5Eo3
  103. LV Write Access read/write
  104. LV Creation host, time cinder, 2015-06-15 03:21:30 +0800
  105. LV Status available
  106. # open 0
  107. LV Size 1.00 GiB
  108. Current LE 256
  109. Segments 1
  110. Allocation inherit
  111. Read ahead sectors auto
  112. - currently set to 256
  113. Block device 252:6


--------------------- 本文来自 chinagissoft 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/chinagissoft/article/details/46874617?utm_source=copy   


用户评论