共計 1857 個字符,預計需要花費 5 分鐘才能閱讀完成。
行業(yè)資訊
服務器
云計算
如何修復 nova 的后端鏡像文件掛 ceph、生成虛擬機文件變大 1024 倍 bug
這篇文章給大家分享的是有關如何修復 nova 的后端鏡像文件掛 ceph、生成虛擬機文件變大 1024 倍 bug 的內容。丸趣 TV 小編覺得挺實用的,因此分享給大家做個參考,一起跟隨丸趣 TV 小編過來看看吧。
前端界面生成虛擬機:
1、直接從 nova/virt/libvirt/imagebackend.py 的 RBD 類的 create_image 函數開始講解
附上源碼:
def create_image(self, prepare_template, base, size, *args, **kwargs):
import pydevd
pydevd.settrace(192.168.10.10 , port=51234, stdoutToServer=True, stderrToServer=True)
if self.rbd is None:
raise RuntimeError(_( rbd python libraries not found))
if not os.path.exists(base):
# 檢查路徑是否存在
prepare_template(target=base, max_size=size, *args, **kwargs)
else:
self.verify_base_size(base, size)
# 驗證 size 是否滿足要求,同之前博客本地 file 創(chuàng)建分析一致
# keep using the command line import instead of librbd since it
# detects zeroes to preserve sparseness in the image
args = [–pool , self.pool, base, self.rbd_name]
# 構造虛擬機文件生成參數
if self._supports_layering():
args += [–new-format]
args += self._ceph_args()
libvirt_utils.import_rbd_image(*args)
# 根據到 1.1
base_size = disk.get_disk_size(base)
# 求出 base 鏡像模板文件大小
if size and size base_size:
# 見圖 1 -1:
self._resize(self.rbd_name, size)
# 跟進到 1.2
1.1:
(rbd import –pool , nova , /var/lib/nova/instances/_base/8b925177989924ee3e316b28b3abc03a829fbb29 , fec8e16e-0055-4117-aa5c-afbd845773f2_disk , –new-format , –id , admin , –conf , /etc/ceph/ceph.conf)
在執(zhí)行此命令前:
執(zhí)行命令之后:
rbd info:
圖 1 -1:
其中 size 為頁面?zhèn)鬟f過來的 falvor 參數 1G。即(1024*1024*1024),base_size 為鏡像文件 cirros_ceph 大小。
1.2:
def _resize(self, volume_name, size):
size = int(size) * units.Ki
# 見圖 1.2-1
with RBDVolumeProxy(self, volume_name) as vol:
vol.resize(size)
# 根據見 1.3
圖 1.2-1:
1.3:
此處納悶之后找不到 resize 函數(后續(xù)有時間在研究,先以解決問題為主。)
執(zhí)行完此命令:
發(fā)現 size 為 1024GB,比預期打了 1024 倍。
修復 bug:
將圖 1.2- 1 中的
size = int(size) * units.Ki
屏蔽掉:
再次實驗:
問題解決。
感謝各位的閱讀!關于“如何修復 nova 的后端鏡像文件掛 ceph、生成虛擬機文件變大 1024 倍 bug”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!