R系实时KVM

物理机配置

型号

配置

华为 RH2288H V3

CPU:Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz

内存:251G

磁盘:1x600G SSD, 5x600G SATA

网络:2x1000M,2x10000M

曙光 I620-G30

CPU:Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz

内存:1T

磁盘:1x240G SSD, 7x4T SATA

网络:2x1000M,2x10000M

1. 修改BIOS

禁用电源管理,包括CPU睡眠状态

禁用超线程或与逻辑处理器相关的任何选项

2. 安装实时核

2.1 将yum源换成阿里的源

在/etc/yum.repo.d/下修改CentOS.Base.repo

# CentOS-Base.repo

#

# The mirror system uses the connecting IP address of the client and the

# update status of each mirror to pick mirrors that are updated to and

# geographically close to the client.  You should use this for CentOS updates

# unless you are manually picking other mirrors.

#

# If the mirrorlist= does not work for you, as a fall back you can try the 

# remarked out baseurl= line instead.

#

#

[base]

name=CentOS-7.7.1908 - Base - mirrors.aliyun.com

failovermethod=priority

baseurl=http://mirrors.aliyun.com/centos/7.7.1908/os/x86_64/

        http://mirrors.aliyuncs.com/centos/7.7.1908/os/x86_64/

        http://mirrors.cloud.aliyuncs.com/centos/7.7.1908/os/x86_64/

gpgcheck=1

gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#released updates 

[updates]

name=CentOS-7.7.1908 - Updates - mirrors.aliyun.com

failovermethod=priority

baseurl=http://mirrors.aliyun.com/centos/7.7.1908/updates/x86_64/

        http://mirrors.aliyuncs.com/centos/7.7.1908/updates/x86_64/

        http://mirrors.cloud.aliyuncs.com/centos/7.7.1908/updates/x86_64/

gpgcheck=1

gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful

[extras]

name=CentOS-7.7.1908 - Extras - mirrors.aliyun.com

failovermethod=priority

baseurl=http://mirrors.aliyun.com/centos/7.7.1908/extras/x86_64/

        http://mirrors.aliyuncs.com/centos/7.7.1908/extras/x86_64/

        http://mirrors.cloud.aliyuncs.com/centos/7.7.1908/extras/x86_64/

gpgcheck=1

gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages

[centosplus]

name=CentOS-7.7.1908 - Plus - mirrors.aliyun.com

failovermethod=priority

baseurl=http://mirrors.aliyun.com/centos/7.7.1908/centosplus/x86_64/

        http://mirrors.aliyuncs.com/centos/7.7.1908/centosplus/x86_64/

        http://mirrors.cloud.aliyuncs.com/centos/7.7.1908/centosplus/x86_64/

gpgcheck=1

enabled=0

gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-Ce

​​​​​​​2.2 添加rt源

在/etc/yum.repos.d/下新建CentOS-RT.repo

写入以下内容

# CentOS-RT.repo

#

# The Real Time (RT) repository.

#

[rt]

name=CentOS-7 - rt

baseurl=http://mirrors.aliyun.com/centos/7.7.1908/rt/x86_64/

gpgcheck=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

enabled=1


2.3 更新源

yum update -y


2.4 安装包

yum install kernel-rt kernel-rt-kvm tuned-profiles-realtime

3. 配置实时配置文件

3.1 看NUMA信息

[root@compute1 ~]# lscpu | grep NUMA

NUMA 节点:         2

NUMA 节点0 CPU:    0-7

NUMA 节点1 CPU:    8-15

3.2 配置实时cpu

通常CPU 0用来处理控制台中断,CPU 1用于处理主机的其他开销,因此理论上只需cpu 0和1预留给物理机,其余给虚拟机用即可。

以下为测试的隔离方案及测试结果供参考

Isolcpus   虚拟机最大延时   物理机最大延时(40cpus)

2-39            43          2642

4-39            44          2657

8-39            47          2483

4-19, 24-39     49          3237

4-35            39          2503

2-37            42          2810

2-19, 22-39     46          2634

4-15            44          27           (16cpus)

4-11            55          18

2-15            47          21

2-13            45          19

2-7, 10-15      39          20

经测试,性能差距不大,如果想创更多虚拟机,隔离更多的cpu即可。

3.3 配置隔离

echo "isolated_cores=4-11" >> /etc/tuned/realtime-variables.conf

如果cpu不连续,用逗号隔开。


3.4 加载实时配置文件

systemctl enable tuned

systemctl start tuned

3.5 设置为realtime

tuned-adm profile realtime

3.6 查看是否配置成功

grep tuned_params= /boot/grub2/grub.cfg

输出:

set tuned_params="skew_tick=1 isolcpus=4-11 intel_pstate=disable nosoftlockup"

4 配置huge pages

4.1 添加default_hugepagesz=1G到/etc/default/grub的GRUB_CMDLINE_LINUX

4.2 使配置生效

grub2-mkconfig -o /boot/grub2/grub.cfg

4.3 重启系统

4.4 查看是否默认挂载hugetlbfs文件系统

cat /proc/mounts | grep huge

4.5 否则mount一个hugetlbfs文件系统

mount -t hugetlbfs hugetlbfs /dev/hugepages


为huge pages保留一定数量的内存,在/etc/sysctl.conf加入如下配置

vm.nr_hugepages=16

修改后,用命令sysctl -p 使设置生效

4.6 查看是否生效

cat /proc/meminfo

注意:根据需要及物理机内存填写。hugepagesz为1G,配置16个page,会用掉16G内存

5 测试是否安装成功

# yum install -y rt-tests

# hwlatdetect

   hwlatdetect: test duration 120 seconds

parameters: Latency threshold: 10us

Sample window: 1000000us

Sample width: 500000us

Non-sampling period: 500000us

Output File: None

Starting test test

finished Max Latency: 0us

Samples recorded: 0

Samples exceeding threshold: 0

如果任何样本超出阈值,则需重新配置

虚拟机配置

参考物理机配置

注:

虚拟机不用配置hugepage的个数,只用配置hugepage的大小。

不用安装kernel-rt-kvm。

1 用安装好实时核的虚拟机做快照生成镜像

云平台配置

2.1 使cpu支持实时

修改物理机/etc/kolla/nova-compute/nova.conf

在[libvirt]下添加

cpu_mode=host-passthrough


2.2 配置flavor

# nova flavor-create --is-public true rt_flavor 70 8192 80 4

# nova flavor-key 70 set hw:cpu_policy=dedicated hw:cpu_realtime=yes hw:cpu_realtime_mask=^0-1 hw:mem_page_size=1GB tag=kcmp

hw:cpu_policy=delicated:表示实例必须为其分配独占的pCPU。

hw:cpu_realtime=yes:表示实例将具有实时策略。

hw:cpu_realtime_mask=^0-1:表示实例的vcpu除了vcpu 0和vcpu 1都有实时策略

hw:mem_page_size=1GB:表示实例将会分配的每个大页内存为1GB

tag=kcmp: 表示该flavor会在web页面展示,供选择。


2.3 隔离cpu

让虚拟机只使用隔离出的cpu

查看隔离出的cpu,此处即为realtime-variables.conf配置的隔离出的cpu

cat /proc/cmdline

isolcpus=4-11

修改物理机/etc/kolla/nova-compute/nova.conf

在[libvirt]下添加

vcpu_pin_set = 4-11

重启nova_compute

2.4 创建虚拟机

用生成的镜像和配置好的flavor创建虚拟机

测试

测试命令

cyclictest -m -n -q -p90 -D 12h -h100 -i 200

cyclictest -p 90 - m -c 0 -i 200 -n -h 100 -q -l 10000000

参数说明

-m  锁定内存分配

-n  使用nanosleep 而不是简单的sleep

-q  运行时不打印即时信息

-p  给cyclictest 赋优先级

-D  测试时间

-h  总共统计100个信息在最后的结果中

-i  指定一个循环为200us

-l  指定循环次数

-c 0指定使用默认的MONOTONIC 时钟

cyclictest用于测试定时器的精度,假定定时器时间间隔为 interval,定时器启动前记录下当前时间t1,定时器到时后记录下当前时间t2,则测出的时延为 t2 - (t1 + interval)

为能实时查看测试信息,可将-q参数去掉。

1. 物理机(华为)实时核

# Total: 263706597

# Min Latencies: 00001

# Avg Latencies: 00002

# Max Latencies: 00042

# Histogram Overflows: 00000


2. 物理机(华为)非实时核

# Total: 010135378

# Min Latencies: 00001

# Avg Latencies: 00002

# Max Latencies: 05004

# Histogram Overflows: 00106


3. 物理机(华为)实时核,虚拟机实时核

# Total: 369213964

# Min Latencies: 00003

# Avg Latencies: 00007

# Max Latencies: 00055

# Histogram Overflows: 00000


4. 物理机(华为)非实时核,虚拟机实时核

# Total: 327727659

# Min Latencies: 00003

# Avg Latencies: 00005

# Max Latencies: 00051

# Histogram Overflows: 00000


5. 物理机(华为)实时核,虚拟机非实时核

# Total: 15057973

# Min Latencies: 00003

# Avg Latencies: 00014

# Max Latencies: 17737

# Histogram Overflows: 195438


6. 物理机(华为)非实时核,虚拟机非实时核

# Total: 000949607

# Min Latencies: 00003

# Avg Latencies: 00119

# Max Latencies: 69721

# Histogram Overflows: 57768


7. 物理机(曙光)实时核

# Total: 263748117

# Min Latencies: 00001

# Avg Latencies: 00002

# Max Latencies: 00034

# Histogram Overflows: 00000


8. 物理机(曙光)非实时核

# Total: 10027138

# Min Latencies: 00001

# Avg Latencies: 00002

# Max Latencies: 03237

# Histogram Overflows: 00138


9. 物理机(曙光)实时核,虚拟机非实时核

# Total: 002455887

# Min Latencies: 00003

# Avg Latencies: 00015

# Max Latencies: 24009

# Histogram Overflows: 48213


10. 物理机(曙光)实时核,虚拟机实时核

# Total: 126359639

# Min Latencies: 00003

# Avg Latencies: 00005

# Max Latencies: 00048

# Histogram Overflows: 00000


11. 物理机(曙光)非实时核,虚拟机非实时核

# Total: 17369394

# Min Latencies: 00002

# Avg Latencies: 00016

# Max Latencies: 37601

# Histogram Overflows: 195751


12. 物理机(曙光)非实时核,虚拟机实时核

# Total: 125625396

# Min Latencies: 00003

# Avg Latencies: 00006

# Max Latencies: 00049

# Histogram Overflows: 00000

结果分析

服务器

测试对象

host有无实时核

guest有无实时核

Min

Avg

Max

循环总数

超过99us循环数

华为

host

/

1

2

42

263,706,597

0

华为

host

/

1

2

5004

10,135,378

106

华为

guest

3

7

55

369,213,964

0

华为

guest

3

119

69721

949,607

57768

华为

guest

3

5

51

327,727,659

0

华为

guest

3

14

17737

15,057,973

195438

曙光

host

/

1

2

34

263,748,117

0

曙光

host

/

1

2

3237

10,027,138

138

曙光

guest

2

16

37601

17,369,394

195,751

曙光

guest

3

6

49

125,625,396

0

曙光

guest

3

5

48

126,359,639

0

曙光

guest

3

15

24009

2,455,887

48213

在配置hugepagesz后需要重启系统,选择以带实时核的系统启动或不带实时核的系统启动。

  1. 虚拟机实时性与虚拟机实时核正相关,与物理机实时核无实质影响
  2. 实时虚拟机最小延时在3us左右,平均延时在6us左右,最大延时在55us
  3. 物理机无论是否安装实时核,均需要配置huge pages、tuned profile,具备创建具有实时策略虚拟机的条件,具体体现flavor具备cpu_policy、cpu_realtime、cpu_realtime_mask、mem_page_size
  4. 虚拟机有无实时核,最大时延差距巨大,平均时延相差也较大
  5. 通过华为和曙光服务器的正向比较,相当性能的服务器实时数据无明显差别

常见问题


1. http://mirror.centos.org/centos/7/rt/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirror.centos.org; 未知的错误

配置域名解析

vim /etc/resolv.conf

网络不可达,配置网关

route add default gw 192.168.1.254


2. 创建虚拟机时warning host doesn't support requested feature: CPUID.01H:EDX.ds [bit 21] 

出现许多warning,cpu不支持某些flag。

解决办法:修改/etc/kolla/nova-compute/nova.conf

在[libvirt]下添加

cpu_mode=host-passthrough

重启nova_compute

host-passthrough: libvirt 令 KVM 把宿主机的 CPU 指令集全部透传给虚拟机。因此虚拟机能够最大限度的使用宿主机 CPU 指令集.


3. 创建虚拟机时Insufficient compute resources: Requested instance NUMA topology cannot fit the given host NUMA topology

解决办法:

1、查看是否挂载文件系统

cat /proc/mounts | grep huge

如果没有挂载重新挂载

2、查看是否配置vm.hugepages或hugepages_free不足

cat /proc/meminfo

如果没有则重新生成hugepage,如果不足则加大

  1. 查看物理机系统盘空间是否充足,如果不足,删一些无用的文件
  2. 查看cpu是否充足,虚拟机cpu之和不能超过物理机总的cpu数

3. 如果发现虚拟机实时性能较差,可以查看该虚拟机是否同时使用了两个numa节点的cpu或vcpu_pin_set配置有误

virsh

list

dumpxml ID


4. could not find capabilities for domaintype=kvm 

缺少kernel-rt-kvm.x86_64包

​​​​​​​


5. libvirtError: unsupported configuration: CPU mode 'host-passthrough' for x86_64 qemu domain on x86_64 host is not supported by hypervisor

重启机器

参考文章

1、Deploying Real Time Openstack | that.guru

2、http://www.voidcn.com/article/p-wvsnxbgc-bpt.html

3、2.3. Setting BIOS Parameters Red Hat Enterprise Linux for Real Time 7 | Red Hat Customer Portal

4、linux - host doesn't support requested feature: CPUID.01H:EDX.ds [bit 21] Does this warn affect virtual machine performance or use? - Stack Overflow

5、实时 KVM(Realtime KVM) - AspxHtml学习分享网

6、HugePage简介和KVM中使用HugePage_junmuzi的专栏-CSDN博客_hugepage kvm

7、hugepage设置相关总结_shaoyunzhe的专栏-CSDN博客_anonhugepages

8、Linux 实时性能测试工具——Cyclictest - konglingbin - 博客园

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值