標籤:

OpenStack Mitaka在CentOS 7配置 虛擬機CPU拓撲及綁核

花了兩天時間,終於在CentOS 7.3下搞定了OpenStack Mitaka的虛擬機CPU拓撲和綁核配置,解決了一個一個的坑,記錄一下。


KVM版本

CentOS 7默認的qemu 1.5版本非常老,OpenStack libvirt driver好些功能都因此不能使用,所以一定要使用專門倉庫的qemu-kvm,我因此遇到的問題包括:

  • compute節點的resource_tracker不能上報numa_topoloty到controller節點,導致NUMATopologyFilter無法調度;
  • nova-compute創建虛擬機失敗,日誌顯示: Per-node memory binding is not supported with this QEMU;

安裝qemu-kvm-ev

CentOS 7有一個virt repo, 提供了很多最新的虛擬化軟體包,其中之一就是qemu-kvm-ev, 基於qemu 2.6.0構建, 網易的CentOS鏡像也包括這個repo:

$ sudo rpm -Uvh http://mirrors.163.com/centos/7.3.1611/virt/x86_64/kvm-common/centos-release-qemu-ev-1.0-1.el7.noarch.rpm $ sudo yum install qemu-kvm-ev

配置OpenStack

以下內容可以參考Nova Admin手冊中CPU topologies章節: nova.conf 添加NUMATopologyFilter調度器,nova默認沒有啟用這個filter.

scheduler_default_filters=...,NUMATopologyFilter

設置flavor

$ openstack flavor set m1.large --property hw:cpu_policy=dedicated --property hw:cpu_thread_policy=require

Valid CPU-POLICY values are:

  • shared: (default) The guest vCPUs will be allowed to freely float across host pCPUs, albeit potentially constrained by NUMA policy.
  • dedicated: The guest vCPUs will be strictly pinned to a set of host pCPUs. In the absence of an explicit vCPU topology request, the drivers typically expose all vCPUs as sockets with one core and one thread. When strict CPU pinning is in effect the guest CPU topology will be setup to match the topology of the CPUs to which it is pinned. This option implies an overcommit ratio of 1.0. For example, if a two vCPU guest is pinned to a single host core with two threads, then the guest will get a topology of one socket, one core, two threads.

Valid CPU-THREAD-POLICY values are:

  • prefer: (default) The host may or may not have an SMT architecture. Where an SMT architecture is present, thread siblings are preferred.
  • isolate: The host must not have an SMT architecture or must emulate a non-SMT architecture. If the host does not have an SMT architecture, each vCPU is placed on a different core as expected. If the host does have an SMT architecture - that is, one or more cores have thread siblings - then each vCPU is placed on a different physical core. No vCPUs from other guests are placed on the same core. All but one thread sibling on each utilized core is therefore guaranteed to be unusable.
  • require: The host must have an SMT architecture. Each vCPU is allocated on thread siblings. If the host does not have an SMT architecture, then it is not used. If the host has an SMT architecture, but not enough cores with free thread siblings are available, then scheduling fails.

創建虛擬機

openstack server create --image cirros --nic net-id=provider-net --flavor m1.large instance-001

驗證 virsh dumpxml domID輸出的xml應該包括類似下面的內容

<cputune><vcpupin vcpu=0 cpuset=2/><vcpupin vcpu=1 cpuset=3/><emulatorpin cpuset=2-3/></cputune>

推薦閱讀:

優雅安裝OpenStack
OpenStack使用Ceph存儲,Ceph到底做了什麼?
那些年走過的OpenStack的坑(上)
開源大時代,EasyStack格局與勝局
為何現在流行OpenStack和Docker結合?

TAG:OpenStack |