openstack 运行时调度思路

本文介绍了如何利用Ganglia API和OpenStack API进行虚拟机调度,包括配置、使用方法及核心代码实现。重点讨论了在虚拟机调度过程中面临的问题及其解决方案,涉及动态VM合并、负载均衡、VM选择与迁移等关键步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >



主要是依据两个api ,ganglia API 和 openstack API


Ganglia-api
a small standalone python application that takes XML data from a number of Ganglia gmetad processes and presents a RESTful JSON API of the most recently received data.
Address:https://github.com/guardian/ganglia-api


Configuration
Download the source code and configure as follows:
 virtualenv ve
 source ve/bin/activate
 pip install -r requirements.txt
 python ganglia/ganglia_api.py


Api use
import urllib2
url = "http://192.168.1.11:8080/ganglia/api/v1/metrics?environment=PROD&metric=load_one"
req = urllib2.Request(req_url)


Metrics Data format (返回数据格式)

{u'response': {
	u'metrics': [
		{u'group': u'load', 
		 u'description': u'One minute load average', 
		 u'service': u'unspecified', 
		 u'title': u'One Minute Load Average', 
		 u'type': u'gauge', 
		 u'metric': u'load_one', 
		 u'sampleTime': u'2014-08-20T21:04:46.000Z', 
		 u'value': 0.08, 
		 u'environment': u'PROD', 
		 u'instance': u'', 
		 u'host': u'192.168.1.31', 
		 u'graphUrl': u'http://controller/ganglia/graph.......', 
		 u'units': u' ', 
		 u'dataUrl': u'http://ganglia.guprod.gnl:8080/g.......', 
		 u'cluster': u'openstack', 
		 u'id': u'prod.unspecified.openstack.192.168.1.31.load.load_one'
		 }, 
		 u'status': u'ok', 
		 u'total': 1, 
		 u'localTime': u'2014-08-20T21:06:01.703541', 
		 u'time': u'0.001'
	}
}


Openstack-api
Install api(linux):
 apt-get install python-pip
 pip install python-novaclient
 pip install python-keystoneclient
 ……
How to use openstack-api
import novaclient.v1_1.client as nvclient
nova = nvclient.Client(auth_url="http://controller:35357/v2.0", username="admin",\
                       api_key="ADMIN_PASS", project_id="admin")
nova.servers.live_migrate(vm, host_name, False, True)

调度的核心代码

get_daemon()
gangliaClient = sche_ganglia.GangliaClient()
localNovaClient = sche_nova.LocalNovaClient()

while(True):
    busy_hosts, idle_hosts= gangliaClient.get_busy_idle_hosts()
    localNovaClient.migrate_hosts(busy_hosts)
    #localNovaClient.live_migrate_hosts(busy_hosts,idle_hosts)
    time.sleep(50)

做虚拟机调度需要注意的4个问题:


In general, the problem of dynamic VM consolidation can be split into 4 sub-problems:

1、Deciding when a host is considered to be underloaded, so that all the VMs should be migrated from it, and the host should be switched to a low power mode, such as the sleep mode.

2、Deciding when a host is considered to be overloaded, so that some VMs should be migrated from the host to other hosts to avoid performance degradation.

3、Selecting VMs to migrate from an overloaded host out of the full set of the VMs currently served by the host.

4、Placing VMs selected for migration to other active or re-activated hosts.





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值