SlideShare une entreprise Scribd logo
1  sur  30
Télécharger pour lire hors ligne
Nova 与虚拟机管理
戢友
2012/11/10
Self-introduce
• Eucalyptus 云计算    2010.5 ~2010.10
• OpenStack 企业私有云     2010.10~ 今
• 快速部署 + 模块添加 +Nova 定制
概要
Nova 与虚拟机管理
Nova Traps and Pitfalls
Nova 开发 VS Eucalyptus 开发
Nova 在 OpenStack 中的位置
• Nova-Compute 的结构
Nova 的核心部件
Nova 源码分析
• Hacking on OpenStack’s Nova Source code

• http://e.gensee.com/v_154692_2



• 重点 :

• 阅读源码 + 按需定制与修改

• Make hands dirty.

• 虚拟机建立流程
Traps & Pitfalls
Compute 服务的稳定性
• Compute 服务不稳定因素

• libvirt >= 0.9.13

经测试稳定。低版本的 libvirt 有异步操作 bug 。容易导致 lib
virtd 服务死掉。升级吧,不用犹豫了。
• 锁机制

compute 模块在与 libvirt 交互时,没有采用锁机制。
• 信息更新

compute 模块有不少定时服务去刷 libvirt 关于虚拟机的信息
。
锁机制
•   为了保证libvirtd服务的正常运行。在compute通过libvirt_connection访问libvirt时,加了锁机制。
class Connection(object):
    def __init__(self):
      Connection.getInst()
    __libvirt_conn = None
    __inst = None
    __lock = threading.Lock()


    @property
    def uri(self): ….
    @staticmethod
    def getInst():
      auth = [[libvirt.VIR_CRED_AUTHNAME, libvirt.VIR_CRED_NOECHOPROMPT],
            'root',
            None]
      Connection.__lock.acquire()
      if not Connection.__libvirt_conn:
         Connection.__inst = object.__new__(Connection)
         object.__init__(Connection.__inst)
         Connection.__libvirt_conn = libvirt.openAuth(Connection.__inst.uri, auth, 0)
      Connection.__lock.release()
      return Connection.__inst


    @utils.synchronized('virt_libvirt_Connection', external=True)
    def __getattr__(self,attr):
      return getattr(Connection.__libvirt_conn, attr)
信息的更新
• 改变传统的自顶向下的询问方式,采用自底向上的信息更
 新。




db.instance_get_all_by_host(host)


改为利用 libvirt 收集到的本机的虚拟机,然后直接针对 insta
nce 进行更新:
db._instance_update()
虚拟机的快速启动
• 常规启动多台虚拟机:
利用 qcow2 快速启动
• 快速启动原理:
                     增量文件




      backing_file




• 增量文件只保存不一致的部分
Traps & Pitfalls
• 通过 FLAGS.use_cow_images=True 则使用快速启动。

• 增量文件的格式: qcow2



• Xen 快速启动的陷阱

• Windows 快速启动的缺陷

• 何时不应该使快速启动?
Xen 快速启动
Xen 快速启动的条件 :
• Backing file 格式需要使用 raw 格式。

• 增量文件使用 qcow2 格式。

• 需要用 Xen 自带的 qemu-img 工具生成 qcow2 文件。不建
 议用标准的 qemu 。因为 Xen 的 stubdom 就是一个修改过
 的 qemu 。
• 底层 libvirt XML 文件的配置 :
  <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
  <disk type='file' device='disk'>
    <driver name='tap' type='qcow2'/>
    <source file='${basepath}/disk'/>
    <target dev='hda' bus='ide'/>
  </disk>
Windows 的快速启动
• Windows Image 在移植至 OpenStack 时,利用快速启动容
 易遇到蓝屏问题。
• 1 、 virtio driver.

   virtio-win-0.1-22.iso
   virtio-win-1.1.16.vfd
• 2 、 qcow2 增量文件大小指定需要比原有

       windows image 大。一般 2~3 倍没有问题。
何时不要使用快速启动
• Qcow2 文件缺点:

删除文件时,并没真正将文件从磁盘中删除。只是设置此文
件失效。
如果需要在 Openstack 的虚拟机中建立存储服务,不建议使
用快速启虚拟机模式。
设置 :
/etc/nova/nova.conf
FLAGS.use_cow_images=False
Snapshot
• Nova 的 snapshot 是针对磁盘而言,并没有做内存的 snapsh
ot 。
• Nova 做 Snapshot 的大致流程:
Snapshot 流程
1   定位至相应的虚拟机。
2   将虚拟机挂起:即内存保存至 checkpoint 文件中。
3   利用 qemu-img 对磁盘建立 snapshot 。
4   整合磁盘文件与 snapshot 生成一个新的独立的磁盘。
5   将磁盘上传至 Glance 服务。
利用 snapshot 进行恢复
1 从 glance 下载 image 。
2 利用这个新的 image 启动一个虚拟机。



问题:
Snapshot: 相当于把原有虚拟机的磁盘上传至 glance 。
恢复        : 从 glance 上下载此磁盘,新开一个虚拟机。和原
来的虚拟机关系不大。

时间漫长………………………… .
快速 Snapshot
需求: 1 、快速地做 Snapshot 与恢复
   2 、必要时,才把 image 上传至 Glance 。
        不用每次都上传。

步骤:
1 做 snapshot :
$qemu-img snapshot –c snapshot_name disk_path 创建 snapshot.
此时不用将 image 上传至 glance
2 恢复时:
$ qemu-img snapshot –a snapshot_name disk_path
亦不用从 glance 下载磁盘进行恢复
3 必要时,将虚拟机磁盘上传至 glance
image_service.update(context, image_href, metadata, image_file)
快速 snapshot
优点
1 并不是每次 snapshot 都涉及到 glance 。
  都是在本地操作。因此可以很快地完成。
2 可以把多次 snapshot 放在一个磁盘里面,
  直接上传至 Glance 。不用把多个 snapshot 单独上传。
快速 Snapshot
Note:

磁盘 snapshot 针对 qcow2 格式磁盘较易操作。对于 raw 格式
磁盘不易进行。

亦可以在针对磁盘做 snapshot 时,同时对内存做 snapshot 。
这样可以做到对虚拟机的点恢复。

在做 snapshot 时,建议用 qemu-img 针对磁盘做 snapshot 。
利用 libvirt 对内存做快照。不建议利用 libvirt 提供的 snapshot
功能。因为 libvirt 提供的 snapshot 在操作时,会把部分消息保
存至 libivrt 的数据库中。增删易造成不一致。
Terminate 虚拟机
如果创建虚拟机失败。导致虚拟机并没有正常启动。那么 Terminate 操作亦
会失效。看一下流程:
def do_terminate_instance():
     elevated = context.elevated()
     instance = self.db.instance_get_by_uuid(elevated, instance_uuid)
     compute_utils.notify_usage_exists(instance, current_period=True)
     try:
        self._delete_instance(context, instance)
     except exception.InstanceTerminationFailure as error:
        msg = _('%s. Setting instance vm_state to ERROR')
        LOG.error(msg % error, instance_uuid=instance_uuid)
        self._set_instance_error_state(context, instance_uuid)
     except exception.InstanceNotFound as e:
        LOG.warn(e, instance_uuid=instance_uuid)
Live Migration
Live Migration 支持两种
shared storage.
Non-shared storage.

为什么迁移经常出错?哪里出了问题?
检测目标机器

                                 根据
             是否需要从
                            block_migration
 检测目标机器      glance 下载
                            决定是否需要迁
             backing file
                                 移磁盘
Live Migration 逻辑陷阱
                              传入
                       block_migration 参数



     Admin 有 1000 台机
                                        block_migration 决定
     器,他并不清楚这两
                                          是否迁移 VM 的
     台机器是否是共享存
                                              image
            储




          最终是否迁移 image            是否迁移 image 是由
          由参数与底层存储决               底层存储是否共享决
              定                       定
Live Migration
不需参数指定。直接使用
block_migration = self. mounted_on_same_shared_storage()
来进行决定。



 CPU 的比较
 底层基于 libvirt 的 CPU 比较过于严格,可以放松条件。厂商
 一致,型号差别不是太远,基本可以完成迁移。
Live Migration
迁移时,去掉下面这个参数,则否会导致重新从 glance 下载
backing file.

image.cache(fetch_func=libvirt_utils.fetch_image,
       context=ctxt,
       filename=cache_name,
       image_id=instance['image_ref'],
       user_id=instance['user_id'],
       project_id=instance['project_id'],
       size=info['virt_disk_size'])
Live Migration 什么时候可以使用
总的前提条件:网络数据传输允许!数据传输有独立的通道!
比如:可以的情况
计算密集型 + 小磁盘: 迁移量 = 内存 + 增量磁盘
计算节点之间采用共享存储
允许小概率的迁移失败

不建议的情况:
非共享存储 + 大磁盘
关键服务 + 不允许迁移失败
Xen 在 OpenStack 状况
python-libvirt 对 Xen 的支持并不好。一些功能都不能实现。底
层虚拟机启动配置需要修改。
live_migration
pause/unpause
suspend/resume
save/restore

底层实现最好是利用 xen-tools 来进行操作或者
XenAPI 。 Virsh 在一定程度上也可以帮忙。
OpenStack VS Eucalyptus
OpenStack         cc

松耦合 / 异步消息传递与函数调用
python rest API 易修改与定制         cc
Eucalptus
上层发布 ec2 接口的 java 代码混乱
                         clc
模块连续紧密
层层调用的消息传递与函数调用                 nc
c/axis2c/WSDL 开发调试难度加大

Contenu connexe

Tendances

BAS010_虛擬化基礎_v190330
BAS010_虛擬化基礎_v190330BAS010_虛擬化基礎_v190330
BAS010_虛擬化基礎_v190330rwp99346
 
BAS011_VMware資料中心虛擬化-基礎_v190418
BAS011_VMware資料中心虛擬化-基礎_v190418BAS011_VMware資料中心虛擬化-基礎_v190418
BAS011_VMware資料中心虛擬化-基礎_v190418rwp99346
 
雲端的架構開發 (Designing Cloud Application Architecture with Windows Azure Platform)
雲端的架構開發 (Designing Cloud Application Architecture with Windows Azure Platform)雲端的架構開發 (Designing Cloud Application Architecture with Windows Azure Platform)
雲端的架構開發 (Designing Cloud Application Architecture with Windows Azure Platform)Jeff Chu
 
前端自動化工具
前端自動化工具前端自動化工具
前端自動化工具國昭 張
 
Sheepdog内部实现机制
Sheepdog内部实现机制Sheepdog内部实现机制
Sheepdog内部实现机制Liu Yuan
 
再生龍於雲端環境之應用
再生龍於雲端環境之應用再生龍於雲端環境之應用
再生龍於雲端環境之應用Chenkai Sun
 
Sheepdog介绍
Sheepdog介绍Sheepdog介绍
Sheepdog介绍Liu Yuan
 
云端的数据库
云端的数据库云端的数据库
云端的数据库thinkinlamp
 
FtnApp 的缩略图实践
FtnApp 的缩略图实践FtnApp 的缩略图实践
FtnApp 的缩略图实践Frank Xu
 
2011 06-12-lamp-mysql-顾春江
2011 06-12-lamp-mysql-顾春江2011 06-12-lamp-mysql-顾春江
2011 06-12-lamp-mysql-顾春江thinkinlamp
 
大家都愛的 VMware - VMware 簡單介紹
大家都愛的 VMware - VMware 簡單介紹大家都愛的 VMware - VMware 簡單介紹
大家都愛的 VMware - VMware 簡單介紹Fan-Yu Kuan
 
Openstack nova
Openstack novaOpenstack nova
Openstack novaYong Luo
 
淘宝主备数据库自动切换
淘宝主备数据库自动切换淘宝主备数据库自动切换
淘宝主备数据库自动切换mysqlops
 
Ezilla
EzillaEzilla
Ezillahs1250
 
主库自动切换 V2.0
主库自动切换 V2.0主库自动切换 V2.0
主库自动切换 V2.0jinqing zhu
 
PyCon China 2012 孙毅
PyCon China 2012 孙毅PyCon China 2012 孙毅
PyCon China 2012 孙毅Yi Sun
 
下一代虚拟存储解决方案:Vaai
下一代虚拟存储解决方案:Vaai下一代虚拟存储解决方案:Vaai
下一代虚拟存储解决方案:VaaiITband
 
Bypat博客出品-linux+apache+mysql+php之linux系统安装
Bypat博客出品-linux+apache+mysql+php之linux系统安装Bypat博客出品-linux+apache+mysql+php之linux系统安装
Bypat博客出品-linux+apache+mysql+php之linux系统安装redhat9
 
Node js实践
Node js实践Node js实践
Node js实践jay li
 

Tendances (19)

BAS010_虛擬化基礎_v190330
BAS010_虛擬化基礎_v190330BAS010_虛擬化基礎_v190330
BAS010_虛擬化基礎_v190330
 
BAS011_VMware資料中心虛擬化-基礎_v190418
BAS011_VMware資料中心虛擬化-基礎_v190418BAS011_VMware資料中心虛擬化-基礎_v190418
BAS011_VMware資料中心虛擬化-基礎_v190418
 
雲端的架構開發 (Designing Cloud Application Architecture with Windows Azure Platform)
雲端的架構開發 (Designing Cloud Application Architecture with Windows Azure Platform)雲端的架構開發 (Designing Cloud Application Architecture with Windows Azure Platform)
雲端的架構開發 (Designing Cloud Application Architecture with Windows Azure Platform)
 
前端自動化工具
前端自動化工具前端自動化工具
前端自動化工具
 
Sheepdog内部实现机制
Sheepdog内部实现机制Sheepdog内部实现机制
Sheepdog内部实现机制
 
再生龍於雲端環境之應用
再生龍於雲端環境之應用再生龍於雲端環境之應用
再生龍於雲端環境之應用
 
Sheepdog介绍
Sheepdog介绍Sheepdog介绍
Sheepdog介绍
 
云端的数据库
云端的数据库云端的数据库
云端的数据库
 
FtnApp 的缩略图实践
FtnApp 的缩略图实践FtnApp 的缩略图实践
FtnApp 的缩略图实践
 
2011 06-12-lamp-mysql-顾春江
2011 06-12-lamp-mysql-顾春江2011 06-12-lamp-mysql-顾春江
2011 06-12-lamp-mysql-顾春江
 
大家都愛的 VMware - VMware 簡單介紹
大家都愛的 VMware - VMware 簡單介紹大家都愛的 VMware - VMware 簡單介紹
大家都愛的 VMware - VMware 簡單介紹
 
Openstack nova
Openstack novaOpenstack nova
Openstack nova
 
淘宝主备数据库自动切换
淘宝主备数据库自动切换淘宝主备数据库自动切换
淘宝主备数据库自动切换
 
Ezilla
EzillaEzilla
Ezilla
 
主库自动切换 V2.0
主库自动切换 V2.0主库自动切换 V2.0
主库自动切换 V2.0
 
PyCon China 2012 孙毅
PyCon China 2012 孙毅PyCon China 2012 孙毅
PyCon China 2012 孙毅
 
下一代虚拟存储解决方案:Vaai
下一代虚拟存储解决方案:Vaai下一代虚拟存储解决方案:Vaai
下一代虚拟存储解决方案:Vaai
 
Bypat博客出品-linux+apache+mysql+php之linux系统安装
Bypat博客出品-linux+apache+mysql+php之linux系统安装Bypat博客出品-linux+apache+mysql+php之linux系统安装
Bypat博客出品-linux+apache+mysql+php之linux系统安装
 
Node js实践
Node js实践Node js实践
Node js实践
 

En vedette

Putting the wow into your school's wom, NYSAIS Presentation
Putting the wow into your school's wom, NYSAIS PresentationPutting the wow into your school's wom, NYSAIS Presentation
Putting the wow into your school's wom, NYSAIS PresentationRick Newberry
 
Stepping Towards Self Sufficiency: An Indigenous Economic Development Plan fo...
Stepping Towards Self Sufficiency: An Indigenous Economic Development Plan fo...Stepping Towards Self Sufficiency: An Indigenous Economic Development Plan fo...
Stepping Towards Self Sufficiency: An Indigenous Economic Development Plan fo...Wayne Dunn
 
Future grps0-1226583494014006-9
Future grps0-1226583494014006-9Future grps0-1226583494014006-9
Future grps0-1226583494014006-9Neha Suman
 
Director project
Director projectDirector project
Director projectmegzy143
 
Jhe 33-3-147-11-2176-bhasin-v-tt
Jhe 33-3-147-11-2176-bhasin-v-ttJhe 33-3-147-11-2176-bhasin-v-tt
Jhe 33-3-147-11-2176-bhasin-v-ttsahiloct11969
 
Manual dreamweaver-cs4-espanol-by reparaciondepc.cl
Manual dreamweaver-cs4-espanol-by reparaciondepc.clManual dreamweaver-cs4-espanol-by reparaciondepc.cl
Manual dreamweaver-cs4-espanol-by reparaciondepc.clEmmanuel Berumen
 
User manual hl_wp_ss
User manual hl_wp_ssUser manual hl_wp_ss
User manual hl_wp_ssDebjani Roy
 
KVH Data Center Solutions
KVH Data Center SolutionsKVH Data Center Solutions
KVH Data Center SolutionsKVH Co. Ltd.
 
Chuong 1 tu bat on vi mo den con duong tai co cau
Chuong 1   tu bat on vi mo den con duong tai co cauChuong 1   tu bat on vi mo den con duong tai co cau
Chuong 1 tu bat on vi mo den con duong tai co cauDat Nguyen
 
Assignment 1 - Certification in Dispute Management
Assignment 1 - Certification in Dispute ManagementAssignment 1 - Certification in Dispute Management
Assignment 1 - Certification in Dispute ManagementJyotpreet Kaur
 
The politics of policy making around pastoralism in kenya
The politics of policy making around pastoralism in kenyaThe politics of policy making around pastoralism in kenya
The politics of policy making around pastoralism in kenyafutureagricultures
 
2) exam section a question 1
2) exam section a   question 12) exam section a   question 1
2) exam section a question 1adamporter
 
The Day Ahead. 2/14/2013
The Day Ahead. 2/14/2013The Day Ahead. 2/14/2013
The Day Ahead. 2/14/2013Clint Hammond
 
The Changing Resource Development Paradigm: Maximizing Sustainable Local Be...
The Changing Resource Development Paradigm:   Maximizing Sustainable Local Be...The Changing Resource Development Paradigm:   Maximizing Sustainable Local Be...
The Changing Resource Development Paradigm: Maximizing Sustainable Local Be...Wayne Dunn
 

En vedette (20)

Tibet
TibetTibet
Tibet
 
Andy warhol work
Andy warhol workAndy warhol work
Andy warhol work
 
Putting the wow into your school's wom, NYSAIS Presentation
Putting the wow into your school's wom, NYSAIS PresentationPutting the wow into your school's wom, NYSAIS Presentation
Putting the wow into your school's wom, NYSAIS Presentation
 
How to Search Twitter
How to Search TwitterHow to Search Twitter
How to Search Twitter
 
Stepping Towards Self Sufficiency: An Indigenous Economic Development Plan fo...
Stepping Towards Self Sufficiency: An Indigenous Economic Development Plan fo...Stepping Towards Self Sufficiency: An Indigenous Economic Development Plan fo...
Stepping Towards Self Sufficiency: An Indigenous Economic Development Plan fo...
 
Future grps0-1226583494014006-9
Future grps0-1226583494014006-9Future grps0-1226583494014006-9
Future grps0-1226583494014006-9
 
Director project
Director projectDirector project
Director project
 
Jhe 33-3-147-11-2176-bhasin-v-tt
Jhe 33-3-147-11-2176-bhasin-v-ttJhe 33-3-147-11-2176-bhasin-v-tt
Jhe 33-3-147-11-2176-bhasin-v-tt
 
Manual dreamweaver-cs4-espanol-by reparaciondepc.cl
Manual dreamweaver-cs4-espanol-by reparaciondepc.clManual dreamweaver-cs4-espanol-by reparaciondepc.cl
Manual dreamweaver-cs4-espanol-by reparaciondepc.cl
 
User manual hl_wp_ss
User manual hl_wp_ssUser manual hl_wp_ss
User manual hl_wp_ss
 
Demanding freedom
Demanding freedomDemanding freedom
Demanding freedom
 
KVH Data Center Solutions
KVH Data Center SolutionsKVH Data Center Solutions
KVH Data Center Solutions
 
Canadas beauty
Canadas beautyCanadas beauty
Canadas beauty
 
Chuong 1 tu bat on vi mo den con duong tai co cau
Chuong 1   tu bat on vi mo den con duong tai co cauChuong 1   tu bat on vi mo den con duong tai co cau
Chuong 1 tu bat on vi mo den con duong tai co cau
 
Phrasal verbs
Phrasal verbsPhrasal verbs
Phrasal verbs
 
Assignment 1 - Certification in Dispute Management
Assignment 1 - Certification in Dispute ManagementAssignment 1 - Certification in Dispute Management
Assignment 1 - Certification in Dispute Management
 
The politics of policy making around pastoralism in kenya
The politics of policy making around pastoralism in kenyaThe politics of policy making around pastoralism in kenya
The politics of policy making around pastoralism in kenya
 
2) exam section a question 1
2) exam section a   question 12) exam section a   question 1
2) exam section a question 1
 
The Day Ahead. 2/14/2013
The Day Ahead. 2/14/2013The Day Ahead. 2/14/2013
The Day Ahead. 2/14/2013
 
The Changing Resource Development Paradigm: Maximizing Sustainable Local Be...
The Changing Resource Development Paradigm:   Maximizing Sustainable Local Be...The Changing Resource Development Paradigm:   Maximizing Sustainable Local Be...
The Changing Resource Development Paradigm: Maximizing Sustainable Local Be...
 

Similaire à Nova与虚拟机管理

【VM保護備份專題】Dell Power Protect Data Manager (PPDM) 詳解TSDM機制
【VM保護備份專題】Dell Power Protect Data Manager (PPDM) 詳解TSDM機制【VM保護備份專題】Dell Power Protect Data Manager (PPDM) 詳解TSDM機制
【VM保護備份專題】Dell Power Protect Data Manager (PPDM) 詳解TSDM機制裝機安 Angelo
 
HPE SimpliVity install mgmt guide 201907-01 (Taiwan-Chinese) ;HPE SimpliVity ...
HPE SimpliVity install mgmt guide 201907-01 (Taiwan-Chinese) ;HPE SimpliVity ...HPE SimpliVity install mgmt guide 201907-01 (Taiwan-Chinese) ;HPE SimpliVity ...
HPE SimpliVity install mgmt guide 201907-01 (Taiwan-Chinese) ;HPE SimpliVity ...裝機安 Angelo
 
Vulkan introduction
Vulkan introductionVulkan introduction
Vulkan introductionJiahan Su
 
Beyond rails server
Beyond rails serverBeyond rails server
Beyond rails serverMichael Chen
 
Mysql proxy+mysql-mmm
Mysql proxy+mysql-mmmMysql proxy+mysql-mmm
Mysql proxy+mysql-mmmYiwei Ma
 
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩Wen-Tien Chang
 
用Maven管理專案的依賴關係
用Maven管理專案的依賴關係用Maven管理專案的依賴關係
用Maven管理專案的依賴關係Huang Bruce
 
基于Fuel的超融合一体机
基于Fuel的超融合一体机基于Fuel的超融合一体机
基于Fuel的超融合一体机EdwardBadBoy
 
StackOps step by-step guide
StackOps step by-step guideStackOps step by-step guide
StackOps step by-step guideslmagicbox
 
Maven初级培训
Maven初级培训Maven初级培训
Maven初级培训Cody Zhang
 
Ceph Day Shanghai - Ceph in Chinau Unicom Labs
Ceph Day Shanghai - Ceph in Chinau Unicom LabsCeph Day Shanghai - Ceph in Chinau Unicom Labs
Ceph Day Shanghai - Ceph in Chinau Unicom LabsCeph Community
 
Kvmopt osforce
Kvmopt osforceKvmopt osforce
Kvmopt osforcemeecheng
 
Linux Container Introduction
Linux Container IntroductionLinux Container Introduction
Linux Container Introduction家弘 周
 
探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG
探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG
探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUGYingSiang Geng
 
2, installation
2, installation2, installation
2, installationted-xu
 
Docker tutorial
Docker tutorialDocker tutorial
Docker tutorialazole Lai
 
使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 ...
使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 ...使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 ...
使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 ...Laird Cheng
 
自动化运维管理
自动化运维管理自动化运维管理
自动化运维管理frankwsj
 

Similaire à Nova与虚拟机管理 (20)

【VM保護備份專題】Dell Power Protect Data Manager (PPDM) 詳解TSDM機制
【VM保護備份專題】Dell Power Protect Data Manager (PPDM) 詳解TSDM機制【VM保護備份專題】Dell Power Protect Data Manager (PPDM) 詳解TSDM機制
【VM保護備份專題】Dell Power Protect Data Manager (PPDM) 詳解TSDM機制
 
HPE SimpliVity install mgmt guide 201907-01 (Taiwan-Chinese) ;HPE SimpliVity ...
HPE SimpliVity install mgmt guide 201907-01 (Taiwan-Chinese) ;HPE SimpliVity ...HPE SimpliVity install mgmt guide 201907-01 (Taiwan-Chinese) ;HPE SimpliVity ...
HPE SimpliVity install mgmt guide 201907-01 (Taiwan-Chinese) ;HPE SimpliVity ...
 
Vulkan introduction
Vulkan introductionVulkan introduction
Vulkan introduction
 
Beyond rails server
Beyond rails serverBeyond rails server
Beyond rails server
 
Mysql proxy+mysql-mmm
Mysql proxy+mysql-mmmMysql proxy+mysql-mmm
Mysql proxy+mysql-mmm
 
Zabbix in PPTV
Zabbix in PPTVZabbix in PPTV
Zabbix in PPTV
 
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩
 
Double take 6.0 實機體驗營
Double take 6.0 實機體驗營Double take 6.0 實機體驗營
Double take 6.0 實機體驗營
 
用Maven管理專案的依賴關係
用Maven管理專案的依賴關係用Maven管理專案的依賴關係
用Maven管理專案的依賴關係
 
基于Fuel的超融合一体机
基于Fuel的超融合一体机基于Fuel的超融合一体机
基于Fuel的超融合一体机
 
StackOps step by-step guide
StackOps step by-step guideStackOps step by-step guide
StackOps step by-step guide
 
Maven初级培训
Maven初级培训Maven初级培训
Maven初级培训
 
Ceph Day Shanghai - Ceph in Chinau Unicom Labs
Ceph Day Shanghai - Ceph in Chinau Unicom LabsCeph Day Shanghai - Ceph in Chinau Unicom Labs
Ceph Day Shanghai - Ceph in Chinau Unicom Labs
 
Kvmopt osforce
Kvmopt osforceKvmopt osforce
Kvmopt osforce
 
Linux Container Introduction
Linux Container IntroductionLinux Container Introduction
Linux Container Introduction
 
探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG
探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG
探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG
 
2, installation
2, installation2, installation
2, installation
 
Docker tutorial
Docker tutorialDocker tutorial
Docker tutorial
 
使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 ...
使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 ...使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 ...
使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 ...
 
自动化运维管理
自动化运维管理自动化运维管理
自动化运维管理
 

Plus de OpenCity Community

Plus de OpenCity Community (20)

开源讲义.pdf
开源讲义.pdf开源讲义.pdf
开源讲义.pdf
 
物联网操作系统漫谈-GIAC大会.pdf
物联网操作系统漫谈-GIAC大会.pdf物联网操作系统漫谈-GIAC大会.pdf
物联网操作系统漫谈-GIAC大会.pdf
 
2017开源年会-企业开源那些事儿-更新.pdf
2017开源年会-企业开源那些事儿-更新.pdf2017开源年会-企业开源那些事儿-更新.pdf
2017开源年会-企业开源那些事儿-更新.pdf
 
社会化研发
社会化研发社会化研发
社会化研发
 
Containers & CaaS
Containers & CaaSContainers & CaaS
Containers & CaaS
 
OaaS:Open as a Strategy
OaaS:Open as a StrategyOaaS:Open as a Strategy
OaaS:Open as a Strategy
 
Hello openstack 2014
Hello openstack 2014Hello openstack 2014
Hello openstack 2014
 
Docker openstack-2014
Docker openstack-2014Docker openstack-2014
Docker openstack-2014
 
Learn OpenStack from trystack.cn
Learn OpenStack from trystack.cnLearn OpenStack from trystack.cn
Learn OpenStack from trystack.cn
 
OpenStack系列公开课2 -20130508
OpenStack系列公开课2 -20130508OpenStack系列公开课2 -20130508
OpenStack系列公开课2 -20130508
 
OpenStack ecosystem
OpenStack ecosystemOpenStack ecosystem
OpenStack ecosystem
 
How to master OpenStack in 2 hours
How to master OpenStack in 2 hoursHow to master OpenStack in 2 hours
How to master OpenStack in 2 hours
 
Learn OpenStack from trystack.cn ——Folsom in practice
Learn OpenStack from trystack.cn  ——Folsom in practiceLearn OpenStack from trystack.cn  ——Folsom in practice
Learn OpenStack from trystack.cn ——Folsom in practice
 
Quantum Networks
Quantum NetworksQuantum Networks
Quantum Networks
 
云计算思考
云计算思考云计算思考
云计算思考
 
Openstorage Openstack
Openstorage OpenstackOpenstorage Openstack
Openstorage Openstack
 
Openstack的研究与实践
Openstack的研究与实践Openstack的研究与实践
Openstack的研究与实践
 
Open Stack Cheng Du Swift Alex Yang
Open Stack Cheng Du Swift Alex YangOpen Stack Cheng Du Swift Alex Yang
Open Stack Cheng Du Swift Alex Yang
 
Look Into Libvirt Osier Yang
Look Into Libvirt Osier YangLook Into Libvirt Osier Yang
Look Into Libvirt Osier Yang
 
Deep Dive Into Quantum
Deep Dive Into QuantumDeep Dive Into Quantum
Deep Dive Into Quantum
 

Nova与虚拟机管理

  • 2. Self-introduce • Eucalyptus 云计算 2010.5 ~2010.10 • OpenStack 企业私有云 2010.10~ 今 • 快速部署 + 模块添加 +Nova 定制
  • 3. 概要 Nova 与虚拟机管理 Nova Traps and Pitfalls Nova 开发 VS Eucalyptus 开发
  • 4. Nova 在 OpenStack 中的位置 • Nova-Compute 的结构
  • 6. Nova 源码分析 • Hacking on OpenStack’s Nova Source code • http://e.gensee.com/v_154692_2 • 重点 : • 阅读源码 + 按需定制与修改 • Make hands dirty. • 虚拟机建立流程
  • 8. Compute 服务的稳定性 • Compute 服务不稳定因素 • libvirt >= 0.9.13 经测试稳定。低版本的 libvirt 有异步操作 bug 。容易导致 lib virtd 服务死掉。升级吧,不用犹豫了。 • 锁机制 compute 模块在与 libvirt 交互时,没有采用锁机制。 • 信息更新 compute 模块有不少定时服务去刷 libvirt 关于虚拟机的信息 。
  • 9. 锁机制 • 为了保证libvirtd服务的正常运行。在compute通过libvirt_connection访问libvirt时,加了锁机制。 class Connection(object): def __init__(self): Connection.getInst() __libvirt_conn = None __inst = None __lock = threading.Lock() @property def uri(self): …. @staticmethod def getInst(): auth = [[libvirt.VIR_CRED_AUTHNAME, libvirt.VIR_CRED_NOECHOPROMPT], 'root', None] Connection.__lock.acquire() if not Connection.__libvirt_conn: Connection.__inst = object.__new__(Connection) object.__init__(Connection.__inst) Connection.__libvirt_conn = libvirt.openAuth(Connection.__inst.uri, auth, 0) Connection.__lock.release() return Connection.__inst @utils.synchronized('virt_libvirt_Connection', external=True) def __getattr__(self,attr): return getattr(Connection.__libvirt_conn, attr)
  • 10. 信息的更新 • 改变传统的自顶向下的询问方式,采用自底向上的信息更 新。 db.instance_get_all_by_host(host) 改为利用 libvirt 收集到的本机的虚拟机,然后直接针对 insta nce 进行更新: db._instance_update()
  • 12. 利用 qcow2 快速启动 • 快速启动原理: 增量文件 backing_file • 增量文件只保存不一致的部分
  • 13. Traps & Pitfalls • 通过 FLAGS.use_cow_images=True 则使用快速启动。 • 增量文件的格式: qcow2 • Xen 快速启动的陷阱 • Windows 快速启动的缺陷 • 何时不应该使快速启动?
  • 14. Xen 快速启动 Xen 快速启动的条件 : • Backing file 格式需要使用 raw 格式。 • 增量文件使用 qcow2 格式。 • 需要用 Xen 自带的 qemu-img 工具生成 qcow2 文件。不建 议用标准的 qemu 。因为 Xen 的 stubdom 就是一个修改过 的 qemu 。 • 底层 libvirt XML 文件的配置 : <emulator>/usr/lib/xen/bin/qemu-dm</emulator> <disk type='file' device='disk'> <driver name='tap' type='qcow2'/> <source file='${basepath}/disk'/> <target dev='hda' bus='ide'/> </disk>
  • 15. Windows 的快速启动 • Windows Image 在移植至 OpenStack 时,利用快速启动容 易遇到蓝屏问题。 • 1 、 virtio driver. virtio-win-0.1-22.iso virtio-win-1.1.16.vfd • 2 、 qcow2 增量文件大小指定需要比原有 windows image 大。一般 2~3 倍没有问题。
  • 16. 何时不要使用快速启动 • Qcow2 文件缺点: 删除文件时,并没真正将文件从磁盘中删除。只是设置此文 件失效。 如果需要在 Openstack 的虚拟机中建立存储服务,不建议使 用快速启虚拟机模式。 设置 : /etc/nova/nova.conf FLAGS.use_cow_images=False
  • 17. Snapshot • Nova 的 snapshot 是针对磁盘而言,并没有做内存的 snapsh ot 。 • Nova 做 Snapshot 的大致流程:
  • 18. Snapshot 流程 1 定位至相应的虚拟机。 2 将虚拟机挂起:即内存保存至 checkpoint 文件中。 3 利用 qemu-img 对磁盘建立 snapshot 。 4 整合磁盘文件与 snapshot 生成一个新的独立的磁盘。 5 将磁盘上传至 Glance 服务。
  • 19. 利用 snapshot 进行恢复 1 从 glance 下载 image 。 2 利用这个新的 image 启动一个虚拟机。 问题: Snapshot: 相当于把原有虚拟机的磁盘上传至 glance 。 恢复 : 从 glance 上下载此磁盘,新开一个虚拟机。和原 来的虚拟机关系不大。 时间漫长………………………… .
  • 20. 快速 Snapshot 需求: 1 、快速地做 Snapshot 与恢复 2 、必要时,才把 image 上传至 Glance 。 不用每次都上传。 步骤: 1 做 snapshot : $qemu-img snapshot –c snapshot_name disk_path 创建 snapshot. 此时不用将 image 上传至 glance 2 恢复时: $ qemu-img snapshot –a snapshot_name disk_path 亦不用从 glance 下载磁盘进行恢复 3 必要时,将虚拟机磁盘上传至 glance image_service.update(context, image_href, metadata, image_file)
  • 21. 快速 snapshot 优点 1 并不是每次 snapshot 都涉及到 glance 。 都是在本地操作。因此可以很快地完成。 2 可以把多次 snapshot 放在一个磁盘里面, 直接上传至 Glance 。不用把多个 snapshot 单独上传。
  • 22. 快速 Snapshot Note: 磁盘 snapshot 针对 qcow2 格式磁盘较易操作。对于 raw 格式 磁盘不易进行。 亦可以在针对磁盘做 snapshot 时,同时对内存做 snapshot 。 这样可以做到对虚拟机的点恢复。 在做 snapshot 时,建议用 qemu-img 针对磁盘做 snapshot 。 利用 libvirt 对内存做快照。不建议利用 libvirt 提供的 snapshot 功能。因为 libvirt 提供的 snapshot 在操作时,会把部分消息保 存至 libivrt 的数据库中。增删易造成不一致。
  • 23. Terminate 虚拟机 如果创建虚拟机失败。导致虚拟机并没有正常启动。那么 Terminate 操作亦 会失效。看一下流程: def do_terminate_instance(): elevated = context.elevated() instance = self.db.instance_get_by_uuid(elevated, instance_uuid) compute_utils.notify_usage_exists(instance, current_period=True) try: self._delete_instance(context, instance) except exception.InstanceTerminationFailure as error: msg = _('%s. Setting instance vm_state to ERROR') LOG.error(msg % error, instance_uuid=instance_uuid) self._set_instance_error_state(context, instance_uuid) except exception.InstanceNotFound as e: LOG.warn(e, instance_uuid=instance_uuid)
  • 24. Live Migration Live Migration 支持两种 shared storage. Non-shared storage. 为什么迁移经常出错?哪里出了问题? 检测目标机器 根据 是否需要从 block_migration 检测目标机器 glance 下载 决定是否需要迁 backing file 移磁盘
  • 25. Live Migration 逻辑陷阱 传入 block_migration 参数 Admin 有 1000 台机 block_migration 决定 器,他并不清楚这两 是否迁移 VM 的 台机器是否是共享存 image 储 最终是否迁移 image 是否迁移 image 是由 由参数与底层存储决 底层存储是否共享决 定 定
  • 26. Live Migration 不需参数指定。直接使用 block_migration = self. mounted_on_same_shared_storage() 来进行决定。 CPU 的比较 底层基于 libvirt 的 CPU 比较过于严格,可以放松条件。厂商 一致,型号差别不是太远,基本可以完成迁移。
  • 27. Live Migration 迁移时,去掉下面这个参数,则否会导致重新从 glance 下载 backing file. image.cache(fetch_func=libvirt_utils.fetch_image, context=ctxt, filename=cache_name, image_id=instance['image_ref'], user_id=instance['user_id'], project_id=instance['project_id'], size=info['virt_disk_size'])
  • 28. Live Migration 什么时候可以使用 总的前提条件:网络数据传输允许!数据传输有独立的通道! 比如:可以的情况 计算密集型 + 小磁盘: 迁移量 = 内存 + 增量磁盘 计算节点之间采用共享存储 允许小概率的迁移失败 不建议的情况: 非共享存储 + 大磁盘 关键服务 + 不允许迁移失败
  • 29. Xen 在 OpenStack 状况 python-libvirt 对 Xen 的支持并不好。一些功能都不能实现。底 层虚拟机启动配置需要修改。 live_migration pause/unpause suspend/resume save/restore 底层实现最好是利用 xen-tools 来进行操作或者 XenAPI 。 Virsh 在一定程度上也可以帮忙。
  • 30. OpenStack VS Eucalyptus OpenStack cc 松耦合 / 异步消息传递与函数调用 python rest API 易修改与定制 cc Eucalptus 上层发布 ec2 接口的 java 代码混乱 clc 模块连续紧密 层层调用的消息传递与函数调用 nc c/axis2c/WSDL 开发调试难度加大