OpenStack配置虚拟机vcpu绑定步骤 转至元数据结尾

1. Changed in compute node:

给宿主机预留资源:

宿主机可用cpu:cpuid 0 – cpuid 5

宿主机可用内存:25G


#vim /etc/nova/nova.conf
vcpu_pin_set=6-31
reserved_host_memory_mb=25600

#grubby --update-kernel=ALL --args="isolcpus=6-31"
#reboot

 

 

2. Changed in controller node:

给nova-scheduler服务添加两个过滤器,以过滤带有vcpu绑定的计算节点出来,给用户使用。

这里的过滤是根据flavor的metadata中的aggregate_instance_extra_specs:pinned是true还是false,

来判断用户是否需要给云主机做vcpu绑定。


#vim /etc/nova/nova.conf
scheduler_default_filters=...,NUMATopologyFilter,AggregateInstanceExtraSpecsFilter
#systemctl restart openstack-nova-scheduler

 

 

3. Configure aggregate:

创建两个机组,分别为不给云主机绑定vcpu的normal机组,和给云主机绑定vcpu的performance机组。

并添加计算节点到各个机组中。10-0-192-21为normal机组host,10-0-192-20为performance机组。

# nova aggregate-create performance
# nova aggregate-create normal

# nova aggregate-list
+----+-------------+-------------------+
| Id | Name | Availability Zone |
+----+-------------+-------------------+
| 6 | performance | - |
| 9 | normal | - |
+----+-------------+-------------------+

# nova aggregate-set-metadata 6 pinned=true
# nova aggregate-set-metadata 9 pinned=false

# nova aggregate-add-host 9 10-0-192-21
Host 10-0-192-21 has been successfully added for aggregate 9
+----+--------+-------------------+---------------+----------------+
| Id | Name | Availability Zone | Hosts | Metadata |
+----+--------+-------------------+---------------+----------------+
| 9 | normal | - | '10-0-192-21' | 'pinned=false' |
+----+--------+-------------------+---------------+----------------+
# nova aggregate-add-host 6 10-0-192-20
Host 10-0-192-20 has been successfully added for aggregate 6
+----+-------------+-------------------+---------------+---------------+
| Id | Name | Availability Zone | Hosts | Metadata |
+----+-------------+-------------------+---------------+---------------+
| 6 | performance | - | '10-0-192-20' | 'pinned=true' |
+----+-------------+-------------------+---------------+---------------+

 

 

4. Configure flavor:
Add metadata 'aggregate type: normal' to old flavor:

将已经存在的flavor的metadata的机组vcpu绑定属性设置为不绑定:
#for FLAVOR in ` nova flavor-list | cut -f 2 -d ' ' | grep [0-9]* | grep -v "\-\-" | grep -v ID`; do nova flavor-key ${FLAVOR} set "aggregate_instance_extra_specs:pinned"="false"; done


Create new flavor with metadata 'aggregate type: performance':

创建新的flavor, 带有的metadata中vcpu绑定属性设置为绑定:
#nova flavor-create m1.big-1.vcpuPin 10 8192 20 4
#nova flavor-create m1.small.vcpuPin 11 4096 20 2

... ...
#for i in `nova flavor-list | grep vcpuPin | awk '{print $2}'`; do nova flavor-key $i set hw:cpu_policy=dedicated; nova flavor-key $i set aggregate_instance_extra_specs:pinned=true; done


Launch an instance to test the new flavor, check if the instance runs in host whose aggegate type is performance:

启动一个虚拟机,使用新创建的flavor,验证虚拟机是否运行在了10-0-192-20服务器上,检查虚拟机的xml配置信息是否包含vcpu绑定配置:
#nova boot --image ...

Attention:
1. if flavor's metadata is NULL, then the vm may be scheduled to this pin=true host。

如果flavor的metadata为空, 即创建flavor的时候,不指定metadata的机组绑定属性,则使用这个flavor的云主机可以像没配置vcpu绑定的时候那样, 运行在normal不绑定vcpu节点,或

performance绑定vcpu节点。

猜你喜欢

转载自www.cnblogs.com/gushiren/p/9591068.html
今日推荐