由于nova flavor 可以指定虚拟机cpu在numa node 使用跨node指定的方式,以及单个node指定的方式,后者性能会更好,但是这两种逻辑混用会出现 numa node不均衡的结果,导致双node flavor无法创建出虚拟机,即使总体来看,还有虚拟机剩余
基于 nova compute_nodes表统计 物理cpu的分配数目,手动对不均衡的虚拟机进行热迁移或者调整规格
# tools/get_numa_nodes.py
#!/usr/bin/env python
import mysql.connector
from pprint import pprint as pp
import json
def main():
mydb = mysql.connector.connect(
host="10.120.12.21",
user="root",
password="AVL13CYlSZvAYDTzYpJtu8Ykt2mWKjgf3CHcTHFW"
)
mycursor = mydb.cursor()
mycursor.execute("SELECT host,numa_topology FROM nova.compute_nodes")
myresult = mycursor.fetchall()
numa_hosts = {}
for x in myresult:
host_name = x[0]
numa_host_info = json.loads(x[1])
#pp(numa_host_info)
cells = numa_host_info['nova_object.data']['cells']
#print('%s nodes: %s' % (host_name, len(cells)))
#pp(cells)
numa_hosts[host_name] = {}
node0 = cells[0]['nova_object.data']
node1 = cells[1]['nova_object.data']
#numa_hosts[host_name]['node0'] = node0
#numa_hosts[host_name]['node1'] = node1
#numa_hosts[host_name]['node0'] = {}
#numa_hosts[host_name]['node1'] = {}
#numa_hosts[host_name]['node0']['pcpu_total'] = len(node0['pcpuset'])
#numa_hosts[host_name]['node0']['pcpu_pined'] = len(node0['pinned_cpus'])
numa_hosts[host_name]['node0'] = "%s/%s" % (len(node0['pinned_cpus']), len(node0['pcpuset']))
numa_hosts[host_name]['node1'] = "%s/%s" % (len(node1['pinned_cpus']), len(node1['pcpuset']))
#numa_hosts[host_name]['node1']['pcpu_total'] = len(node1['pcpuset'])
#numa_hosts[host_name]['node1']['pcpu_pined'] = len(node1['pinned_cpus'])
pp(numa_hosts)
if __name__ == '__main__':
main()
基于virsh 定位到不均衡的机器
(nova-libvirt)[root@compute002 /]# virsh list --all --uuid
88feed61-d3aa-4dd6-b752-1a2760f0b5c9
b88c197f-24bb-4632-96c3-7183f274674f
260aa0aa-c97d-42dd-890e-4abd2cd644a1
dde5564a-59e1-45e1-85a5-acbee4b29b92
3c07a3ca-009e-4688-9f24-08e57b6aa115
7cdab948-065a-47b6-9f5d-4edf18131e20
2f7e51ab-2983-47cd-be45-1380ec121abc
ecdea0d0-9aa8-4f98-bec1-eadf20bbfa3b
8c7d8023-25d1-42c4-9062-d802bd4540cb
(nova-libvirt)[root@compute002 /]# virsh numatune 88feed61-d3aa-4dd6-b752-1a2760f0b5c9
numa_mode : strict
numa_nodeset :
共享型虚拟机
(nova-libvirt)[root@compute002 /]# virsh numatune b88c197f-24bb-4632-96c3-7183f274674f
numa_mode : strict
numa_nodeset : 0
cpu 只在numa 0 上面
(nova-libvirt)[root@compute002 /]# virsh numatune 260aa0aa-c97d-42dd-890e-4abd2cd644a1
numa_mode : strict
numa_nodeset : 0-1
cpu 平均占用在两个numa node上
然后逐个处理即可
网友评论