OpenStack启动虚拟机、虚拟机做快照加速
2015-09-24 22:35
621 查看
虚拟机做快照加速:
启动虚拟机加速:
本文出自 “the-way-to-cloud” 博客,请务必保留此出处http://iceyao.blog.51cto.com/9426658/1697988
[root@controller-39 ~]# vim /usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py cfg.StrOpt('snapshots_directory', default='$instances_path/snapshots', help='Location where libvirt driver will store snapshots ' 'before uploading them to image service'), CONF = cfg.CONF CONF.register_opts(libvirt_opts, 'libvirt') # 可以看出nova.conf中可以配置虚拟机做快照(默认全量快照),快照上传到glance之前的过渡目录(比如:配置在ssd盘上)。
启动虚拟机加速:
# openstack第一次启动虚拟机的时候会从glance拉镜像到本地(默认是$instances_path/_base) # 第二次以同样的镜像启动虚拟机的时候就直接从$image_cache_directory_name/_base启动了 # 同样,如果base目录是ssd的话,启动虚拟机快是理所应当的。 # 下面的patch就是把虚拟机的base目录变成一个nova.conf的配置选项。 --- virt/imagecache.py | 4 ++++ virt/libvirt/imagebackend.py | 3 ++- virt/libvirt/imagecache.py | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/virt/imagecache.py b/virt/imagecache.py index b63013f..593a48e 100644 --- a/virt/imagecache.py +++ b/virt/imagecache.py @@ -29,6 +29,10 @@ imagecache_opts = [ 'This is NOT the full path - just a folder name. ' 'For per-compute-host cached images, set to _base_$my_ip', deprecated_name='base_dir_name'), + cfg.StrOpt('image_cache_directory_name', + default='/var/lib/nova/instances', + help='Where cached images are stored under cache directory. ', + deprecated_name='base_dir'), cfg.BoolOpt('remove_unused_base_images', default=True, help='Should unused base images be removed?', diff --git a/virt/libvirt/imagebackend.py b/virt/libvirt/imagebackend.py index 6511496..8c0b887 100644 --- a/virt/libvirt/imagebackend.py +++ b/virt/libvirt/imagebackend.py @@ -84,6 +84,7 @@ __imagebackend_opts = [ CONF = cfg.CONF CONF.register_opts(__imagebackend_opts, 'libvirt') CONF.import_opt('image_cache_subdirectory_name', 'nova.virt.imagecache') +CONF.import_opt('image_cache_directory_name', 'nova.virt.imagecache') CONF.import_opt('preallocate_images', 'nova.virt.driver') LOG = logging.getLogger(__name__) @@ -181,7 +182,7 @@ class Image(object): def fetch_func_sync(target, *args, **kwargs): fetch_func(target=target, *args, **kwargs) - base_dir = os.path.join(CONF.instances_path, + base_dir = os.path.join(CONF.image_cache_directory_name, CONF.image_cache_subdirectory_name) if not os.path.exists(base_dir): fileutils.ensure_tree(base_dir) diff --git a/virt/libvirt/imagecache.py b/virt/libvirt/imagecache.py index 5320bad..e1453de 100644 --- a/virt/libvirt/imagecache.py +++ b/virt/libvirt/imagecache.py @@ -72,6 +72,7 @@ CONF = cfg.CONF CONF.register_opts(imagecache_opts, 'libvirt') CONF.import_opt('instances_path', 'nova.compute.manager') CONF.import_opt('image_cache_subdirectory_name', 'nova.virt.imagecache') +CONF.import_opt('image_cache_directory_name', 'nova.virt.imagecache') def get_cache_fname(images, key): @@ -578,7 +579,7 @@ class ImageCacheManager(imagecache.ImageCacheManager): # cache to the instance directory. Files ending in _sm are no longer # created, but may remain from previous versions. - base_dir = os.path.join(CONF.instances_path, + base_dir = os.path.join(CONF.image_cache_directory_name, CONF.image_cache_subdirectory_name) if not os.path.exists(base_dir): LOG.debug(_('Skipping verification, no base directory at %s'), --
本文出自 “the-way-to-cloud” 博客,请务必保留此出处http://iceyao.blog.51cto.com/9426658/1697988
相关文章推荐
- Linux文件操作与IO函数
- ecshop二次开发 使用ecshop电子商务系统的100个小问题
- Linux下使用openssl生成证书
- Nginx的功能特性
- opencv2-1随机图形与文字生成
- shell脚本学习 一
- linux kernel 的配置及编译
- Linux C编程学习笔记-------讲19图形界面编程
- linux c语言实现 执行shell命令
- 第 十 四 天 : 服 务 器 日 常 的 监 控 工 具
- Shell编程(1)
- Linux 应用程序编程基础
- linux命令后台运行
- Android数据存储之文件 openFileOutput & openFileInput
- linux驱动结构
- Linux C编程学习笔记----Fedora系统下开发环境配置
- Linux下SVN服务器自动更新文件到Web目录的方法
- Praat在CentOS 6.5中安装出现./praat /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.18' not found错误的解决办法
- 解决因特网和xshell考虑到问题
- Linux下MySql的登陆和管理操作