xen管理命令

相关管理命令:

    启动,停止虚拟机:
    可以使用xm 命令来启动停止虚拟机启动虚拟机命令如下:
    xm create vm1 #其中vm1 为虚拟机的配置文件,位于/etc/xen/vm/vm1
    xm create -c vm1 #如果需要启动控制台,则可以运行命令
    xm list #可以列出所有的虚拟机
    xm console <domid> #可以显示某虚拟机的控制台
    xm reboot|shutdown <domid> #可以重起和关闭id 为domid 的虚拟机
    xm destroy <domid> #可以销毁id 为domid 的虚拟机
    xm console fc5 #从终端或控制台登录正在运行的虚拟操作系统
    xm save <DomId> <File> # 存储正在运行的虚拟操作系统的状态
    xm restore <File> # 唤醒虚拟操作系统
    xm pause <DomId> #停止正在运行的虚拟操作系统
    xm unpause <DomId> #激活停止的虚拟操作系统
    xm mem-set <DomId> <Mem> #调整虚拟平台/虚拟操作系统的占用内存
    xm shutdown 虚拟操作系统的Name或DomID #关闭被虚拟的系统
    xm destroy <DomId> #立即停止虚拟的系统 (重要);
    xm vcpu-set <DomId> <VCPUs> #调整虚拟平台及虚拟操作系统的虚拟CPU个数
    xm top 或 xentop # 查看虚拟系统运行的状态
    xm save VM1 VM1.chk # stop the domain and save its current state into a file called VM1.chk
    xm restore VM1.chk #resume execution of this domain

其它

++如果妳想要在系统开机时就自动启动某个 domain-U 的话,可以将该设定档指定连结到这个目录中。 举例来说,如果妳要在开机后立即使用 /etc/xen/xmexample.hvm 设定档来启动某个 domain-U , 那可以这样做:
cd /etc/xen/auto
ln -s ../xmexample.hvm .
最后保证xendomains是开机自动启动即可

++ 列出所以的vif与bridage 对应关系
xen ~ # brctl show

++修改启动顺序
boot=”cda” # boot on floppy (a), hard disk (c) or CD-ROM (d)

++相关配置文件说明
disk = [ 'file:/opt/xen/kcwin2k3_2/disk1.img,hda,w',
'file:/opt/xen/kcwin2k3_2/disk2.img,hdb,w', 'file:/iso/win2k3.iso,hdc:cdrom,r', ] 虚拟机的第1和第2块虚拟磁盘, 指定了虚拟机的CDROM,目标其实是宿主机上的一张Win2k3安装ISO镜像的路径,然后r代表只读
serial = “pty” # enable serial console
#cpus = “0-3,5,^1″ # run on cpus 0,2,3,5

++网络相关
brctl show #桥链状态
network-bridge start bridge=xenbr1 netdev=eth1 vifnum=1 #新增一个桥连口xenbr1,以本机eth1为源网卡

++新增一个网桥xenbr1,并使用eth1网卡
http://blog.zhangjianfeng.com/article/744

++修改宿主机的网卡IP
/usr/share/doc/packages/xen/README.SuSE 中这么一段说明
Configuring network interfaces when using Xen bridging:
Due to the renaming of network interfaces by the network-bridge script
(e.g. eth0 to peth0), network interfaces should not be configured or restarted
while they are enslaved to a Xen bridge. Before configuring a network
interface enslaved to a Xen bridge, shutdown all VMs using the interface.
Then use the network-bridge script to remove the Xen bridge and to restore the
network interface back to normal (put peth0 back to eth0). For example, to
remove the Xen bridge and restore eth0 back to normal do the following:
/etc/xen/scripts/network-bridge stop netdev=eth0
With the Xen bridge removed and eth0 put back to normal, eth0 can then be
configured or restarted. Once the configuration is complete, Xen bridging can
be started back up again (creating the Xen bridge and renaming eth0 to peth0)
by doing the following:
/etc/xen/scripts/network-bridge start netdev=eth0
The VMs can then be started again.

++XEN中安装windows操作系统后,出现登录屏幕却无法按ctrl+alt+delete解决办法
- hit crtl-alt-2 (the two-key on top of you normal keyboard, not on the
numeric keypad)
- type this literally (without the quotes): “sendkey ctrl-alt-delete”
- hit ctrl-alt-1 to get back to the vm
*此问题在xen3.2中已经可以用过管理菜单控制

++Domain-0的内存不自动回收的解决办法
xen子机Domain-U关机后,Domain-0并不会自动回收内存,需要手工用命令回收
xm mem-set Domain-0 2048

附1: 安装时用到的配置

more /etc/xen/vm/mgr1_install
ostype=”sles10″
name=”mgr1″
memory=512
vcpus=1
uuid=”29d6679c-7cd8-e731-c9e7-47b4276296da”
#on_crash=”destroy”
on_poweroff=”destroy”
#on_reboot=”destroy”
localtime=0
builder=”linux”
kernel=”/tmp/kernel.UjQch1″
ramdisk=”/tmp/install-initrd.ndmsAh”
extra=”TERM=xterm install=http://192.169.0.155/iso/ ”
disk=[ 'file:/zhangjianfeng/data/xen/images/mgr1/disk0,xvda,w', ]
vif=[ 'mac=00:16:3e:00:00:01', ]
vfb=["type=vnc,vncunused=1"]

附2: 安装系统后,需要手工处理配置文件,加入相关参数,防止不停重启安装

ostype=”sles10″
name=”mgr1″
#memory=512
memory=768
vcpus=2
uuid=”29d6679c-7cd8-e731-c9e7-47b4276296da”
on_crash=”restart”
on_poweroff=”destroy”
on_reboot=”restart”
localtime=0
builder=”linux”
#kernel=”/tmp/kernel.UjQch1″
#ramdisk=”/tmp/install-initrd.ndmsAh”
kernel = “/boot/vmlinuz-xen”
ramdisk = “/boot/initrd-xen”
extra=”TERM=xterm install=http://192.169.0.155/iso/ ”
disk=[ 'file:/zhangjianfeng/data/xen/images/mgr1/disk0,xvda,w', 'phy:/dev/cdrom,xvdb,r', 'file:/zhangjianfeng/iso/sles10.1.iso,xvdc,r', ]
#vif=[ 'mac=00:16:3e:00:00:01', ]
vif=[ 'mac=00:16:3e:00:00:01,bridge=xenbr0', 'mac=00:16:3e:00:00:02,bridge=xenbr1' ]
vfb=["type=vnc,vncunused=1"]
#bootloader = “/usr/lib/xen/boot/domUloader.py”
#bootentry = “xvda2:/boot/vmlinuz-xen,/boot/initrd-xen”
root = “/dev/xvda2″
boot=”cda”
##为安装好的虚拟机配置新的kernel和ramdisk配置

附3: 一个windowsXP的配置(Full 虚拟化)

ostype=”windowsxp”
name=”windowsxp”
memory=1024
#memory=512
vcpus=1
uuid=”c759db4d-c15d-23f4-84ed-5c53d4fd1472″
#on_crash=”destroy”
#on_poweroff=”destroy”
#on_reboot=”destroy”
on_crash=”restart”
on_poweroff=”destroy”
on_reboot=”restart”
localtime=1
builder=”hvm”
device_model=”/usr/lib/xen/bin/qemu-dm”
kernel=”/usr/lib/xen/boot/hvmloader”
boot=”dc”
disk=[ 'file:/zhangjianfeng/data/xen/images/windowsxp/disk0,hda,w', 'file:/media/system/windows/xp-en/1.iso,hdc:cdrom,r', ]
#disk=[ 'file:/zhangjianfeng/data/xen/images/windowsxp/disk0,hda,w', 'file:/zhangjianfeng/iso/WXPVOL_EN.ISO,hdc:cdrom,r', ]
vif=[ 'mac=00:16:3e:0a:ef:c0,model=rtl8139,type=ioemu', ]
vnc=1
vncunused=1
apic=0
acpi=1
pae=1
usb=1
usbdevice=’tablet’
usbdevice = ‘host:Generic:058F0O1111B1′
serial=”pty”
audio = 1 #开启声卡
soundhw=’all’ #开启声卡

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值