码迷,mamicode.com
首页 > 其他好文 > 详细

openstack主机内存ram超额分配

时间:2015-06-26 11:13:36      阅读:406      评论:0      收藏:0      [点我收藏+]

标签:

openstack提供资源利用率的方式一种主要途径是创建虚拟机时对内存进行超额分配。在对物理主机的选择策略如下代码所示:

    def host_passes(self, host_state, filter_properties):
        """Only return hosts with sufficient available RAM."""
        instance_type = filter_properties.get(‘instance_type‘)
        requested_ram = instance_type[‘memory_mb‘]
        free_ram_mb = host_state.free_ram_mb
        total_usable_ram_mb = host_state.total_usable_ram_mb

        ram_allocation_ratio = self._get_ram_allocation_ratio(host_state,
                                                          filter_properties)

        memory_mb_limit = total_usable_ram_mb * ram_allocation_ratio
        used_ram_mb = total_usable_ram_mb - free_ram_mb
        usable_ram = memory_mb_limit - used_ram_mb
        if not usable_ram >= requested_ram:
            LOG.debug("%(host_state)s does not have %(requested_ram)s MB "
                    "usable ram, it only has %(usable_ram)s MB usable ram.",
                    {‘host_state‘: host_state,
                     ‘requested_ram‘: requested_ram,
                     ‘usable_ram‘: usable_ram})
            return False

        # save oversubscription limit for compute node to test against:
        host_state.limits[‘memory_mb‘] = memory_mb_limit
        return True

total_usable_ram_mb为物理主机所能提供的物理内存,如4G,8G,ram_allocation_ration为内存超额分配系数,在nova.conf中设置。openstack默认超额分配系数为1.5。free_ram_mb为主机剩余内存值,该值可为负数。used_ram_mb为以分配内存,一般为该主机上已创建虚拟机内存总和。memory_mb_limit为超额后的内存,当剩余可以可用的useble_ram内存小于虚拟机的创建时所需内存时,表示该主机无法创建虚拟机,系统将不会选择该主机创建虚拟机。

openstack主机内存ram超额分配

标签:

原文地址:http://my.oschina.net/inchtek/blog/470984

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!