image-volume cache

標簽: cinder openstack 翻譯


原文: Image-Volume cache

Openstack塊存儲有一個可選的功能,鏡像緩存,可以提升從鏡像創(chuàng)建卷的性能。這個改進依賴很多因素,主要看存儲的后端克隆卷的速度有多快。

當一個卷第一次從鏡像創(chuàng)建的時候,塊存儲的內(nèi)部租戶也會創(chuàng)建一個image-volume緩存。之后如果再請求從這個image創(chuàng)建volume的話就直接clone這個緩存,不需要再下載鏡像的內(nèi)容然后復(fù)制數(shù)據(jù)到卷里了。

每個后端可以配置自己的緩存,可以包含大部分常用的鏡像。

設(shè)置內(nèi)部租戶

image-volume緩存需要配置塊存儲的內(nèi)部租戶。這個租戶擁有這些緩存并且可以進行管理。這可以保護用戶不必看到這些緩存,但是也沒有全局隱藏。

使塊存儲服務(wù)能進入內(nèi)部租戶,需要在conder.conf配置:

cinder_internal_tenant_project_id = PROJECT_ID
cinder_internal_tenant_user_id = USER_ID

為內(nèi)部租戶配置的用戶和項目不需要特殊的額權(quán)限。可以使塊存儲服務(wù)的租戶或者是其他任何的項目和用戶。

配置image-volume cache

在cinder.conf中配置如下:

image_volume_cache_enabled = True

每個后端可以獨立定義或者在默認項里定義。

緩存的大小和數(shù)量限制也可以在每個后端獨立定義,或者在默認項里定義。

image_volume_cache_max_size_gb = SIZE_GB
image_volume_cache_max_count = MAX_COUNT

默認被設(shè)置為0,表示不限制。

通知

緩存操作會觸發(fā)Telemetry消息。這幾種會被發(fā)送:

  • image_volume_cache.miss - 創(chuàng)建卷時,沒有從緩存中找到相應(yīng)的鏡像。這意味著一個新的緩存會被創(chuàng)建
  • image_volume_cache.hit - 從鏡像創(chuàng)建卷時,在緩存中找到了相應(yīng)的鏡像并將被使用。
  • image_volume_cache.evict - 一個鏡像的緩存被刪除。

管理image-volume緩存

通常來說,緩存都是自動管理的,不需要手動干預(yù)。
如果需要,可以手動刪除緩存。通過標準的卷刪除API,塊存儲服務(wù)會執(zhí)行清理。

注意:

代碼可以看出,如果直接clone的話,就不會創(chuàng)建cache了

# vim cinder/volume/flows/manager/create_volume.py
...
    def _create_from_image(self, context, volume_ref,
                           image_location, image_id, image_meta,
                           image_service, **kwargs):
        LOG.debug("Cloning %(volume_id)s from image %(image_id)s "
                  " at location %(image_location)s.",
                  {'volume_id': volume_ref['id'],
                   'image_location': image_location, 'image_id': image_id})

        # Create the volume from an image.
        #
        # First see if the driver can clone the image directly.
        #
        # NOTE (singn): two params need to be returned
        # dict containing provider_location for cloned volume
        # and clone status.
        model_update, cloned = self.driver.clone_image(context,
                                                       volume_ref,
                                                       image_location,
                                                       image_meta,
                                                       image_service)

        # Try and clone the image if we have it set as a glance location.
        if not cloned and 'cinder' in CONF.allowed_direct_url_schemes:
            model_update, cloned = self._clone_image_volume(context,
                                                            volume_ref,
                                                            image_location,
                                                            image_meta)

        # Try and use the image cache.
        should_create_cache_entry = False
        internal_context = cinder_context.get_internal_tenant_context()
        if not internal_context:
            LOG.warning(_LW('Unable to get Cinder internal context, will '
                            'not use image-volume cache.'))


----------


        if not cloned and internal_context and self.image_volume_cache:
            model_update, cloned = self._create_from_image_cache(
                context,
                internal_context,
                volume_ref,
                image_id,
                image_meta
            )
            if not cloned:
                should_create_cache_entry = True


----------

...
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 第一章 OpenStack基礎(chǔ) OpenStack管理的資源及提供的服務(wù)OpenStack做為一個操作系統(tǒng),...
    sgt_tiger閱讀 13,238評論 4 72
  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,569評論 19 139
  • Android 自定義View的各種姿勢1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 179,063評論 25 709
  • 老師叫我們同桌交流自己長大后想干什么。我一聽,快速地轉(zhuǎn)過頭,目不轉(zhuǎn)睛地看著我的同桌任稼臻,仔細地想了想,說:“我想...
    摩天大樓8歲閱讀 268評論 0 1
  • 本文轉(zhuǎn)載自:眾成翻譯譯者:學(xué)會微笑審校: huangxiaolu鏈接:http://www.zcfy.cc/art...
    __越過山丘__閱讀 395評論 0 1

友情鏈接更多精彩內(nèi)容