CentOS 6.4에 Xen 설치하기

설치환경

OS: CentOS 6.4

설치전 selinux 를 사용하지 않도록 변경한 후 서버를 재부팅한다.

# vi /etc/selinux/config

SELINUX=disabled

1. bridge 인터페이스를 만든다. /etc/sysconfig/network-scripts/ifcfg-br0 생성하고, 같은 디렉토리의 ifcfg-eth0를 수정.

# cat ifcfg-br0
DEVICE=br0
TYPE=Bridge
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
IPADDR=59.29.142.121
NETMASK=255.255.255.0
NAME=”System br0″
DEFROUTE=yes

# cat ifcfg-eth0
DEVICE=eth0
HWADDR=00:0A:E4:82:A5:DE
TYPE=Ethernet
UUID=a050e280-9ad9-48cd-b234-7cf33b0eea48
ONBOOT=yes
NM_CONTROLLED=yes
#BOOTPROTO=static
#IPADDR=59.29.142.121
#NETMASK=255.255.255.0
NAME=”system eth0″
BRIDGE=br0

2. xen 커널 설치

아래 커맨드로 repository를 등록한다.

 #yum install http://au1.mirror.crc.id.au/repo/el6/x86_64/kernel-xen-release-6-5.noarch.rpm

xen 하이퍼바이저와 Dom0 커널을 설치한다.

 # yum install kernel-xen xen

3. grub의 설정 변경: xen 커널로 부팅하도록 grub설정을 변경한다.

/boot/grub/menu.lst 화일에 아래 부분을 추가해 준다. 버전에 따라 화일 이름이 약간씩 다르므로 잘 비교하여 작성한다. title은 임의로 주어도 되며, 여기서는 CentOS Xen으로 했다.

title CentOS Xen (3.9.5-1.el6xen.x86_64)
root (hd0,0)
kernel /xen.gz dom0_mem=1024M cpufreq=xen dom0_max_vcpus=1 dom0_vcpus_pin
module /vmlinuz-3.9.5-1.el6xen.x86_64 ro root=/dev/mapper/vg_fox5-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=vg_fox5/lv_swap SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rd_LVM_LV=vg_fox5/lv_root rhgb quiet
module /initramfs-3.9.5-1.el6xen.x86_64.img

title CentOS (3.9.5-1.el6xen.x86_64)
root (hd0,0)
kernel /vmlinuz-3.9.5-1.el6xen.x86_64 ro root=/dev/mapper/vg_fox5-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=vg_fox5/lv_swap SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rd_LVM_LV=vg_fox5/lv_root rhgb quiet
initrd /initramfs-3.9.5-1.el6xen.x86_64.img

4. 재부팅한 후, 아래 커맨드로 xen커널이 정상 작동하는지 확인한다.

# xm info
host : fox5
release : 3.9.5-1.el6xen.x86_64
version : #1 SMP Mon Jun 10 18:07:49 EST 2013
machine : x86_64
nr_cpus : 2
nr_nodes : 1
cores_per_socket : 2
threads_per_core : 1
cpu_mhz : 2992
hw_caps : bfebfbff:20000800:00000000:00000940:0004e3bd:00000000:00000001:00000000
virt_caps : hvm
total_memory : 2046
free_memory : 998
free_cpus : 0
xen_major : 4
xen_minor : 2
xen_extra : .2
xen_caps : xen-3.0-x86_64 xen-3.0-x86_32p hvm-3.0-x86_32 hvm-3.0-x86_32p hvm-3.0-x86_64
xen_scheduler : credit
xen_pagesize : 4096
platform_params : virt_start=0xffff800000000000
xen_changeset : unavailable
xen_commandline : dom0_mem=1024M cpufreq=xen dom0_max_vcpus=1 dom0_vcpus_pin
cc_compiler : gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-3)
cc_compile_by : mockbuild
cc_compile_domain : crc.id.au
cc_compile_date : Mon Jun 10 19:58:54 EST 2013
xend_config_format : 4

5. 필요한 경우 libvirt를 설치한다.

# yum install libvirt

#virsh list –all
error: failed to connect to the hypervisor
error: no valid connection
error: Failed to connect socket to ‘/var/run/libvirt/libvirt-sock’: No such file or directory

# /etc/init.d/libvirtd start

# virsh list –all
Id Name State
—————————————————-
0 Domain-0 running

libvirt 를 설치하면, /var/lib/libvirt/images 디렉토리가 생기고, 여기에 가상서버의 이미지가 생성된다.

# virt-install –prompt –network bridge=br0 –virt-type=xen
Would you like a fully virtualized guest (yes or no)? This will allow you to run unmodified operating systems.
no
What is the name of your virtual machine?
cent64-1
How much RAM should be allocated (in megabytes)?
1024
What would you like to use as the disk (file path)?
/var/lib/libvirt/images/cent64-1.img
How large would you like the disk (/var/lib/libvirt/images/cent64-1.img) to be ( in gigabytes)?
10
What is the install URL?
http://ftp.tu-chemnitz.de/pub/linux/centos/6.4/os/x86_64/

Starting install…
Retrieving file .treeinfo… | 798 B 00:00 …
Retrieving file vmlinuz… | 7.7 MB 00:09 …
Retrieving file initrd.img… | 62 MB 00:35 …
Creating storage file cent64-1.img | 10 GB 00:00
Creating domain… | 0 B 00:00
Connected to domain cent64-1
Escape character is ^]
Initializing cgroup subsys cpuset
Initializing cgroup subsys cpu
Linux version 2.6.32-358.el6.x86_64 (mockbuild@c6b8.bsys.dev.centos.org) (gcc ve rsion 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) ) #1 SMP Fri Feb 22 00:31:26 UTC 20 13
Command line: method=http://ftp.tu-chemnitz.de/pub/linux/centos/6.4/os/x86_64/
KERNEL supported cpus:
Intel GenuineIntel

detecting hardware…
waiting for hardware to initialize…
Welcome to CentOS for x86_64

┌────────┤ Choose a Language ├────────┐
│ │
│ What language would you like to use │
│ during the installation process? │
│ │
│ Catalan ↑ │
│ Chinese(Simplified) ▒ │
│ Chinese(Traditional) ▮ │
│ Croatian ▒ │
│ Czech ▒ │
│ Danish ▒ │
│ Dutch ▒ │
│ English ↓ │
│ │
│ ┌────┐ │
│ │ OK │ │
│ └────┘ │
│ │
│ │
└─────────────────────────────────────┘

<Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen

설치가 진행된다. 설치를 마치면, ctrl+] 를 눌러 호스트 OS로 나올 수 있다.

다시 게스트 OS로 접속하고자 한다면,

# virsh console cent64-1
Connected to domain cent64-1
Escape character is ^]

Password:
Login incorrect

login:

 

 

댓글 남기기

Your email address will not be published.

%d 블로거가 이것을 좋아합니다: