版 5.8
1801 Varsity Drive
Raleigh, NC 27606-2072 USA
Phone: +1 919 754 3700
Phone: 888 733 4281
Fax: +1 919 754 3701
ftpd
单行粗体
要看到文件您当前工作目录中文件my_next_bestselling_novel
的内容,请在 shell 提示符后输入cat my_next_bestselling_novel
命令并按 Enter 键执行该命令。
按 Enter 执行该命令。按 Ctrl+Alt+F2 切换到第一个虚拟终端。Ctrl+Alt+F1 返回您的 X-Windows 会话。
固定粗体
。例如:
与文件相关的等级包括用于文件系统的filesystem
、用于文件的file
以及用于目录的dir
。每个等级都有其自身相关的权限。
在主菜单条中选择鼠标首选项。在「按钮」标签中点击「惯用左手鼠标」 复选框并点击 切换到主鼠标按钮从左向右(让鼠标适合左手使用)。→ → 启动要在 gedit 文件中插入一个特殊字符,请在主菜单中选择 → → 。下一步在 字符映射表菜单条中选择 → ,在「搜索」字段输入字符名称并点击 按钮。您输入的字符会在「字符表」中突出出来。双击这个突出的字符将其放入「要复制的文本」字段,然后点击 按钮。现在切换回您的文档并在 gedit 菜单条中选择 → 。
固定粗斜体
或者 比例粗斜体
要使用 ssh 连接到远程机器,请在 shell 提示符后输入ssh
。如果远程机器是username
@domain.name
example.com
且您在该其机器中的用户名为 john,请输入ssh john@example.com
。mount -o remount
命令会重新挂载命名的文件系统。例如:要重新挂载file-system
/home
文件系统,则命令为mount -o remount /home
。要查看目前安装的软件包版本,请使用rpm -q
命令。它会返回以下结果:package
。
package-version-release
Publican 是一个 DocBook 发布系统。
Mono-spaced Roman
并显示为:
books Desktop documentation drafts mss photos stuff svn books_tests Desktop1 downloads images notes scripts svgs
Mono-spaced Roman
,但添加下面突出的语法:
package org.jboss.book.jca.ex1; import javax.naming.InitialContext; public class ExClient { public static void main(String args[]) throws Exception { InitialContext iniCtx = new InitialContext(); Object ref = iniCtx.lookup("EchoBean"); EchoHome home = (EchoHome) ref; Echo echo = home.create(); System.out.println("Created Echo"); System.out.println("Echo.echo('Hello') = " + echo.echo("Hello")); } }
5
.
NFS
、FTP
或者 HTTP
协议通过网络使用红帽企业版 Linux 5 安装树。
/var/lib/libvirt/images/
directory by default. If you use a different directory you must label the new directory according to SELinux policy. Refer to 第 18.2 节 “SELinux 和虚拟化” for details.
yum
安装 Xen 管理程序 for more information.
grub.conf
file.
virtio
的半虚拟设备是 PCI 设备。目前客户端最多可使用 32 个 PCI 设备。有些 PCI 设备对客户端运行至关重要,这些设备是不能删除的。默认需要的设备有:
fstab
file, the initrd
file or used by the kernel command line. If less privileged users, especially virtualized guests, have write access to whole partitions or LVM volumes the host system could be compromised.
/dev/sdb
). Virtualized guests with access to block devices may be able to access other block devices on the system or modify volume labels which can be used to compromise the host system. Use partitions (for example, /dev/sdb1
) or LVM volumes to prevent this issue.
phy
数是不受限制的。
/etc/modprobe.conf
中添加以下行:
options loop max_loop=64
# rmmod loop # modprobe loop
yum
命令和红帽网络(RHN)安装。
virt-manager
、libvirt
和 virt-viewer
以及所有相依性进行安装。
定制软件包(需要时)
%packages
部分附加以下软件包组:
%packages @xen
xen-ia64-guest-firmware
rhn_register
命令并根据提示进行操作。
yum
安装 Xen 管理程序xen
和 kernel-xen
软件包。xen
软件包中含有管理程序以及基本虚拟化工具。kernel-xen
软件包中含有修改的 linux 内核,它可作为虚拟机客户端在管理程序中运行。
xen
和 kernel-xen
软件包,请运行:
# yum install xen kernel-xen
xen-ia64-guest-firmware
)。您也可从 RHN 使用 yum
命令安装该软件包:
# yum install xen-ia64-guest-firmware
python-virtinst
virt-install
命令。
libvirt
libvirt
是一个可与管理程序互动的 API 程序库。libvirt
使用 xm
虚拟化构架以及 virsh
命令行工具管理和控制虚拟机。
libvirt-python
libvirt
API 提供的界面。
virt-manager
virt-manager
,也称 Virtual Machine Manager,它可为管理虚拟机提供图形工具。它使用 libvirt
程序库作为管理 API。
# yum install virt-manager libvirt libvirt-python python-virtinst
virt-manager
、libvirt
和 virt-viewer
进行安装。
定制软件包(需要时)
%packages
部分附加以下软件包组:
%packages @kvm
rhn_register
命令并根据提示进行操作。
yum
安装 KVM 管理程序kvm
软件包。kvm
软件包中含有 KVM 内核模块,它可在默认红帽企业版 Linux 内核中提供 KVM 管理程序。
kvm
软件包,请运行:
# yum install kvm
python-virtinst
virt-install
命令。
libvirt
libvirt
是一个可与管理程序互动的 API 程序库。libvirt
使用 xm
虚拟化构架以及 virsh
命令行工具管理和控制虚拟机。
libvirt-python
libvirt
API 提供的界面。
virt-manager
virt-manager
,也称 Virtual Machine Manager,它可为管理虚拟机提供图形工具。它使用 libvirt
程序库作为管理 API。
# yum install virt-manager libvirt libvirt-python python-virtinst
virt-install
进行此操作。本章论述了这两种方法。
virt-install
命令从命令行创建虚拟客户端。virt-install
可以交互方式使用,也可以使用脚本从而自动生成虚拟机。将 Kickstart 文件与 virt-install
共同使用即可进行虚拟机的自动安装。
virt-install
工具提供很多选项,可将其提交给命令行。要查看选项完整列表请运行:
$ virt-install --help
virt-install
man page 还记录了每个命令选项和重要变量。
qemu-img
是一个关联命令,可在 virt-install
前用来配置存储选项。
--vnc
option which opens a graphical window for the guest's installation.
rhel3support
的红帽企业版 Linux 3 客户端。这个示例使用的是 KVM 管理程序。
# virt-install --accelerate --hvm --connect qemu:///system \ --network network:default \ --name rhel3support --ram=756\ --file=/var/lib/libvirt/images/rhel3support.img \ --file-size=6 --vnc --cdrom=/dev/sr0
# virt-install --name fedora11 --ram 512 --file=/var/lib/libvirt/images/fedora11.img \ --file-size=3 --vnc --cdrom=/var/lib/libvirt/images/fedora11.iso
virt-manager
即虚拟机管理器,是创建和管理虚拟客户端的图形工具。
Open virt-manager
virt-manager
. Launch the application from the menu and submenu. Alternatively, run the virt-manager
command as root.
Optional: Open a remote hypervisor
Create a new guest
New guest wizard
Name the virtual machine
Choose virtualization method
kernel-xen
内核,则「半虚拟」选项就会是灰色的。
Select the installation method
.iso
file).
HTTP
, FTP
or NFS
.
HTTP
, FTP
or NFS
. The installation media URL must contain a Red Hat Enterprise Linux installation tree. This tree is hosted using NFS
, FTP
or HTTP
.
Installation media selection
ISO image or physical media installation
Network install tree installation
NFS
, FTP
or HTTP
. Optionally, a kickstart file can be specified to automated the installation. Kernel parameters can also be specified if required.
Network boot (PXE)
Storage setup
/var/lib/libvirt/images/
directory by default. In the default configuration, other directory locations for file-based images are prohibited by SELinux. If you use a different directory you must label the new directory according to SELinux policy. Refer to 第 18.2 节 “SELinux 和虚拟化” for details.
/var/lib/libvirt/images/
. If you are using a different location (such as /images/
in this example) make sure it is added to your SELinux policy and relabeled before you continue with the installation (later in the document you will find information on how to modify your SELinux policy).
Network setup
Memory and CPU allocation
Verify and start guest installation
virt-manager
. 第 8 章 客户端操作系统安装过程 contains step-by-step instructions to installing a variety of common operating systems.
创建新桥接
/etc/sysconfig/network-scripts/
目录中创建新网络脚本文件。这个示例创建了名为 ifcfg-installation
的文件,它可生成名为 installation
的桥接。
# cd /etc/sysconfig/network-scripts/ # vim ifcfg-installation DEVICE=installation TYPE=Bridge BOOTPROTO=dhcp ONBOOT=yes
TYPE=Bridge
, is case-sensitive. It must have uppercase 'B' and lower case 'ridge'.
ifup installation
command can start the individual bridge but it is safer to test the entire network restarts properly.
# service network restart
brctl show
命令查看系统中网络桥接的详情。
# brctl show bridge name bridge id STP enabled interfaces installation 8000.000000000000 no virbr0 8000.000000000000 yes
virbr0
是 libvirt
在默认以太网设备中用于网络地址转换(NAT)的默认桥接。
在新桥接中添加接口
BRIDGE
参数,使用在前一步中创建的桥接名称。
# Intel Corporation Gigabit Network Connection DEVICE=eth1 BRIDGE=installation BOOTPROTO=dhcp HWADDR=00:13:20:F7:6E:8E ONBOOT=yes
# service network restart
brctl show
命令验证添加的接口:
# brctl show bridge name bridge id STP enabled interfaces installation 8000.001320f76e8e no eth1 virbr0 8000.000000000000 yes
安全性配置
iptables
配置为允许通过桥接转发所有流量。
# iptables -I FORWARD -m physdev --physdev-is-bridged -j ACCEPT # service iptables save # service iptables restart
iptables
规则阻止处理桥接的流量。在 /etc/sysctl.conf
这添加以下行:
net.bridge.bridge-nf-call-ip6tables = 0 net.bridge.bridge-nf-call-iptables = 0 net.bridge.bridge-nf-call-arptables = 0
sysctl
配置的内核参数
# sysctl -p /etc/sysctl.conf
安装前重新启动 libvirt
libvirt
守护进程。
# service libvirtd reload
virt-install
安装,请附加 --network=bridge:installation
安装参数,其中 installation
是您桥接的名称。对于 PXE 安装请使用 --pxe
参数。
# virt-install --accelerate --hvm --connect qemu:///system \ --network=bridge:installation --pxe\ --name EL10 --ram=756 \ --vcpus=4 --os-type=linux --os-variant=rhel5 --file=/var/lib/libvirt/images/EL10.img \
选择 PXE
选择桥接
开始安装
virsh update-device Guest1 ~/Guest1.xml
(substituting your guest's name and XML file), and select OK to continue past this step.
kernel-xen
内核。
virt-manager
, refer to the procedure in 第 7.2 节 “使用 virt-manager 创建客户端”.
virt-install
的命令行工具创建半虚拟客户端。--vnc
选项显示图形安装。这个示例中的客户端名称为 rhel5PV
,磁盘映像文件为 rhel5PV.dsk
,红帽企业版 Linux 5 安装树的本地镜像为 ftp://10.1.1.1/trees/RHEL5-B2-Server-i386/
。使用您系统和网络的准确值替换这些值。
# virt-install -nrhel5PV
-r 500 \ -f /var/lib/libvirt/images/rhel5PV.dsk
-s 3 --vnc -p \ -lftp://10.1.1.1/trees/RHEL5-B2-Server-i386/
DHCP
(as shown below) or a static IP address:
Installation Number
字段输入:
rhn_register
命令确认您的红帽网络帐户详情。rhn_register
命令需要根用户访问。
virt-install
in 第 8.1 节 “将红帽企业版 Linux 5 作为半虚拟客户端安装”. If you used the default example the name is rhel5PV
.
virsh
重启客户端:
# virsh reboot rhel5PV
virt-manager
,选择您客户端的名称,点击 ,然后点击 。
kdump
. The use of kdump
is unsupported on para-virtualized guests.
yum
command or RHN. Click .
打开 virt-manager
virt-manager
会话。请在 菜单和 子菜单中启动 。另外也可作为根用户运行 virt-manager
。
选择管理程序
qemu
。
启动新虚拟机向导
为虚拟机命名
选择虚拟化方法
选择安装方法
定位安装介质
/var/lib/libvirt/images/
directory. Any other location may require additional configuration for SELinux, refer to 第 18.2 节 “SELinux 和虚拟化” for details.
存储设置
/var/lib/libvirt/images/
directory. Assign sufficient space for your virtualized guest and any applications the guest requires.
网络设置
内存和 CPU 分配
验证并启动客户端安装
安装红帽企业版 Linux
启动 virt-manager
为您的虚拟系统命名
选择虚拟化方法
选择安装方法
/var/lib/libvirt/images/
directory. Any other location may require additional configuration for SELinux, refer to 第 18.2 节 “SELinux 和虚拟化” for details.
Choose installation image
/var/lib/libvirt/images/
directory by default. In the default configuration, other directory locations for file-based images are prohibited by SELinux. If you use a different directory you must label the new directory according to SELinux policy. Refer to 第 18.2 节 “SELinux 和虚拟化” for details.
/var/lib/libvirt/images/
。如果您要使用不同的位置(比如在本示例中使用 /images/
),请确定将其添加到 SELinux 策略中并在您继续安装前对其进行重新标记(后面会介绍如何修改 SELinux 策略)。
联网设置
HAL
, once you get the dialog box in the Windows install select the 'Generic i486 Platform
' tab. Scroll through selections with the Up and Down arrows.
# virsh start WindowsGuest
WindowsGuest
是您的虚拟机名称。
virsh reboot WindowsGuestName
重启该客户端。您重启虚拟机后会看到如下信息:Setup is being restarted
。
virt-install
command. virt-install
can be used instead of virt-manager
This process is similar to the Windows XP installation covered in 第 8.3 节 “将 Windows XP 作为全虚拟客户端安装”.
virt-install
for installing Windows Server 2003 as the console for the Windows guest opens the virt-viewer
window promptly. The examples below installs a Windows Server 2003 guest with the virt-install
command.
Xen virt-install
# virt-install --virt-type=xen -hvm \ --name windows2003sp1 --file=/var/lib/libvirt/images/windows2003sp2.img \ --file-size=6 \ --cdrom=/var/lib/libvirt/images/ISOs/WIN/en_windows_server_2003_sp1.iso \ --vnc --ram=1024
KVM virt-install
# virt-install --accelerate --hvm --connect qemu:///system \ --name rhel3support \ --network network:default \ --file=/var/lib/libvirt/images/windows2003sp2.img \ --file-size=6 \ --cdrom=/var/lib/libvirt/images/ISOs/WIN/en_windows_server_2003_sp1.iso \ --vnc --ram=1024
Standard PC
作为 「计算机类型」。在 Windows 服务器 2003 虚拟客户端中需要更改 「计算机类型」。
打开 virt-manager
virt-manager
。请在 菜单和 子菜单中启动 程序。另外以根用户身份运行 virt-manager
命令。
选择管理程序
qemu
。
启动新虚拟机向导
虚拟机名称
选择虚拟化方法
选择安装方法
定位安装介质
/var/lib/libvirt/images/
directory. Any other location may require additional configuration for SELinux, refer to 第 18.2 节 “SELinux 和虚拟化” for details.
存储设置
/var/lib/libvirt/images/
directory. Assign sufficient space for your virtualized guest and any applications the guest requires.
联网设置
内存和 CPU 分配情况
验证并启动客户端安装
安装 Windows
/dev/xvd[a to z][1 to 15]
/dev/xvdb13
/dev/xvd[a to i][a to z][1 to 15]
/dev/xvdbz13
/dev/sd[a to p][1 to 15]
/dev/sda1
/dev/hd[a to t][1 to 63]
/dev/hdd3
dd
command. Replace /dev/fd0
with the name of a floppy device and name the disk appropriately.
# dd if=/dev/fd0 of=~/legacydrivers.img
virt-manager
创建一个客户端,该客户端使用位于 /var/lib/libvirt/images/rhel5FV-1.img
的映像运行全虚拟红帽企业版 Linux 安装。在这个示例中使用 Xen 管理程序。
virsh
命令为您的客户端映像生成 XML 配置文件。
# virsh dumpxml rhel5FV > rhel5FV.xml
# dd if=/dev/zero of=/var/lib/libvirt/images/rhel5FV-floppy.img bs=512 count=2880
<disk type='file' device='floppy'> <source file='/var/lib/libvirt/images/rhel5FV-floppy.img'/> <target dev='fda'/> </disk>
virsh shutdown
command instead.
# virsh destroy rhel5FV
# virsh create rhel5FV.xml
dd
命令创建稀疏文件。因为有数据完整性和性能问题,所以不建议使用稀疏文件。创建稀疏文件的速度较快,并可用来进行测试,但不应在产品环境中使用。
# dd if=/dev/zero of=/var/lib/libvirt/images/FileName.img bs=1M seek=4096 count=0
# dd if=/dev/zero of=/var/lib/libvirt/images/FileName.img bs=1M count=4096
Guest1
,该文件保存在用户主目录中。
# virsh dumpxmlGuest1
> ~/Guest1
.xml
Guest1.xml
)。找到描述存储设备的 "<disk>
" 元素。以下为磁盘元素示例:
<disk type='file' device='disk'> <driver name='tap' type='aio'/> <source file='/var/lib/libvirt/images/Guest1.img'/> <target dev='xvda'/> </disk>
<disk>
元素来添加附加存储。确定为虚拟块设备属性指定了设备名称,这些属性在每个客户端配置文件中必须是唯一的。以下是含有名为 FileName.img
的基于文件的附加存储容器的配置文件示例:
<disk type='file' device='disk'> <driver name='tap' type='aio'/> <source file='/var/lib/libvirt/images/Guest1.img'/> <target dev='xvda'/> </disk> <disk type='file' device='disk'> <driver name='tap' type='aio'/> <source file='/var/lib/libvirt/images/FileName.img'/> <target dev='hda'/> </disk>
# virsh create Guest1.xml
FileName.img
as the device called /dev/sdb
. This device requires formatting from the guest. On the guest, partition the device into one primary partition for the entire device then format the device.
n
添加新分区。
# fdisk /dev/sdb Command (m for help):
p
添加主分区。
Command action e extended p primary partition (1-4)
1
选择第一个分区。
Partition number (1-4): 1
Enter
输入默认首柱面。
First cylinder (1-400, default 1):
Enter
则分配整个磁盘。
Last cylinder or +size or +sizeM or +sizeK (2-400, default 400):
t
选择分区类型。
Command (m for help): t
1
。
Partition number (1-4): 1
83
选择 linux 分区。
Hex code (type L to list codes): 83
Command (m for help):w
Command (m for help):q
ext3
文件系统格式化新分区。
# mke2fs -j /dev/sdb1
# mount /dev/sdb1 /myfiles
fstab
file, the initrd
file or used by the kernel command line. If less privileged users, especially virtualized guests, have write access to whole partitions or LVM volumes the host system could be compromised.
/dev/sdb
). Virtualized guests with access to block devices may be able to access other block devices on the system or modify volume labels which can be used to compromise the host system. Use partitions (for example, /dev/sdb1
) or LVM volumes to prevent this issue.
multipath
配置该设备,如果需要则在该主机中永久保留。
virsh attach
command. Replace: myguest
with your guest's name, /dev/sdb1
with the device to add, and sdc
with the location for the device on the guest. The sdc
must be an unused device name. Use the sd*
notation for Windows guests as well, the guest will recognize the device correctly.
--type cdrom
parameter to the command for CD-ROM or DVD devices.
--type floppy
参数。
# virsh attach-diskmyguest
/dev/sdb1
sdc
--driver tap --mode readonly
/dev/sdb
on Linux or D: drive
, or similar, on Windows. This device may require formatting.
multipath
must use 单一路径配置. Systems running multipath
can use 多路径配置.
udev
. Only use this procedure for hosts which are not using multipath
.
/etc/scsi_id.config
文件。
options=-b
行。
# options=-b
options=-g
udev
配置为假设所有附加的 SCSI 都会返回 UUID。
scsi_id -g -s /block/sd*
。例如:
# scsi_id -g -s /block/sd* 3600a0b800013275100000015427b625e
/dev/sdc
的 UUID。
scsi_id -g -s /block/sd*
命令输出的 UUID 与访问该设备的计算机中的一致。
/etc/udev/rules.d
目录中创建名为 20-names.rules
的文件。添加到同一文件中的所有规则都使用相同的格式。规则格式如下:
KERNEL=="sd[a-z]", BUS=="scsi", PROGRAM="/sbin/scsi_id -g -s /block/%k", RESULT="UUID
", NAME="devicename
"
UUID
和 devicename
。这是如上示例中的一个规则:
KERNEL="sd*", BUS="scsi", PROGRAM="/sbin/scsi_id -g -s", RESULT="3600a0b800013275100000015427b625e", NAME="rack4row16"
udev
守护进程现在为该规则中的 UUID 搜索所有名为 /dev/sd*
的设备。当将匹配的设备连接到系统后,会根据该规则为这个设备分配一个名称。UUID 为 3600a0b800013275100000015427b625e 的设备会以 /dev/rack4row16
的形式出现。
/etc/rc.local
中附加这一行:
/sbin/start_udev
/etc/scsi_id.config
、/etc/udev/rules.d/20-names.rules
和 /etc/rc.local
文件中的更改复制到所有相关主机中。
/sbin/start_udev
multipath
软件包用于在计算机和存储设备间有超过一个物理路径的系统。multipath
为附加到红帽企业版 Linux 系统的网络存储设备提供容错、故障切换以及改进的性能。
multipath
environment requires defined alias names for your multipath devices. Each storage device has a UUID which acts as a key for the aliased names. Identify a device's UUID using the scsi_id
command.
# scsi_id -g -s /block/sdc
/dev/mpath
目录中生成。在下面的示例中 /etc/multipath.conf
文件定义了 4 个设备:
multipaths { multipath { wwid 3600805f30015987000000000768a0019 alias oramp1 } multipath { wwid 3600805f30015987000000000d643001a alias oramp2 } mulitpath { wwid 3600805f3001598700000000086fc001b alias oramp3 } mulitpath { wwid 3600805f300159870000000000984001c alias oramp4 } }
/dev/mpath/oramp1
, /dev/mpath/oramp2
, /dev/mpath/oramp3
and /dev/mpath/oramp4
. Once entered, the mapping of the devices' WWID to their new names are now persistent after rebooting.
virsh
with the attach-disk
parameter.
# virsh attach-disk [domain-id] [source] [target] --driver file --type cdrom --mode readonly
The source
and target
parameters are paths for the files and devices, on the host and guest respectively. The source
parameter can be a path to an ISO file or the device from the /dev
directory.
libvirt
installation provides NAT based connectivity to virtual machines out of the box. This is the so called 'default virtual network'. Verify that it is available with the virsh net-list --all
command.
# virsh net-list --all Name State Autostart ----------------------------------------- default active yes
# virsh net-define /usr/share/libvirt/networks/default.xml
/usr/share/libvirt/networks/default.xml
中定义的
# virsh net-autostart default Network default marked as autostarted
# virsh net-start default Network default started
libvirt
默认网络运行后,您将会看到独立的桥接设备。这个设备没有添加任何物理接口,因为它使用 NAT 和 IP 转发与外界连接,因此不要添加新接口。
# brctl show bridge name bridge id STP enabled interfaces virbr0 8000.000000000000 yes
libvirt
可添加 iptables
规则,该规则允许所有进入和来自附加到 virbr0
设备的客户端流量,该设备可处于 INPUT
、FORWARD
、OUTPUT
和 POSTROUTING
链中。libvirt
随后试图启用 ip_forward
参数。其它一些程序可能会禁用 ip_forward
,因此最佳选择是在 /etc/sysctl.conf
中添加以下内容。
net.ipv4.ip_forward = 1
<interface type='network'> <source network='default'/> </interface>
<interface type='network'> <source network='default'/> <mac address='00:16:3e:1a:b3:4a'/> </interface>
/etc/xen/xend-config.sxp
文件并更改以下行禁用默认 Xen 网络桥接:
(network-script network-bridge)
(network-script /bin/true)
/etc/sysconfig/network-scripts/
directory):
# chkconfig NetworkManager off # chkconfig network on # service NetworkManager stop # service network start
NM_CONTROLLED=no
" to the ifcfg-*
scripts used in the examples. If you do not either set this parameter or disable NetworkManager entirely, any bridge configuration will be overwritten and lost when NetworkManager next starts.
/etc/sysconfig/network-scripts
目录:
# cd /etc/sysconfig/network-scripts
ifcfg-eth0
定义已被设定为桥接一部分的物理网络接口:
DEVICE=eth0 # change the hardware address to match the hardware address your NIC uses HWADDR=00:16:76:D6:C9:45 ONBOOT=yes BRIDGE=br0
MTU
variable to the end of the configuration file.
MTU=9000
/etc/sysconfig/network-scripts
目录中创建名为 ifcfg-br0
和类似的新网络脚本。br0
是桥接名称,它可以是任何名称,只要该文件名称与 DEVICE 参数一致即可。
DEVICE=br0 TYPE=Bridge BOOTPROTO=dhcp ONBOOT=yes DELAY=0
ifcfg-br0
file). Network access will not function as expected if IP address details are configured on the physical interface that the bridge is connected to.
TYPE=Bridge
, is case-sensitive. It must have uppercase 'B' and lower case 'ridge'.
# service network restart
iptables
配置为允许使用桥接转发所有流量。
# iptables -I FORWARD -m physdev --physdev-is-bridged -j ACCEPT # service iptables save # service iptables restart
iptables
规则阻止桥接的流量。请在 /etc/sysctl.conf
附加以下行:
net.bridge.bridge-nf-call-ip6tables = 0 net.bridge.bridge-nf-call-iptables = 0 net.bridge.bridge-nf-call-arptables = 0
sysctl
配置的内核参数。
# sysctl -p /etc/sysctl.conf
libvirt
守护进程。
# service libvirtd reload
# brctl show bridge name bridge id STP enabled interfaces virbr0 8000.000000000000 yes br0 8000.000e0cb30550 no eth0
virbr0
桥接。不要试图将物理设备附加到 virbr0
。virbr0
桥接只用于网络地址转换(NAT)连接性。
virsh
(第 25 章 使用 virsh 管理客户端) and virt-manager
(第 26 章 用虚拟机管理器(virt-manager)管理客户端). Those chapters provide a detailed description of the networking configuration tasks using both tools.
system-config-network
应用程序配置另一个网络接口。另外还可以在 /etc/sysconfig/network-scripts/
目录中创建名为 ifcfg-ethX
的文件,其中 X
只要不是正在使用中的数字即可。以下是为第二个名为 eth1
的网络接口配置文件示例:
$ cat /etc/sysconfig/network-scripts/ifcfg-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 the line (network-xen-multi-bridge)
. A typical xend-config.sxp
file should have the following line. Comment this line out. Use the # symbol to comment out lines.
network-script network-bridge
network-xen-multi-bridge
parameter to enable multiple network bridges.
#network-script network-bridge network-script network-xen-multi-bridge
network-xen-multi-bridge.sh
in the /etc/xen/scripts/
directory. A sample scripts is below, this example script will create two Xen network bridges (xenbr0 and xenbr1) one will be attached to eth1 and the other one to eth0. If you want to create additional bridges just follow the example in the script and copy nad paste the lines as required:
#!/bin/sh # network-xen-multi-bridge # Exit if anything goes wrong. set -e # First arg is the 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
# chmod +x /etc/xen/scripts/network-xen-multi-bridge.sh
# service network restart
virt-manager
创建客户端时请使用「虚拟网络」适配器。在红帽企业版 Linux 5.1 及更新的版本中,网络管理器默认可管理虚拟网络设备。
<interface type='network'> <mac address='AA:AA:AA:AA:AA:AA'/> <source network='default'/> <target dev='vnet0'/> <model type='virtio'/> </interface>
xm
配置文件中将虚拟网络设备标记为 "vif
"。
ifup
or ifdown
calls to the network interface it is using. In addition wireless network cards do not work well in a virtualization environment due to Xen's (default) bridged network usage.
dummy0
. This will also allow you to use a hidden IP address space for your guests.
/etc/modprobe.conf
中添加以下行:
alias dummy0 dummy options dummy numdummies=1
/etc/sysconfig/network-scripts/ifcfg-dummy0
文件:
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
/etc/xen/xend-config.sxp
文件,使其包含条目 netdev=dummy0
:
(network-script 'network-bridge bridge=xenbr0 netdev=dummy0')
/etc/sysconfig/network
in the guest and modify the default gateway to point to dummy0
. If you are using a static IP, set the guest's IP address to exist on the same subnet as dummy0
.
NETWORKING=yes HOSTNAME=localhost.localdomain GATEWAY=10.1.1.1 IPADDR=10.1.1.10 NETMASK=255.255.255.0
/etc/init.d/xenLaptopNAT
中,并生成软链接 /etc/rc3.d/S99xenLaptopNAT
。这样就可在引导时自动启动 NAT。
#!/bin/bash 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
dnsmasq
的具体方法:
dnsmasq.tgz
. The tar archive includes the following files:
nm-dnsmasq
可用于 NetworkManager 的调度程序脚本。它会在 NetworkManager 每次侦测到连接性改变时运行,并强制重启/重新载入 dnsmasq。应将其复制到 /etc/NetworkManager/dispatcher.d/nm-dnsmasq
中。
xenDNSmasq
可作为 /etc/init.d/xenDNSmasq
的主要启动和关闭脚本。
dnsmasq.conf
是 /etc/dnsmasq.conf
的示例配置文件。
dnsmasq
是 /usr/local/sbin/dnsmasq
的二进制映像。
/usr/local/sbin/dnsmasq
中加入二进制码),您需要编辑您的 dnsmasq 配置文件。该文件位于 /etc/dnsmaqs.conf
。
interface
参数允许 dnsmasq
只为 DHCP
和 DNS
请求在指定接口进行侦听。这可以是 dummy 接口,但不可以是您的公共接口或者本地回送接口。如果多于一个接口,请添加另一个 interface
行。interface=dummy0
是一个示例,即在 dummy0
接口中侦听。
dhcp-range
要启用整合的 DHCP
服务器,您需要提供可租用的地址范围,有时还需要租用时间。如果您有多个网络,您将需要为每个需要提供 DHCP
服务的网络重复此操作。例如(网络 10.1.1.*,租期 12 小时):dhcp-range=10.1.1.10,10.1.1.50,255.255.255.0,12h
。
dhcp-option
可覆盖由 dnsmasq 提供的默认路由,即假设路由器与运行 dnsmasq 的机器是同一台机器。例如:dhcp-option=3,10.1.1.1
xenDNSmasq
复制到 /etc/init.d
中
chkconfig --add xenDNSmasq
chkconfig --levels 345 xenDNSmasq on
dnsmasq
配置为每次 NetworkManager 侦测到连接性改变时重新启动,您可以使用我们提供的脚本 nm-dnsmasq
。
nm-dnsmasq
脚本复制到 /etc/NetworkManager/dispatcher.d/
中
dnsmasq
还可探测您 /etc/resolv.conf
文件的改变,并自动重新载入它们(例如:如果您启动了 VPN 会话)。
nm-dnsmasq
和 xenDNSmasq
脚本还将会设定 NAT,以便它们可以访问公共网络。
pv-on-hvm
模块。这就是说半虚拟驱动程序可用于红帽企业版 Linux 4.7 及更新的客户端,或者红帽企业版 Linux 5.3 或者更新的客户端。
kmod-xenpv
.
kmod-xenpv
,
modules-init-tools
(for versions prior to Red Hat Enterprise Linux 4.6z you require modules-init-tools-3.1-0.pre5.3.4.el4_6.1
or greater), and
modversions
.
kmod-xenpv
.
/lib
file system.
# rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' kernel
内核构架 | 红帽企业版 Linux 3 | 红帽企业版 Linux 4 | 红帽企业版 Linux 5 |
---|---|---|---|
athlon | 支持的(AMD) | ||
athlon-SMP | 支持的(AMD) | ||
i32e | 支持的(Intel) | ||
i686 | 支持的(Intel) | 支持 | 支持 |
i686-PAE | 支持 | ||
i686-SMP | 支持的(Intel) | 支持 | |
i686-HUGEMEM | 支持的(Intel) | 支持 | |
x86_64 | 支持的(AMD) | 支持 | 支持 |
x86_64-SMP | 支持的(AMD) | 支持 | |
x86_64-LARGESMP | 支持 | ||
Itanium(IA64) | 支持 |
# rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' kernel
kernel-PAE-2.6.18-53.1.4.el5.i686
GRUB
GRUB
无法访问半虚拟块设备,因此无法在使用半虚拟块设备驱动程序的设备中引导客户端,特别是那些包含主引导记录(MBR)、引导装载程序(GRUB
)或者内核 initrd
映像的磁盘。就是说,任何包含 /boot
目录或者分区的磁盘都无法使用半虚拟块设备驱动程序。
xen-pci-platform
模块。
客户端内核类型 | 需要的主机内核类型 |
---|---|
ia32e(UP 和 SMP) | x86_64 |
i686 | i686 |
i686-SMP | i686 |
i686-HUGEMEM | i686 |
客户端内核类型 | 需要的主机内核类型 |
---|---|
athlon | i686 |
athlon-SMP | i686 |
x86_64 | x86_64 |
x86_64-SMP | x86_64 |
MBR
和引导装载程序(GRUB
)的磁盘以及 /boot
分区使用半虚拟驱动程序。这个分区可能非常小,因为它只要可以装下 /boot
文件即可。
/
、/usr
)或者逻辑卷。
/boot
分区就可以使用虚拟块设备驱动程序。
rpm
或者 yum
命令安装这些软件包。rpm
程序会在 /lib/modules/[%kversion][%kvariant]/extra/xenpv/%release
中安装以下四个新内核模块:
xen_platform_pci.ko
,
xen_balloon.ko
,
xen_vbd.ko
,
xen_vnif.ko
.
xen-vbd
) disk driver.
<disk type='file' device='disk'> <driver name='file'/> <source file='/dev/hda6'/> <target dev='hda'/> </disk>
<disk type='file' device='disk'> <driver name='tap' type='aio'/> <source file='/dev/hda6'/> <target dev='xvda'/> </disk>
# xm start YourGuestName
YourGuestName
is the name of the configuration file or the guest operating system's name as defined in its configuration file in the name = "os_name" parameter.
kernel-2.4.21-60.EL
for all the required headers.
kmod-xenpv
rpm 复制到您的客户端操作系统中。
rpm
程序安装 RPM 软件包。请确定您正确选择了客户端操作系统变体和构架所需软件包。
[root@rhel3]# rpm -ivh kmod-xenpv*
[root@rhel3]# mkdir -p /lib/modules/'uname -r'/extra/xenpv [root@rhel3]# cp -R /lib/modules/2.4.21-52.EL[%kvariant]/extra/xenpv/%release \ /lib/modules/'uname -r'/extra/xenpv [root@rhel3]# depmod -ae [root@rhel3]# modprobe xen-vbd [root@rhel3]# modprobe xen-vnif
insmod
会生成警告信息,因为红帽企业版 Linux 3 启用了 MODVERSIONS。可以忽略这些警告。
/etc/modules.conf
并确定您为 eth0
定义了类似下面的别名。如果您计划配置多个接口,请为每个接口添加一行。
alias eth0 xen-vnif
/etc/rc.local
并添加行:
insmod /lib/modules/'uname -r'/extra/xenpv/%release/xen-vbd.o
#shutdown -h now
”)。
/etc/xen/YourGuestName
with a text editor, performing the following changes:
vif=
”部分的“type=ioemu
”条目。
xen-vbd
)磁盘驱动程序访问它们。
<disk type='file' device='disk'> <driver name='file'/> <source file='/dev/hda6'/> <target dev='hda'/> </disk>
<disk type='file' device='disk'> <driver name='tap' type='aio'/> <source file='/dev/hda6'/> <target dev='xvda'/> </disk>
# xm start YourGuestName
YourGuestName
is the name of the configuration file or the guest operating system's name as defined in its configuration file in the name = "os_name" parameter.
weak-modules
和 modversions
。要插入该模块请执行以下命令:
insmod xen_vbd.ko
xen-vbd
命令为块设备生成特殊文件。下面的步骤将介绍如何创建和注册半虚拟块设备。
#!/bin/sh module="xvd" mode="664" major=`awk "\\$2==\"$module\" {print \\$1}" /proc/devices` # < mknod for as many or few partitions on xvd disk attached to FV guest > # change/add xvda to xvdb, xvbd, etc. for 2nd, 3rd, etc., disk added in # in xen config file, respectively. mknod /dev/xvdb b $major 16 mknod /dev/xvdb1 b $major 17 mknod /dev/xvdb2 b $major 18 chgrp disk /dev/xvd* chmod 0660 /dev/xvd*
# mknod /dev/xvdc b $major 16 # mknod /dev/xvdc1 b $major 17
# mknod /dev/xvdd b $major 32 # mknod /dev/xvdd1 b $major 33
[root@rhel3]# cat /proc/partitions major minor #blocks name 3 0 10485760 hda 3 1 104391 hda1 3 2 10377990 hda2 202 16 64000 xvdb 202 17 32000 xvdb1 202 18 32000 xvdb2 253 0 8257536 dm-0 253 1 2031616 dm-1
xvdb
”。
[root@rhel3]# mkdir /mnt/pvdisk_p1 [root@rhel3]# mkdir /mnt/pvdisk_p2
[root@rhel3]# mount /dev/xvdb1 /mnt/pvdisk_p1 [root@rhel3]# mount /dev/xvdb2 /mnt/pvdisk_p2
[root@rhel3]# df /mnt/pvdisk_p1 Filesystem 1K-blocks Used Available Use% Mounted on /dev/xvdb1 32000 15 31985 1% /mnt/pvdisk_p1
/etc/fstab
文件以便在引导过程中挂载设备。添加以下行:
/dev/xvdb1 /mnt/pvdisk_p1 ext3 defaults 1 2 /dev/xvdb2 /mnt/pvdisk_p2 ext3 defaults 1 2
dom0
), the "noapic
" parameter should be added to the kernel boot line in your virtual guest's /boot/grub/grub.conf
entry as seen below. Keep in mind your architecture and kernel version may be different.
kernel /vmlinuz-2.6.9-67.EL ro root=/dev/VolGroup00/rhel4_x86_64 rhgb noapic
kmod-xenpv
、modules-init-tools
和 modversions
RPM 复制到您的客户端操作系统中。
rpm
程序安装 RPM 软件包。请确定为您的客户端操作系统变体和构架正确选择了所需软件包。这个软件包需要更新的模块初始工具(module-init-tool),在红帽企业版 Linux 4-6-z 内核及更新的内核中有这个工具。
[root@rhel4]# rpm -ivh modversions [root@rhel4]# rpm -Uvh module-init-tools [root@rhel4]# rpm -ivh kmod-xenpv*
cat /etc/modprobe.conf
to verify you have an alias for eth0
like the one below. If you are planning to configure multiple interfaces add an additional line for each interface. If it does not look like the entry below change it.
alias eth0 xen-vnif
#shutdown -h now
”)。
/etc/xen/YourGuestsName
中的客户端配置文件:
vif=
”部分的“type=ioemu
”条目。
xen-vbd
)磁盘驱动程序访问它们。
disk=
”部分为每个附加物理设备、LUN、分区或者卷添加类似下面的条目。原来的“disk=
”条目类似如下:
disk = [ "file:/var/lib/libvirt/images/rhel4_64_fv.dsk,hda,w"]
disk = [ "file:/var/lib/libvirt/images/rhel3_64_fv.dsk,hda,w", "tap:aio:/var/lib/libvirt/images/UserStorage.dsk,xvda,w" ]
tap:aio
”。
virsh
命令引导虚拟机:
# virsh start YourGuestName
kudzu
会询问“Keep or Delete the Realtek Network device”以及“Configure the xen-bridge device”。您应该配置 xen-bridge
并删除 Realtek 物理设备。
dom0
), the "noapic
" parameter should be added to the kernel boot line in your virtual guest's /boot/grub/grub.conf
entry as seen below. Keep in mind your architecture and kernel version may be different.
kernel /vmlinuz-2.6.9-67.EL ro root=/dev/VolGroup00/rhel4_x86_64 rhgb noapic
[root@rhel4]# cat /proc/partitions major minor #blocks name 3 0 10485760 hda 3 1 104391 hda1 3 2 10377990 hda2 202 0 64000 xvdb 202 1 32000 xvdb1 202 2 32000 xvdb2 253 0 8257536 dm-0 253 1 2031616 dm-1
xvdb
”。
[root@rhel4]# mkdir /mnt/pvdisk_p1 [root@rhel4]# mkdir /mnt/pvdisk_p2
[root@rhel4]# mount /dev/xvdb1 /mnt/pvdisk_p1 [root@rhel4]# mount /dev/xvdb2 /mnt/pvdisk_p2
[root@rhel4]# df /mnt/pvdisk_p1 Filesystem 1K-blocks Used Available Use% Mounted on /dev/xvdb1 32000 15 31985 1% /mnt/pvdisk_p1
/etc/fstab
文件以便在引导过程中挂载设备。添加以下行:
/dev/xvdb1 /mnt/pvdisk_p1 ext3 defaults 1 2 /dev/xvdb2 /mnt/pvdisk_p2 ext3 defaults 1 2
xen-vbd
驱动程序。在客户端中执行以下命令,使用半虚拟驱动程序的正确发行版本替换 %release。
# insmod /lib/modules/'uname -r'/weak-updates/xenpv/%release/xen_vbd.ko
#shutdown -h now
”)。
/etc/xen/YourGuestsName
中的客户端配置文件:
vif=
”部分的“type=ioemu
”条目。
xen-vbd
)磁盘驱动程序访问它们。
disk=
”部分为每个附加物理设备、LUN、分区或者卷添加类似下面的条目。原来的“disk=
”条目类似如下:
disk = [ "file:/var/lib/libvirt/images/rhel4_64_fv.dsk,hda,w"]
disk = [ "file:/var/lib/libvirt/images/rhel3_64_fv.dsk,hda,w", "tap:aio:/var/lib/libvirt/images/UserStorage.dsk,xvda,w" ]
tap:aio
”。
virsh
命令引导虚拟机:
# virsh start YourGuestName
[root@rhel5]# ifconfig eth0
[root@rhel5]# cat /proc/partitions major minor #blocks name 3 0 10485760 hda 3 1 104391 hda1 3 2 10377990 hda2 202 0 64000 xvdb 202 1 32000 xvdb1 202 2 32000 xvdb2 253 0 8257536 dm-0 253 1 2031616 dm-1
xvdb
”。
[root@rhel5]# mkdir /mnt/pvdisk_p1 [root@rhel5]# mkdir /mnt/pvdisk_p2
[root@rhel5]# mount /dev/xvdb1 /mnt/pvdisk_p1 [root@rhel5]# mount /dev/xvdb2 /mnt/pvdisk_p2
[root@rhel5]# df /mnt/pvdisk_p1 Filesystem 1K-blocks Used Available Use% Mounted on /dev/xvdb1 32000 15 31985 1% /mnt/pvdisk_p1
/etc/fstab
文件以便在引导过程中挂载设备。添加以下行:
/dev/xvdb1 /mnt/pvdisk_p1 ext3 defaults 1 2 /dev/xvdb2 /mnt/pvdisk_p2 ext3 defaults 1 2
dom0
), the "noapic
" parameter should be added to the kernel boot line in your virtual guest's /boot/grub/grub.conf
entry as seen below. Keep in mind your architecture and kernel version may be different.
kernel /vmlinuz-2.6.9-67.EL ro root=/dev/VolGroup00/rhel4_x86_64 rhgb noapic
/etc/modprobe.d/blacklist
file. Blacklist 8139cp
and 8139too
for the RealTek 8139 and e1000
for the virtualized Intel e1000 NIC.
8139cp
8139too
e1000
/etc/sysconfig/network-scripts
directory.
xen_emul_unplug=never
virt-manager
中为客户端打开控制台窗口并以 root
身份登录。
/etc/modprobe.conf
中有“alias eth0 xen-vnif
”这样一行。
# cat /etc/modprobe.conf alias eth0 xen-vnif
eth0
execute “# ifconfig eth0
”. If you receive an error about the device not existing you should load the modules manually as outlined in 第 36.4 节 “手动载入半虚拟驱动程序”.
ifconfig eth0 eth0 Link encap:Ethernet HWaddr 00:00:00:6A:27:3A BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:630150 errors:0 dropped:0 overruns:0 frame:0 TX packets:9 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:109336431 (104.2 MiB) TX bytes:846 (846.0 b)
# system-config-network
”. Click on the “ ” button to start the network card configuration.
ifconfig eth0 eth0 Link encap:Ethernet HWaddr 00:16:3E:49:E4:E0 inet addr:192.168.78.180 Bcast:192.168.79.255 Mask:255.255.252.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:630150 errors:0 dropped:0 overruns:0 frame:0 TX packets:501209 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:109336431 (104.2 MiB) TX bytes:46265452 (44.1 MiB)
/etc/xen/YourGuestName
中的配置文件,用您的客户端名称替换 YourGuestName
。
vif = [ "mac=00:16:3e:2e:c5:a9,bridge=xenbr0" ]
vif=
”部分添加类似如下的附加条目:
vif = [ "mac=00:16:3e:2e:c5:a9,bridge=xenbr0", "mac=00:16:3e:2f:d5:a9,bridge=xenbr0" ]
# echo 'import virtinst.util ; print virtinst.util.randomMAC()' | python
/etc/modules.conf
或者在红帽企业版 Linux 4 和 5 中将更新添加到 /etc/modprobe.conf
。为您添加的每个新接口添加新的别名。
alias eth1 xen-vnif
# ifconfig eth1
redhat-config-network
(红帽企业版 Linux 3)或者 system-config-network
(红帽企业版 Linux 4 和红帽企业版 Linux 5)配置新的网络接口。
/etc/xen/YourGuestName
的客户端配置文件,用您的客户端名称替换 YourGuestName
。原来的条目如下:
disk = [ "file:/var/lib/libvirt/images/rhel5_64_fv.dsk,hda,w"]
disk=
”部分添加附加条目。使用半虚拟驱动程序的存储条目应该类似如下。“tap:aio
”参数指导管理程序使用半虚拟驱动程序。
disk = [ "file:/var/lib/libvirt/images/rhel5_64_fv.dsk,hda,w", "tap:aio:/var/lib/libvirt/images/UserStorage1.dsk,xvda,w" ]
disk=
”部分添加它们并以逗号隔开。
xvd
' device, that is for your second storage entity it would be 'xvdb
' instead of 'xvda
'.
disk = [ "file:/var/lib/libvirt/images/rhel5_64_fv.dsk,hda,w", "tap:aio:/var/lib/libvirt/images/UserStorage1.dsk,xvda,w", "tap:aio:/var/lib/libvirt/images/UserStorage2.dsk,xvdb,w" ]
# cat /proc/partitions major minor #blocks name 3 0 10485760 hda 3 1 104391 hda1 3 2 10377990 hda2 202 0 64000 xvda 202 1 64000 xvdb 253 0 8257536 dm-0 253 1 2031616 dm-1
xvdb
”中。
/etc/fstab
文件以便在引导时挂载设备和分区。
# mkdir /mnt/pvdisk_xvda # mkdir /mnt/pvdisk_xvdb # mount /dev/xvda /mnt/pvdisk_xvda # mount /dev/xvdb /mnt/pvdisk_xvdb # df /mnt Filesystem 1K-blocks Used Available Use% Mounted on /dev/xvda 64000 15 63985 1% /mnt/pvdisk_xvda /dev/xvdb 64000 15 63985 1% /mnt/pvdisk_xvdb
下载驱动程序
yum
command.
# yum install virtio-win
/usr/share/virtio-win/
目录中安装安装光驱映像 virtio-win.iso
。
安装半虚拟驱动程序
virt-manager
在 Windows 客户端中挂载光驱映像” to add a CD-ROM image with virt-manager
and then install the drivers.
virt-manager
在 Windows 客户端中挂载光驱映像Open virt-manager and the virtualized guest
virt-manager
, select your virtualized guest from the list by double clicking the guest name.
Open the hardware tab
Select the device type
Select the ISO file
/usr/share/virtio-win/virtio-win.iso
.
Disc assigned
Reboot
Open My Computer
Select the correct installation files
RHEV-Block.msi
for 32-bit guests or RHEV-Block64.msi
for 64-bit guests),
RHEV-Network.msi
for 32-bit guests or RHEV-Block64.msi
for 64-bit guests),
Install the block device driver
Start the block device driver installation
RHEV-Block.msi
or RHEV-Block64.msi
.
Confirm the exception
Finish
Install the network device driver
Start the network device driver installation
RHEV-Network.msi
or RHEV-Network64.msi
.
Performance setting
Value | Action |
---|---|
0 | Disable TCP timestamps and window scaling. |
1 | Enable TCP window scaling. |
2 | Enable TCP timestamps. |
3 | Enable TCP timestamps and window scaling. |
Confirm the exception
Finish
Reboot
viostor.vfd
附加为一个软盘
Windows Server 2003
Windows Server 2008
virtio
driver instead of virtualized IDE driver. This example edits libvirt configuration files. Alternatively, virt-manager
, virsh attach-disk
or virsh attach-interface
can add a new device using the para-virtualized drivers 第 13.4 节 “在新设备中使用 KVM 半虚拟驱动程序”.
<disk type='file' device='disk'> <source file='/var/lib/libvirt/images/disk1.img'/> <target dev='vda' bus='ide'/> </disk>
virtio
可让该条目使用半虚拟设备。
<disk type='file' device='disk'>
<source file='/var/lib/libvirt/images/disk1.img'/>
<target dev='vda' bus='virtio'/>
</disk>
virt-manager
创建使用 KVM 半虚拟驱动程序的新设备。
virsh attach-disk
或者 virsh attach-interface
命令可附加使用半虚拟驱动程序的设备。
virt-manager
中双击客户端名称打开虚拟客户端。
Enable the Intel VT-d extensions
Activate Intel VT-d in the kernel
intel_iommu=on
parameter to the kernel line of the kernel line in the /boot/grub/grub.conf
file.
grub.conf
file with Intel VT-d activated.
default=0 timeout=5 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title Red Hat Enterprise Linux Server (2.6.18-190.el5) root (hd0,0) kernel /vmlinuz-2.6.18-190.el5 ro root=/dev/VolGroup00/LogVol00 intel_iommu=on initrd /initrd-2.6.18-190.el5.img
Ready to use
Enable AMD IOMMU extensions
iommu=on
parameter to the hypervisor command line. Modify the /boot/grub/grub.conf
file as follows to enable PCI passthrough:
default=0 timeout=5 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title Red Hat Enterprise Linux Server (2.6.18-192.el5) root (hd0,0) kernel /xen.gz-2.6.18-192.el5 iommu=on module /vmlinuz-2.6.18-192.el5xen ro root=/dev/VolGroup00/LogVol00 module /initrd-2.6.18-190.el5xen.img
pci_8086_3a6c
, and a fully virtualized guest named win2k3
.
Identify the device
virsh nodedev-list
command lists all devices attached to the system. The --tree
option is useful for identifying devices attached to the PCI device (for example, disk controllers and USB controllers).
# virsh nodedev-list --tree
# virsh nodedev-list | grep pci
****
is a four digit hexadecimal code):
pci_8086_****
lspci
output to lspci -n
(which turns off name resolution) output can assist in deriving which device has which device identifier code.
virsh nodedev-dumpxml
command:
# virsh nodedev-dumpxml pci_8086_3a6c <device> <name>pci_8086_3a6c</name> <parent>computer</parent> <capability type='pci'> <domain>0</domain> <bus>0</bus> <slot>26</slot> <function>7</function> <id='0x3a6c'>82801JD/DO (ICH10 Family) USB2 EHCI Controller #2</product> <vendor id='0x8086'>Intel Corporation</vendor> </capability> </device>
# virsh nodedev-dettach pci_8086_3a6c Device pci_8086_3a6c dettached
$ printf %x 0 0 $ printf %x 26 1a $ printf %x 7 7
bus='0x00' slot='0x1a' function='0x7'
virsh edit
(or virsh attach device) and add a device entry in the <devices>
section to attach the PCI device to the guest. Only run this command on offline guests. Red Hat Enterprise Linux does not support hotplugging PCI devices at this time.
# virsh edit win2k3
<hostdev mode='subsystem' type='pci' managed='yes'>
<source>
<address domain='0x0000' bus='0x00' slot='0x1a' function='0x7'/>
</source>
</hostdev>
ehci
driver is loaded by default for the USB PCI controller.
$ readlink /sys/bus/pci/devices/0000\:00\:1d.7/driver ../../../bus/pci/drivers/ehci_hcd
$ virsh nodedev-dettach pci_8086_3a6c
$ readlink /sys/bus/pci/devices/0000\:00\:1d.7/driver ../../../bus/pci/drivers/pci-stub
# setsebool -P virt_use_sysfs 1
# virsh start win2k3
virt-manager
tool. The following procedure adds a 2 port USB controller to a virtualized guest.
Identify the device
virsh nodedev-list
command lists all devices attached to the system. The --tree
option is useful for identifying devices attached to the PCI device (for example, disk controllers and USB controllers).
# virsh nodedev-list --tree
# virsh nodedev-list | grep pci
****
is a four digit hexadecimal code):
pci_8086_****
lspci
output to lspci -n
(which turns off name resolution) output can assist in deriving which device has which device identifier code.
Detach the PCI device
# virsh nodedev-dettach pci_8086_3a6c Device pci_8086_3a6c dettached
Power off the guest
Open the hardware settings
Add the new device
Select a PCI device
Confirm the new device
--host-device
parameter.
Identify the PCI device
virsh nodedev-list
command lists all devices attached to the system. The --tree
option is useful for identifying devices attached to the PCI device (for example, disk controllers and USB controllers).
# virsh nodedev-list --tree
# virsh nodedev-list | grep pci
****
is a four digit hexadecimal code):
pci_8086_****
lspci
output to lspci -n
(which turns off name resolution) output can assist in deriving which device has which device identifier code.
Add the device
virsh nodedev
command as the value for the --host-device
parameter.
# virt-install \
-n hostdev-test -r 1024 --vcpus 2 \
--os-variant fedora11 -v --accelerate \
-l http://download.fedoraproject.org/pub/fedora/linux/development/x86_64/os \
-x 'console=ttyS0 vnc' --nonetworks --nographics \
--disk pool=default,size=8 \
--debug --host-device=pci_8086_10bd
Complete the installation
/etc/modprobe.conf
hides the device from dom0. Either the bnx2
module must be reloaded or the host must be restarted.
install bnx2 /sbin/modprobe pciback; /sbin/modprobe --first-time --ignore-install bnx2 options pciback hide=(0000:09:00.0)
/etc/modprobe.conf
to hide multiple devices.
options pciback hide=(0000:09:00.0)(0000:0a:04.1)
virsh
(第 14.1 节 “Adding a PCI device with virsh” - Step 5);
virt-manager
(第 14.2 节 “Adding a PCI device with virt-manager”); or
virt-install
(第 14.3 节 “PCI passthrough with virt-install”)
/boot/grub/grub.conf
file to enable SR-IOV. To enable SR-IOV with Xen for Intel systems append the pci_pt_e820_access=on
parameter to the kernel.
default=0 timeout=5 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title Red Hat Enterprise Linux Server (2.6.18-192.el5xen) root (hd0,0) kernel /xen.gz-2.6.18-192.el5 iommu=1 module /vmlinuz-2.6.18-192.el5xen ro root=/dev/VolGroup00/LogVol00 pci_pt_e820_access=on module /initrd-2.6.18-192.el5xen.img
Enable Intel VT-d in BIOS and in the kernel
Verify support
lspci
command to verify if the device was detected.
# lspci 03:00.0 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01) 03:00.1 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)
Start the SR-IOV kernel modules
modprobe
command. The Intel 82576 network interface card uses the igb
driver kernel module.
# modprobe igb [<option>=<VAL1>,<VAL2>,] # lsmod |grep igb igb 87592 0 dca 6708 1 igb
Activate Virtual Functions
max_vfs
parameter of the igb
module allocates the maximum number of Virtual Functions. The max_vfs
parameter causes the driver to spawn, up to the value of the parameter in, Virtual Functions. For this particular card the valid range is 0
to 7
.
# modprobe -r igb
max_vfs
set to 1
or any number of Virtual Functions up to the maximum supported by your device.
# modprobe igb max_vfs=1
Inspect the new Virtual Functions
lspci
command, list the newly added Virtual Functions attached to the Intel 82576 network device.
# lspci | grep 82576 03:00.0 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01) 03:00.1 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01) 03:10.0 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01) 03:10.1 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01)
-n
parameter of the lspci
command.
# lspci -n | grep 03:00.0 03:00.0 0200: 8086:10c9 (rev 01) # lspci -n | grep 03:10.0 03:10.0 0200: 8086:10ca (rev 01)The Physical Function corresponds to
8086:10c9
and the Virtual Function to 8086:10ca
.
Find the devices with virsh
virsh nodedev-list
command to list available host devices.
# virsh nodedev-list | grep 8086
pci_8086_10c9
pci_8086_10c9_0
pci_8086_10ca
pci_8086_10ca_0
[output truncated]
Get advanced details
pci_8086_10c9
is one of the Physical Functions and pci_8086_10ca_0
is the first corresponding Virtual Function for that Physical Function. Use the virsh nodedev-dumpxml
command to get advanced output for both devices.
# virsh nodedev-dumpxml pci_8086_10ca # virsh nodedev-dumpxml pci_8086_10ca_0 <device> <name>pci_8086_10ca_0</name> <parent>pci_8086_3408</parent> <driver> <name>igbvf</name> </driver> <capability type='pci'> <domain>0</domain> <bus>3</bus> <slot>16</slot> <function>1</function> <product id='0x10ca'>82576 Virtual Function</product> <vendor id='0x8086'>Intel Corporation</vendor> </capability> </device>
pci_8086_10ca_0
to the guest in 步骤 8. Note the bus
, slot
and function
parameters of the Virtual Function, these are required for adding the device.
Add the Virtual Function to the guest
virsh nodedev-dumpxml pci_8086_10ca_0
command to calculate the values for the configuration file. Convert slot and function values to hexadecimal values (from decimal) to get the PCI bus addresses. Append "0x" to the beginning of the output to tell the computer that the value is a hexadecimal number.
printf
utility to convert decimal values to hexadecimal values.
$ printf %x 3 3 $ printf %x 16 10 $ printf %x 1 1
bus='0x03' slot='0x10' function='0x01'
virsh edit
command. This example edits a guest named MyGuest
.
# virsh edit MyGuest
devices
section of the XML configuration file.
<hostdev mode='subsystem' type='pci' managed='yes'> <source> <address bus='0x03' slot='0x10' function='0x01'/> </source> </hostdev>
Restart
# virsh start MyGuest
# virsh start test error: Failed to start domain test error: internal error unable to start guest: char device redirected to /dev/pts/2 get_real_device: /sys/bus/pci/devices/0000:03:10.0/config: Permission denied init_assigned_device: Error: Couldn't get real device (03:10.0)! Failed to initialize assigned device host=03:10.0
ntpd
服务:
# service ntpd start
# chkconfig ntpd on
ntpd
服务应该可以在各种情况下最小化时钟偏移造成的影响。
constant_tsc
标签,那么您的 CPU 就有恒定时间戳计数器。要确定您的 CPU 是否有 constant_tsc
标签,请运行以下命令:
$ cat /proc/cpuinfo | grep constant_tsc
constant_tsc
字节。如果没有输出结果,请按以下步骤执行。
constant_tsc
字节,则请禁用所有电源管理特性(BZ#513138)。每个系统都有多个用来计时的计时器。TSC 在主机中不稳定,有时是由于 cpufreq
变化、deep C 状态或者迁移到拥有更迅速 TSC 的主机所致。Deep C 睡眠状态可停止 TSC。要防止内核使用 deep C 状态,请在主机 grub.conf
文件的内核引导选项后附加 "processor.max_cstate=1
":
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
cpufreq
(只在没有 cpufreq
的主机中需要),请编辑 /etc/sysconfig/cpuspeed
配置文件并将 MIN_SPEED
和 MAX_SPEED
变量改为可用的最高频率。有效上限请查看 /sys/devices/system/cpu/cpu*/cpufreq/scaling_available_frequencies
文件。
红帽企业版 Linux | 附加客户端内核参数 |
---|---|
使用半虚拟时钟的 5.4 AMD64/Intel 64 | 不需要附加参数 |
没有半虚拟时钟的 5.4 AMD64/Intel 64 | divider=10 notsc lpj=n |
使用半虚拟时钟的 5.4 x86 | 不需要附加参数 |
没有半虚拟时钟的 5.4 x86 | divider=10 clocksource=acpi_pm lpj=n |
5.3 AMD64/Intel 64 | divider=10 notsc |
5.3 x86 | divider=10 clocksource=acpi_pm |
4.8 AMD64/Intel 64 | notsc divider=10 |
4.8 x86 | clock=pmtmr divider=10 |
3.9 AMD64/Intel 64 | 不需要附加参数 |
3.9 x86 | 不需要附加参数 |
boot.ini
文件中添加以下行:
/use pmtimer
boot.ini
file is no longer used from Windows Vista and newer. Windows Vista, Windows Server 2008 and Windows 7 use the Boot Configuration Data Editor (bcdedit.exe
) to modify the Windows boot parameters.
{default}
in the example below) should be changed if the system UUID is different than the default boot device.
C:\Windows\system32>bcdedit /set {default} USEPLATFORMCLOCK on The operation completed successfully
# setenforce 1
AutoFS
、NFS
、FTP
、HTTP
、NIS
、telnetd
、sendmail
等等。
/var/lib/libvirt/images/
目录中。如果您要为您的虚拟机使用不同的目录,请确定将该目录添加到您的 SELinux 策略中并在开始安装前对其进行重新标记。
vsftpd
服务器。
fstab
file, the initrd
file or used by the kernel command line. If less privileged users, especially virtualized guests, have write access to whole partitions or LVM volumes.
/dev/sdb
). Use partitions (for example, /dev/sdb1
) or LVM volumes.
virt_image_t
label applied to them. The /var/lib/libvirt/images
directory has this label applied to it and its contents by default. This does not mean that images must be stored in this directory; images can be stored anywhere, provided they are labeled with virt_image_t
.
NewVolumeName
,位置在名为 volumegroup
的卷组中。
# lvcreate -nNewVolumeName
-L5G volumegroup
NewVolumeName
逻辑卷,比如 ext3。
# mke2fs -j /dev/volumegroup/NewVolumeName
/etc
、/var
、/sys
)或者主目录中(/home
或者 /root
)。这个示例使用名为 /virtstorage
的目录。
# mkdir /virtstorage
# mount /dev/volumegroup/NewVolumeName /virtstorage
semanage fcontext -a -t xen_image_t "/virtstorage(/.*)?"
semanage fcontext -a -t virt_image_t "/virtstorage(/.*)?"
/etc/selinux/targeted/contexts/files/file_contexts.local
文件中添加一行,以便使更改持久。添加的行可能类似如下:
/virtstorage(/.*)? system_u:object_r:xen_image_t:s0
/dev/volumegroup/NewVolumeName
with the correct label:
# semanage fcontext -a -t xen_image_t /dev/volumegroup/NewVolumeName # restorecon /dev/volumegroup/NewVolumeName
# semanage fcontext -a -t xen_image_t -f -b /dev/sda2 # restorecon /dev/sda2
xend_disable_t
在未修改的模式中设置 xend
。最好是为单一守护进程而不是整个系统禁用此保护。建议您不要将广泛使用的目录重新标记为 xen_image_t
。
SELinux Boolean | Description |
---|---|
allow_unconfined_qemu_transition | Default: off. This boolean controls whether KVM guests can be transitioned to unconfined users. |
qemu_full_network | Default: on. This boolean controls full network access to KVM guests. |
qemu_use_cifs | Default: on. This boolean controls KVM's access to CIFS or Samba file systems. |
qemu_use_comm | Default: off. This boolean controls whether KVM can access serial or parallel communications ports. |
qemu_use_nfs | Default: on. This boolean controls KVM's access to NFS file systems. |
qemu_use_usb | Default: on. This boolean allows KVM to access USB devices. |
net.ipv4.ip_forward = 1
) is required for virtual bridge devices. Note that installing libvirt enables this variable so it will be enabled when the virtualization packages are installed unless it was manually disabled.
xend
管理客户端xend-config.sxp
来指定操作参数。下面是您可以在 xend-config.sxp
配置文件里启用或禁用的参数:
项目 | 描述 |
---|---|
(console-limit)
|
Determines the console server's memory buffer limit and assigns that limit on a per domain basis.
|
(min-mem)
|
决定为 domain0 保留的最小内存数量(以 MB 为单位),如果为 0,则该值不变化。
|
(dom0-cpus)
|
决定 domain0 使用的 CPU 数量(默认情况下至少分配一个 CPU)。
|
(enable-dump)
|
如果启用这个参数,但发生崩溃时,Xen 会创建一个转储文件(默认值为 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 域套接字服务器。套接字服务器是一个通信终点,它处理底层的网络连接以及接受或拒绝转入的连接。默认值为 yes。
|
(xend-relocation-server)
|
启用用于跨机器迁移的重定向服务器(默认为 no)。
|
(xend-unix-path)
|
确定
xend-unix-server 命令输出数据的位置(默认为 var/lib/xend/xend-socket )
|
(xend-port)
|
确定 http 管理服务器使用的端口(默认为 8000)。
|
(xend-relocation-port)
|
确定重定向服务器所使用的端口(默认为 8002)。
|
(xend-relocation-address)
|
确定允许迁移的主机地址。默认值为
xend-address 。
|
(xend-address)
|
确定域套接字服务器绑定的地址。默认为允许所有连接。
|
service xend start
service xend stop
service xend restart
service xend status
xend
chkconfig
命令在 initscript
中添加 xend
。
chkconfig --level 345 xend
xend
。
virsh migrate
命令。
# virsh migrateGuestName
libvirtURI
virsh migrate
命令的 --live
选项。
# virsh migrate--liveGuestName
libvirtURI
/etc/xen/xend-config.sxp
进行一些修改。默认情况下是迁移是禁用的,因为会对主机的安全性造成潜在威胁。打开迁移端口可能使未授权主机启动迁移或者连接到该迁移端口。没有为迁移请求配置验证和授权,且控制机制是基于主机名和 IP 地址。需要小心确定未通过验证的主机无法访问迁移端口和服务器。
/etc/xen/xend-config.sxp
文件中的以下条目启用迁移。需要时修改数值并删除以下参数前的注释符号(#
符号):
(xend-relocation-server yes)
no
。将 xend-relocation-server
值改为 yes 启用迁移。
(xend-relocation-port 8002)
xend-relocation-server
设为 yes
,则参数 (xend-relocation-port)
将指定端口 xend
作为重新定位接口。
xend-relocation-port
参数中设定的端口。
(xend-relocation-address '')
xend-relocation-server
,那么 (xend-relocation-address)
就应该是 xend
在 relocation-socket
连接中侦听迁移命令的地址。
(xend-relocation-address)
parameter restricts the migration server to only listen to a specific interface. The default value in /etc/xen/xend-config.sxp
is an empty string(''
). This value should be replaced with a single, valid IP address. For example:
(xend-relocation-address '10.0.0.1')
(xend-relocation-hosts-allow '')
(xend-relocation-hosts-allow 'hosts')
parameter controls which hostnames can communicate on the relocation port.
xend-relocation-hosts-allow
option to restrict access to the migration server.
xend-relocation-port
和 xend-relocation-address
。
(xend-relocation-hosts-allow)
参数应该是一组用空格分开的正则表达式。任意与这些正则表达式之一匹配的全限定域名或者 IP 地址都会被接受。
(xend-relocation-hosts-allow)
属性示例:
(xend-relocation-hosts-allow '^localhost$ ^localhost\\.localdomain$')
# service xend restart
et-virt07
和 et-virt08
)组成,它们都使用 eth1
作为其默认网络接口,因此它们也都使用 xenbr1
作为其 Xen 联网桥接。我们要使用在 et-virt07
上本地附加的 SCSI 磁盘(/dev/sdb
)作为使用 NFS 的共享存储。
# mkdir /var/lib/libvirt/images # mount /dev/sdb /var/lib/libvirt/images
/var/lib/libvirt/images/
,请确定只导出 /var/lib/libvirt/images/
而不包括 /var/lib/xen/
,因为该目录由 xend
守护进程和其它工具使用。共享 /var/lib/xen/
可能会导致不可预测的行为。
# cat /etc/exports /var/lib/libvirt/images *(rw,async,no_root_squash)
# showmount -e et-virt07 Export list for et-virt07: /var/lib/libvirt/images *
# virt-install -p -f /var/lib/libvirt/images/testvm1
.dsk -s 5 -n\testvm1
--vnc -r 1024 -l http://example.com/RHEL5-tree\ Server/x86-64/os/ -b xenbr1
[et-virt08 ~]# brctl show bridge name bridge id STP enabled interfaces xenbr1 8000.feffffffffff no peth1 vif0.1
[et-virt07 ~]# brctl show bridge name bridge id STP enabled interfaces xenbr1 8000.feffffffffff no peth1 vif0.1
[et-virt07 ~]# grep xend-relocation /etc/xen/xend-config.sxp |grep -v '#' (xend-relocation-server yes) (xend-relocation-port 8002) (xend-relocation-address '') (xend-relocation-hosts-allow '')
[et-virt08 ~]# grep xend-relocation /etc/xen/xend-config.sxp |grep -v '#' (xend-relocation-server yes) (xend-relocation-port 8002) (xend-relocation-address '') (xend-relocation-hosts-allow '')
[et-virt07 ~]# lsof -i :8002 COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME python 3445 root 14u IPv4 10223 TCP *:teradataordbms (LISTEN)
[et-virt08 ~]# lsof -i :8002 COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME python 3252 root 14u IPv4 10901 TCP *:teradataordbms (LISTEN)
/var/lib/libvirt/images
directory is available and mounted with networked storage on both hosts. Shared, networked storage is required for migrations.
[et-virt08 ~]# df /var/lib/libvirt/images Filesystem 1K-blocks Used Available Use% Mounted on et-virt07:/var/lib/libvirt/images 70562400 2379712 64598336 4% /var/lib/libvirt/images
[et-virt08 ~]# file /var/lib/libvirt/images/testvm1
.dsk /var/lib/libvirt/images/testvm1
.dsk: x86 boot sector; partition 1: ID=0x83, active, starthead 1, startsector 63, 208782 sectors; partition 2: ID=0x8e, starthead 0, startsector 208845, 10265535 sectors, code offset 0x48
[et-virt08 ~]# touch /var/lib/libvirt/images/foo [et-virt08 ~]# rm -f /var/lib/libvirt/images/foo
[et-virt07 ~]# virsh list Id Name State ---------------------------------- Domain-0 running
[et-virt07 ~]# virsh starttestvm1
Domaintestvm1
started
[et-virt07 ~]# virsh list
Id Name State
----------------------------------
Domain-0 running
testvm1
blocked
[et-virt07 images]# time virsh savetestvm1
testvm1
.sav real 0m15.744s user 0m0.188s sys 0m0.044s
[et-virt07 images]# ls -lrttestvm1
.sav -rwxr-xr-x 1 root root 1075657716 Jan 12 06:46testvm1
.sav
[et-virt07 images]# virsh list Id Name State ---------------------------------- Domain-0 running
[et-virt07 images]# virsh restore testvm1
.sav
[et-virt07 images]# virsh list
Id Name State
----------------------------------
Domain-0 running
testvm1
blocked
domain-id
from et-virt08
to et-virt07
. The hostname you are migrating to and <domain-id> must be replaced with valid values. This example uses the et-virt08
host which must have SSH access to et-virt07
[et-virt08 ~]# xm migrate --live testvm1
et-virt07
et-virt08
[et-virt08 ~]# virsh list Id Name State ---------------------------------- Domain-0 running
et-virt07
:
[et-virt07 ~]# virsh list
Id Name State
----------------------------------
Domain-0 running
testvm1
running
#!/bin/bash while true do touch /var/tmp/$$.log echo `hostname` >> /var/tmp/$$.log echo `date` >> /var/tmp/$$.log cat /var/tmp/$$.log df /var/tmp ls -l /var/tmp/$$.log sleep 3 done
et-virt07
前,它是在 et-virt08 中运行的:
[et-virt08 ~]# virsh list
Id Name State
----------------------------------
Domain-0 running
testvm1
blocked
et-virt07
中启动动态迁移。您可以添加 time
命令查看迁移使用了多少时间:
[et-virt08 ~]# xm migrate --live testvm1
et-virt07
# ./doit dhcp78-218.lab.boston.redhat.com Fri Jan 12 02:26:27 EST 2007 Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 2983664 2043120 786536 73% / -rw-r--r-- 1 root root 62 Jan 12 02:26 /var/tmp/2279.log dhcp78-218.lab.boston.redhat.com Fri Jan 12 02:26:27 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 02:26:30 EST 2007 Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 2983664 2043120 786536 73% / -rw-r--r-- 1 root root 124 Jan 12 02:26 /var/tmp/2279.log dhcp78-218.lab.boston.redhat.com Fri Jan 12 02:26:27 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 02:26:30 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 02:26:33 EST 2007 Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 2983664 2043120 786536 73% / -rw-r--r-- 1 root root 186 Jan 12 02:26 /var/tmp/2279.log Fri Jan 12 02:26:45 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 02:26:48 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 02:26:51 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:54:57 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:55:00 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:55:03 EST 2007 Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 2983664 2043120 786536 73% / -rw-r--r-- 1 root root 744 Jan 12 06:55 /var/tmp/2279.log dhcp78-218.lab.boston.redhat.com Fri Jan 12 02:26:27 EST 2007
et-virt08
中关闭了虚拟机:
[et-virt08 ~]# virsh list Id Name State ---------------------------------- Domain-0 running
et-virt07
中启动了虚拟机:
[et-virt07 images]# virsh list
Id Name State
----------------------------------
Domain-0 running
testvm1
blocked
et-virt07
迁移到 et-virt08
。启动从 et-virt07
到 et-virt08
的迁移:
[et-virt07 images]# xm migrate --live testvm1
et-virt08
[et-virt07 images]# virsh list Id Name State ---------------------------------- Domain-0 running
# ./doit dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:57:53 EST 2007 Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 2983664 2043120 786536 73% / -rw-r--r-- 1 root root 62 Jan 12 06:57 /var/tmp/2418.log dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:57:53 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:57:56 EST 2007 Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 2983664 2043120 786536 73% / -rw-r--r-- 1 root root 124 Jan 12 06:57 /var/tmp/2418.log dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:57:53 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:57:56 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:58:00 EST 2007 Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 2983664 2043120 786536 73% / -rw-r--r-- 1 root root 186 Jan 12 06:57 /var/tmp/2418.log dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:57:53 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:57:56 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:58:00 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 02:30:00 EST 2007 Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 2983664 2043120 786536 73% / -rw-r--r-- 1 root root 248 Jan 12 02:30 /var/tmp/2418.log dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:57:53 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:57:56 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:58:00 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 02:30:00 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 02:30:03 EST 2007 Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 2983664 2043120 786536 73% / -rw-r--r-- 1 root root 310 Jan 12 02:30 /var/tmp/2418.log dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:57:53 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:57:56 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 06:58:00 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 02:30:00 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 02:30:03 EST 2007 dhcp78-218.lab.boston.redhat.com Fri Jan 12 02:30:06 EST 2007 Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 2983664 2043120 786536 73% / -rw-r--r-- 1 root root 372 Jan 12 02:30 /var/tmp/2418.log
et-virt07
完成迁移命令后,请确定在 et-virt08
中启动了虚拟机:
[et-virt08 ~]# virsh list
Id Name State
----------------------------------
Domain-0 running
testvm1
blocked
[et-virt08 ~]# time virsh migrate --live testvm1
et-virt07
real 0m10.378s
user 0m0.068s
sys 0m0.052s
xm migrate
命令)。可使用同样的命令进行实时迁移。但是您必须对 xend-config
配置文件进行一些修改。这个示例列出保证成功迁移必须修改的条目:
(xend-relocation-server yes)
(xend-relocation-port 8002)
xend
用来进行迁移的端口。除非您的网络环境需要自定义值不要使用这个值。删除该注释启用它。
(xend-relocation-address )
xend-relocation-server
后用来侦听重新定位插槽连接的地址。Xen 管理程序只在指定接口中侦听迁移网络流量。
(xend-relocation-hosts-allow )
(xend-relocation-hosts-allow- '^localhost\\.localdomain$' )>
virsh
命令可将客户端迁移到另一台主机中。migrate
命令接受以下格式的参数:
# virsh migrate --live GuestName DestinationURL
GuestName
参数代表您要迁移的客户端名称。
DestinationURL
参数是目的系统的 URL 或者主机名。目的系统必须运行同一版本的红帽企业版 Linux,使用同样的管理程序并运行 libvirt
。
test1.bne.redhat.com
迁移至 test2.bne.redhat.com
。请为您的环境更改主机名。这个示例迁移了名为 RHEL4test
的虚拟机。
确定客户端正在运行
test1.bne.redhat.com
中确定 RHEL4test
正在运行:
[root@test1 ~]# virsh list Id Name State ---------------------------------- 10 RHEL4 running
迁移客户端
test2.bne.redhat.com
。在目的系统 URL 结尾添加 /system
告知 libvirt 您需要完全访问权限。
# virsh migrate --live RHEL4test qemu+ssh://test2.example.com/system
等待
virsh
只报告出错信息。客户端仍将在源主机中继续运行直至全部迁移完成。
确定客户端已到达目的主机
test2.bne.redhat.com
中确定 RHEL4test
正在运行:
[root@test2 ~]# virsh list Id Name State ---------------------------------- 10 RHEL4 running
virt-manager
迁移使用 KVM 的客户端。
ssh
、TLS 和 SSL 对您的虚拟化客户端进行远程管理。
ssh
软件包提供加密网络协议,可向远程虚拟化服务器安全发送管理功能。本方法使用 libvirt
通过 SSH 连接安全管理远程机器。所有验证都通过 SSH 公钥加密法和密码或者由您的本地 SSH 代理获得的密码短语进行。另外,每个客户端虚拟机的 VNC 控制台都将通过 SSH 连接。
virt-manager
virt-manager
must run as the user who owns the keys to connect to the remote host. That means, if the remote systems are managed by a non-root user virt-manager
must be run in unprivileged mode. If the remote systems are managed by the local root user then the SSH keys must be own and created by root.
virt-manager
.
Optional: Changing user
$ su -
Generating the SSH key pair
virt-manager
is used. This example uses the default key location, in the ~/.ssh/
directory.
$ ssh-keygen -t rsa
Coping the keys to the remote hosts
root@example.com
).
# ssh-copy-id -i ~/.ssh/id_rsa.pub root@example.com root@example.com's password: Now try logging into the machine, with "ssh 'root@example.com'", and check in: .ssh/authorized_keys to make sure we haven't added extra keys that you weren't expecting
Optional: Add the passphrase to the ssh-agent
ssh-agent
, if required. On the local host, use the following command to add the passphrase (if there was one) to enable password-less login.
# ssh-add ~/.ssh/id_rsa.pub
libvirt
守护进程(libvirtd
)libvirt
daemon provide an interface for managing virtual machines. You must have the libvirtd
daemon installed and running on every remote host that needs managing.
$ ssh root@somehost
# chkconfig libvirtd on
# service libvirtd start
libvirt
和 SSH 后,您应该可以远程访问并管理您的虚拟机。此时您还应该可以使用 VNC
访问您的客户端。
libvirt
management connection opens a TCP port for incoming connections, which is securely encrypted and authenticated based on x509 certificates. In addition the VNC console for each guest virtual machine will be setup to use TLS with x509 certificate authentication.
libvirt
服务器设定/etc/xen/xend-config.sxp
启用 TLS。删除配置文件 (vnc-tls 1)
配置参数前的注释标记。
/etc/xen/vnc
directory needs the following 3 files:
ca-cert.pem
- The CA certificate
server-cert.pem
- The Server certificate signed by the CA
server-key.pem
- The server private key
(vnc-x509-verify 1)
parameter.
virt-manager
和 virsh
客户端设定libvirt
管理 API,就必须将 CA 以及客户端证书放在 /etc/pki
中。有关详情请参考 http://libvirt.org/remote.html。
virt-manager
user interface, use the ' ' transport mechanism option when connecting to a host.
virsh
中 URI 有以下格式:
qemu://hostname.guestname/system
。
xen://hostname.guestname/
。
$HOME/.pki
中,即以下三个文件:
ca-cert.pem
- CA 证书。
libvirt-vnc
或者 clientcert.pem
- CA 签注的客户端证书。
libvirt-vnc
或者 clientkey.pem
- 客户端私钥。
libvirt
支持以下传输模式:
/var/run/libvirt/libvirt-sock
和 /var/run/libvirt/libvirt-sock-ro
(用于只读连接)。
libvirtd
)。必须为 SSH 访问打开端口 22。您应该使用某种 ssh 密钥管理(例如:ssh-agent
程序),或者会提示您输入密码。
virsh
和 libvirt
用来连接到远程主机的工具。URI 还可用于 virsh
命令的 --connect
参数执行单一命令或者在远程主机中迁移。
driver[+transport]://[username@][hostname][:port]/[path][?extraparameters]
towada
的主机中使用 SSH 传输和 SSH 用户名 ccurran
连接到远程 Xen 管理程序。
xen+ssh://ccurran@towada/
towada
的主机中连接到远程 Xen 管理程序。
xen://towada/
towada
using TLS. The no_verify=1
tells libvirt not to verify the server's certificate.
xen://towada/?no_verify=1
towada
中连接到远程 KVM 管理程序。
qemu+ssh://towada/system
qemu+unix:///system?socket=/opt/libvirt/run/libvirt/libvirt-sock
test+tcp://10.1.1.10:5000/default
名称 | 传输模式 | 描述 | 示例用法 |
---|---|---|---|
名称 | 所有模式 | 为 virConnectOpen 功能提供的名称。该名称通常由删除的传输、主机名、端口号、用户名以及远程 URI 中的附加参数组成,但在这个非常复杂的例子中,最好提供单独的名称。 | name=qemu:///system |
命令 | ssh 和 ext | 外部命令。ext 传输需要这个。ssh 默认为 ssh。会为该命令搜索 PATH。 | command=/opt/openssh/bin/ssh |
套接字 | unix 和 ssh | 到 UNIX 域套接字的路径,可覆盖默认设置。ssh 传输中会将其转发给远程 netcat 命令(参考 netcat)。 | socket=/opt/libvirt/run/libvirt/libvirt-sock |
netcat | ssh |
netcat 可用来连接到远程系统。默认 netcat 参数使用 nc 命令。SSH 传输中 libvirt 构成使用以下格式的 SSH 命令:
可将
port 、username 和 hostname 参数指定为远程 URI 的一部分。command 、netcat 和 socket 来自其它外部参数。
| netcat=/opt/netcat/bin/nc |
no_verify | tls | If set to a non-zero value, this disables client checks of the server's certificate. Note that to disable server checks of the client's certificate or IP address you must change the libvirtd configuration. | no_verify=1 |
no_tty | ssh | 如果设置为非零值,则在其无法自动登录(使用 ssh 代理或者类似机制)远程机器时停止 ssh 询问密码。在您无法访问终端时,例如在使用 libvirt 的图形程序中,可使用这个参数。 | no_tty=1 |
目录
vmstat
iostat
lsof
# lsof -i :5900 xen-vncfb 10635 root 5u IPv4 218738 TCP grumble.boston.redhat.com:5900 (LISTEN)
qemu-img
systemTap
crash
xen-gdbserver
sysrq
sysrq t
sysrq w
sysrq c
brtcl
# brctl show bridge name bridge id STP enabled interfaces xenbr0 8000.feffffffffff no vif13.0 pdummy0 vif0.0
# brctl showmacs xenbr0 port no mac addr is local? aging timer 1 fe:ff:ff:ff:ff:ff yes 0.00
# brctl showstp xenbr0 xenbr0 bridge id 8000.feffffffffff designated root 8000.feffffffffff 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 aging time 300.01 hello timer 1.43 tcn timer 0.00 topology change timer 0.00 gc timer 0.02 flags vif13.0 (3) port id 8003 state forwarding designated root 8000.feffffffffff path cost 100 designated bridge 8000.feffffffffff message age timer 0.00 designated port 8003 forward delay timer 0.00 designated cost 0 hold timer 0.43 flags pdummy0 (2) port id 8002 state forwarding designated root 8000.feffffffffff path cost 100 designated bridge 8000.feffffffffff message age timer 0.00 designated port 8002 forward delay timer 0.00 designated cost 0 hold timer 0.43 flags vif0.0 (1) port id 8001 state forwarding designated root 8000.feffffffffff path cost 100 designated bridge 8000.feffffffffff message age timer 0.00 designated port 8001 forward delay timer 0.00 designated cost 0 hold timer 0.43 flags
ifconfig
tcpdump
ps
pstree
top
kvmtrace
kvm_stat
xentop
xm dmesg
xm log
virsh
是用来管理客户端及其管理程序的命令行界面工具。
virsh
工具是构建在 libvirt
管理 API 上,可作为 xm 命令和图形客户端管理程序(virt-manager
)的替代工具使用。非特权用户只能以只读模式使用 virsh
。您可使用 virsh
为客户端机器执行脚本。
命令 | 描述 |
---|---|
help
| 打印基本帮助信息。 |
list
| 列出所有客户端。 |
dumpxml
| 输出客户端 XML 配置文件。 |
create
| 从 XML 配置文件生成客户端并启动新客户端。 |
start
| 启动未激活的客户端。 |
destroy
| 强制客户端停止。 |
define
| 为客户端输出 XML 配置文件。 |
domid
| Displays the guest's ID. |
domuuid
| Displays the guest's UUID. |
dominfo
| 显示客户端信息。 |
domname
| Displays the guest's name. |
domstate
| 显示客户端状态。 |
quit
| 退出这个互动终端。 |
reboot
| 重新启动客户端。 |
restore
| 恢复以前保存在文件中的客户端。 |
resume
| 恢复暂停的客户端。 |
save
| 将客户端当前状态保存到某个文件中。 |
shutdown
| 关闭某个域。 |
suspend
| 暂停客户端。 |
undefine
| 删除与客户端关联的所有文件。 |
migrate
| 将客户端迁移到另一台主机中。 |
virsh
命令可管理客户端及管理程序资源:
命令 | 描述 |
---|---|
setmem
| 为客户端设定分配的内存。 |
setmaxmem
| 为管理程序设定内存上限。 |
setvcpus
| 修改为客户端分配的虚拟 CPU 数目。 |
vcpuinfo
| 显示客户端的虚拟 CPU 信息。 |
vcpupin
| 控制客户端的虚拟 CPU 亲和性。 |
domblkstat
| 显示正在运行的客户端的块设备统计。 |
domifstat
| 显示正在运行的客户端的网络接口统计。 |
attach-device
| 使用 XML 文件中的设备定义在客户端中添加设备。 |
attach-disk
| 在客户端中附加新磁盘设备。 |
attach-interface
| 在客户端中附加新网络接口。 |
detach-device
|
从客户端中分离设备,使用同样的 XML 描述作为命令 attach-device 。
|
detach-disk
| 从客户端中分离磁盘设备。 |
detach-interface
| 从客户端中分离网络接口。 |
virsh
选项:
命令 | 描述 |
---|---|
version
|
显示 virsh 版本
|
nodeinfo
| 有关管理程序的输出信息 |
virsh
连接到管理程序会话:
# virsh connect {hostname OR URL}
<name>
是管理程序所在的机器名。要初始化只读连接,请在上面的命令中附加 readonly
。
virsh
:
# virsh dumpxml {domain-id, domain-name or domain-uuid}
stdout
). You can save the data by piping the output to a file. An example of piping the output to a file called guest.xml
:
# virsh dumpxmlThis fileGuestID
>guest.xml
guest.xml
can recreate the guest (refer to Editing a guest's configuration file. You can edit this XML configuration file to configure additional devices or to deploy additional guests. Refer to 第 33.1 节 “使用带 virsh 的 XML 配置文件” for more information on modifying files created with virsh dumpxml
.
virsh dumpxml
输出示例:
# virsh dumpxml r5b2-mySQL01 <domain type='xen' id='13'> <name>r5b2-mySQL01</name> <uuid>4a4c59a7ee3fc78196e4288f2862f011</uuid> <bootloader>/usr/bin/pygrub</bootloader> <os> <type>linux</type> <kernel>/var/lib/libvirt/vmlinuz.2dgnU_</kernel> <initrd>/var/lib/libvirt/initrd.UQafMw</initrd> <cmdline>ro root=/dev/VolGroup00/LogVol00 rhgb quiet</cmdline> </os> <memory>512000</memory> <vcpu>1</vcpu> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> <interface type='bridge'> <source bridge='xenbr0'/> <mac address='00:16:3e:49:1d:11'/> <script path='vif-bridge'/> </interface> <graphics type='vnc' port='5900'/> <console tty='/dev/pts/4'/> </devices> </domain>
dumpxml
option (refer to 创建虚拟机 XML 转储(配置文件)). To create a guest with virsh
from an XML file:
# virsh create configuration_file.xml
dumpxml
option (refer to 创建虚拟机 XML 转储(配置文件)) guests can be edited either while they run or while they are offline. The virsh edit
command provides this functionality. For example, to edit the guest named softwaretesting
:
# virsh edit softwaretesting
$EDITOR
shell 参数(默认将其设定为 vi
)。
virsh
挂起客户端:
# virsh suspend {domain-id, domain-name or domain-uuid}
resume
(恢复客户端) option.
virsh
的 resume
选项恢复客户端:
# virsh resume {domain-id, domain-name or domain-uuid}
suspend
和 resume
的循环中。
virsh
命令将客户端的当前状态保存到文件中:
# virsh save {domain-name, domain-id or domain-uuid} filename
restore
(恢复客户端) option. Save is similar to pause, instead of just pausing a guest the present state of the guest is saved.
# virsh restore filename
virsh
命令关闭客户端:
# virsh shutdown {domain-id, domain-name or domain-uuid}
on_shutdown
parameter in the guest's configuration file.
virsh
重启客户端:
#virsh reboot {domain-id, domain-name or domain-uuid}
on_reboot
element in the guest's configuration file.
virsh
强制客户端停止:
# virsh destroy {domain-id, domain-name or domain-uuid}
virsh destroy
can corrupt guest file systems . Use the destroy
option only when the guest is unresponsive. For para-virtualized guests, use the shutdown
option(关闭客户端) instead.
# virsh domid {domain-name or domain-uuid}
# virsh domname {domain-id or domain-uuid}
# virsh domuuid {domain-id or domain-name}
virsh domuuid
命令输出示例:
# virsh domuuid r5b2-mySQL01 4a4c59a7-ee3f-c781-96e4-288f2862f011
virsh
with the guest's domain ID, domain name or UUID you can display information on the specified guest:
# virsh dominfo {domain-id, domain-name or domain-uuid}
virsh dominfo
命令的输出示例:
# virsh dominfo r5b2-mySQL01 id: 13 name: r5b2-mysql01 uuid: 4a4c59a7-ee3f-c781-96e4-288f2862f011 os type: linux state: blocked cpu(s): 1 cpu time: 11.0s max memory: 512000 kb used memory: 512000 kb
# virsh nodeinfo
virsh nodeinfo
命令输出示例:
# 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
virsh
显示客户端列表以及当前状态:
# virsh list
--inactive
选项列出不活动的域(已经被定义但目前不活动的域),以及
--all
选项列出所有客户端。例如:
# virsh list --all Id Name State ---------------------------------- 0 Domain-0 running 1 Domain202 paused 2 Domain010 inactive 3 Domain9600 crashed
virsh list
输出结果分类成以下 6 个状态之一(如下)。
running
状态是指目前在 CPU 中活跃的客户端。
blocked
的客户端是被阻断的,且目前没有运行或者无法运行。这是由于客户端正在等待 I/O(传统的等待状态)或者客户端处于睡眠模式。
paused
状态列出暂停的域。如果管理员在 virt-manager
、xm pause
或者 virsh suspend
中使用 pause 标记就会出现这种状态。当客户端处于暂停状态时,它仍会消耗内存和其它资源,但无法从管理程序中调度 CPU 资源。
shutdown
状态是用于处于关闭过程中的客户端。向该客户端发送关闭信号并使其温和地停止操作。这可能不适用于所有客户端操作系统,有些操作系统对这些信号没有响应。
dying
状态的域是处于濒死状态,即该域还没有完全关闭或者崩溃。
crashed
状态的客户端是在运行时失败且无法再运行。这个状态只在将客户端配置为崩溃时不重启时出现。
virsh
显示客户端中虚拟 CPU 的信息:
# virsh vcpuinfo {domain-id, domain-name or domain-uuid}
virsh vcpuinfo
命令输出示例:
# virsh vcpuinfo r5b2-mySQL01 VCPU: 0 CPU: 0 State: blocked CPU time: 0.0s CPU Affinity: yy
# virsh vcpupin domain-id vcpu cpulist
domain-id
parameter is the guest's ID number or name.
vcpu
参数表示分配给该客户端的虚拟 CPU 数。必须提供 vcpu
参数。
cpulist
参数是用逗号分开的一组物理 CPU 识别符号码。cpulist
参数决定 VCPU 可在那个物理 CPU 中运行。
virsh
修改分配给客户端的 CPU 数:
# virsh setvcpus {domain-name, domain-id or domain-uuid} count
count
值不能超过创建客户端时指定的数目。
virsh
:
# virsh setmem {domain-id or domain-name} count
virsh domblkstat
显示运行的客户端的块设备统计。
# virsh domblkstat GuestName block-device
virsh domifstat
为运行的客户端显示网络接口统计。
# virsh domifstat GuestName interface-device
virsh
将某个客户端迁移到另一台主机中。将域迁移到另一台主机中。添加 --live 进行实时迁移。migrate
命令接受以下格式的参数:
# virsh migrate --live GuestName DestinationURL
--live
参数是可选的。实时迁移需要添加 --live
参数。
GuestName
参数代表您要迁移的客户端名称。
DestinationURL
参数是目的系统的 URL 或者主机名。目的系统需要:
libvirt
服务。
virsh
管理虚拟网络。要列出虚拟网络:
# virsh net-list
# virsh net-list Name State Autostart ----------------------------------------- default active yes vnet1 active yes vnet2 active yes
# virsh net-dumpxml NetworkName
# 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
命令:
virsh net-autostart network-name
— 自动启动指定为 network-name
的网络。
virsh net-create XMLfile
— 使用现有 XML 文件创建并启动新网络。
virsh net-define XMLfile
— 使用现有 XML 文件创建新网络设备但不启动。
virsh net-destroy network-name
— 销毁指定为 network-name
的网络。
virsh net-name networkUUID
— 将指定的 networkUUID
转换为网络名称。
virsh net-uuid network-name
— 将指定的 network-name
转换为网络 UUID。
virsh net-start nameOfInactiveNetwork
— 启动不活跃的网络。
virsh net-undefine nameOfInactiveNetwork
— 删除不活跃网络的定义。
virt-manager
)窗口、对话框及各种的 GUI 控制。
virt-manager
提供管理程序以及您系统和远程机器中客户端的图形视图。您可使用 virt-manager
定义半虚拟和全虚拟客户端。virt-manager
可执行虚拟化管理任务,其中包括:
virt-manager
. The UUID field displays the globally unique identifier for the virtual machines.
dom0
)'s loopback address (127.0.0.1
). This ensures only those with shell privileges on the host can access virt-manager and the virtual machine through VNC.
virt-manager
sticky key capability to send these sequences. To use this capability, you must press any modifier key (Ctrl or Alt) 3 times and the key you specify gets treated as active until the next non-modifier key is pressed. You can then send Ctrl-Alt-F11 to the guest by entering the key sequence 'Ctrl Ctrl Ctrl Alt+F1'.
virt-manager
, it is not possible to use this sticky key feature to send a Sysrq key combination to a guest.
virt-manager
会话,请打开 菜单,然后点击 ,并选择 (virt-manager
)。
virt-manager
主窗口。
virt-manager
virt-manager
can be started remotely using ssh as demonstrated in the following command:
ssh -X host's address
[remotehost]# virt-manager
Using ssh
to manage virtual machines and hosts is discussed further in 第 22.1 节 “使用 SSL 进行远程管理”.
virt-manager
's preferences window.
DHCP
范围xm
命令可管理 Xen 管理程序。的多时操作可使用 libvirt 工具、virt-manager 程序或者 virsh
命令执行。xm
命令没有 libvirt 工具的错误检查功能,因此不应用于 libvirt 工具支持的任务。
xm
命令的其它 Xen 部署选项无法在红帽企业版 Linux 5 中使用。下面的列表提供了可用的和不可用的命令选项总览。
virsh
或者 virt-manager
,而不要使用 xm
。xm
命令无法无法很好处理错误检查或者配置文件错误,这些错误可导致系统不稳定或者在虚拟机中出错。手动编辑 Xen 配置文件是很危险的,所以应该避免。使用本章提供的方法后果自负。
xm
命令:
xm help [--long]
:查看可用选项和帮助文本。
xm list
命令列出活跃的域:
$ xm list Name ID Mem(MiB) VCPUs State Time(s) Domain-0 0 520 2 r----- 1275.5 r5b2-mySQL01 13 500 1 -b---- 16.1
xm create [-c] DomainName/ID
: start a virtual machine. If the -c option is used, the start up process will attach to the guest's console.
xm console DomainName/ID
: attach to a virtual machine's console.
xm destroy DomainName/ID
:终止虚拟机,类似关闭电源。
xm reboot DomainName/ID
:重启某台虚拟机,和一般系统的关机、开机过程相同。
xm shutdown DomainName/ID
:关闭虚拟机,运行一般系统关闭过程。
xm pause
xm unpause
xm save
xm restore
xm migrate
xm
命令管理资源:
xm mem-set
xm vcpu-list
列出虚拟 CPU 亲和性:
$ xm vcpu-list Name ID VCPUs CPU State Time(s) CPU Affinity Domain-0 0 0 0 r-- 708.9 any cpu Domain-0 0 1 1 -b- 572.1 any cpu r5b2-mySQL01 13 0 1 -b- 16.1 any cpu
xm vcpu-pin
xm vcpu-set
xm sched-credit
命令为给定的域显示调度程序参数:
$ xm sched-credit -d 0 {'cap': 0, 'weight': 256} $ xm sched-credit -d 13 {'cap': 25, 'weight': 256}
xm
命令进行监控和故障排除:
xm top
xm dmesg
xm info
xm log
xm uptime
命令显示客户端和主机的正常运行时间:
$ xm uptime Name ID Uptime Domain-0 0 3:42:18 r5b2-mySQL01 13 0:06:27
xm sysrq
xm dump-core
xm rename
xm domid
xm domname
xm vnet-list
。
/boot/grub/grub.conf
)可生成 GRUB 的菜单里界面中引导的操作系统列表。当您安装 kernel-xen
RPM 时,会有一个脚本将 kernel-xen
条目添加到 GRUB 配置文件中并默认引导 kernel-xen
。编辑 grub.conf
文件修改默认内核或者添加附加内核参数。
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 内核。因为内核条目在其它条目之上,所以最先将内核载入内存。引导装载程序将向管理程序和 Linux 内核发送命令行参数,同时也从其中接收参数。这个示例条目显示如何将 Dom0 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
/etc/elilo.conf
,其中包含一组全局选项和映像片段。当您安装 kernel-xen
RPM 时,后安装脚本会在 elilo.conf
中添加适当的映像片段。
image=vmlinuz-2.6.18-92.el5xen vmm=xen.gz-2.6.18-92.el5 label=linux initrd=initrd-2.6.18-92.el5xen.img read-only root=/dev/VolGroup00/rhel5_2 append="-- rhgb quiet"
image
parameter indicates the following lines apply to a single boot selection. This stanza defines a hypervisor (vmm
), initrd
, and command line arguments (read-only
, root
and append
) to the hypervisor and kernel. When ELILO is loaded during the boot sequence, the image is labeled linux
.
read-only
转换为内核命令行选项 ro
,这将导致以只读形式挂载根文件系统,除非 initscripts
以读写形式挂载根驱动器。ELILO 会将 "root
" 行复制到内核命令行。将其与 "append
" 合并为一个完整命令行:
"-- root=/dev/VolGroup00/rhel5_2 ro rhgb quiet"
--
符号分开管理程序和内核参数。先出现的是管理程序参数,然后是 --
分界符,后面是内核参数。管理程序通常没有参数。
--
前面插入参数。内核管理程序内存(mem
)参数以及 quiet
参数示例如下:
append="dom0_mem=2G -- quiet"
参数 | 描述 |
---|---|
mem= | mem 参数定义管理程序最大 RAM 用量。系统中的任何附加 RAM 将会被忽略。可用后缀 B、K、M 或者 G 代表参数,分别代表字节、KB、MB 以及 GB。如果没有指定后缀,则默认单位为 KB。 |
dom0_mem= | dom0_mem= 设定分配给 dom0 的 RAM 量。使用之前在 mem 参数中使用的同一后缀。在 Itanium® 中红帽企业版 Linux 5.2 的默认值为 4G。 |
dom0_max_vcpus= | dom0_max_vcpus= 设定分配到管理程序中的 CPU 数。在 Itanium® 中红帽企业版 Linux 5.2 的默认 CPU 数为 4。 |
com1= | com1= 为第一个串口设定参数,例如:com1=9600,8n1,0x408,5 。可忽略 io_base 和 irq 选项,使其保留标准默认值。可将 baud 参数设为 auto ,说明应保留引导装载程序设置。如果在 ELILO 或者 EFI 配置中将串口参数设为全局选项,则可忽略 com1 参数。 |
com2= | 为第二个串口设定参数。请参考以上 com1 参数的描述。 |
console= | console 是用逗号分开的控制台选项首选项列表。选项包括 vga、com1 和 com2。应该省略这个设置,因为管理程序将沿用 EFI 控制台设置。 |
image=vmlinuz-2.6.18-92.el5xen vmm=xen.gz-2.6.18-92.el5 label=linux initrd=initrd-2.6.18-92.el5xen.img read-only root=/dev/VolGroup00/rhel5_2 append="dom0_mem=2G dom0_max_vcpus=2 --"
rhgb quiet
",以便可在控制台中生成内核以及 initscript
输出。请注意:保留 -- 以便可将附加行正确解读为管理程序参数。
Item | Description |
---|---|
pae
|
Specifies the physical address extension configuration data.
|
apic
|
Specifies the advanced programmable interrupt controller configuration data.
|
memory
|
Specifies the memory size in megabytes.
|
vcpus
|
Specifies the numbers of virtual CPUs.
|
console
|
Specifies the port numbers to export the domain consoles to.
|
nic
|
Specifies the number of virtual network interfaces.
|
vif
|
Lists the randomly-assigned MAC addresses and bridges assigned to use for the domain's network addresses.
|
disk
|
Lists the block devices to export to the domain and exports physical devices to domain with read only access.
|
dhcp
|
Enables networking using DHCP.
|
netmask
|
Specifies the configured IP netmasks.
|
gateway
|
Specifies the configured IP gateways.
|
acpi
|
Specifies the advanced configuration power interface configuration data.
|
libvirt
configuration files for most tasks. Some users may need Xen configuration files which contain the following standard variables. Configuration items within these files must be enclosed in single quotes('). These configuration files reside in the /etc/xen
directory.
xm create --help_config
.
Parameter
|
Description
|
---|---|
vncpasswd =NAME
| HVM 域中 VNC 控制台的密码。 |
vncviewer=no | yes
|
在域中生成侦听 vnc 服务器的 vncviewer。vncviewer 的地址会在内核命令行中使用 VNC_SERVER=<host>:<port> 传递给该域。vnc 使用的端口为 5500 + DISPLAY。如果可能请选择带自由端口的显示值。只在 vnc=1 时有效。
|
vncconsole =no | yes
| Spawn a vncviewer process for the domain's graphical console. Only valid when vnc=1. |
name =NAME
| 域名,必须唯一。 |
bootloader =FILE
| 到引导装载程序的路径。 |
bootargs =NAME
| 传递给引导装载程序的参数。 |
bootentry =NAME
|
过时了。通过引导装载程序引导的条目。现使用 bootargs 。
|
kernel =FILE
| 到内核映像的路径。 |
ramdisk =FILE
| 到 ramdisk 的路径。 |
features =FEATURES
| 在客户端内核中启用的特性 |
builder =FUNCTION
| 用来构建域的功能。 |
memory =MEMORY
| 域内存,单位 MB。 |
maxmem =MEMORY
| 最大域内存,单位 MB。 |
shadow_memory =MEMORY
| 影子域内存,单位 MB。 |
cpu =CPU
| 托管 VCPU0 的 CPU。 |
cpus =CPUS
| 运行域的 CPU。 |
pae =PAE
| 禁用或者启用 HVM 域的 PAE。 |
acpi =ACPI
| 禁用或者启用 HVM 域的 ACPI。 |
apic =APIC
| 禁用或者启用 HVM 域的 APIC。 |
vcpus =VCPUs
| 域中的虚拟 CPUS 数。 |
cpu_weight =WEIGHT
|
Set the new domain's cpu weight. WEIGHT is a float that controls the domain's share of the cpu.
|
restart =onreboot | always | never
|
过期。用 on_poweroff 、on_reboot 和 on_crash 替代。无论是应该重启还是退出域。- onreboot :退出后重启并关闭代码重启。- always:总是退出后重启,忽略退出编码。- never:从不退出后重启,忽略退出代码。
|
on_poweroff =destroy | restart | preserve | destroy
|
Behavior when a domain exits with reason 'poweroff '. - destroy: the domain is cleaned up as normal; - restart: a new domain is started in place of the old one; - preserve: no clean-up is done until the domain is manually destroyed (using xm destroy, for example); - rename-restart: the old domain is not cleaned up, but is renamed and a new domain started in its place.
|
on_reboot =destroy | restart | preserve | destroy
| Behavior when a domain exits with reason 'reboot'. - destroy: the domain is cleaned up as normal; - restart: a new domain is started in place of the old one; - preserve: no clean-up is done until the domain is manually destroyed (using xm destroy, for example); - rename-restart: the old domain is not cleaned up, but is renamed and a new domain started in its place. |
on_crash =destroy | restart | preserve | destroy
| Behavior when a domain exits with reason 'crash'. - destroy: the domain is cleaned up as normal; - restart: a new domain is started in place of the old one; - preserve: no clean-up is done until the domain is manually destroyed (using xm destroy, for example); - rename-restart: the old domain is not cleaned up, but is renamed and a new domain started in its place. |
blkif =no | yes
| 将域作为块设备后台。 |
netif =no | yes
| 将域作为网络接口后台。 |
tpmif =no | yes
| 将域作为 TPM 接口后台。 |
disk =phy:DEV,VDEV,MODE[,DOM]
|
在域中添加磁盘设备。物理设备是 DEV ,可将其作为 VDEV 导出到域中。如果 MODE 是 r ,那么该磁盘为只读磁盘;如果 MODE 是 w ,那么该磁盘为读写磁盘。如果指定了 DOM ,那么它会为该磁盘定义要使用的后端驱动程序。重复此选项可添加多个磁盘。
|
pci =BUS:DEV.FUNC
|
请使用给定参数(六个字符)在域中添加 PCI 设备,例如:pci=c0:02.1a 。重复该选项可添加多个 pci 设备。
|
ioports =FROM[-TO]
|
使用给定参数(六个字符)在域中添加可继承的 I/O 范围,例如:ioports=02f8-02ff 。重复此选项可添加多个 I/O 范围。
|
irq =IRQ
|
在域中添加 IRQ(中断行),例如:irq=7 。重复此选项可添加多个 IRQ。
|
usbport =PATH
| 在域中添加由到该端口的路径指定的物理 USB 端口。重复从选项可添加多个端口。 |
vfb=type=
vnclisten=
xauthority=
keymap =KEYMAP
|
Make the domain a framebuffer backend. The backend type should be either sdl or vnc . For type=vnc , connect an external vncviewer. The server will listen on ADDR (default 127.0.0.1) on port N+5900. N defaults to the domain id. If vncunused=1 , the server will try to find an arbitrary unused port above 5900. For type=sdl , a viewer will be started automatically using the given DISPLAY and XAUTHORITY , which default to the current user's ones.
|
vif=type=
script= =NAME
|
添加有给定 MAC 地址和桥接的网络接口。vif 是通过调用给定配置脚本配置的。如果没有指定类型,默认则为 netfront,而不是 ioemu 设备。如果没有指定 mac,则会使用随机 MAC 地址。如果没有指定,那么网络后端会选择其自身 MAC 地址。如果没有指定桥接,则会使用发现的第一个桥接。如果没有指定脚本,则使用默认脚本。如果没有指定后端,则会使用默认后端驱动程序域。如果没有指定 vifname,那么后端虚拟接口名称将为 vifD.N,其中 D 是域 id,N 是接口 id。可重复此选项添加多个 vif。指定 vif 可以根据需要增加接口数目。
|
vtpm=instance= INSTANCE ,backend=DOM
|
添加 TPM 接口。在后端使用给定事例作为虚拟 TPM 事例。给定数字是首选事例数。热插拔脚本会决定给域分配什么样的事例数。有关虚拟机和 TPM 事例数之间的关联请参考 /etc/xen/vtpm.db 。在给定的域中使用后端。
|
access_control=policy= POLICY ,label=LABEL
| 添加安全性标签以及定义它的安全性策略参考。在启动或者恢复该域时会计算本地 ssid 参考。此时还要根据活跃策略检查策略。这个方法包括使用保存或者恢复功能进行迁移,且会在启动或者恢复域的系统中自动生成正确的本地标签。 |
nics =NUM
| 过时。使用空白 vif 条目替换。设定网络接口数目。使用 vif 选项定义接口参数,否则使用默认设定。指定 vif 将根据需要增加接口数目。 |
root =DEVICE
|
在内核命令行中设定 root = 参数。使用设备,比如 /dev/sda1 ,或者为 NFS 根使用设备 /dev/nfs 。
|
extra =ARGS
| 在内核命令行中附加额外的参数。 |
ip =IPADDR
| 设定内核 IP 接口地址。 |
gateway =IPADDR
| 设定内核 IP 网关。 |
netmask =MASK
| 设定内核 IP 子网掩码。 |
hostname =NAME
| 设定内核 IP 主机名。 |
interface =INTF
| 设定内核 IP 接口名称。 |
dhcp =off|dhcp
| 设定内核 dhcp 选项。 |
nfs_server =IPADDR
| 为 NFS 根设定 NFS 服务器地址。 |
nfs_root =PATH
| 设定根 NFS 目录的路径。 |
device_model =FILE
| 到设备型号程序的路径。 |
fda =FILE
| 到 fda 的路径。 |
fdb =FILE
| 到 fdb 的路径。 |
serial =FILE
| 到串口、pty 或者 vc 的路径 |
localtime =no | yes
| 将 RTC 设为本地时间了吗? |
keymap =FILE
| 设定要使用的键盘布局 |
usb =no | yes
| 模拟 USB 设备 |
usbdevice =NAME
|
要添加的 USB 设备名称
|
stdvga =no | yes
|
Use std vga or Cirrus Logic
graphics
|
isa =no | yes
| 只模拟 ISA 系统 |
boot =a|b|c|d
| 默认引导设备 |
nographic =no | yes
| 设备模型是否应该使用图像? |
soundhw =audiodev
| 设备模型是否应该启用音频设备? |
vnc
| 设备模型是否应该使用 VNC? |
vncdisplay
| 要使用的 VNC 显示 |
vnclisten
| VNC 服务器要侦听的地址。 |
vncunused
| 试着为 VNC 服务器找出可用的端口。只有当 vnc=1 时有效。 |
sdl
| 设备模型可以使用 SDL 吗? |
display =DISPLAY
| 要使用的 X11 显示 |
xauthority =XAUTHORITY
| X11 管理使用 |
uuid
| 使用 xenstore UUID(全球唯一识别符)。如果没有设定这个选项,则会随机生成一个,类似与虚拟网络接口的 MAC 地址。这必须是群集中的唯一值。 |
解析程序功能 | 有效参数 |
---|---|
set_bool
|
可接受的数值:
|
set_float
|
Accepts a floating point number with Python's float(). For example:
|
set_int
|
Accepts an integer with Python's int().
|
set_value
|
接受任何 Python 数值。
|
append_value
|
接受任意 Python 值,并将其追加到之前保存在阵列中的数值。
|
Parameter | 解析程序功能 | 默认值 |
---|---|---|
name
|
setter
|
default value
|
vncpasswd
|
set_value
|
None
|
vncviewer
|
set_bool
|
None
|
vncconsole
|
set_bool
|
None
|
name
|
set_value
|
None
|
bootloader
|
set_value
|
None
|
bootargs
|
set_value
|
None
|
bootentry
|
set_value
|
None
|
kernel
|
set_value
|
None
|
ramdisk
|
set_value
|
''
|
features
|
set_value
|
''
|
builder
|
set_value
|
'linux'
|
memory
|
set_int
|
128
|
maxmem
|
set_int
|
None
|
shadow_memory
|
set_int
|
0
|
cpu
|
set_int
|
None
|
cpus
|
set_value
|
None
|
pae
|
set_int
|
0
|
acpi
|
set_int
|
0
|
apic
|
set_int
|
0
|
vcpus
|
set_int
|
1
|
cpu_weight
|
set_float
|
None
|
restart
|
set_value
|
None
|
on_poweroff
|
set_value
|
None
|
on_reboot
|
set_value
|
None
|
on_crash
|
set_value
|
None
|
blkif
|
set_bool
|
0
|
netif
|
set_bool
|
0
|
tpmif
|
append_value
|
0
|
disk
|
append_value
|
[]
|
pci
|
append_value
|
[]
|
ioports
|
append_value
|
[]
|
irq
|
append_value
|
[]
|
usbport
|
append_value
|
[]
|
vfb
|
append_value
|
[]
|
vif
|
append_value
|
[]
|
vtpm
|
append_value
|
[]
|
access_control
|
append_value
|
[]
|
nics
|
set_int
|
-1
|
root
|
set_value
|
''
|
extra
|
set_value
|
''
|
ip
|
set_value
|
''
|
gateway
|
set_value
|
''
|
netmask
|
set_value
|
''
|
hostname
|
set_value
|
''
|
interface
|
set_value
|
"eth0"
|
dhcp
|
set_value
|
'off'
|
nfs_server
|
set_value
|
None
|
nfs_root
|
set_value
|
None
|
device_model
|
set_value
|
''
|
fda
|
set_value
|
''
|
fdb
|
set_value
|
''
|
serial
|
set_value
|
''
|
localtime
|
set_bool
|
0
|
keymap
|
set_value
|
''
|
usb
|
set_bool
|
0
|
usbdevice
|
set_value
|
''
|
stdvga
|
set_bool
|
0
|
isa
|
set_bool
|
0
|
boot
|
set_value
|
'c'
|
nographic
|
set_bool
|
0
|
soundhw
|
set_value
|
''
|
vnc
|
set_value
|
None
|
vncdisplay
|
set_value
|
None
|
vnclisten
|
set_value
|
None
|
vncunused
|
set_bool
|
1
|
sdl
|
set_value
|
None
|
display
|
set_value
|
None
|
xauthority
|
set_value
|
None
|
uuid
|
set_value
|
None
|
目录
ftpd
ftpd
virsh
设置客户端 TestServer
,使其在主机引导时自动启动。
# virsh autostart TestServer
Domain TestServer marked as autostarted
--disable
停止客户端自动引导
# virsh autostart --disable TestServer
Domain TestServer unmarked as autostarted
安装 KVM 软件包
# yum install kvm
验证所用内核
uname
命令确定正在运行的内核:
$ uname -r 2.6.18-159.el5xen
2.6.18-159.el5xen
" 内核。如果运行的是默认 "2.6.18-159.el5xen
",请跳过该分步。
将 Xen 内核改为默认内核
grub.conf
文件确定引导的是哪个内核。要更改默认内核请编辑如下所示的 /boot/grub/grub.conf
文件。
default=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title 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
initrd /initrd-2.6.18-159.el5.img
title Red Hat Enterprise Linux Server (2.6.18-159.el5xen)
root (hd0,0)
kernel /xen.gz-2.6.18-159.el5
module /vmlinuz-2.6.18-159.el5xen ro root=/dev/VolGroup00/LogVol00 rhgb quiet
module /initrd-2.6.18-159.el5xen.img
0
(或者代表默认内核的数字):
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title 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
initrd /initrd-2.6.18-159.el5.img
title Red Hat Enterprise Linux Server (2.6.18-159.el5xen)
root (hd0,0)
kernel /xen.gz-2.6.18-159.el5
module /vmlinuz-2.6.18-159.el5xen ro root=/dev/VolGroup00/LogVol00 rhgb quiet
module /initrd-2.6.18-159.el5xen.img
重启载入新内核
$ lsmod | grep kvm kvm_intel 85992 1 kvm 222368 2 ksm,kvm_intel
kvm
模块和 kvm_intel
模块或者 kvm_amd
模块之一。
安装 Xen 软件包
# yum install kernel-xen xen
验证所用内核
uname
命令确定正在运行的内核。
$ uname -r 2.6.18-159.el5
2.6.18-159.el5
" 就是正在系统中运行的内核。这是默认内核。如果内核在结尾处有 xen
(例如 2.6.18-159.el5xen
),那么是 Xen 内核正在运行,这样您就可以跳过下面的子步骤。
将默认内核改为 Xen 内核
grub.conf
文件确定引导的是哪个内核。要更改默认内核请编辑如下所示的 /boot/grub/grub.conf
文件。
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title 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
initrd /initrd-2.6.18-159.el5.img
title Red Hat Enterprise Linux Server (2.6.18-159.el5xen)
root (hd0,0)
kernel /xen.gz-2.6.18-159.el5
module /vmlinuz-2.6.18-159.el5xen ro root=/dev/VolGroup00/LogVol00 rhgb quiet
module /initrd-2.6.18-159.el5xen.img
1
(或者其它代表 Xen 内核的数字):
default=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title 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
initrd /initrd-2.6.18-159.el5.img
title Red Hat Enterprise Linux Server (2.6.18-159.el5xen)
root (hd0,0)
kernel /xen.gz-2.6.18-159.el5
module /vmlinuz-2.6.18-159.el5xen ro root=/dev/VolGroup00/LogVol00 rhgb quiet
module /initrd-2.6.18-159.el5xen.img
重启载入新内核
uname
命令验证:
$ uname -r 2.6.18-159.el5xen
xen
,那么运行的就是 Xen 内核。
qemu-img
命令行工具是 Xen 和 KVM 用来格式化各种文件系统的。可使用 qemu-img
格式化虚拟客户端映像、附加存储设备以及网络存储。qemu-img
选项及用法如下。
size
,格式为 format
。
# qemu-img create [-6] [-e] [-b base_image] [-f format] filename [size]
convert
选项用于将识别的格式转换成另一个映像格式。
# qemu-img convert [-c] [-e] [-f format]filename
[-Ooutput_format
]output_filename
output_format
将磁盘映像 filename
转换为磁盘映像 output_filename
。可使用 -e
选项对该磁盘映像进行加密或者使用 -c
选项对其进行压缩。
qcow
" 支持加密或者压缩。加密是只读的,就是说如果重新写入压缩的字段,那么会以未压缩数据形式重新写入。
qcow
或 cow
时,映像转换可帮助您获得较小的映像。在目的映像中可检测并压缩空白字段。
info
参数显示磁盘映像信息。info
选项的格式如下:
# qemu-img info [-f format] filename
raw
qemu-img info
了解 Unix/Linux 中映像或者 ls -ls
使用的实际大小。
qcow2
qcow
cow
cow
格式的目的只是为了与前面的版本兼容。它无法在 Windows 中使用。
vmdk
cloop
(0.5 * RAM) + (overcommit ratio * RAM) = Recommended swap size
/etc/grub.conf
file to use the virtualization kernel. You must use the xen
kernel to use the Xen hypervisor. Copy your existing xen
kernel entry make sure you copy all of the important lines or your system will panic upon boot (initrd
will have a length of '0
'). If you require xen
hypervisor specific values you must append them to the xen
line of your grub entry.
grub.conf
条目示例。在您的系统中的 grub.conf
文件可能会有所不同。示例中重要的是从 title
行到下一个新行之间的部分。
#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.21.el5xen ro root=/dev/VolGroup00/LogVol00 module /initrd-2.6.17-1.2519.4.21.el5xen.img
grub.conf
中重要的一点......grub.conf
could look very different if it has been manually edited before or copied from an example. Read 第 28 章 配置 Xen 内核引导参数 for more information on using virtualization and grub.
grub.conf
文件的 xen
行中附加 dom0_mem=256M
。前面示例的 grub 配置文件的修订版本如下:
#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 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
$ grep -E 'svm|vmx' /proc/cpuinfo
vmx
条目,说明是带 Intel VT 扩展的 Intel 处理器:
flags : fpu tsc msr pae mce cx8 apic mtrr mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall lm constant_tsc pni monitor ds_cpl vmx est tm2 cx16 xtpr lahf_lm
svm
条目,说明是带 AMD-V 扩展的 AMD 处理器:
flags : fpu tsc msr pae mce cx8 apic mtrr mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt lm 3dnowext 3dnow pni cx16 lahf_lm cmp_legacy svm cr8legacy ts fid vid ttp tm stc
flags:
" 内容。
For users of the KVM hypervisor
kvm
modules are loaded in the kernel:
# lsmod | grep kvm
kvm_intel
or kvm_amd
then the kvm
hardware virtualization modules are loaded and your system meets requirements. sudo
virsh
command can output a full list of virtualization system capabilities. Run virsh capabilities
as root to receive the complete list.
kpartx
tool, covered by this section, to mount the guest file system as a loop device which can then be accessed.
kpartx
command creates device maps from partition tables. Each guest storage image has a partition table embedded in the file.
# yum install kpartx
guest1.img
.
# kpartx -l /var/lib/libvirt/images/guest1.img
loop0p1 : 0 409600 /dev/loop0 63
loop0p2 : 0 10064717 /dev/loop0 409663
guest1
is a Linux guest. The first partition is the boot partition and the second partition is an EXT3 containing the root partition.
/dev/mapper/
.
# kpartx -a /var/lib/libvirt/images/guest1.img
# ls /dev/mapper/ loop0p1 loop0p2
loopXpY
.
/mnt/guest1
for mounting the partition.
# mkdir /mnt/guest1
# mount /dev/mapper/loop0p1
/mnt/guest1 -o loop,ro
/mnt/guest1
directory. Read or copy the files.
# umount /mnt/tmp
# kpartx -d /var/lib/libvirt/images/guest1.img
guest1.img
to the recognized devices in the /dev/mapper/
directory.
# kpartx -a /var/lib/libvirt/images/guest1.img
vgscan
command to find the new volume groups.
# vgscan Reading all physical volumes . This may take a while... Found volume group "VolGroup00" using metadata type lvm2
VolGroup00
by default) with the vgchange -ay
command.
# vgchange -ay VolGroup00 2 logical volumes in volume group VolGroup00 now active.
lvs
command to display information about the new volumes. The volume names (the LV
column) are required to mount the volumes.
# lvs LV VG Attr Lsize Origin Snap% Move Log Copy% LogVol00 VolGroup00 -wi-a- 5.06G LogVol01 VolGroup00 -wi-a- 800.00M
/dev/VolGroup00/LogVol00
in the /mnt/guestboot/
directory.
# mount /dev/VolGroup00/LogVol00 /mnt/guestboot
/mnt/guestboot
directory. Read or copy the files.
# umount /mnt/
VolGroup00
# vgchange -an VolGroup00
# kpartx -d /var/lib/libvirt/images/guest1.img
virsh nodeinfo
command provides information about how many sockets, cores and hyperthreads there are attached a host.
# virsh nodeinfo CPU model: x86_64 CPU(s): 8 CPU frequency: 1000 MHz CPU socket(s): 2 Core(s) per socket: 4 Thread(s) per core: 1 NUMA cell(s): 1 Memory size: 8179176 kB
virsh capabilities
to get additional output data on the CPU configuration.
# virsh capabilities
<capabilities>
<host>
<cpu>
<arch>x86_64</arch>
</cpu>
<migration_features>
<live/>
<uri_transports>
<uri_transport>tcp</uri_transport>
</uri_transports>
</migration_features>
<topology>
<cells num='2'>
<cell id='0'>
<cpus num='4'>
<cpu id='0'/>
<cpu id='1'/>
<cpu id='2'/>
<cpu id='3'/>
</cpus>
</cell>
<cell id='1'>
<cpus num='4'>
<cpu id='4'/>
<cpu id='5'/>
<cpu id='6'/>
<cpu id='7'/>
</cpus>
</cell>
</cells>
</topology>
<secmodel>
<model>selinux</model>
<doi>0</doi>
</secmodel>
</host>
[ Additional XML removed ]
</capabilities>
virsh freecell
command to display the free memory on all NUMA nodes.
# virsh freecell 0: 2203620 kB 1: 3354784 kB
virsh capabilities
command) about NUMA topology.
virsh capabilities
output.
<topology> <cells num='2'> <cell id='0'> <cpus num='4'> <cpu id='0'/> <cpu id='1'/> <cpu id='2'/> <cpu id='3'/> </cpus> </cell> <cell id='1'> <cpus num='4'> <cpu id='4'/> <cpu id='5'/> <cpu id='6'/> <cpu id='7'/> </cpus> </cell> </cells> </topology>
<cell id='1'>
, has physical CPUs 4 to 7.
cpuset
attribute to the configuration file.
virsh edit
.
vcpus
element.
<vcpus>4</vcpus>
cpuset
attribute with the CPU numbers for the relevant NUMA cell.
<vcpus cpuset='4-7'>4</vcpus>
virt-install
provisioning tool provides a simple way to automatically apply a 'best fit' NUMA policy when guests are created.
cpuset
option for virt-install
can use a CPU set of processors or the parameter auto
. The auto
parameter automatically determines the optimal CPU locking using the available NUMA data.
--cpuset=auto
with the virt-install
command when creating new guests.
virsh vcpuinfo
and virsh vcpupin
commands can perform CPU affinity changes on running guests.
virsh vcpuinfo
command gives up to date information about where each virtual CPU is running.
guest1
is a guest with four virtual CPUs is running on a KVM host.
# virsh vcpuinfo guest1
VCPU: 0
CPU: 3
State: running
CPU time: 0.5s
CPU Affinity: yyyyyyyy
VCPU: 1
CPU: 1
State: running
CPU Affinity: yyyyyyyy
VCPU: 2
CPU: 1
State: running
CPU Affinity: yyyyyyyy
VCPU: 3
CPU: 2
State: running
CPU Affinity: yyyyyyyy
virsh vcpuinfo
output (the yyyyyyyy
value of CPU Affinity
) shows that the guest can presently run on any CPU.
# virsh vcpupinguest1
0 4 # virsh vcpupinguest1
1 5 # virsh vcpupinguest1
2 6 # virsh vcpupinguest1
3 7
virsh vcpuinfo
command confirms the change in affinity.
# virsh vcpuinfo guest1
VCPU: 0
CPU: 4
State: running
CPU time: 32.2s
CPU Affinity: ----y---
VCPU: 1
CPU: 5
State: running
CPU time: 16.9s
CPU Affinity: -----y--
VCPU: 2
CPU: 6
State: running
CPU time: 11.9s
CPU Affinity: ------y-
VCPU: 3
CPU: 7
State: running
CPU time: 14.6s
CPU Affinity: -------y
macgen.py
. Now from that directory you can run the script using ./macgen.py
and it will generate a new MAC address. A sample output would look like the following:
$ ./macgen.py 00:16:3e:20:b0:11 #!/usr/bin/python # macgen.py script to generate a MAC address for virtualized guests on Xen # import random # def randomMAC(): mac = [ 0x00, 0x16, 0x3e, random.randint(0x00, 0x7f), random.randint(0x00, 0xff), random.randint(0x00, 0xff) ] return ':'.join(map(lambda x: "%02x" % x, mac)) # print randomMAC()
python-virtinst
的内嵌模块生成用于客户端配置文件的新 MAC 地址以及 UUID
:
# echo 'import virtinst.util ; print\ virtinst.util.uuidToString(virtinst.util.randomUUID())' | python # echo 'import virtinst.util ; print virtinst.util.randomMAC()' | python
#!/usr/bin/env python # -*- mode: python; -*- print "" print "New UUID:" import virtinst.util ; print virtinst.util.uuidToString(virtinst.util.randomUUID()) print "New MAC:" import virtinst.util ; print virtinst.util.randomMAC() print ""
rate
” parameter part of the VIF
entries can throttle virtualized guests.
rate
rate=
option can be added to the VIF=
entry in a virtual machine configuration file to limit a virtual machine's network bandwidth or specify a specific time interval for a time window.
rate=
选项来说时间窗是可选的:
rate
参数值及使用示例。
rate=10Mb/s
rate=250KB/s
rate=10MB/s@50ms
VIF
条目示例如下:
vif = [ 'rate=10MB/s , mac=00:16:3e:7a:55:1c, bridge=xenbr1']
rate
entry would limit the virtual machine's interface to 10MB/s for outgoing traffic
virsh
或者 virt-manager
定义 CPU 亲和性:
virsh
refer to 配置虚拟 CPU 亲和性 for more information.
virt-manager
refer to 第 26.11 节 “显示虚拟 CPU” for more information.
/boot/grub/grub.conf
. Managing several or more hosts configuration files quickly becomes difficult. System administrators often prefer to use the 'cut and paste' method for editing multiple grub.conf
files. If you do this, ensure you include all five lines in the Virtualization entry (or this will create system errors). Hypervisor specific values are all found on 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 is the grub.conf
with the hypervisor's memory entry modified.
# 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
ftpd
vsftpd
为半虚拟客户端(例如:红帽企业版 Linux 5 程序库)或者其他数据库提供对安装树的访问。如果您在安装服务器的过程中还没有安装 vsftpd
,您可以从您安装介质的 Server
目录中获得 RPM 软件包,并使用 rpm -ivh vsftpd*.rpm
安装(请注意:RPM 软件包必须位于您的当前目录中)。
vsftpd
, edit /etc/passwd
using vipw
and change the ftp user's home directory to the directory where you are going to keep the installation trees for your para-virtualized guests. An example entry for the FTP user would look like the following:
ftp:x:14:50:FTP User:/xen/pub:/sbin/nologin
chkconfig --list vsftpd
确定没有启用 vsftpd
:
$ chkconfig --list vsftpd vsftpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
chkconfig --levels 345 vsftpd on
为运行级别 3、4 和 5 自动启用 vsftpd。
chkconfig --list vsftpd
命令验证在系统引导时会自动启动 vsftdp:
$ chkconfig --list vsftpd vsftpd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
service vsftpd start vsftpd
启动 vsftpd 服务:
$service vsftpd start vsftpd Starting vsftpd for vsftpd: [ OK ]
udev
部署 LUN 持久性。在您的系统中部署 LUN 持久性前,请确定您有正确的 UUID。您得到它们后,即可编辑位于 /etc
目录的 scsi_id
文件来配置 LUN 持久性。当您在文本编辑器中打开此文件时,您必须注释出这一行:
# options=-b
# options=-g
scsi_id
命令:
# 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
"
UUID
和 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 中创建了别名。
/sbin/service smartd stop /sbin/chkconfig --del smartd
/var/lib/xen
, the usually named vmlinuz.******
and initrd.******
. These files are the initrd and vmlinuz files from virtual machines which either failed to boot or failed for some other reason. These files are temporary files extracted from virtual machine's boot disk during the start up sequence. These files should be automatically removed after the virtual machine is shut down cleanly. Then you can safely delete old and stale copies from this directory.
vino-preferences
命令配置 VNC 服务器。
~/.vnc/xstartup
文件来启动 GNOME 会话。在您第一次运行 vncserver 脚本时,它会询问您要使用的 VNC 会话的密码。
xstartup
文件示例:
#!/bin/sh # Uncomment the following two lines for normal desktop: # unset SESSION_MANAGER # exec /etc/X11/xinit/xinitrc [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources #xsetroot -solid grey #vncconfig -iconic & #xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & #twm & if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then eval `dbus-launch --sh-syntax –exit-with-session` echo "D-BUS per-session daemon address is: \ $DBUS_SESSION_BUS_ADDRESS" fi exec gnome-session
uuidgen
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
条目。
name
uuid
uuidgen
命令可重新生成一个新的 UUID。UUID 输出示例:
$ uuidgen a984a14f-4191-4d14-868e-329906b211e5
vif
xenbr
条目以符合您的本地联网配置(您可以使用 brctl show
命令获得桥接信息)。
disk=
部分的条目使其指向正确的客户端映像。
/etc/sysconfig/network
HOSTNAME
entry to the guest's new hostname
.
/etc/sysconfig/network-scripts/ifcfg-eth0
ifconfig eth0
输出中的硬件地址替换 HWADDR
地址。
IPADDR
条目。
libvirt
编写自定义脚本的程序员和系统管理员提供一些有用信息。
libvirt
.
virsh
can handle XML configuration files. You may want to use this to your advantage for scripting large deployments with special options. You can add devices defined in an XML file to a running para-virtualized guest. For example, to add a ISO file as hdc
to a running guest create an XML file:
# cat satelliteiso.xml <disk type="file" device="disk"> <driver name="file"/> <source file="/var/lib/libvirt/images/rhn-satellite-5.0.1-11-redhat-linux-as-i386-4-embedded-oracle.iso"/> <target dev="hdc"/> <readonly/> </disk>Run
virsh attach-device
to attach the ISO as hdc
to a guest called "satellite" :
# virsh attach-device satellite satelliteiso.xml
目录
xentop
xentop
显示主机系统以及客户端域的实时信息。
xm
dmesg
和 log
vmstat
iostat
lsof
iostat
、mpstat
和 sar
命令都来自 sysstat
软件包。
XenOprofile
systemtap
crash
sysrq
sysrq t
sysrq w
ifconfig
tcpdump
tcpdump
command 'sniffs' network packets. tcpdump
is useful for finding network abnormalities and problems with network authentication. There is a graphical version of tcpdump
named wireshark
.
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? aging 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 aging-time 300.01 hello-timer 1.43 tcn-timer 0.00 topology-change-timer 0.00 gc-timer 0.02
Server
库中找到。
yum install vnc
command.
yum install vnc-server
命令安装 vncserver。
/etc/xen/
。该目录包含了 xend
守护进程以及其它虚拟机配置文件。联网脚本文件位于 script
目录中。
/var/log/xen
目录中。
/var/lib/libvirt/images
。
/proc/xen/
目录中。
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
进程 PID。注意您必须用实际的 qemu-dm
进程的 PID 来替换 [PID]。
/.virt-manager
目录中 virt-manager.log
文件生成的数据。请注意每次您启动虚拟机管理者,它都会覆盖现有的日志文件内容。当出现系统错误后,在重启虚拟机管理者前,请确定备份了 virt-manager.log
文件。
/var/lib/libvirt/images
目录中的虚拟客户端映像。
xend
守护进程时,它会更新位于 /var/lib/xen/xend-db
目录中的 xend-database
。
xm dump-core
命令生成的)位于 /var/lib/xen/dumps
目录中。
/etc/xen
目录包含您用来管理系统资源的配置文件。xend
守护进程的配置文件是 /etc/xen/xend-config.sxp
。您可以使用这个文件来实施系统范围的修改并配置联网,但不建议手动编辑 /etc/xen/
文件夹中的文件。
proc
命令是另一个允许您收集系统信息的文件夹。这些 proc 条目位于 /proc/xen
目录。
/proc/xen/capabilities
/proc/xen/balloon
/proc/xen/xenbus/
xend.log
file contains the same basic information as when you run the xm log
command. This log is found 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
grub.conf
file to enable a 38400-bps serial console on com1
/dev/ttyS0
:
title Red Hat Enterprise Linux (2.6.18-8.2080_xen0) 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
可以帮助您诊断导致异步的管理程序控制台输出挂起的问题,"pnpacpi=off"
可以解决中断串口控制台中输入的问题。参数 "console=ttyS0"
和 "console=tty"
表示内核错误将在普通的 VGA 控制台以及串口控制台上被记载。然后您可以通过标准的非调制解调器(null-modem)的电缆来安装并设置 ttywatch
,捕获连接到非调制解调器电缆的远程主机中的数据。例如,在远程主机中,您可以输入:
ttywatch --name myhost --port /dev/ttyS0
/dev/ttyS0
的输出导出至 /var/log/ttywatch/myhost.log
文件。
# virsh console [guest name, ID or UUID]
virt-manager
to display the virtual text console. In the guest console window, select Serial Console from the View menu.
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). To use the guest's serial console, you must edit the libvirt configuration file configuration file. On the host, access the serial console with the following command:
# virsh console
virt-manager
to display the virtual text console. In the guest console window, select Serial Console from the View menu.
xend
服务时,什么也没有发生。键入 virsh list
后可以看到下面的输出:
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' )
kernel-xen
内核。要修正这个问题,您必须在引导时选择 kernel-xen
内核(或在 grub.conf
文件中将 kernel-xen
内核设置为默认选项)。
"Invalid argument"
错误信息。这通常是代表您试图引导的内核映像和管理程序(hypervisor)不兼容。例如,当您试图在支持 PAE 的 FC6 管理程序中运行 non-PAE FC5 内核时,就会出现这个问题。
grub.conf
里的缺省内核选项切换回普通内核而不是虚拟化内核。
/etc/sysconfig/kernel/
directory. You must ensure that kernel-xen
parameter is set as the default option in your grub.conf
file.
/boot/grub/grub.conf
文件并设定恰当的串口设备参数。
com1
,请修改 /boot/grub/grub.conf
文件,插入行 com1=115200,8n1
、console=tty0
和 console=ttyS0,115200
。
title Red Hat Enterprise Linux 5 i386 Xen (2.6.18-92.el5xen) root (hd0, 8) kernel /boot/xen.gz-2.6.18-92.el5com1=115200,8n1
module /boot/vmlinuz-2.6.18-92.el5xen ro root=LABEL=VG_i386console=tty0
console=ttyS0,115200
module /boot/initrd-2.6.18-92.el5xen.img
com2
,请修改 /boot/grub/grub.conf
,插入 com2=115200,8n1 console=com2L
、console=tty0
和 console=ttyS0,115200
。
title Red Hat Enterprise Linux 5 i386 Xen (2.6.18-92.el5xen) root (hd0, 8) kernel /boot/xen.gz-2.6.18-92.el5 com2=115200,8n1 console=com2L module /boot/vmlinuz-2.6.18-92.el5xen ro root=LABEL=VG_i386 console=tty0 console=ttyS0,115200 module /boot/initrd-2.6.18-92.el5xen.img
com1
、com2
等等)中输出连续数据。
com2
端口,在 vmlinuz
行中使用 console=ttyS0
参数。作为 console=ttyS0
使用的每个端口的行为都不是标准 Linux 行为,它们是为 Xen 环境特别指定的。
virsh console
" 或者 virt-manager
的"「串口控制台」"窗口获得来自半虚拟客户端的串口控制台输出。使用一下步骤配置虚拟串口控制台:
/boot/grub/grub.conf
:
Red Hat Enterprise Linux 5 i386 Xen (2.6.18-92.el5xen) root (hd0, 0) kernel /boot/vmlinuz-2.6.18-92.el5xen ro root=LABEL=VG_i386 console=xvc0 initrd /boot/initrd-2.6.18-92.el5xen.img
xend
)配置为记录来自半虚拟客户端串口控制台的输出。
xend
,请编辑 /etc/sysconfig/xend
。更改条目:
# Log all guest console output (cf xm console) #XENCONSOLED_LOG_GUESTS=no
# Log all guest console output (cf xm console) XENCONSOLED_LOG_GUESTS=yes
/var/log/xen/console
文件中。
virsh console
命令查看全虚拟客户端查看控制台输出。
ttyS0
,在 Windows 中名为 COM1
。
/boot/grub/grub.conf
文件,插入行 "console=tty0 console=ttys0,115200
"。
title Red Hat Enterprise Linux Server (2.6.18-92.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-92.el5 ro root=/dev/volgroup00/logvol00
console=tty0 console=ttys0,115200
initrd /initrd-2.6.18-92.el5.img
virsh console
" 命令查看串口控制台信息。
/var/log/xen/console
中,因为它们用于半虚拟客户端。
virt-manager
or virt-install
tools on Red Hat Enterprise Linux 5, the guests configuration files are created automatically in the /etc/xen
directory.
name = "rhel5vm01" memory = "2048" disk = ['tap:aio:/var/lib/libvirt/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"
是配置文件的缺省设置。下面是完全虚拟化客户端的一个配置文件示例:
name = "rhel5u5-86_64" builder = "hvm" memory = 500 disk = ['/var/lib/libvirt/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'
virsh dumpxml
和 virsh create
(或者 virsh edit
)编辑 libvirt
配置文件(xml 文件),该文件有错误和安全检查功能。
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
命令检查 domain0 所使用的内存量。如果还有 domain0 内存可用,您可以用命令 virsh setmem dom0 NewMemSize
来查看内存。
wrong kernel image: non-PAE kernel on a PAE
# 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: domain=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!
# xm create mySQL01 Using config file " 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
/etc/xen
directory. For example, editing the guest mySQL01
# vim /etc/xen/mySQL01
Locate the vif
entry. Assuming you are using xenbr0
as the default bridge, the proper entry should resemble the following:
# vif = ['mac=00:16:3e:49:1d:11, bridge=xenbr0',]
# xm shutdown win2k3xen12 # 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)
/etc/xen/
目录包含xend
守护进程使用的配置文件。
scripts
目录。
/var/log/xen/
/var/lib/libvirt/images/
/proc/xen/
cat /proc/partitions
" 进行此操作,如下:
# cat /proc/partitions major minor #blocks name 202 16 104857600 xvdb 3 0 8175688 hda
/etc/inittab
文件中添加以下行:
1:12345:respawn:/sbin/mingetty xvc0
Xen Virtual Ethernet
网卡。执行以下命令对其进行确认(用于红帽企业版 Linux 4 和 5):
cat /etc/modprobe.conf
cat /etc/modules.conf
alias eth0 xen-vnif
alias eth0 xen-vnif
)。
/etc/modprobe.conf
中调整回送设备数目。请编辑 /etc/modprobe.conf
文件并在其中添加以下行:
options loop max_loop=64
phy: block device
命令或者 tap:aio
命令。要使用回送设备为全虚拟系统备份客户端,请使用 phy: device
或者 file: file
命令。
dom0
has not ballooned down enough to provide space for a recently created or started guest. In your /var/log/xen/xend.log
, an example error message indicating this has occurred:
[2006-11-21 20:33:31 xend 3198] DEBUG (balloon:133) Balloon: 558432 KiB free; 0 to scrub; need 1048576; retries: 20. [2006-11-21 20:33:52 xend.XendDomainInfo 3198] ERROR (XendDomainInfo:202) Domain construction failedYou can verify the amount of memory currently used by
dom0
with the command “xm list Domain-0
”. If dom0
is not ballooned down you can use the command “xm mem-set Domain-0 NewMemSize
” where NewMemSize
should be a smaller value.
# xm create testVM Using config file "./testVM". Going to boot Red Hat Enterprise Linux Server (2.6.18-1.2839.el5) kernel: /vmlinuz-2.6.18-1.2839.el5 initrd: /initrd-2.6.18-1.2839.el5.img Error: (22, 'Invalid argument')In the above error you can see that the kernel line shows that the system is trying to boot a non kernel-xen kernel. The correct entry in the example is ”
kernel: /vmlinuz-2.6.18-1.2839.el5xen
”.
/etc/grub.conf
配置文件中的默认引导内核。
kernel-xen
,您就可以启动您的客户端:
xm create -c GuestName
GuestName
is the name of the guest. The previous command will present you with the GRUB boot loader screen and allow you to select the kernel to boot. You will have to choose the kernel-xen kernel to boot. Once the guest has completed the boot process you can log into the guest and edit /etc/grub.conf
to change the default boot kernel to your kernel-xen. Simply change the line “default=X
” (where X is a number starting at '0
') to correspond to the entry with your kernel-xen line. The numbering starts at '0
' so if your kernel-xen entry is the second entry you would enter '1
' as the default,for example “default=1
”.
# xm create -c va-base Using config file "va-base". Error: (22, 'Invalid argument') [2006-12-14 14:55:46 xend.XendDomainInfo 3874] ERROR (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 (XendDomainInfo:1449) XendDomainInfo.destroy: domid=1 [2006-12-14 14:55:46 xend.XendDomainInfo 3874] DEBUG (XendDomainInfo:1457) XendDomainInfo.destroyDomain(1)If you need to run a 32 bit or non-PAE kernel you will need to run your guest as a fully-virtualized virtual machine. The rules for hypervisor compatibility are:
Your CPU does not support long mode. Use a 32 bit distribution
. This problem is caused by a missing or incorrect pae
setting. Ensure you have an entry “pae=1
” in your guest's configuration file.
virt-manager
应用程序可能无法启动并显示出错信息,比如“Unable to open a connection to the Xen hypervisor/daemon
”。这通常是由于在 /etc/hosts
文件中缺少 localhost
条目所致。请确定您确实有 localhost
条目,同时,如果在 /etc/hosts
文件中缺少该条目,请插入一个新条目。不正确的 /etc/hosts
可能类似如下:
# 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
Applying Intel CPU microcode update: FATAL: Module microcode not found. ERROR: Module microcode does not exist in /proc/modulesAs the virtual machine is running on virtual CPUs there is no point updating the microcode. Disabling the microcode update for your virtual machines will stop this error:
/sbin/service microcode_ctl stop /sbin/chkconfig --del microcode_ctl
xm create
”会先在当前目录中查找配置文件,然后才在 /etc/xen
中查找。
# xm shutdown win2k3xen12 # xm create win2k3xen12 Using config file "win2k3xen12". /usr/lib64/python2.4/site-packages/xen/xm/opts.py:520: DeprecationWarning: 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 (win2k3xen12, line 1)
Enabling the virtualization extensions in BIOS
cat /proc/cpuinfo | grep vmx svm
。如果命令有输出结果,则启用了虚拟化扩展。如果没有结果,那么您的系统可能没有虚拟化扩展或者没有启用正确的 BIOS 设置。
virsh
command (where GUEST
is the guest's name):
# virsh edit GUEST
virsh edit
命令使用 $EDITOR
shell 变量确定要使用的编辑器。
<interface type='network'>
[output truncated]
<model type='rtl8139' />
</interface>
'rtl8139'
to 'e1000'
. This will change the driver from the rtl8139 driver to the e1000 driver.
<interface type='network'>
[output truncated]
<model type='e1000'
/>
</interface>
# virsh dumpxml GUEST > /tmp/guest.xml
# cp /tmp/guest.xml /tmp/new-guest.xml # vi /tmp/new-guest.xml
<interface type='network'>
[output truncated]
<model type='e1000' />
</interface>
# virsh define /tmp/new-guest.xml # virsh start new-guest
/var/log/xen/
xend
守护进程和 qemu-dm 进程生成的日志文件。
xend.log
xend-debug.log
xen-hotplug.log
qemu-dm.PID
.log
qemu-dm
进程生成,会为每个全虚拟客户端启动该进程。
PID
替换 PID
ps
命令为给定 qemu-dm
进程查询 PID
,并可在查看确定用来验证 qemu-dm
进程所属虚拟机的进程参数。
.virt-manager
in the user's home
directory whom ran virt-manager. This directory will usually be ~/.virt-manager/virt-manager
.
/var/lib/libvirt/images/
/var/lib/xen/xend-db/
/etc/xen/
/etc/xen/xend-config.sxp
是 xend 守护进程的主要配置文件。xend-config.sxp
文件启用或者禁用迁移以及其它 libvirt
没有配置的特性。其它特性请使用 libvirt
工具。
/var/lib/xen/dump/
xm dump-core
命令生成的转储。
/proc/xen/
xen-kernel
信息:
/proc/xen/capabilities
/proc/xen/privcmd
/proc/xen/balloon
/proc/xen/xenbus
/proc/xen/xsd_port
/proc/xen/xsd_kva
# insmod xen-platform-pci.o Warning: kernel-module version mismatch xen-platform-pci.o was compiled for kernel version 2.4.21-52.EL while this kernel is version 2.4.21-50.EL xen-platform-pci.o: unresolved symbol __ioremap_R9eac042a xen-platform-pci.o: unresolved symbol flush_signals_R50973be2 xen-platform-pci.o: unresolved symbol pci_read_config_byte_R0e425a9e xen-platform-pci.o: unresolved symbol __get_free_pages_R9016dd82 [...]The solution is to use the correct RPM package for your hardware architecture for the para-virtualized drivers.
Warning: kernel-module version mismatch xen-platform-pci.o was compiled for kernel version 2.4.21-52.EL while this kernel is version 2.4.21-50.EL Warning: loading xen-platform-pci.o will taint the kernel: forced load See http://www.tux.org/lkml/#export-tainted for information about tainted modules Module xen-platform-pci loaded, with warnings
# cd /lib/modules/`uname -r`/ # find . -name 'xen_*.ko' -print
# insmod \ /lib/modules/'uname -r'/{LocationofPV-drivers}/xen_platform_pci.ko # insmod /lib/modules/'uname -r'/{LocationofPV-drivers}/xen_balloon.ko # insmod /lib/modules/'uname -r'/{LocationofPV-drivers}/xen_vnif.ko # insmod /lib/modules/'uname -r'/{LocationofPV-drivers}/xen_vbd.ko
/var/log/messages
# grep -E "vif|vbd|xen" /var/log/messages xen_mem: Initialising balloon driver vif vif-0: 2 parsing device/vif/0/mac vbd vbd-768: 19 xlvbd_add at /local/domain/0/backend/vbd/21/76 vbd vbd-768: 19 xlvbd_add at /local/domain/0/backend/vbd/21/76 xen-vbd: registered block device major 202You can also use the
lsmod
command to list the loaded para-virtualized drivers. It should output a list containing the xen_vnif
, xen_vbd
, xen_platform_pci
and xen_balloon
modules.
# lsmod|grep xen xen_vbd 19168 1 xen_vnif 28416 0 xen_balloon 15256 1 xen_vnif xen_platform_pci 98520 3 xen_vbd,xen_vnif,xen_balloon,[permanent]
type=ioemu
' part of 'vif
=' line in your guest's configuration file.
domU
refers to the guest operating systems which run on the host system (the dom0 domain).
/dev/VolGroup00/LogVol02
),
/dev/sda5
), and
/dev/sda
).
tap:aio
tap:aio
parameter sets the Xen hypervisor to use an advanced access mode designed for safety and performance. File-based, are accessed using a kernel thread and a user-space process. The tap:aio
method respects guest flush requests which makes it safer than the file
driver. The virtualization tools use tap:aio
by default for accessing file-based guest disks on the Xen Hypervisor.
ext2
和 ext3
文件系统识别符、RAID 设备识别符、iSCSI 和 LUN 设备识别符、MAC 地址以及虚拟机识别符。
libvirt
虚拟化 API 的官方网站。
/usr/share/doc/xen-<version-number>
/
是包含有关 Xen 半虚拟化监控程序以及相关管理工具信息的目录,其中包括各种示例配置、硬件特别信息以及当前 Xen 上级用户文档。
man virsh
和 /usr/share/doc/libvirt-<version-number>
— 包含了 virsh
虚拟机管理工具的子命令和选项,还包括有关 libvirt
虚拟化库 API 的综合信息。
/usr/share/doc/gnome-applet-vm-<version-number>
— 监控和管理本地运行的虚拟机的 GNOME 图形化面板 applet 的文档。
/usr/share/doc/libvirt-python-<version-number>
— 提供 libvirt
库的 Python 绑定的细节。libvirt-python
软件包允许 python 开发者用 libvirt
虚拟化管理库编写程序。
/usr/share/doc/python-virtinst-<version-number>
— 提供在虚拟机里启动 Fedora 和红帽企业 Linux 安装的 virt-install
命令的文档。
/usr/share/doc/virt-manager-<version-number>
— 提供虚拟机管理者(管理虚拟机的图形化工具)的文档。