6.13. 其它虚拟机任务
6.13.1. 启用 SAP监测
过程 6.27. 在虚拟机上启用 SAP监测
- 点虚拟机标签页并选择一个虚拟机。
- 点。
- 点自定义属性标签页。

图 6.17. 启用 SAP
- 使用下拉菜单选择
sap_agent,并把它设为 True。如果有其它属性已被设置,点加号按钮来添加一个属性设置。然后选择sap_agent。 - 点。
6.13.2. 配置 Red Hat Enterprise Linux 5.4 或更新版本的虚拟机来使用 SPICE
注意
6.13.2.1. 安装并配置 QXL 驱动
过程 6.28. 安装 QXL 驱动
- 登录到 Red Hat Enterprise Linux 虚拟机上。
- 安装 QXL 驱动:
# yum install xorg-x11-drv-qxl
过程 6.29. 在 GNOME 中配置 QXL 驱动
- 点系统。
- 点管理。
- 点显示。
- 点硬件。
- 点显卡配置。
- 选择 qxl 并点 OK。
- 通过重新登录到虚拟机来重启 X-Windows。
过程 6.30. 在命令行中配置 QXL 驱动:
- 备份
/etc/X11/xorg.conf文件:# cp /etc/X11/xorg.conf /etc/X11/xorg.conf.$$.backup
- 在
/etc/X11/xorg.conf文件的 Device 段中做以下修改:Section "Device" Identifier "Videocard0" Driver "qxl" Endsection
6.13.2.2. 配置一个虚拟机的平板输入设备和鼠标来使用 SPICE
/etc/X11/xorg.conf 文件来为虚拟机的平板输入设备使用 SPICE。
过程 6.31. 配置一个虚拟机的平板输入设备和鼠标来使用 SPICE
- 确认平板输入设备在您的客户端上可以被使用:
# /sbin/lsusb -v | grep 'QEMU USB Tablet'
如果以上命令没有输出,请不要继续以下的配置。 - 备份
/etc/X11/xorg.conf文件:# cp /etc/X11/xorg.conf /etc/X11/xorg.conf.$$.backup
- 对
/etc/X11/xorg.conf文件进行以下修改:Section "ServerLayout" Identifier "single head configuration" Screen 0 "Screen0" 0 0 InputDevice "Keyboard0" "CoreKeyboard" InputDevice "Tablet" "SendCoreEvents" InputDevice "Mouse" "CorePointer" EndSection Section "InputDevice" Identifier "Mouse" Driver "void" #Option "Device" "/dev/input/mice" #Option "Emulate3Buttons" "yes" EndSection Section "InputDevice" Identifier "Tablet" Driver "evdev" Option "Device" "/dev/input/event2" Option "CorePointer" "true" EndSection
- 通过重新登录到虚拟机来重新启动 X-Windows。
6.13.3. KVM 虚拟机时间管理
pvclock 为 KVM 客户端系统提供了一个稳定的时间源。
- 虚拟机的时钟和实际的时间不同步,导致无效的进程和网络操作。
- 虚拟机的时钟慢会导致迁移出现问题。
重要
ntpd 服务:
# service ntpd start
# chkconfig ntpd on
ntpd 服务可以减轻时钟不同步的问题。
如果有 constant_tsc 标识,说明您的 CPU 有 constant TSC。运行以下命令来检查是否有 constant_tsc 标识:
$ cat /proc/cpuinfo | grep constant_tsc
constant_tsc。如果没有输出,请进行以下步骤。
没有 constant TSC 的系统需要额外的配置。电源管理功能会影响到时间的准确性,因此为了保证时间的准确,使用 KVM 的虚拟机应该禁用这个功能。
重要
constant_tsc 位,禁用所有的电源管理功能 (BZ#513138)。每个系统都会有多个计时器来管理时间。TSC 在主机上并不稳定,cpufreq 改变,deep C state,或迁移到一个有更快的 TSC 主机都可能会对它产生影响。Deep C 休眠可能导致 TSC 被停止。为了防止内核使用 deep C states,把 "processor.max_cstate=1" 添加到主机的 grub.conf 文件的内核引导选项中:
term Red Hat Enterprise Linux Server (2.6.18-159.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-159.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet processor.max_cstate=1/etc/sysconfig/cpuspeed 配置文件,把 MIN_SPEED 和 MAX_SPEED 变量设置为最高的有效主频来禁用 cpufreq(只需要在没有 constant_tsc 的主机上进行)。您可以在 /sys/devices/system/cpu/cpu*/cpufreq/scaling_available_frequencies 文件中找到有效主频值。
engine-config 工具在主机不同步的时候接收警告信息。
您可以使用 engine-config 工具在主机不同步的时候接收配置信息。
EnableHostTimeDrift 和 HostTimeDriftInSec。EnableHostTimeDrift 可以被启用来接收关于主机时间漂移的警告信息(它的默认值是“false”)。HostTimeDriftInSec 参数用来指定在开始发送漂移警告信息前可以发生的最大时间漂移。
对于一些特定的 Red Hat Enterprise Linux 虚拟机,需要为它们配置额外的内核参数。这些参数可以被添加到虚拟机上的 /boot/grub/grub.conf 文件中的 /kernel 行的后面。
注意
ktune 软件包可以自动配置内核参数。
ktune 软件包提供了一个交互式的 Bourne shell 脚本 - fix_clock_drift.sh。当以 superuser 的身份运行时,这个脚本会检查不同的系统参数来判断是否虚拟机可能会出现时间漂移的问题。如果会出现问题,它会在 /boot/grub/ 目录中创建一个新的 grub.conf.kvm 文件。这个文件包括了一个 KVM 引导行,这个引导行带有可以防止时钟漂移的内核参数。在以 superuser 的身份运行 fix_clock_drift.sh 命令并创建了 grub.conf.kvm 文件后,系统管理员应该手动备份当前的 grub.conf 文件,并检查新的 grub.conf.kvm 文件中除了新添加的引导行参数以外的内容和 grub.conf 文件的内容完全一致。最后,把 grub.conf.kvm 文件的文件名改为 grub.conf 并重新启动虚拟机。
| Red Hat Enterprise Linux | 额外的虚拟机内核参数 |
|---|---|
| 5.4 AMD64/Intel 64 有准虚拟化时钟(with paravirtualized clock) | 不需要额外的参数 |
| 5.4 AMD64/Intel 64 没有准虚拟化时钟(without paravirtualized clock) | notsc lpj=n |
| 5.4 x86 有准虚拟化时钟(with the paravirtualized clock) | 不需要额外的参数 |
| 5.4 x86 没有准虚拟化时钟(without the paravirtualized clock) | clocksource=acpi_pm lpj=n |
| 5.3 AMD64/Intel 64 | notsc |
| 5.3 x86 | clocksource=acpi_pm |
| 4.8 AMD64/Intel 64 | notsc |
| 4.8 x86 | clock=pmtmr |
| 3.9 AMD64/Intel 64 | 不需要额外的参数 |
| 3.9 x86 | 不需要额外的参数 |

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.