CentOS 5.6까지는 Xen을 기본적으로 지원하였으나 버전 6부터는 Xen이 빠지고 KVM만 지원합니다.
# yum groupinstall -y "Development tools" "Additional Development" "Debugging Tools" "System administration tools" "Compatibility libraries" "Console internet tools" "Desktop Platform Development"
# yum install glibc-devel.i686
2. 다음으로 Xen을 설치합니다.
# mkdir /root/src && cd /root/src
//Xen 4.0.1 설치시
# wget http://ftp.funet.fi/pub/mirrors/fedora.redhat.com/pub/fedora/linux/releases/14/Everything/source/SRPMS/xen-4.0.1-6.fc14.src.rpm
//Xen 4.1.0 설치시
# wget http://ftp.funet.fi/pub/mirrors/fedora.redhat.com/pub/fedora/linux/releases/15/Everything/source/SRPMS/xen-4.1.0-1.fc15.src.rpm
//4.0.1이나 4.1.0이나 설치방법은 동일합니다. 아래부터는 그냥 4.0.1버전으로 설명할게요.
# rpm -i xen-4.0.1-6.fc14.src.rpm
# cd /root/rpmbuild/SPECS
# rpmbuild -bb xen.spec
//xen에 맞는 qemu를 먼저 설치해야함
# cd /root/src
# wget http://ftp.funet.fi/pub/mirrors/fedora.redhat.com/pub/fedora/linux/updates/13/SRPMS/qemu-0.12.5-1.fc13.src.rpm
# rpm -i qemu-0.12.5-1.fc13.src.rpm
# cd /root/rpmbuild/SPECS
# rpmbuild -bb qemu.spec
# cd /root/rpmbuild/RPMS/x86_64
//qemu부터 설치
# rpm -Uvh qemu-common-0.12.5-1.el6.x86_64.rpm
//xen 설치
# rpm -Uvh xen*4.0.1-6*.rpm
3. xen을 위한 kernel을 빌드합니다.
# mkdir /root/kernel && cd /root/kernel
# git clone git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen.git linux-2.6-xen
# cd linux-2.6-xen
# git checkout -b xen/stable-2.6.32.x origin/xen/stable-2.6.32.x
또는 # git checkout -b xen/next-3.1 origin/xen/next-3.1 //kernel 3.1버전으로 하실분은 이걸로..
# wget -O .config http://pasik.reaktio.net/xen/kernel-config/config-2.6.32.25-pvops-dom0-xen-stable-x86_64
# make oldconfig
//cpufreq사용할 경우 intel enhanced speedstep 옵션 확인할것.
// Power management and ACPI options - CPU Frequency scaling - Intel Enhanced SpeedStep (deprecated)
//CONFIG_X86_SPEEDSTEP_CENTRINO=y
// -j 뒤에 옵션은 cpu 코어수
# make -j8 bzImage && make -j8 modules && make modules_install
# depmod -a 2.6.32.45
# cp -a arch/x86/boot/bzImage /boot/vmlinuz-2.6.32.45
# cp -a System.map /boot/System.map-2.6.32.45
# cp -a .config /boot/config-2.6.32.45
# cd /boot
# dracut initramfs-2.6.32.45.img 2.6.32.45
# cat /boot/grub/grub.conf
//본인의 환경에 맞게 grub을 수정할 것
----------------------------------------------------------------------------------------------
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/mapper/vg00-lvroot
# initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
#hiddenmenu
title Red Hat Enterprise Linux Server (2.6.32-71.7.1.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-71.7.1.el6.x86_64 ro root=/dev/mapper/vg00-lvroot rd_LVM_LV=vg00/lvroot rd_LVM_LV=vg00/lvswap rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=fi crashkernel=auto rhgb quiet
initrd /initramfs-2.6.32-71.7.1.el6.x86_64.img
title Red Hat Enterprise Linux (2.6.32-71.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-71.el6.x86_64 ro root=/dev/mapper/vg00-lvroot rd_LVM_LV=vg00/lvroot rd_LVM_LV=vg00/lvswap rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=fi crashkernel=auto rhgb quiet
initrd /initramfs-2.6.32-71.el6.x86_64.img
title Xen 4.0 with Linux 2.6.32.45 dom0
root (hd0,0)
kernel /xen.gz dom0_mem=1024M loglvl=all guest_loglvl=all
module /vmlinuz-2.6.32.45 ro root=/dev/mapper/VolGroup-lv_root rd_LVM_LV=VolGroup/lv_root nomodeset
module /initramfs-2.6.32.45.img
------------------------------------------------------------------------------------
* dom0_mem설정에 따라 부팅이 정상적으로 안될수도 있음.
* 자신의 실제 메모리 크기를 기준으로 1/2이상으로 설정해볼것.
# chkconfig ksm off
# chkconfig ksmtuned off
# reboot
//[재부팅] xen커널로 부팅 - 행운을 빌어요~
//재부팅후 커널이 xen이 정상적으로 동작하는지 확인
# xm list
# xm info
4. xen에 맞는 libvirt를 설치
# yum install libvirt virt-manager xorg-x11-xauth
//설치된 libvirt의 버전을 확인
# rpm -qa | grep libvirt
//[재부팅] xen커널이 아닌 일반커널로 재부팅
# cd /root/src
# wget ftp://ftp.redhat.com/pub/redhat/linux/enterprise/6Server/en/os/SRPMS/libvirt-0.8.1-27.el6.src.rpm
# rpm -i libvirt-0.8.1-27.el6.src.rpm
# wget http://pasik.reaktio.net/xen/patches/libvirt-spec-rhel6-enable-xen.patch
# cd /root/rpmbuild/SPECS
# cp -a libvirt.spec libvirt.spec.orig
# patch -p0 < ~/src/libvirt-spec-rhel6-enable-xen.patch
# yum install libnl-devel xhtml1-dtds libudev-devel libpciaccess-devel yajl-devel libpcap-devel avahi-devel parted-devel device-mapper-devel numactl-devel netcf-devel
# rpmbuild -bb libvirt.spec
# cd /root/rpmbuild/RPMS/x86_64/
# rpm -Uvh --force libvirt-0.8.1-27.el6.x86_64.rpm libvirt-client-0.8.1-27.el6.x86_64.rpm libvirt-python-0.8.1-27.el6.x86_64.rpm
# chkconfig --list libvirtd
libvirtd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
//[재부팅] libvirt설치완료~
//재부팅후 동작확인 아래 명령어를 입력하면 domain-0가 나타날것임
# virsh list
//브릿지 오류 확인
# brctl show
//[재부팅] 브릿지 brctl 오류 수정
# wget http://ftp.funet.fi/pub/mirrors/fedora.redhat.com/pub/fedora/linux/releases/14/Everything/source/SRPMS/bridge-utils-1.2-9.fc13.src.rpm
# rpm -i bridge-utils-1.2-9.fc13.src.rpm
#cd /root/rpmbuild/SPECS
# rpmbuild -bb libvirt.spec
# cd /root/rpmbuild/RPMS
# rpm -Uvh --force libvirt-*
//[재부팅] xen커널로 부팅해서 brctl 확인
#brctl show
출력예)
bridge_name bridge_id STP_enabled interfaces
이름 mac주소 no eth0
5. 추가적으로 Bridge를 설정하실분들은 아래 수행 //xenbr0에 브릿지
# vi /etc/sysconfig/network-scripts/ifcfg-xenbr0
//아래 내용 입력
--------------------------
DEVICE=xenbr0
TYPE=Bridge
BOOTPROTO=static //고정아이피일경우, 동적일경우는 dhcp로하고 아래 아이피설정은 지울것
BROADCAST=192.168.1.255 //자신의 아이피환경에 맞게 설정
IPADDR=192.168.1.2 //자신의 아이피환경에 맞게 설정
NETMASK=255.255.255.0 //자신의 아이피환경에 맞게 설정
ONBOOT=yes
DELAY=0
NM_CONTROLLED=no
---------------------------
# sysctl -p /etc/sysctl.conf
//네트웍이 모두 브릿지로 처리되도록
#echo "-I FORWARD -m physdev --physdev-is-bridged -j ACCEPT" > /etc/sysconfig/iptables-forward-bridged
#lokkit --custom-rules=ipv4:filter:/etc/sysconfig/iptables-forward-bridged
#service libvirtd reload
#service network restart
//domU(GuestOS)설치시 이더넷장치를 xenbr0로 선택
* cpufreq을 dom0에서 수행할 경우 grub.conf에 아래 내용 추가
kernel /xen.gz dom0_mem=1024M loglvl=all guest_loglvl=all cpufreq=dom0-kernel
cpufreq은 xenpm명령어를 사용하여 설정.
[reference]
http://wiki.xensource.com/xenwiki/RHEL6Xen4Tutorial
http://wiki.xensource.com/xenwiki/XenParavirtOps#head-05b0622497e9eea7b48a0a61a44bec39b6c1bfe2
http://wiki.xensource.com/xenwiki/HostConfiguration/Networking
http://wiki.xensource.com/xenwiki/xenpm
http://software.intel.com/en-us/articles/enhanced-intel-speedstepr-technology-and-demand-based-switching-on-linux/