CentOS6下快速配置Xen 4.1.1环境


准备工作

  • CentOS 6.0, Minimal安装, SELINUX=disabled, 配置好SRPM的repo地址

操作步骤

 1. 安装基本软件包

  1. yum -y install openssh-clients gcc g++ make automake autoconf wget glibc-devel glibc-devel.i686 libaio rpm-build yum-utils transfig libidn-devel zlib-devel texi2html SDL-devel curl-devel libX11-devel python-devel ghostscript tetex-latex ncurses-devel gtk2-devel libaio-devel texinfo dev86 gettext gnutls-devel openssl-devel pciutils-devel libuuid-devel iasl bzip2-devel xz-devel e2fsprogs-devel PyXML kpartx bridge-utils libsysfs-devel libsysfs libnl-devel libtool nfs-utils libxml2-devel xhtml1-dtds readline-devel libudev-devel  libpciaccess-devel yajl-devel libpcap-devel avahi-devel dnsmasq cyrus-sasl-devel polkit lvm2 iscsi-initiator-utils parted-devel device-mapper-devel numactl-devel libcap-ng-devel netcf-devel ebtables lzop nc cyrus-sasl-md5 python-virtinst  
 2. 安装qemu
  1. wget http://mirrors.ustc.edu.cn/Fedora/linux/updates/13/x86_64/qemu-common-0.13.0-1.fc13.x86_64.rpm  
  2. wget http://mirrors.ustc.edu.cn/fedora/linux/updates/13/x86_64/qemu-img-0.13.0-1.fc13.x86_64.rpm  
  3. rpm -Uvh qemu-*.rpm  

 3. 通过srpm编译安装Xen

  1. wget http://mirrors.ustc.edu.cn/fedora/linux/updates/15/SRPMS/xen-4.1.1-3.fc15.src.rpm  
  2. rpm -i xen-4.1.1-3.fc15.src.rpm  
  3. cd ~/rpmbuild/SPECS/  
  4. rpmbuild -bb xen.spec  
  5. cd ~/rpmbuild/RPMS/x86_64/  
  6. rpm -Uvh xen-*4.1.1-*.rpm  
4. 修改bridge-utils, CentOS 6.0的默认内核被加了IGMP的patch, 其自带的bridge-utils也打了这个patch, 在非rhel6的内核上运行会出现很多没用的提示。
  1. yumdownloader --source bridge-utils  
  2. rpm -i bridge-utils-1.2-9.el6.src.rpm # 版本可能不同  
  3. cd ~/rpmbuild/SPECS/  
  4. vi bridge-utils.spec  
  5. # 去除两行有patch4的地方, 也即有IGMP的patch的行  
  6. rpmbuild -bb bridge-utils.spec  
  7. cd ~/rpmbuild/RPMS/x86_64/  
  8. rpm -Uvh --force bridge-utils-1.2-9.el6.x86_64.rpm  

提供一个patch

  1. --- bridge-utils.spec.orig      2010-04-30 00:29:16.000000000 +0800  
  2. +++ bridge-utils.spec   2011-09-30 23:27:19.090747706 +0800  
  3. @@ -10,7 +10,6 @@  
  4.  Patch1: bridge-utils-1.2-show-ports.patch  
  5.  Patch2: bridge-utils-1.2-foreach.patch  
  6.  Patch3: bridge-utils-1.2-params.patch  
  7. -Patch4: bridge-utils-1.2-Add_IGMP_snooping_support.patch  
  8.   
  9.  BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)  
  10.  BuildRequires: libsysfs-devel autoconf  
  11. @@ -32,7 +31,6 @@  
  12.  %patch1 -p1  
  13.  %patch2 -p1  
  14.  %patch3 -p1  
  15. -%patch4 -p1 -b .Add_IGMP_snooping_support  
  16.   
  17.  %build  
  18.  autoconf  
 5. 安装libvirt, CentOS6自带的不支持xen, 需要打开xen的选项重新编译
  1. yumdownloader --source libvirt  
  2. rpm -i libvirt-0.8.1-27.el6_0.6.src.rpm # 版本可能不同  
  3. cd ~/rpmbuild/SPECS/  
  4. vi libvirt.spec # 按下面的patch修改  
  5. rpmbuild -bb libvirt.spec  
  6. cd ~/rpmbuild/RPMS/x86_64/  
  7. rpm -Uvh libvirt-*0.8.1*.rpm  
Patch: 
  1. --- libvirt.spec.orig   2010-08-18 15:02:53.000000000 +0300  
  2. +++ libvirt.spec        2010-11-15 14:17:36.388996162 +0200  
  3. @@ -104,7 +104,7 @@  
  4.  %ifnarch x86_64  
  5.  %define with_qemu 0  
  6.  %endif  
  7. -%define with_xen 0  
  8. +%define with_xen 1  
  9.  %endif  
  10.   
  11.  # If Xen isn't turned on, we shouldn't build the xen proxy either  

6. 安装python-virtinst,旧的版本不支持的参数太多了

  1. # 从RedHat网站下载srpm  
  2. wget http://ftp.redhat.com/redhat/linux/enterprise/6Server/en/os/SRPMS/python-virtinst-0.500.5-3.el6.src.rpm  
  3.   
  4. rpm -i python-virtinst-0.500.5-3.el6.src.rpm  
  5.   
  6. cd ~/rpmbuild/SPECS/  
  7. rpmbuild -bb python-virtinst.spec  
  8.   
  9. cd ~/rpmbuild/RPMS/noarch/  
  10. rpm -Uvh --force python-virtinst-*.rpm  
7. 编译安装内核
  1. # 从github下载内核  
  2. wget https://github.com/jsgf/linux-xen/tarball/xen-2.6.32.46 -O kernel-xen-2.6.32.46.tar.gz  
  3. # 下载config  
  4. wget http://pasik.reaktio.net/xen/kernel-config/config-2.6.32.43-pvops-dom0-xen-stable-x86_64  
  5.   
  6. # 可以先修改config里面的CONFIG_LOCALVERSION项, 给这个内核起个别名, 比如-dom0-xen, 以下为没有修改的情况   
  7. tar xzf kernel-xen-2.6.32.46.tar.gz  
  8. cp config-2.6.32.43-pvops-dom0-xen-stable-x86_64 jsgf-linux-xen-1c3f03c/.config  
  9. cd jsgf-linux-xen-1c3f03c  
  10. make oldconfig  
  11. make -j4 bzImage  
  12. make -j4 modules  
  13. make modules_install  
  14. depmod -a 2.6.32.46  
  15. cp -a arch/x86/boot/bzImage /boot/vmlinuz-2.6.32.46  
  16. cp -a System.map /boot/System.map-2.6.32.46  
  17. cp -a .config /boot/config-2.6.32.46  
  18. cd /boot/  
  19. dracut --force initramfs-2.6.32.46.img 2.6.32.46  
  20.   
  21. # 关闭ksm, 跟xen不兼容  
  22. chkconfig ksm off  
  23. chkconfig ksmtuned off  
 8. 编辑/boot/grub/menu.lst, 添加
  1. title Xen 4.0 with Linux 2.6.32.46  
  2.         root (hd0,0)  
  3.         kernel /xen.gz dom0_mem=2048M loglvl=all guest_loglvl=all  
  4.         module /vmlinuz-2.6.32.46 ro root=/dev/sda2 rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM KEYBO  
  5. ARDTYPE=pc KEYTABLE=us SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 nomodeset  
  6.         module /initramfs-2.6.32.46.img  
 9. 编辑/etc/xen/xend-config.sxp, 按自己的需求修改
  1. ......  
  2. (xend-http-server yes)  
  3. (xend-unix-server yes)  
  4. (xend-tcp-xmlrpc-server yes)  
  5. ......  
  6. (xend-relocation-server yes)  
  7. ......  
  8. (xend-tcp-xmlrpc-server-address '0.0.0.0')  
  9. (xend-tcp-xmlrpc-server-port 8006)  
  10. ......  
  11. (xend-relocation-port 8002)  
  12. ......  
  13. (xend-address localhost)  
  14. ......  
  15. (xend-relocation-address '0.0.0.0')  
  16. ......  
  17. ......  
  18. ......  
10.  配置libvirtd
  1. groupadd libvirt  
  2. vi /etc/libvirt/libvirtd.conf  
  3. unix_sock_group = "libvirt"  
  4. unix_sock_ro_perms = "0777"  
  5. unix_sock_rw_perms = "0770"  
 11. 重启, 启动Xen的内核

 12. 把上面做的事情, 写成一套脚本

  • 1
  • 2
  • 下一页

相关内容