OpenStack Nova 的存儲(chǔ)管理
OpenStack Nova 創(chuàng)建出來(lái)的 instance 是沒(méi)有永久存儲(chǔ)的,也就是說(shuō)關(guān)閉 instance 后所有數(shù)據(jù)都會(huì)丟失,所以需要 storage 來(lái)保存每個(gè) instance 的數(shù)據(jù)。這種把 instance 和 storage 分開(kāi)的設(shè)計(jì)方法很聰明,這樣上面運(yùn)行的 instance 有了很大的靈活性,并且對(duì) storage 的管理也很方便,使得 instance 在不同服務(wù)器 node 之間的在線遷移(live migration)更為方便和簡(jiǎn)單。OpenStack Nova 使用 nova-volume 服務(wù)來(lái)管理存儲(chǔ),實(shí)現(xiàn)和 Amazon 的 Elastic Block Storage (EBS) 不同,nova-volume 提供的是一種基于 Linux LVM 的 iSCSI 解決方案。
Nova-volume 需要一個(gè)單獨(dú)的分區(qū)做 LVM,如果系統(tǒng)上沒(méi)有多余的分區(qū)做 LVM 的話可以用一個(gè)文件來(lái)充當(dāng)硬盤,當(dāng)然這種方法只能自己測(cè)試玩玩,應(yīng)用到生產(chǎn)環(huán)境最好還是用物理硬盤上的分區(qū)做 LVM.
新建一個(gè)文件來(lái)做 LVM:
# dd if=/dev/zero of=/home/vpsee/nova-volumes.img bs=1M seek=100000 count=0 # losetup -f nova-volumes.img # losetup -a /dev/loop0: [fb00]:24120015 (/home/vpsee/nova-volumes.img) # vgcreate nova-volumes /dev/loop0 No physical volume label read from /dev/loop0 Physical volume "/dev/loop0" successfully created Volume group "nova-volumes" successfully created # pvscan PV /dev/sda5 VG node01 lvm2 [465.52 GiB / 48.00 MiB free] PV /dev/loop0 VG nova-volumes lvm2 [97.65 GiB / 77.65 GiB free] Total: 2 [563.17 GiB] / in use: 2 [563.17 GiB] / in no VG: 0 [0 ]
默認(rèn)情況下 iscsitarget 軟件包安裝后并沒(méi)有自動(dòng)啟動(dòng),所以需要手動(dòng)配置和啟動(dòng) iscsitarget 服務(wù):
# vi /etc/default/iscsitarget ISCSITARGET_ENABLE=true # service iscsitarget start * Starting iSCSI enterprise target service
新建一個(gè)大小為 10GB 的 volume,檢查一下是否創(chuàng)建成功(available),并把剛創(chuàng)建的 volume 附加到正在運(yùn)行的 instance 上,附加成功后再次檢查 volume 的狀態(tài)就變成 in-use 了:
# euca-create-volume -s 10 -z nova VOLUME vol-00000003 10 creating (mycloud, None, None, None) 2011-08-30T13:20:04Z # euca-describe-volumes VOLUME vol-00000003 10 nova available (mycloud, node01, None, None) 2011-08-30T13:20:04Z # euca-describe-instances RESERVATION r-i5927300 mycloud default INSTANCE i-00000031 ami-00000006 172.16.39.224 172.16.39.224 running mykey.priv (mycloud, node01) 0 m1.tiny 2011-08-26T07:12:57Z nova # euca-attach-volume -i i-00000031 -d /dev/vdb vol-00000003 VOLUME vol-00000003 # euca-describe-volumes VOLUME vol-00000003 10 nova in-use (mycloud, node01, i-00000031[node01], /dev/vdb) 2011-08-30T13:20:04Z
如果想從運(yùn)行的 instance 上卸載 volume 的話用 euca-detach-volume,卸載成功的話就會(huì)看到 volume 的狀態(tài)又變回 available 了:
# euca-detach-volume vol-00000003 VOLUME vol-00000003 # euca-describe-volumes VOLUME vol-00000003 10 nova available (mycloud, node01, None, None) 2011-08-30T13:20:04Z
原文:http://www.vpsee.com/2011/09/openstack-nova-storage-management/
【編輯推薦】