glance image cache

The Glance Image Cache

The Glance API server may be configured to have an optional local image cache. A local image cache stores a copy of image files, essentially enabling multiple API servers to serve the same image file, resulting in an increase in scalability due to an increased number of endpoints serving an image file.

This local image cache is transparent to the end user – in other words, the end user doesn’t know that the Glance API is streaming an image file from its local cache or from the actual backend storage system.

Managing the Glance Image Cache

While image files are automatically placed in the image cache on successful requests to GET/images/<IMAGE_ID>, the image cache is not automatically managed. Here, we describe the basics of how to manage the local image cache on Glance API servers and how to automate this cache management.

Controlling the Growth of the Image Cache

The image cache has a configurable maximum size (the image_cache_max_size configuration file option). The image_cache_max_size is an upper limit beyond which pruner, if running, starts cleaning the images cache. However, when images are successfully returned from a call to GET/images/<IMAGE_ID>, the image cache automatically writes the image file to its cache, regardless of whether the resulting write would make the image cache’s size exceed the value ofimage_cache_max_size. In order to keep the image cache at or below this maximum cache size, you need to run the glance-cache-pruner executable.

The recommended practice is to use cron to fire glance-cache-pruner at a regular interval.

Cleaning the Image Cache

Over time, the image cache can accumulate image files that are either in a stalled or invalid state. Stalled image files are the result of an image cache write failing to complete. Invalid image files are the result of an image file not being written properly to disk.

To remove these types of files, you run the glance-cache-cleaner executable.

The recommended practice is to use cron to fire glance-cache-cleaner at a semi-regular interval.

Prefetching Images into the Image Cache

Some installations have base (sometimes called “golden”) images that are very commonly used to boot virtual machines. When spinning up a new API server, administrators may wish to prefetch these image files into the local image cache to ensure that reads of those popular image files come from a local cache.

To queue an image for prefetching, you can use one of the following methods:

  • If the cache_manage middleware is enabled in the application pipeline, you may callPUT /queued-images/<IMAGE_ID> to queue the image with identifier <IMAGE_ID>

    Alternately, you can use the glance-cache-manage program to queue the image. This program may be run from a different host than the host containing the image cache. Example usage:

    $> glance-cache-manage --host=<HOST> queue-image <IMAGE_ID>
    

    This will queue the image with identifier <IMAGE_ID> for prefetching

Once you have queued the images you wish to prefetch, call the glance-cache-prefetcherexecutable, which will prefetch all queued images concurrently, logging the results of the fetch for each image.

Finding Which Images are in the Image Cache

You can find out which images are in the image cache using one of the following methods:

  • If the cachemanage middleware is enabled in the application pipeline, you may callGET /cached-images to see a JSON-serialized list of mappings that show cached images, the number of cache hits on each image, the size of the image, and the times they were last accessed.

    Alternately, you can use the glance-cache-manage program. This program may be run from a different host than the host containing the image cache. Example usage:

    $> glance-cache-manage --host=<HOST> list-cached
    
  • You can issue the following call on *nix systems (on the host that contains the image cache):
    $> ls -lhR $IMAGE_CACHE_DIR
    

    where $IMAGE_CACHE_DIR is the value of the image_cache_dir configuration variable.

    Note that the image’s cache hit is not shown using this method.

Manually Removing Images from the Image Cache

If the cachemanage middleware is enabled, you may call DELETE /cached-images/<IMAGE_ID> to remove the image file for image with identifier <IMAGE_ID> from the cache.

Alternately, you can use the glance-cache-manage program. Example usage:

$> glance-cache-manage --host=<HOST> delete-cached-image <IMAGE_ID>

http://docs.openstack.org/developer/glance/cache.html

时间: 2024-10-07 01:23:57

glance image cache的相关文章

glance cache

用在多个glance API server 中,对相同的image文件提供服务.该cache对用户透明. 配置文件有一个image_cache_max_size,超过的话image cache会被修剪pruner. 然而,当GET /images/<IMAGE_ID>成功返回一个image时,不管是否超cache,该image都会写入到cache中. 实践中,一般都cron来运行glance-cache-pruner. glance cache工具有: 1. glance-cache-clea

openstack运维实战系列(十三)之glance更改路径引发的&quot;血案&quot;

1. 背景说明 glance在openstack中负责镜像相关的服务,支持将运行的虚拟机转换为快照,镜像和快照都存储在glance中,glance的后端支持多种存储方式,包括本地的文件系统,http,glusterfs,ceph,swift等等. 默认情况下,glance采用本地文件系统的方式存储image,存储的路径为/var/lib/glance/images,随着时间的推移,当镜像越来越多的时候,根目录的空间将会越来越大,所以对于glance的路径来说,需要提前做好规划和准备,如划分一个单

The Boot Process at a Glance x86/x64系统启动过程解析

哥又来干体力活了.人肉翻译一下: The Boot Process at a Glance This section explains the boot process in sufficient detail to understand the system address map and other bus protocol-related matters that are explained later in this article. You need to have a clear u

OpenStack(i版)之Keystone,Glance,Nova,Neutron,Horizon

一.前期准备 1.1.linux-node1端: [[email protected]1 ~]# egrep '(vmx|svm)' /proc/cpuinfo ##有输出就支持虚拟化 [[email protected] ~]# cat /etc/redhat-release CentOS release 6.8 (Final) [[email protected] ~]# uname -r 2.6.32-642.el6.x86_64 [[email protected] ~]# getenf

centos7开机无法进入图形界面,出现sda assuming drive cache write through的一个解决方案

centos7开机无法进入图形界面,出现sda assuming drive cache write through.no valid rapl domains found in package之类信息. 这个问题是我在VMware里面操作出现的,原因是我在使用虚拟机和实体机之间文件共享功能时,centos系统无法出现hgfs文件夹, 为了解决hgfs的不出现问题,我参考了如下帖子: http://blog.csdn.net/cindy_cheng/article/details/5045697

Linux内存学习之buffer和cache的区别详解

本文和大家分享的主要是linux 中 内存buffer 和 cache 的区别相关内容,一起来看看吧,希望对大家 学习linux有所帮助. 细心的朋友会注意到, 当你在 linux 下频繁存取文件后 , 物理内存会很快被用光 , 当程序结束后 , 内存不会被正常释放 , 而是一直作为 caching. 这个问题 , 貌似有不少人在问 , 不过都没有看到有什么很好解决的办法 . 那么我来谈谈这个问题 . 先来说说free 命令 [[email protected] ~]# free -m tota

Ubuntu16.10安装Ocata之3:Glance

1.创建Glance数据库 [email protected]:~/ocata# mysql -uroot -p -e "CREATE DATABASE glance" Enter password: [email protected]:~/ocata# mysql -uroot -p -e "GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'zoomtech'" Ente

58 Openstack基础、openstack之glance、openstack之keystone

03 openstack之keystone 配置环境 Controller CentOS release 6.7 controller eth0:仅主机 192.168.28.121 eth1:桥接 192.168.1.121 node2 192.168.1.122 CentOS release 6.7 compute1 eth0:仅主机,eth1:VMnet2 不会直接与外部网络通信 node3 192.168.1.123 CentOS release 6.7 networking eth0:

【N版】openstack——镜像服务glance(四)

[N版]openstack--镜像服务glance 一.openstack之glance镜像服务 1.1glance介绍 glance主要是由三部分组成 glance-api:接收云系统镜像的创建,删除,读取请求,类似nova-api,通过其他模块(glance-registry及image store)来完成诸如镜像的查找.获取.上传.删除等操作,api监听端口9292. glance-registry:云系统的镜像注册服务,用于与mysql数据库交互,存储或获取镜像的元数据(metadata