openstack-cinder_lvm_driver命令匯總

來源:互聯網
上載者:User

http://blog.csdn.net/sxmatch/article/details/9304127

【

dd if=/dev/zero of=cinder-volumes bs=1 count=0 seek=2Glosetup /dev/loop2 cinder-volumesfdisk /dev/loop2#Type in the followings:np1ENTERENTERt8ew

Proceed to create the physical volume then the volume group:

pvcreate /dev/loop2vgcreate cinder-volumes /dev/loop2

】

Cinder在使用LVM(邏輯卷管理)作為driver時,在suse環境和不安裝lvm的ubuntu環境上需要先執行一系列的命令才能正常使用cinder:

1.建立物理卷(一般選擇伺服器沒有使用的另一塊或多塊硬碟作為供cinder使用的物理卷)

pvcreate [磁碟裝置路徑] 例如:pvcreate /dev/sdb 建立完成後可以使用 pvdisplay 命令查看物理卷詳情

2.建立卷組(cinder預設使用的卷組名稱為cinder-volumes)

vgcreate [卷組名稱] [要添加到卷組的分區或者磁碟] 例如: vgcreate cinder-volumes /dev/sdb 建立完成後可以使用 vgdisplay 命令查看卷組詳情

3.啟用卷組(這步完成後,cinder就可以正常使用lvm了)

vgchange -ay [卷組名稱] 例如 vgchange -ay cinder-volumes

4.如果卷組的空間不夠用了,後續可以添加新的物理卷到卷組中

vgextend [卷組名] [物理卷路徑] 例如:vgextend cinder-volumes /dev/sdc 注意添加新的物理卷也要再次啟用一下卷組

5.從卷組中刪除一個物理卷,首先要確保沒有邏輯卷使用這個物理卷

vgreduce [卷組名] [物理卷路徑] 例如:vgreduce cinder-volumes /dev/sdc

6.建立邏輯卷(cinder的lvm driver就是使用這個命令建立一個卷)

lvcreate -L [卷大小MB] -n [卷名稱] [卷組名] 例如: lvcreate -L 1000 -n volume1 cinder-volumes 建立完成後還可以查詢一下: lvdisplay

7.擴充邏輯卷(可以擴充邏輯卷的大小,根據參數不同有兩種方式)

lvextend -L [大小] [邏輯卷路徑] 例如:1.擴充到12G lvextend -L 12G /dev/cinder-volumes/volume1 ;2.增加12G lvextend -L +12G /dev/cinder-volumes/volume1

8.減少邏輯卷(和擴充一樣,根據參數不同有兩種方式)

lvreduce -L [大小] [邏輯卷路徑] 例如: 1.減少到4G lvreduce -L 4G /dev/cinder-volumes/volume1 ; 2.減少4G lvreduce -L -4G /dev/cinder-volumes/volume1

9.刪除邏輯卷(要先確保該卷沒有被掛載使用)

lvremove [邏輯卷路徑] 例如: lvremove /dev/cinder-volumes/volume1

注意有時候刪除邏輯卷時會報:Can't remove open logical volume 的錯誤,這時需要先清除一下linux系統中塊裝置映射關係,例如:dmsetup remove -f /dev/mapper/cinder–volumes-volume1

10.lvm driver在建立卷後還會為卷建立iscsi target,為後續掛卷使用,當cinder的實現用的是TgtAdm(此外還有IteAdm和LioAdm兩種實現)其使用的命令為:

tgt-admin –update [iscsi target名稱] 例如:tgt-admin –update iqn.2010-10.org.openstack:volume-2748f2f2-4394-4e6e-af8d-8dd34496c024 (cinder預設iscsi名稱的構成是 首碼+卷uuid, 其中首碼預設是iqn.2010-10.org.openstack:)

查詢所有的iscsi target的命令:tgt-admin –show

刪除iscsi target的命令:tgt-admin –force –delete [iscsi target名稱] 例如:tgt-admin –force –delete iqn.2010-10.org.openstack:volume-2748f2f2-4394-4e6e-af8d-8dd34496c024


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.