openstack 运行时调度思路



主要是依据两个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.





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
OpenStack平台的Simple Scheduler是默认的调度器,它基于过滤器和权重器决定在哪里启动虚拟机实例。下面是配置OpenStack平台Simple Scheduler的步骤: 1. 编辑nova配置文件(/etc/nova/nova.conf),设置scheduler_driver为filter_scheduler: ``` [scheduler] scheduler_driver = filter_scheduler ``` 2. 确认compute节点上nova-scheduler进程正在运行: ``` systemctl status openstack-nova-scheduler.service ``` 3. 配置可用性和容量过滤器,以过滤无法满足虚拟机需求的主机。默认情况下,Simple Scheduler使用RamFilter和DiskFilter来过滤掉内存和磁盘空间低于虚拟机需求的主机。如果需要使用其他的过滤器,可以通过编辑nova配置文件(/etc/nova/nova.conf)来配置。例如,如果需要使用AvailabilityZoneFilter过滤掉不属于指定可用区的主机,可以添加以下配置: ``` [scheduler] scheduler_available_filters = nova.scheduler.filters.all_filters scheduler_default_filters = AvailabilityZoneFilter, RamFilter, DiskFilter, ComputeFilter, RetryFilter ``` 4. 配置权重器,以决定在可用主机中选择哪个主机部署虚拟机。默认情况下,Simple Scheduler使用WeightOfLeastUtilized和RandomWeigher来决定部署在哪个主机上。如果需要使用其他的权重器,可以通过编辑nova配置文件(/etc/nova/nova.conf)来配置。例如,如果需要使用AggregateInstanceExtraSpecsWeigher来决定部署在哪个主机上,可以添加以下配置: ``` [scheduler] scheduler_weight_classes = nova.scheduler.weights.all_weighers scheduler_default_weighers = AggregateInstanceExtraSpecsWeigher, WeightOfLeastUtilized, RandomWeigher ``` 5. 保存并关闭nova配置文件(/etc/nova/nova.conf),重启nova-scheduler服务以使配置生效: ``` systemctl restart openstack-nova-scheduler.service ``` 以上就是配置OpenStack平台Simple Scheduler的步骤。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值