fedora18下的xen安装与管理
############################# xen installation ##############################
关闭防火墙和禁用selinux
# iptables -F
# service iptables save
# vim /etc/selinux/config
SELINUXTYPE=permissive
xen的安装
# yum update
# yum -y install xen xen-hypervisor kernel-xen libvirt-daemon-xen virt-manager virt-viewer libvirt libvirt-pythonpython-virtinst libvirt-daemon-config-network libvirt-daemon-driver-network
# yum -y install tigervnc
xen的默认启动(grub2)的配置
# GRUB_DEFAULT="saved"
# grub2-mkconfig -o /boot/grub2/grub.cfg
# grep ^menuentry /boot/grub2/grub.cfg | cut -d "'" -f2
xend服务的配置
# systemctl enable xend.service
# systemctl start xend.service
# systemctl status xend.service
xen-tools的安装
# yum -y install debootstrap perl-Text-Templateh perl-Config-IniFiles perl-File-Slurp perl-File-Which perl-Data-Dumper
# wget http://xen-tools.org/software/xen-tools/xen-tools-4.3.1.tar.gz
# tar zxvf xen-tools-4.3.1.tar.gz
# cd xen-tools-4.3.1
# make install
############################## xen configuration file ##############################
fedora18下,xen虚拟机的配置文件存放路径: /var/lib/xend/domains/"uuid",镜像存放路径: /var/lib/xen/p_w_picpaths/“virtual name”
rhel5.4下,xen虚拟机的配置文件存放路径: /etc/xen/“virtual name”,镜像存放路径: /var/lib/xen/p_w_picpaths/“virtual name”
故需/var/lib/xend/domains/"uuid"内容转出到/etc/xen/“virtual name”下,实例“virtual name”为vm0{1..5},总共5台虚拟机,故有以下的脚本
# vim fedora-xen-virt-manager.sh
#!/bin/bash
xenfile=/etc/xen/vm0{1..5}
if [ -f $xenfile ]
then
rm -rf $xenfile
if
for i in vm0{1..5}
do
virsh dumpxml $i > /root/$i.xml
cd /root
virsh domxml-to-native xen-xm $i.xml > /etc/xen/$i
done
############################## xen manage ##############################
# xm list
# xm create DomainName
# xm console DomainName
# xm destroy DomainName
# xm reboot DomainName
# xm shutdown DomainName
# xm pause DomainName
# xm unpause DomainName
# xm save DomainName
# xm restore DomainName
# xm rename DomainName
# virt-install -p -n vm01 -f /var/lib/xen/p_w_picpaths/vm01.img -s 4 -r 512 --vcpus=2 -b br0 -l ftp://192.168.254.254/pub -x "ks=ftp://192.168.254.254/pub/ks.cfg"
# virt-clone -o vm01 -n vm02 -f /var/lib/xen/p_w_picpaths/vm02.img
############################## xen network configuration ##############################
给vm01增加一块网卡
# vim /etc/xen/vm01
vif = [ "mac=00:16:36:88:76:d4,bridge=br0,script=vif-bridge","mac=00:16:36:77:66:d5,bridge=virbr0,script=vif-bridge" ]
# cp /etc/libvirt/qemu/networks/default.xml /etc/libvirt/qemu/networks/virbr1.xml
# vim /etc/libvirt/qemu/networks/virbr1.xml
<network>
<name>virbr1</name>
<uuid>703619d1-1b15-4621-acc6-6f2d88f51eb9</uuid>
<bridge name="virbr1" />
<forward/>
<ip address="192.168.123.1" netmask="255.255.255.0">
<dhcp>
<range start="192.168.123.2" end="192.168.123.254" />
</dhcp>
</ip>
</network>
# ln -s /etc/libvirt/qemu/networks/virbr1.xml /etc/libvirt/qemu/networks/autostart/virbr1.xml
小结: fedora18下,图形化下调用“虚拟系统管理器”是kvm;在xen下安装和配置虚拟机,还是得靠字符界面下操作,故写下此文,方便日后翻查。
本文来自:Linux学习教程网