1,安装第三方xen yum源 # yum install http://au1.mirror.crc.id.au/repo ... ease-6-5.noarch.rpm 2,安装桥工具
# yum -y install bridge-utils 3,安装xen # yum install xen44
4,验证是否安装成功
# ls -l /boot/xen.gz 5,安装xen内核 # yum install kernel-xen 6,关闭对xen有影响的服务 # service iptables stop # chkconfig iptables off # service NetworkManager stop # chkconfig NetworkManager off # vim /etc/sysconfig/selinux
SELINUX=disabled 7,重启
# reboot 8,重启系统之后查看虚拟机的内核版本,并且查看xen的相关信息 # uname -r # xl list
9,创建虚拟磁盘映像文件 # mkdir /xen # cd /xen # qemu-img create -f qcow2 -o size=120G,preallocation=metadata /xen/centos.qcow2 # du -sh centos.qcow2 # qemu-img info centos.qcow2
10,用Xftp插件将CentOS-6.5-x86_64-minimal.iso 文件上传到xen 的/source 目录下 11,安装Apache并且挂载(CentOS-6.5-x86_64-minimal.iso)ISO镜像文件 # yum -y install httpd # service httpd start # chkconfig httpd on # cd /var/www/html/ # mkdir iso # mount -o loop /source/CentOS-6.5-x86_64-minimal.iso /var/www/html/iso/ 12,为虚拟机提供内核和内核模块文件 # cp /var/www/html/iso/isolinux/{vmlinuz,initrd.img} /source 13,配置br0 # cd /etc/sysconfig/network-scripts/ # cp ifcfg-eth0 ifcfg-br0
# vim ifcfg-br0 DEVICE=br0 TYPE=Bridge ONBOOT=yes BOOTPROTO=none NM_CONTROLLED=no IPADDR=192.168.1.118 NETMASK=255.255.255.0 GATEWAY=192.168.1.1 DNS1=192.168.1.1 USERCTL=no IPV6INIT=no # vim ifcfg-eth0 DEVICE=eth0 TYPE=Ethernet ONBOOT=yes BOOTPROTO=none NM_CONTROLLED=no BRIDGE=br0 USERCTL=no IPV6INIT=no # service network restart # ifconfig
# brctl show # brctl stp br0 on 14,修改xlexample.pvlinux文件
# cd /etc/xen # vim xlexample.pvlinux name = "centos" kernel = "/source/vmlinuz" ramdisk = "/source/initrd.img" memory = 850 vcpus = 1 vif = [ 'ip="192.168.1.123",bridge=br0' ] vfb = [ ''vnc=1,sdl=1 ] disk = [ 'file:/xen/centos.qcow2,xvda,w' ] on_reboot = "destroy" 15,安装libvirt,virt-viewer,virt-manager # yum -y install libvirt virt-viewer virt-manager # service libvirtd start 16,使用virt-manager管理xen(需要依赖Xmanager) # virt-manager & 17,使用virt-install命令创建虚拟机(不依赖/etc/xen/xlexample.pvlinux文件) # virt-install -n "centos" -r 1024 --vcpus=1 -l http://192.168.1.118/iso/ --disk path=/xen/centos.qcow2 --network bridge=br0 --force
|