Virtualization
A reference guide for virsch, xm, vmm and xend.
版 2.0
摘要
http://bugzilla.redhat.com/bugzilla/
)里提交关于红帽企业版 Linux
和虚拟化指南
的报告。
第 1 章 Red Hat虚拟化系统体系结构
第 2 章 操作系统支持
- 用于完全和半虚拟化的 Intel VT-x 或 AMD-V Pacifica 和 Vanderpool 技术。
- 用于 ia64 的 Intel VT-i
- Linux 和 UNIX 操作系统,包括 NetBSD、FreeBSD 和 Solaris。
- Microsoft Windows as an unmodified guest operating system with Intel Vanderpool or AMD's Pacifica technology.
grep vmx /proc/cpuinfo
flags : fpu tsc msr pae mce cx8 apic mtrr mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 cx16 xtpr lahf_lm
grep svm /proc/cpuinfo cat /proc/cpuinfo | grep svm
flags : fpu tsc msr pae mce cx8 apic mtrr mca cmov pat pse36 clflush dt acpi mmx fxsr sse sse2 ss ht tm syscall nx mmtext fxsr_opt rdtscp lm 3dnowext pni cx16 lahf_lm cmp_legacy svm cr8_legacy
注意
第 3 章 硬件支持
- Celeron
- Pentium II
- Pentium III
- Pentium IV
- Xeon
- AMD Athlon
- AMD Duron
mem=32G
参数。这个例子演示了在 grub.conf
文件里怎样采用正确的参数:
title Red Hat Enterprise Linux Server (2.6.18-4.elxen) root (hd0, 0) kernel /xen.gz-2.6.18-4-el5 mem=32G module /vmlinuz -2.6.18-4.el5xen ro root=LABEL=/ module /initrd-2.6.18-4.el5xen.img
grep pae /proc/cpuinfo
flags : fpu tsc msr pae mce cx8 apic mtrr mca cmov pat pse36 mmx fxsr sse syscall mmtext 3dnowext 3dnow up ts
第 4 章 Red Hat虚拟化系统的系统要求
- 正常运行的Red Hat RHEL 5 Linux 系统
- 可用的 GRUB 引导装载程序
- 根访问权限
- P6 级(或更早)的处理器
- The Linux bridge-utils
- Linux 热插拔系统
- zlib 开发库
- Python 2.2 runtime
- initscripts
注意
xen-ia64-guest-firmware
package to run a fully virtualized guest. This package is provided in the Supplementary CD and is not installed by default.
第 5 章 引导系统
service xend start
chkconfig xend
来使 xend
在引导时启动。
第 6 章 配置 GRUB
/boot/grub/grub.conf
) is used to create a list of operating systems to boot in GRUB's menu interface. When you install the kernel-xen RPM, a post script adds kernel-xen entries to the GRUB configuration file. You can edit the grub.conf
file and enable the following GRUB parameter:
title Red Hat Enterprise Linux Server (2.6.18-3.el5xen) root (hd0; 0) kernel /xen.gz.-2.6.18-3.el5 module /vmlinuz-2.6..18-3.el5xen ro root=/dev/VolGroup00/LogVol00 rhgb quiet module /initrd-2.6.18-3. el5xenxen.img
initrd
映像和 Linux 内核。既然关于内核的条目是在所有其他条目之上,内核会先被载入内存。引导装载程序向 hypervisor 和 Linux 内核发送(和接受)命令行参数。下面的示例条目展示了怎样把 Domain0 linux 内核内存限制在 800MB 之内:
title Red Hat Enterprise Linux Server (2.6.18-3.el5xen) root (hd0; 0) kernel /xen.gz.-2.6.18-3.el5 dom0_mem=800M module /vmlinuz-2.6..18-3.el5xen ro root=/dev/VolGroup00/LogVol00 rhgb quiet module /initrd-2.6.18-3. el5xenxen.img
mem
com1=115200, 8n1
dom0_mem
dom0_max_vcpus
acpi
/* **** Linux config options: propagated to domain0 ****/ /* "acpi=off": Disables both ACPI table parsing and interpreter. */ /* "acpi=force": Overrides the disable blacklist. */ /* "acpi=strict": Disables out-of-spec workarounds. */ /* "acpi=ht": Limits ACPI from boot-time to enable HT. */ /* "acpi=noirq": Disables ACPI interrupt routing. */
noacpi
第 7 章 引导客户机域
xm
程序来引导客户机域。你也可以用 virsh
和虚拟机管理者(Virtual Machine Manager)来引导客户机。引导客户机域的先决条件是先安装客户主机。下例使用了 xm
create 子命令:
# xm create -c guestdomain1
guestdomain1
是你所引导的域的配置文件。 -c
选项表示在引导后连接到实际的控制台。
第 8 章 在引导时启动/停止域
/etc/xen/
目录下。所有你想在引导时启动的域必须有到 /etc/xen/auto
的符号链接。
chkconfig xendomains on
chkconfig xendomains on
命令不会自动地启动域,它将在下次引导时启动域。
chkconfig xendomains off
chkconfig xendomains off
命令在下次引导时关闭所有的域。
第 9 章 配置文件
/etc/xen
directory.
项目 | 描述 |
---|---|
pae
|
指定物理地址扩展配置数据。
|
apic
|
指定高级可编程的中断控制器配置数据。
|
memory
|
指定以 megabyte 为单位的内存大小
|
vcpus
|
指定虚拟 CPU 的数量。
|
console
|
指定导出域控制台的端口号。
|
nic
|
指定虚拟网络接口的数量。
|
vif
|
Lists the randomly-assigned MAC addresses and bridges assigned to use for the domain's network addresses.
|
disk
|
列出导出至域的块设备并以只读权限导出物理设备到域。
|
dhcp
|
用 DHCP 启用网络。
|
netmask
|
指定配置的 IP 掩码。
|
gateway
|
指定配置的 IP 网关。
|
acpi
|
指定高级配置电源接口的配置数据。
|
第 10 章 管理 CPU
第 11 章 移植域
xm migrate domain-id [destination domain]
xm migrate domain-id -l [destination domain]
第 12 章 配置网络应用
dom0
by a point to point link. These devices are vif
<domid>
and <vifid>
. vif1.0
for the first interface in domain 1; vif3.1
for the second interface in domain 3.
network-bridge
and vif-bridge
. xend calls these scripts when certain events occur. Arguments can be passed to the scripts to provide additional contextual information. These scripts are located in the /etc/xen/scripts
directory. You can change script properties by modifying the xend-config.sxp configuration file located in the /etc/xen
directory.
network-bridge
— 当 xend 启动或停止时,这个脚本初始化或者停止虚拟网络。之后,初始化过程创建网桥 xen—br0
并把 eth0
移至这个网桥上,且修改对应的路由。当 xend 最后退出时,它删除这个网桥和 eth0
,由此恢复原始的 IP 和路由配置。
vif-bridge
- 对于域里的每个虚拟接口,这个脚本都被调用。它配置防火墙规则且能够把 vif
加入到合适的网桥上。
network-route
、network-nat
、vif-route,
和 vif-nat
。或者这些脚本可以用自定义的变量来替代。
第 13 章 设置 Domain0 的安全性
- 只运行最小数目的必需的服务。不要在 domain0 里运行太多的任务和服务。运行的服务越少,安全性越高。
- 启用 SeLINUX 帮助提高 domain0 的安全性。
- 使用防火墙来限制到 domain0 的通信量。你可以设置采用 default-reject 规则的防火墙,这将有助于避免对 domain0 的攻击。限制网络 facing 服务也是很重要的。
- 不要允许普通用户访问 domain0。如果你允许普通用户访问 domain0,这可能会导致 domain0 易受攻击。记住,domain0 是专用的,允许非专用帐号的访问可能会降低安全级别。
第 14 章 存储
第 15 章 用 virsh 管理虚拟机
xend/qemu
,你应该把 xend/qemu
作为服务来运行。在修改了相应的配置文件后,重新启动系统,xend/qemu
将作为服务运行。你可以把 virsh 用在脚本里。和 xm 工具一样,你可以在命令行里运行 virsh。
15.1. 连接至监控程序
virsh connect <name>
<name>
is the machine name of the hypervisor. If you want to initiate a read—only connection, append the above command with —readonly
.
15.2. 创建虚拟机
virsh create <path to XML configuration file>
15.3. 配置 XML 转储
virsh dumpxml [domain-id | domain-name | domain-uuid]
stdout
. If you save the data to a file, you can use the create
option to recreate the virtual machine.
15.4. 挂起虚拟机
virsh suspend [domain-id | domain-name |domain-uuid]
resume
option.
15.5. 恢复虚拟机的运行
virsh resume [domain-id | domain-name | domain-uuid]
suspend
和 resume
的循环中。
15.6. 保存虚拟机
virsh save [domain-name][domain-id | domain-uuid][filename]
restore
option.
15.7. 恢复虚拟机
virsh save
option:
virsh restore [filename]
15.8. 关闭虚拟机
virsh shutdown [domain-id | domain-name | domain-uuid]
xmdomain.cfg
文件的 on_shutdown
参数,你可以控制虚拟机重启的行为。
15.9. 重新启动虚拟机
virsh reboot [domain-id | domain-name | domain-uuid]
xmdomain.cfg
文件的 on_reboot
参数,你可以控制虚拟机重启的行为。
15.10. 终止域
virsh destroy [domain-name | domain-id | domain-uuid]
destroy
option only when the virtual machine's operating system is non-responsive. For a paravirtualized virtual machine, you should use the shutdown
option.
15.11. 把域名转换为 Domain ID
virsh domid [domain-name | domain-uuid]
15.12. 把 Domain ID 转换为域名
virsh domname [domain-name | domain-uuid]
15.13. 把域名转换为 UUID
virsh domuuid [domain-id | domain-uuid]
15.14. 显示虚拟机信息
virsh dominfo [domain-id | domain-name | domain-uuid]
15.15. 显示节点信息
virsh nodeinfo
CPU model x86_64 CPU (s) 8 CPU frequency 2895 Mhz CPU socket(s) 2 Core(s) per socket 2 Threads per core: 2 Numa cell(s) 1 Memory size: 1046528 kb
15.16. 显示虚拟机信息
virsh list domain-name [ ——inactive | —— -all]
——inactive
选项列出不活动的域(已经被定义但当前不活动的域)。— -all
选项列出所有的域,包括活动和不活动的。输出应该和下例中的类似:
ID Name State ———————————————— 0 Domain0 running 1 Domain202 paused 2 Domain010 inactive 3 Domain9600 crashed
running lists domains currently active on the CPU blocked lists domains that are blocked paused lists domains that are suspended shutdown lists domains that are in process of shutting down shutoff lists domains that are completely down. crashed lists domains that are crashed
15.17. 显示虚拟 CPU 信息
virsh vcpuinfo [domain-id | domain-name | domain-uuid]
15.18. 配置虚拟 CPU 关联
virsh vcpupin [domain-id | domain-name | domain-uuid] [vcpu] , [cpulist]
[vcpu]
是虚拟 VCPU 的号码而 [cpulist]
列出了物理 CPU 序号。
15.19. 配置虚拟 CPU 的数量
virsh setvcpus [domain-name | domain-id | domain-uuid] [count]
15.20. 配置内存分配
virsh setmem [domain-id | domain-name] [count]
[count]
in kilobytes. Note that the new count cannot exceed the amount you specified when you created the Virtual Machine. Values lower than 64 MB probably won't work. You can adjust the Virtual Machine memory as necessary.
15.21. 配置最大内存数量
virsh setmaxmem [domain-name | domain-id | domain-uuid] [count]
15.22. Managing Virtual Networks
virsh net-list
[root@domain ~]# virsh net-list Name State Autostart ----------------------------------------- default active yes vnet1 active yes vnet2 active yes
virsh net-dumpxml [vnet name]
[root@domain ~]# virsh net-dumpxml vnet1 <network> <name>vnet1</name> <uuid>98361b46-1581-acb7-1643-85a412626e70</uuid> <forward dev='eth0'/> <bridge name='vnet0' stp='on' forwardDelay='0' /> <ip address='192.168.100.1' netmask='255.255.255.0'> <dhcp> <range start='192.168.100.128' end='192.168.100.254' /> </dhcp> </ip> </network>
virsh net-autostart [network name]
— Autostart a network specified as [network name]virsh net-create [XML file]
— Generates and starts a new network using a preexisting XML filevirsh net-define [XML file]
— Generates a new network from a preexisting XML file without starting itvirsh net-destroy [network name]
— Destroy a network specified as [network name]virsh net-name [network UUID]
— Convert a specified [network UUID] to a network namevirsh net-uuid [network name
— Convert a specified [network name] to a network UUIDvirsh net-start [name of an inactive network]
— Starts a previously undefined inactive networkvirsh net-undefine [name of an inactive network]
— Undefine an inactive network
第 16 章 用 xend 管理虚拟机
xend-config.sxp
来指定操作参数,这个文件位于 etc/xen
目录。下面是你可以在 xend-config.sxp
配置文件里启用或禁止的参数:
项目 | 描述 |
---|---|
console-limit
|
Determines the console server's memory buffer limit and assigns values on a per-domain basis
|
min-mem
|
给 domain0 保留的最小内存数量(以 MB 为单位),如果为 0,则值不变化。
|
dom0 cpus
|
指定 domain0 使用的 CPU 数量(缺省情况下至少分配一个 CPU)
|
enable-dump
|
指定当发生崩溃时是否启用转储(缺省为 0)
|
external-migration-tool
|
指定用来处理外部设备移植的脚本或应用程序(脚本必须位于
etc/xen/scripts/external-device-migrate )
|
logfile
|
指定日志文件的位置(缺省为
/var/log/xend.log )
|
loglevel
|
指定日志模式:DEBUG、INFO、WARNING、ERROR 或 CRITICAL(缺省为 DEBUG)
|
network-script
|
指定启用网络环境的脚本(脚本必须位于
etc/xen/scripts 目录)
|
xend-http-server
|
是否启用 http stream 数据包管理服务器(缺省为 no)
|
xend-unix-server
|
启用 unix 域套接字服务器(套接字服务器是一个通信终点,它处理底层的网络连接并接受或拒绝转入的连接)。
|
xend-relocation-server
|
启用用于跨机器移植的 relocation 服务器(缺省为 no)
|
xend-unix-path
|
指定
xend-unix-server 命令输出数据的位置(缺省是 var/lib/xend/xend-socket )
|
xend-port
|
指定 http 管理服务器使用的端口(缺省为 8000)
|
xend-relocation-port
|
指定 relocation 服务器所使用的端口(缺省为 8002)
|
xend-relocation-address
|
指定虚拟机允许系统移植的地址
|
xend-address
|
指定域套接字服务器绑定的地址
|
service xend start
service xend stop
service xend restart
service xend status
第 17 章 用虚拟机管理者(Virtual Machine Manager)管理虚拟机
17.1. 虚拟机管理者架构
17.2. Open Connection 窗口
test:///default
in the URL field beneath. Once in test mode, you can connect to a libvirt dummy hypervisor. Note that although the Remote Xen host screen is visible, the functionality to connect to such a host is not implemented into Red Hat Enterprise Linux 5.1.
![Virtual Machine Manager Connection window](https://access.redhat.com/webassets/avalon/d/Red_Hat_Enterprise_Linux-5-Virtualization-zh-CN/images/ca655fb9f46777cd62fe0a7f087fb316/vmm_connect.png)
图 17.1. Virtual Machine Manager Connection window
17.3. 虚拟机管理者窗口
![Virtual Machine Manager main window](https://access.redhat.com/webassets/avalon/d/Red_Hat_Enterprise_Linux-5-Virtualization-zh-CN/images/886367e782a8ac41d2e1c1bc1b675b37/vmm_main.png)
图 17.2. Virtual Machine Manager main window
17.4. 虚拟机 Details 窗口
![Virtual Machine Manager Details window](https://access.redhat.com/webassets/avalon/d/Red_Hat_Enterprise_Linux-5-Virtualization-zh-CN/images/a794f2befcbb6eb0635141a3d8272905/virtual_machine_details1.png)
图 17.3. Virtual Machine Manager Details window
17.5. 虚拟机图形化控制台
![图形化控制台](https://access.redhat.com/webassets/avalon/d/Red_Hat_Enterprise_Linux-5-Virtualization-zh-CN/images/412a89212213cebe5e885063746bb4e1/guest-console-small.png)
图 17.4. 图形化控制台
17.6. Starting the Virtual Machine Manager
Applications
菜单,点击 System Tools
,然后选择 Virtual Machine Manager
。
![Starting the Virtual Machine Manager](https://access.redhat.com/webassets/avalon/d/Red_Hat_Enterprise_Linux-5-Virtualization-zh-CN/images/886367e782a8ac41d2e1c1bc1b675b37/vmm_main.png)
图 17.5. Starting the Virtual Machine Manager
17.7. 创建新的虚拟机
- 创建新的域。
- Configure or adjust a domain's resource allocation and virtual hardware.
- 统计运行的域的性能和资源利用情况。
- 显示性能和资源利用情况的图表。
- 使用内嵌的 VNC 客户端浏览器来作为客户机域的完全图形化控制台。
注意
过程 17.1. 创建客户机操作系统
- 在 Applications 菜单,选择 System Tools,然后选择 Virtual Machine Manager。虚拟机管理者主窗口将出现。
图 17.6. Virtual Machine Manager window
- 在 File 菜单,选择 New machine。
图 17.7. 选择一个新的机器
创建新虚拟机的向导将出现。 - Click.
图 17.8. 创建新虚拟系统的向导
- Enter the name of the new virtual system and then click.
图 17.9. 命名虚拟系统
- 输入安装介质的位置。kickstart 文件的位置是可选的。然后点击 Forward 。
图 17.10. 定位安装介质
- 安装至一个物理磁盘分区或是某个文件里的虚拟文件系统。
注意
这个例子在文件里安装了一个虚拟系统。SELinux policy only allows xen disk images to reside in/var/lib/xen/images
.Open a terminal and create the /xen directory and set the SELinux policy with the commandrestorecon -v /xen
. Specify your location and the size of the virtual disk, then click .图 17.11. 分配存储空间
- Select memory to allocate the guest and the number of virtual CPUs then click.
图 17.12. 分配内存和 CPU
- Selectto open a console and the files start to install.
图 17.13. 分配内存和 CPU
- 在这个窗口里完成安装。
图 17.14. 安装开始...
警告
When installing Red Hat Enterprise Linux 5.1 on a fully virtualized guest, do not use thekernel-xen
kernel. Using this kernel on fully virtualized guests can cause your system to hang.If you are using an Installation Number when installing Red Hat Enterprise Linux 5.1 on a fully virtualized guest, be sure to deselect theVirtualization
package group during the installation. TheVirtualization
package group option installs thekernel-xen
kernel.Note that paravirtualized guests are not affected by this issue. Paravirtualized guests always use thekernel-xen
kernel. - Type
xm create -c xen-guest
to start the Red Hat Enterprise Linux 5.1 guest. Right click on the guest in the Virtual Machine Manager and choose Open to open a virtual console.图 17.15. Red Hat Enterprise Linux 5.1 (guest)
- 输入用户名和密码来继续使用虚拟机管理者。
17.8. 恢复保存的虚拟机
- 在 File 菜单,选择 Restore a saved machine。
图 17.16. Restoring a Virtual Machine
- 恢复虚拟机主窗口将出现。
图 17.17. 选择保存的虚拟机会话
- 导航至正确的目录并选择保存的会话文件。
- 点击 Open。
![被恢复的虚拟机管理者会话](https://access.redhat.com/webassets/avalon/d/Red_Hat_Enterprise_Linux-5-Virtualization-zh-CN/images/886367e782a8ac41d2e1c1bc1b675b37/vmm_main.png)
图 17.18. 被恢复的虚拟机管理者会话
17.9. Displaying Virtual Machine Details
- 在虚拟机管理者主窗口,高亮显示你要查看的虚拟机。
图 17.19. 选择要显示的虚拟机
- 在虚拟机管理者的 Edit 菜单,选择 Machine Details (或在虚拟机管理者主窗口的底部点击 Details 按钮)。
图 17.20. 显示虚拟机细节菜单
Virtual Machine Details Overview 窗口将出现。这个窗口显示了你指定的域的 CPU 和内存使用情况。图 17.21. 显示 Virtual Machine Details Overview
- 在 Virtual Machine Details 窗口,点击 Hardware 页。Virtual Machine Details Hardware 窗口将出现。
图 17.22. 显示 Virtual Machine Details Hardware
- 在 Hardware 页,点击 Processor 可以查看或修改当前的处理器分配情况。
图 17.23. 显示处理器分配情况
- 在 Hardware 窗口,点击 Memory 可以查看和修改当前的内存分配。
图 17.24. 显示内存分配情况
- 在 Hardware 页,点击 Disk 可以查看或修改当前的硬盘配置。
图 17.25. 显示磁盘配置
- 在 Hardware 页,点击 Network 可以查看或修改当前的网络配置。
图 17.26. 显示网络配置
17.10. Configuring Status Monitoring
- 在 Edit 菜单,选择 Preferences。
图 17.27. 改变虚拟机的首选项
虚拟机管理者首选项窗口将出现。 - 在状态监控区选择框,指定你希望系统更新的时间间隔(以秒为单位)。
图 17.28. Configuring Status Monitoring
- 在控制台区,指定怎样打开控制台和输入设备。
17.11. 显示 Domain ID
- 在 View 菜单,选定 Domain ID 复选框。
图 17.29. 显示 Domain-ID
- The Virtual Machine Manager lists the Domain ID's for all domains on your system.
图 17.30. 显示 Domain-ID
17.12. 显示虚拟机状态
- 在 View 菜单,选择 Status 复选框。
图 17.31. 显示虚拟机状态
- 虚拟机管理者列出了系统里所有虚拟机的状态。
图 17.32. 显示虚拟机状态
17.13. 显示虚拟 CPU
- 在 View 菜单,选定 Virtual CPUs 复选框。
图 17.33. 显示虚拟 CPU
- 虚拟机管理者将列出系统里所有虚拟机的虚拟 CPU。
图 17.34. 显示虚拟 CPU
17.14. 显示 CPU 的使用情况
- 在 View 菜单里,选定 CPU Usage 复选框。
图 17.35. 显示 CPU 的使用情况
- 虚拟机管理者将列出系统里所有虚拟机的 CPU 使用百分比。
图 17.36. 显示 CPU 的使用情况
17.15. 显示内存使用情况
- 在 View 菜单里,选定 Memory Usage 复选框。
图 17.37. 显示内存使用情况
- 虚拟机管理者将列出系统里所有虚拟机的内存(以 MB 为单位)使用百分比。
图 17.38. 显示内存使用情况
17.16. Managing a Virtual Network
- From the Edit menu, select Host Details.
图 17.39. Selecting Host Details
- This will open the Virtual Networks tab.menu. Click the
图 17.40. Virtual Network Configuration
- All available virtual networks are listed on the left-hand box of the menu. You can edit the configuration of a virtual network by selecting it from this box and editing as you see fit.
17.17. Creating a Virtual Network
- Open the Host Details menu (refer to 第 17.16 节 “Managing a Virtual Network”) and click the button.
图 17.41. Virtual Network Configuration
This will open themenu. Click to continue.图 17.42. Creating a new virtual network
- Enter an appropriate name for your virtual network and click.
图 17.43. Naming your virtual network
- Enter an IPv4 address space for your virtual network and click.
图 17.44. Choosing an IPv4 address space
- Define the DHCP range for your virtual network by specifying a Start and End range of IP addresses. Click to continue.
图 17.45. Selecting the DHCP range
- Select how the virtual network should connect to the physical network.
图 17.46. Connecting to physical network
If you select Forwarding to physical network, choose whether the Destination should be NAT to any physical device or NAT to physical device eth0.Clickto continue. - You are now ready to create the network. Check the configuration of your network and click.
图 17.47. Ready to create network
- The new virtual network is now available in thetab of the menu.
图 17.48. New virtual network is now available
第 18 章 红帽虚拟化系统的故障解除
18.1. 日志文件概述和位置
- 红帽虚拟化系统的主要配置目录是
/etc/xen/
。这个目录包含了xend
守护进程和其他的虚拟机配置文件。网络脚本文件也存放在此处(在/scripts
目录)。 - 所有你用于故障解除目的的日志文件都存放在
/var/log/xen
目录。
- 你也应该知道所有虚拟机的基于文件的磁盘映像都缺省存放在
/var/lib/xen
目录里。 - 红帽虚拟化系统的
/proc
文件系统信息位于/proc/xen/
目录。
18.2. 日志文件的描述
xend
守护进程和 qemu-dm
进程为特征,这两个工具都把多个日志文件写入到 /var/log/xen/
目录:
xend.log
是包含xend
守护进程收集的所有数据的日志文件,不管这数据是普通的系统事件,还是操作者执行的动作。所有虚拟机的操作(如创建、关闭、销毁等等)都在此出现。xend.log
通常是你跟踪事件或性能问题的第一个着手点。它包含错误信息的详细条目和条件。xend-debug.log
是包含xend
和虚拟化子系统(如 framebuffer、Python 脚本等等)的事件错误记录的日志文件。
xen-hotplug-log
是包含热插拔事件的数据的日志文件。如果设备或网络脚本没有被启动,事件将记录在这里。qemu-dm.[PID].log
是qemu-dm
进程为每个完全虚拟化客户机创建的日志文件。当使用日志文件时,你必须用ps
命令并挑选出qemu-dm
的信息来获取qemu-dm
的进程号。注意你必须用实际的qemu-dm
进程的 PID 来代替 [PID]。
/.virt-manager
目录下的 virt-manager.log
文件里寻找生成的数据。注意每次你启动虚拟机管理者,它都会覆盖现有的日志文件内容。当出现系统错误后,在重启虚拟机管理者前,请确保备份好 virt-manager.log
文件。
18.3. 重要的目录位置
- 虚拟机映像位于
/var/lib/xen/images
目录里。
- 当你重启
xend
守护进程时,它会更新/var/lib/xen/xend-db
目录下的xend-database
。
- 虚拟机的转储文件(使用
xm dump-core
命令生成的)位于/var/lib/xen/dumps
目录下。
/etc/xen
目录包含你用来管理系统资源的配置文件。xend
守护进程的配置文件是xend-config.sxp
,你可以使用这个文件来实施系统范围的修改并配置网络 callout。
proc
命令是另一个允许你收集系统信息的资源。这些 proc 条目位于/proc/xen
目录。
/proc/xen/capabilities
/proc/xen/balloon
/proc/xen/xenbus/
18.4. 故障解除工具
xentop
xm dmesg
xm log
vmstat
iostat
lsof
XenOprofile
systemTap
crash
sysrq
sysrq t
sysrq w
ifconfig
tcpdump
brctl
brctl
是一个在虚拟化 Linux 内核里检查和配置以太网桥配置的网络工具。在执行这些示例命令时,你必须拥有根用户权限:
# brctl show bridge-name bridge-id STP enabled interfaces ----------------------------------------------------------------------------- xenbr0 8000.feffffff no vif13.0 xenbr1 8000.ffffefff yes pddummy0 xenbr2 8000.ffffffef no vif0.0 # brctl showmacs xenbr0 port-no mac-addr local? ageing timer 1 fe:ff:ff:ff:ff: yes 0.00 2 fe:ff:ff:fe:ff: yes 0.00 # brctl showstp xenbr0 xenbr0 bridge-id 8000.fefffffffff designated-root 8000.fefffffffff root-port 0 path-cost 0 max-age 20.00 bridge-max-age 20.00 hello-time 2.00 bridge-hello-time 2.00 forward-delay 0.00 bridge-forward-delay 0.00 ageing-time 300.01 hello-timer 1.43 tcn-timer 0.00 topology-change-timer 0.00 gc-timer 0.02
18.5. 利用日志进行故障解除
xend.log
file contains the same basic information as when you run the xm log
command. It resides in the /var/log/
directory. Here is an example log entry for when you create a domain running a kernel:
[2006-12-27 02:23:02 xend] ERROR (SrvBase: 163) op=create: Error creating domain: (0, 'Error') Traceback (most recent call list) File "/usr/lib/python2.4/site-packages/xen/xend/server/SrvBase.py" line 107 in_perform val = op_method (op,req) File "/usr/lib/python2.4/site-packages/xen/xend/server/SrvDomainDir.py line 71 in op_create raise XendError ("Error creating domain: " + str(ex)) XendError: Error creating domain: (0, 'Error')
xend-debug.log
,对于系统管理员也是非常有用的,因为它包含了比 xend.log
更为详细的信息。下面是同一个内核域创建问题里错误数据:
ERROR: Will only load images built for Xen v3.0 ERROR: Actually saw: GUEST_OS=netbsd, GUEST_VER=2.0, XEN_VER=2.0; LOADER=generic, BSD_SYMTAB' ERROR: Error constructing guest OS
18.6. 用串行控制台进行故障解除
grub.conf
文件里的这些选项来在 com1 /dev/ttyS0
上启用一个速率为 38400-bps 的串行控制台:
title Red Hat Enterprise Linix (2.6.18-8.2080_RHEL5xen0) root (hd0,2) kernel /xen.gz-2.6.18-8.el5 com1=38400,8n1 module /vmlinuz-2.618-8.el5xen ro root=LABEL=/rhgb quiet console=xvc console=tty xencons=xvc module /initrd-2.6.18-8.el5xen.img
sync_console
can help determine a problem that causes hangs with asynchronous hypervisor console output, and the "pnpacpi=off"
works around a problem that breaks input on the serial console. The parameters "console=ttyS0"
and "console=tty"
means that kernel errors get logged with on both the normal VGA console and on the serial console. Then you can install and set up ttywatch
to capture the data on a remote host connected by a standard null-modem cable. For example, on the remote host you could type:
ttywatch --name myhost --port /dev/ttyS0
/dev/ttyS0
的输出导出至 /var/log/ttywatch/myhost.log
文件。
18.7. 对半虚拟化客户机控制台的访问
xm console [domain name or number]
domain100
代表一个运行名或号码。你也可以使用虚拟机管理者来显示虚拟文本控制台。在 Virtual Machine Details 窗口中的 View 菜单里,选择 Serial Console。
18.8. 对完全虚拟化客户机控制台的访问
grub.conf
file, and include the 'console =ttyS0 console=tty0'
parameter. This ensures that the kernel messages are sent to the virtual serial console (and the normal graphical console). If you plan to use the virtual serial console in a full virtualized guest, you must edit the configuration file in the /etc/xen/
directory. On the host domain, you can then access the text console by typing:
xm console
18.9. 实施 Lun 持久化
udev
来实施 lun 持久化。在实施之前,请确保你获得了正确的 UUID。一旦你获得了这些 UUID,你可以通过编辑 /etc
目录里的 scsi_id
文件来配置 lun 持久化。用文本编辑器里打开这个文件后,你必须注释掉如下一行:
# options=-b
# options=-g
# scsi_id -g -s /block/sdc
[root@devices] # scsi_id -g -s /block/sdc *3600a0b80001327510000015427b625e*
/etc/udev/rules.d
目录里的 20-names.rules
文件。设备创建的命名规则应该遵循下面的格式:
# KERNEL="sd*", BUS="scsi", PROGRAM="sbin/scsi_id", RESULT="UUID", NAME="devicename"
KERNEL="sd*", BUS="scsi", PROGRAM="sbin/scsi_id", RESULT="3600a0b80001327510000015427b625e ", NAME="mydevicename"
/dev/sd*
的设备来检查给定的 UUID。当它发现有匹配的设备时,它创建一个叫 /dev/devicename
的设备节点。在这个例子里,设备节点是 /dev/mydevice
。最后,你需要把 /etc
目录里的 rc.local
文件附加在这个路径后:
/sbin/start_udev
/etc/
目录里的 multipath.conf
文件来定义四个设备别名:
multipath { wwid 3600a0b80001327510000015427b625e alias oramp1 } multipath { wwid 3600a0b80001327510000015427b6 alias oramp2 } multipath { wwid 3600a0b80001327510000015427b625e alias oramp3 } multipath { wwid 3600a0b80001327510000015427b625e alias oramp4 }
/dev/mpath/oramp1
、/dev/mpath/oramp2
、/dev/mpath/oramp3
和 dev/mpath/oramp4
。这些设备将位于 /dev/mpath
目录。这些 lun 的名字在重启后也将保持,因为它们都是基于 LUN 的 wwid 创建的别名。
18.10. SELinux 的相关事宜
# semanage fcontext -a -t xen_image _t -f -b /dev/sda2 # restorecon /dev/sda2
xend_disable_trans
使 xend
在重启后进入 unconfined 模式。禁止对单个进程的保护比在整个系统里应用要更好。我们建议你不要把目录重新标记为将在其他地方使用的 xen_image_t
。
18.11. 访问客户机磁盘映像里的数据
yum install kpartx kpartx -av /dev/xen/guest1 add map guest1p1 : 0 208782 linear /dev/xen/guest1 63 add map guest1p2: 0 16563015 linear /dev/xen/guest1 208845
# kpartx -a /dev/xen/guest1 #vgscan Reading all physical volumes . This may take a while... Found volume group "VolGroup00" using metadata type 1vm2 # vgchange -ay VolGroup00 2 logical volume(s) in volume group VolGroup00 now active. # lvs LV VG Attr Lsize Origin Snap% Move Log Copy% LogVol00 VolGroup00 -wi-a- 5.06G LogVol01 VolGroup00 -wi-a- 800.00M # mount /dev/VolGroup00/LogVol00 /mnt/ .... #umount /mnt/ #vgchange -an VolGroup00 #kpartx -d /dev/xen/guest1
vgchange -an
来使逻辑卷无效、用 kpartx-d
来删除分区且在完成后用 losetup -d
删除回路设备。
18.12. 常见的故障解除
xend
服务时,什么也没有发生。键入 xm list1
后可以看到下面的输出:
Error: Error connecting to xend: Connection refused. Is xend running?
xend start
时,发现更多的错误:
Error: Could not obtain handle on privileged command interfaces (2 = No such file or directory) Traceback (most recent call last:) File "/usr/sbin/xend/", line 33 in ? from xen.xend.server. import SrvDaemon File "/usr/lib/python2.4/site-packages/xen/xend/server/SrvDaemon.py" , line 26 in ? from xen.xend import XendDomain File "/usr//lib/python2.4/site-packages/xen/xend/XendDomain.py" , line 33, in ? from xen.xend import XendDomainInfo File "/usr/lib/python2.4/site-packages/xen/xend/image.py" , line37, in ? import images File "/usr/lib/python2.4/site-packages/xen/xend/image.py" , line30, in ? xc = xen.lowlevel.xc.xc () RuntimeError: (2, 'No such file or directory' )
xen-hypervisor
的内核。要解决这个问题,你必须在引导时选择 xen-hypervisor
内核(或在 grub.conf
文件里把 xen-hypervisor
内核设置为缺省选项)。
18.13. 回路设备错误
/etc/modprobe.conf
文件。当修改 modprobe.conf
文件时,你必须包含下面这行:
options loop max_loop=64
phy: block device
或 tap:aio
设备用于半虚拟化系统,把 phy: device
或 file: file
用于完全虚拟化系统。、
18.14. 客户机创建错误
"Invalid argument"
error message. This usually means that the kernel image you are trying to boot is incompatible with the hypervisor. An example of this would be if you were attempting to run a non-PAE FC5 kernel on a PAE only FC6 hypervisor.
grub.conf
里的缺省内核选项切换回普通内核而不是虚拟化内核。
/etc/sysconfig/kernel/
目录里的缺省内核 RPM。你必须确保在 gb.conf
文件里 kernel-xen
参数被设置为缺省选项。
18.15. 串行控制台错误
grub.conf
里的串口参数修改为:
serial --unit=1 --speed=115200
title RHEL5 i386 Xen (2.6.18-1.2910.el5xen) root (hd0, 8) kernel /boot/xen.gz-2.6.18-1.2910.el5 com2=115200,8n1 module /boot/vmlinuz-2.6.18-1.2910.el5xen to root=LABEL=RHEL5_i386 console=tty console=ttyS1115200 module /boot/initrd-2.8.6.18-12910.el5xen.img title RHEL5 i386 xen (2.6.18.-1.2910.el5xen root (hd0, 8) kernel /boot/xen.gz-2.6.18-1.2910.el5 com2=115200 console=com2l module /boot/vmlinuz2.6.18-1.2910.el5xen to root=LABEL=RHEL5_i386 console=xvc xencons=xvc module /boot/ititrd-2.6.18-1.2910.el5xen.img
grub.conf
的修改应该能使串行控制台正常工作。你应该能够使用任何数量的 ttyS
,如 ttyS0
。
18.16. 网桥错误
/etc/sysconfig/network-scripts
. You should use a process to setup multiple Xen bridges. This is an example config file for a second NIC called 'eth1'
:
#/etc/sysconfig/network-scripts/fcfg-eth1 DEVICE=eth1 BOOTPROTO=static ONBOOT=yes USERCTL=no IPV6INIT=no PEERDNS=yes TYPE=Ethernet NETMASK=255.255.255.0 IPADDR=10.1.1.1 GATEWAY=10.1.1.254 ARP=yes
/etc/xen/scripts/network-bridge
复制到 /etc/xen/scripts/network-bridge.xen
。
/etc/xen/xend-config.sxp
and add a line to your new network bridge script (this example uses "network-virtualization-multi-bridge"
).
xend-config.sxp
文件里,加入的新行应该与新脚本相关:
network-script network-xen-multi-bridge
network-script network-bridge
xenbr0
和 xenbr1
)并相应地把它们附加到 eth1
和 eth0
:
# !/bin/sh # network-xen-multi-bridge # Exit if anything goes wrong set -e # First arg is operation. OP=$1 shift script=/etc/xen/scripts/network-bridge.xen case ${OP} in start) $script start vifnum=1 bridge=xenbr1 netdev=eth1 $script start vifnum=0 bridge=xenbr0 netdev=eth0 ;; stop) $script stop vifnum=1 bridge=xenbr1 netdev=eth1 $script stop vifnum=0 bridge=xenbr0 netdev=eth0 ;; status) $script status vifnum=1 bridge=xenbr1 netdev=eth1 $script status vifnum=0 bridge=xenbr0 netdev=eth0 ;; *) echo 'Unknown command: ' ${OP} echo 'Valid commands are: start, stop, status' exit 1 esac
18.17. 笔记本配置
ifcfg-dummy0
并位于 /etc/sysconfig/network-scripts/
目录下。
DEVICE =dummy0 BOOTPROTO=none ONBOOT=yes USERCTL=no IPV6INIT=no PEERDNS=yes TYPE=Ethernet NETMASK=255.255.255.0 IPADDR=10.1.1.1 ARP=yes
xenbr0
绑定至 dummy0
,这样即使和物理网络断开,这也可以允许网络连接。
xend-config.sxp
file. You must locate the ( network-script 'network-bridge' bridge=xenbr0
) section and add include this in the end of the line:
netdev=dummy0
/etc/sysconfig/
directory to reflect the example below:
NETWORKING=yes HOSTNAME=localhost.localdomain GATEWAY=10.1.1.1 IPADDR=10.1.1.10 NETMASK=255.255.255.0
/etc/rc3.d
目录里的 S99XenLaptopNAT
文件。
#!/bin/bash # # XenLaptopNAT Startup script for Xen on Laptops # # chkconfig: - 99 01 # description: Start NAT for Xen Laptops # # PATH=/usr/bin:/sbin:/bin:/usr/sbin # export PATH GATEWAYDEV=`ip route | grep default | awk {'print $5'}` iptables -F case "$1" in start) if test -z "$GATEWAYDEV"; then echo "No gateway device found" else echo "Masquerading using $GATEWAYDEV" /sbin/iptables -t nat -A POSTROUTING -o $GATEWAYDEV -j MASQUERADE fi echo "Enabling IP forwarding" echo 1 > /proc/sys/net/ipv4/ip_forward echo "IP forwarding set to `cat /proc/sys/net/ipv4/ip_forward`" echo "done." ;; *) echo "Usage: $0 {start|restart|status}" ;; esac
/etc/rc3.d/S99XenLaptopNAT
的软链接。
modprobe.conf
文件时,你必须包括下面的行:
alias dummy0 dummy options dummy numdummies=1
18.18. Starting Domains Automatically During System Boot
/etc/xen/auto
里的符号链接。这些文件指向你需要自动启动的客户机配置文件。启动过程是按数字排列的,客户机的数字越大,引导过程所需的时间越长。下例告诉你怎样为客户机 rhel5vm01
使用符号链接:
[root@python xen]# cd /etc/xen [root@python xen]# cd auto [root@python auto]# ls [root@python auto]# ln -s ../rhel5vm01 . [root@python auto]# ls -l lrwxrwxrwx 1 root root 14 Dec 14 10:02 rhel5vm01 -> ../rhel5vm01 [root@python auto]#
18.19. 修改 Domain0
grub.conf
configuration file, that resides in the /etc
directory. Because of the large number of domains to manage, many system administrators prefer to use the 'cut and paste' method when editing grub.conf
. If you do this, make sure that you include all five lines in the Virtualization entry (or this will create system errors). If you require Xen hypervisor specific values, you must add them to the 'xen' line. This example represents a correct grub.conf
Virtualization entry:
# boot=/dev/sda/ default=0 timeout=15 #splashimage=(hd0, 0)/grub/splash.xpm.gz hiddenmenu serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 terminal --timeout=10 serial console title Red Hat Enterprise Linux Server (2.6.17-1.2519.4.21. el5xen) root (hd0, 0) kernel /xen.gz-2.6.17-1.2519.4.21.el5 com1=115200,8n1 module /vmlinuz-2.6.17-1.2519.4.21el5xen ro root=/dev/VolGroup00/LogVol00 module /initrd-2.6.17-1.2519.4.21.el5xen.img
'dom0_mem=256M'
. This example represents the respective grub.conf
xen entry:
# boot=/dev/sda default=0 timeout=15 #splashimage=(hd0,0)/grubs/splash.xpm.gz hiddenmenu serial --unit=0 --speed =115200 --word=8 --parity=no --stop=1 terminal --timeout=10 serial console title Red Hat Enterprise Linux Server (2.6.17-1.2519.4.21. el5xen) root (hd0,0) kernel /xen.gz-2.6.17-1.2519.4.21.el5 com1=115200,8n1 dom0_mem=256MB module /vmlinuz-2.6.17-1.2519.4.21.el5xen ro root=/dev/VolGroup00/LogVol00 module /initrd-2.6.17-1.2519.4.21.el5xen.img
18.20. 客户机配置文件
name = "rhel5vm01" memory = "2048" disk = ['tap:aio:/xen/images/rhel5vm01.dsk,xvda,w',] vif = ["type=ieomu, mac=00:16:3e:09:f0:12 bridge=xenbr0', "type=ieomu, mac=00:16:3e:09:f0:13 ] vnc = 1 vncunused = 1 uuid = "302bd9ce-4f60-fc67-9e40-7a77d9b4e1ed" bootloader = "/usr/bin/pygrub" vcpus=2 on_reboot = "restart" on_crash = "restart"
serial="pty"
is the default for the configuration file. This configuration file example is for a fully-virtualized guest:
name = "rhel5u5-86_64" builder = "hvm" memory = 500 disk = ['file:/xen/images/rhel5u5-x86_64.dsk.hda,w'] vif = [ 'type=ioemu, mac=00:16:3e:09:f0:12, bridge=xenbr0', 'type=ieomu, mac=00:16:3e:09:f0:13, bridge=xenbr1'] uuid = "b10372f9-91d7-ao5f-12ff-372100c99af5' device_model = "/usr/lib64/xen/bin/qemu-dm" kernel = "/usr/lib/xen/boot/hvmloader/" vnc = 1 vncunused = 1 apic = 1 acpi = 1 pae = 1 vcpus =1 serial ="pty" # enable serial console on_boot = 'restart'
18.21. 克隆客户机配置文件
uuidgen(1)
command). Then for the vif
entries you must define a unique MAC address for each guest (if you are copying a guest configuration from an existing guest, you can create a script to handle it). For the xen bridge information, if you move an existing guest configuration file to a new host, you must update the xenbr
entry to match your local networking configuration. For the Device entries, you must modify the entries in the 'disk='
section to point to the correct guest image.
/etc/sysconfig/network
file to match the new guest's hostname.
/etc/sysconfig/network-scripts/ifcfg-eth0
文件的 HWADDR 地址,使之和 ifconfig eth0
的输出相符合。如果你想使用静态 IP 地址,你必修改 IPADDR 条目。
18.22. 创建生成 MAC 地址的脚本
#! /usr/bin/python # macgen.py script generates a MAC address for Xen guests # import random mac = [ 0x00, 0x16, 0x3e, random.randint(0x00, 0x7f), random.randint(0x00, 0xff), random.randint(0x00, 0xff) ] print ':'.join(map(lambda x: "%02x" % x, mac)) Generates e.g.: 00:16:3e:66:f5:77 to stdout
18.23. 配置虚拟机的 Live 移植
xm migrate
command). Live migration can be done from the same command. However there are some additional modifications that you must do to the xend-config
configuration file. This example identifies the entries that you must modify to ensure a successful migration:
(xend-relocation-server yes)
- The default for this parameter is 'no', which keeps the relocation/migration server deactivated (unless on a trusted network) and the domain virtual memory is exchanged in raw form without encryption.
(xend-relocation-port 8002)
- 这个参数设置了
xend
用于移植的端口。请确保把它前面的注释去掉。 (xend-relocation-address )
- 在你启用了
xend-relocation-server
后,这个参数是侦听 relocation 套接字连接的地址。它可以把移植限制到特定的接口。 (xend-relocation-hosts-allow )
- This parameter controls the host that communicates with the relocation port. If the value is empty, then all incoming connections are allowed. You must change this to a space-separated sequences of regular expressions (such as
xend-relocation-hosts-allow- '^localhost\\.localdomain$'
). A host with a fully qualified domain name or IP address that matches these expressions are accepted.
18.24. 翻译错误信息
failed domain creation due to memory shortage, unable to balloon domain0
xend.log
里关于这个错误的内容:
[2006-12-21] 20:33:31 xend 3198] DEBUG (balloon:133) Balloon: 558432 Kib free; 0 to scrub; need 1048576; retries: 20 [2006-12-21] 20:33:31 xend. XendDomainInfo 3198] ERROR (XendDomainInfo: 202 Domain construction failed
xm list Domain0
command. If domain0 is not ballooned down, you can use the command "xm mem-set Domain-0 NewMemSize"
to check memory.
wrong kernel image: non-PAE kernel on a PAE
[root@smith]# xm create -c va base Using config file "va-base" Error: (22, 'invalid argument') [2006-12-14 14:55:46 xend.XendDomainInfo 3874] ERRORs (XendDomainInfo:202) Domain construction failed Traceback (most recent call last) File "/usr/lib/python2.4/site-packages/xen/xend/XendDomainInfo.py", line 195 in create vm.initDomain() File " /usr/lib/python2.4/site-packages/xen/xend/XendDomainInfo.py", line 1363 in initDomain raise VmError(str(exn)) VmError: (22, 'Invalid argument') [2006-12-14 14:55:46 xend.XendDomainInfo 3874] DEBUG (XenDomainInfo: 1449] XendDlomainInfo.destroy: domin=1 [2006-12-14 14:55:46 xend.XendDomainInfo 3874] DEBUG (XenDomainInfo: 1457] XendDlomainInfo.destroy:Domain(1)
Unable to open a connection to the Xen hypervisor or daemon
/etc/hosts
配置文件里没有 localhost 条目时会产生这个错误。请确认配置文件里是否启用了 localhost 条目。下面是一个错误的 localhost 条目示例:
# Do not remove the following line, or various programs # that require network functionality will fail. localhost.localdomain localhost
# Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost localhost.localdomain. localhost
xen-xend.log file
文件里):
Bridge xenbr1 does not exist!
[root@trumble virt]# xm create r5b2-mySQL01 Using config file " r5b2-mySQL01" Going to boot Red Hat Enterprise Linux Server (2.6.18.-1.2747 .el5xen) kernel: /vmlinuz-2.6.18-12747.el5xen initrd: /initrd-2.6.18-1.2747.el5xen.img Error: Device 0 (vif) could not be connected. Hotplug scripts not working.
xend.log
里会有下面的错误:
[2006-11-14 15:07:08 xend 3875] DEBUG (DevController:143) Waiting for devices vif [2006-11-14 15:07:08 xend 3875] DEBUG (DevController:149) Waiting for 0 [2006-11-14 15:07:08 xend 3875] DEBUG (DevController:464) hotplugStatusCallback /local/domain/0/backend/vif/2/0/hotplug-status [2006-11-14 15:08:09 xend.XendDomainInfo 3875] DEBUG (XendDomainInfo:1449) XendDomainInfo.destroy: domid=2 [2006-11-14 15:08:09 xend.XendDomainInfo 3875] DEBUG (XendDomainInfo:1457) XendDomainInfo.destroyDomain(2) [2006-11-14 15:07:08 xend 3875] DEBUG (DevController:464) hotplugStatusCallback /local/domain/0/backend/vif/2/0/hotplug-status
vif
条目。找到配置文件里的 vif
条目,假定你把 xenbr0
作为缺省网桥,正确的设置应该如下所示:
# vif = ['mac=00:16:3e:49:1d:11, bridge=xenbr0',]
[root@python xen]# xm shutdown win2k3xen12 [root@python xen]# xm create win2k3xen12 Using config file "win2k3xen12". /usr/lib64/python2.4/site-packages/xenxm/opts.py:520: Deprecation Warning: Non ASCII character '\xc0' in file win2k3xen12 on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details execfile (defconfig, globs, locs,) Error: invalid syntax 9win2k3xen12, line1)
18.25. 关于故障解除的在线资源
- Red Hat Virtualization Center
http://www.openvirtualization.com
- Red Hat Enterprise Linux 5 Beta 2 文档
http://www.redhat.com/docs/manuals/enterprise/RHEL-5-manual/index.html
- Libvirt API
http://www.libvirt.org
- virt-manager 项目主页
http://virt-manager.et.redhat.com
- Xen 社区中心
http://www.xensource.com/xen/xen/
- 虚拟化技术概述
http://virt.kernelnewbies.org
- Emerging Technologies Projects
http://et.redhat.com
第 19 章 其他的资源
19.1. 有用的网站
- http://www.cl.cam.ac.uk/research/srg/netos/xen/ — Xen™ 半虚拟化机器管理者的项目网站,Red Hat Virtualization源于这个项目。这个站点维护了最新的 Xen 项目的二进制文件和源码,它也包含其他信息,如架构概述、文档和关于 Xen 及其相关技术的链接。
- http://www.libvirt.org/ — 和主机 OS 的虚拟化框架进行交互的
libvirt
虚拟化 API 的官方网站。 - http://virt-manager.et.redhat.com/ — Virtual Machine Manager (virt-manager) (一个管理虚拟机的图形化应用程序)的项目网站。
19.2. 安装的文档
/usr/share/doc/xen-<version-number>/
—. This directory contains a wealth of information about the Xen para-virtualization hypervisor and associated management tools, including a look at various example configurations, hardware-specific information, and the current Xen upstream user documentation.man virsh
and/usr/share/doc/libvirt-<version-number>
— Contains subcommands and options for thevirsh
virtual machine management utility as well as comprehensive information about thelibvirt
virtualization library API./usr/share/doc/gnome-applet-vm-<version-number>
— Documentation for the GNOME graphical panel applet that monitors and manages locally-running virtual machines./usr/share/doc/libvirt-python-<version-number>
— Provides details on the Python bindings for thelibvirt
library. Thelibvirt-python
package allows python developers to create programs that interface with thelibvirt
virtualization management library./usr/share/doc/python-virtinst-<version-number>
— Provides documentation on thevirt-install
command that helps in starting installations of Fedora and Red Hat Enterprise Linux related distributions inside of virtual machines./usr/share/doc/virt-manager-<version-number>
— Provides documentation on the Virtual Machine Manager, which provides a graphical tool for administering virtual machines.
附录 A. 实验 1
- 要检查你的 CPU 是否支持 PAE,键入:
grep pae /proc/cpuinfo
- 下面的输出显示了这个 CPU 支持 PAE。如果这个命令没有返回任何输出,说明这个 CPU 不支持 PAE。这个实验里所有的练习都要求带有 PAE 扩展的 i386 CPU 或者是 x86_64 和 ia64。
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat clflush dts acpi mmx fxsr sse sse2 ss tm pbe nx up est tm2
virt-install
安装 RHEL5 Beta 2 Xen 半虚拟化客户机。
virt-install
安装红帽企业 Linux 5 Beta 2 的 Xen 客户机。
- 要安装红帽企业 Linux 5 Beta 2 的 Xen 客户机,在命令行下键入:
virt-install
。 - 当你被询问是否安装完全虚拟化的客户机时,输入:
no
。 - 输入
rhel5b2-pv1
所为你的虚拟机名称。 - 输入 500 作为分配的内存数量。
- 输入
/xen/rhel5b2-pv1.img
作为你的磁盘(客户机映像)。 - 输入 6 作为你的磁盘(客户机映像)大小。
- 输入
yes
来启用图形化支持。 - 输入
nfs:server:/path/to/rhel5b2
作为安装位置。 - 安装开始了。象平常一样进行安装。
- 在安装结束后,键入
/etc/xen/rhel5b2-pv1
,并进行下面的修改:#vnc=1#vncunused=1sdl=1 - 使用文本编辑器来修改
/etc/inittab
,并把下面的内容附加到文件里:init 5.#id:3:initdefault:id:5:initdefault:
virt-manager
安装 RHEL5 Beta 2 Xen 半虚拟化客户机。
virt-manager
来安装红帽企业 Linux 5 Beta 2 的 Xen 半虚拟化客户机。
- 要安装红帽企业 Linux 5 Beta 2 的 Xen 半虚拟化客户机,在命令行提示下输入:
virt-manager
。 - 在 Open Connection 窗口,选择 Local Xen host,然后点击 Connect。
- Start Red Hat's Virtual Machine Manager application, and from the File menu, click on New.
- 点击 Forward。
- 键入
rhel5b2-pv2
作为你的系统名,然后点击 Forward。 - 选择 Paravirtualized, 并点击 Forward。
- 键入
nfs:server:/path/to/rhel5b2
作为安装介质的 URL,然后点击 Forward。 - 选择
Simple File
,键入/xen/rhel5b2-pv2.img
作为文件位置。选择 6000 MB,然后点击 Forward。 - 选择 500 作为你的虚拟机的启动和最大内存,然后点击 Forward。
- 点击 Finish。
- To determine if your CPU has Intel-VT or AMD-V support, type the following command:
egrep -e 'vmx|svm' /proc/cpuinfo
- 下面的输出表示 CPU 支持 Intel-VT:
.flags : fpu tsc msr pae mce cx8 apic mtrr mca cmov pat clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe constant_tsc pni monitor vmx est tm2 xtpr
如果这个命令没有任何输出,则表示 CPU 不支持 Intel-VT 或 AMD-V。 - 要知道你的 CPU 是否支持 Intel-VT 或 AMD-V,键入下面的命令:
cat /sys/hypervisor/properties/capabilities
- The following output shows that Intel-VT support has been enabled in the BIOS. If the command returns nothing, then go into the BIOS Setup Utlility and look for a setting related to 'Virtualization', i.e. 'Intel(R) Virtualization Technology' under 'CPU' section on a IBM T60p. Enable and save the setting and do a power off to take effect.
xen-3.0-x86_32p hvm-3.0-x86_32 hvm-3.0-x86_32p
virt-install
安装红帽企业 Linux 5 Beta 2 Xen 完全虚拟化客户机。
- 要安装红帽企业 Linux 5 Beta 2 的 Xen 客户机,在命令行下键入:
virt-install
。 - 当被提示安装完全虚拟化客户机时,键入
yes
。 - 键入
rhel5b2-pv2
作为你的虚拟机名。 - 键入 500 作为分配的内存数量。
- 键入
/xen/rhel5b2-fv1.img
作为你的磁盘(客户机映像)。 - 输入 6 作为你的磁盘(客户机映像)大小。
- 键入
yes
来启用图形化支持。 - 键入
/dev/cdrom
作为虚拟 CD 映像。 - The VNC viewer appears within the installation window. If there is an error message that says “main: Unable to connect to host: Connection refused (111)”, then type the following command to proceed:
vncviewer localhost:5900
. VNC port 5900 refers to the first Xen guest that is running on VNC. If it doesn't work, you might need to use 5901, 5902, etc.
virt-manager
安装红帽企业 Linux 5 Beta 2 Xen 完全虚拟化客户机:
- 要安装红帽企业 Linux 5 Beta 2 的 Xen 半虚拟化客户机,在命令行提示下输入:
virt-manager
。 - 在 Open Connection 窗口,选择 Local Xen host,并点击 Connect。
- Start Red Hat's Virtual Machine Monitor application, and from the File menu, click on New.
- 点击 Forward。
- 键入
rhel5b2-fv2
作为你的系统名,然后点击 Forward。 - 选择 Fully virtualized,并点击 Forward。
- 指定 CD-ROM 或 DVD,并输入安装介质的路径。如果你将从 ISO 映像安装的话,指定 ISO 映像的位置。点击 Forward。
- 选择 Simple File,键入
/xen/rhel5b2-fv2.img
作为文件的位置。指定 6000 MB,并点击 Forward。 - 选择 500 作为你的虚拟机的启动和最大内存,然后点击 Forward。
- 点击 Finish 。
- 然后虚拟机控制台窗口将出现。
virt-manager
安装 RHEL3 Xen 完全虚拟化客户机。
virt-manager
安装红帽企业 Linux 3 Xen 客户机。
- 在这里你可以采用和实验步骤 6 相同的说明。
virt-manager
安装 RHEL4 Xen 完全虚拟化客户机。
virt-manager
安装红帽企业 Linux 4 Xen 客户机。
- 在这里你可以采用和实验步骤 6 相同的说明。
virt-manager
安装 Windows XP Xen 完全虚拟化客户机。
virt-manager
安装一个完全虚拟化的 Windows XP Xen 客户机。
- 要在 Windows XP 主机上安装红帽企业 Linux 5,在命令行下输入:
virt-manager
。 - 在 Open Connection 窗口里,选择 Local Xen host,然后点击 Connect。
- Start Red Hat's Virtual Machine Manager application, and from the File menu click on New.
- 点击 Forward。
- 键入
winxp
作为系统名,然后点击 Forward。 - 选择 Fully virtualized,并点击 Forward。
- 指定 CD-ROM 或 DVD,然后输入安装介质的路径。如果你将从 ISO 映像进行安装,指定 ISO 映像的位置。点击 Forward。
- 选择 Simple File,键入
/xen/winxp.img
作为文件的位置。指定 6000 MB,并点击 Forward。 - 选择 1024 作为虚拟机的启动和最大的内存数量,然后选择 2 作为 VCPU 的数量。点击 Forward 。
- 点击 Finish。
- 虚拟机控制台窗口将出现。象往常一样进行并结束安装。
- 选择把
C:\
分区格式化为 FAT 文件系统格式。红帽企业 Linux 5 没有 NTFS 内核模块。如果你想把分区格式化为 NTFS 格式,挂载或写入文件到 Xen 客户机映像里可能不是件简单的事。 - 在你第一次重新启动系统之后,编辑
winxp
客户机映像:losetup /dev/loop0 /xen/winxp.imgkpartx -av /dev/loop0mount /dev/mapper/loop0p1 /mntcp -prv $WINDOWS/i386 /mnt/
。这可以修复你在后面的 Windows 安装部分可能遇到的一个问题。 - 键入
xm create -c winxp/
手工重新启动 Xen 客户机。 - 在虚拟机管理者窗口,选择
winxp
Xen 客户机并点击 Open。 - 虚拟机控制台窗口会出现。象平常一样进行并结束安装。
- Whenever a 'Files Needed' dialog box appears, change the path
GLOBALROOT\DEVICE\CDROM0\I386
toC:\I386
. Depending on your installation, you may or may not see this problem. You may be prompted for missing files during the installation. Changing the path toC:\I386
should compensate for this problem. - 如果 Xen 客户机控制台不动了,点击
shutdown
,进行如下的修改:/etc/xen/winxp:#vnc=1#vncunused=1sdl=1#vcpus=2
。 - 重复步骤 14 并象平常一样进行安装。
附录 B. 实验 2
host1
和 host2
。
xm
)并与 xend 进行通信。要启用跨机器的 live 移植,你必须对它进行配置:
- 备份
xend-config.sxp
文件:cp -pr /etc/xen/xend-config.sxp /etc/xen/xend-config.sxp.default
- 编辑
/etc/xen/xend-config.sxp
并进行如下修改:#(xend-unix-server yes)(xend-relocation-server yes)(xend-relocation-port 8002)(xend-relocation-address '')(xend-relocation-hosts-allow '')#(xend-relocation-hosts-allow '^localhost$ ^localhost\\.localdomain$')
- 重启
xend:service
并xend restart
。
- 编辑
/etc/exports
并包含如下的一行:/xen *(rw,sync,no_root_squash)/
- 保存
/etc/exports
并重新启动 NFS 服务器。确保用default:service nfs startchkconfig nfs on
启动 NFS 服务器。 - 在
host1
上启动 NFS 服务器后,我们就可以挂载它:host2:mount host1:/xen
。 - 现在在
host1
上启动 Xen 客户机并选择fc6-pv1
(或实验 1 里的fc6-pv2
):xm create -c fc6-pv1
- 从
http://www.gnump3d.org/
下载gnump3d-2.9.9.9.tar.bz2
tarball。在gnump3d-2.9.9.9/
目录里解压这个 tarball 文件、编译并安装:gnump3d application:tar xvjf gnump3d-2.9.9.9.tar.bz2cd gnump3d-2.9.9.9/make install
- Create a
/home/mp3
directory and copy TruthHappens.ogg from Red Hat's Truth Happens page tomkdir /home/mp3wget -c http://www.redhat.com/v/ogg/TruthHappens.ogg
- 输入下面的命令来启动 streaming 服务器
command:gnump3d
- 在两台 Xen 主机的任何一台上,运行 Movie Player。如果没有安装,在运行 Movie Player 之前安装 totem 和 iso-codecs 软件包。点击 Applications,然后是 Sound & Video,最后选择 Movie Player。
- 点击 Movie,然后 Open Location,输入 http://guest:8888/TruthHappens.ogg。
- 在两台 Xen 主机的其中一台上运行
TruthHappens.ogg
文件。 - 执行从
host1
到host2
的 live 移植:xm migrate –live fc6-pv1 host2
- 用下面的命令在两台 Xen 主机上打开多个窗口终端:
watch -n1 xm list
- 观察 live 移植。注意完成这个移植需要多少时间。
gdm
starts up. Run VNC viewer and connect to the Xen guest. Play with the Xen guest when the live migration occurs. Attempt to pause/resume, and save/restore the Xen guest and observe what happens to the VNC viewer. If you connect to the VNC viewer via localhost:590x
, and do a live migration, you won't be able to connect to the VNC viewer again when it dies. This is a known bug.
附录 C. Revision History
修订历史 | ||||
---|---|---|---|---|
修订 2.0-11.400 | 2013-10-31 | |||
| ||||
修订 2.0-11 | 2012-07-18 | |||
| ||||
修订 5.1.0-10 | Fri Aug 3 2007 | |||
|