fedora 12에서 kvm 사용하기

kyumin의 이미지

1. KVM(kernel based virtual Machine) 이란 ?


http://www.linux-kvm.org/page/Main_Page

http://en.wikipedia.org/wiki/Kernel-based_Virtual_Machine

http://en.wikipedia.org/wiki/Qumranet

2. kvm의 역사

KVM is maintained by Avi Kivity and is funded primarily by Qumranet, a technology start up,[11] now owned by Red Hat.[12]

From a low-profile Israeli startup [1] the company made waves with the rapid acceptance of KVM into the Linux kernel,[2] and their Solid ICE desktop virtualization platform has received serious attention.[3] [4]
On September 4, 2008, Qumranet was acquired by Red Hat, Inc.[5]

3. Virtualization의 종류

http://www.ibm.com/developerworks/linux/library/l-linuxvirt/

4. guest os 설치
Red Hat Enterprise Linux 6이 Fedora 12 베이스로 패키징 될 예정이므로 Fedora 12를 사용합니다.

1) cpu virtualization관련 extention(intel VT 또는 AMD-V) 지원하는지 확인
$ egrep '^flags.*(vmx|svm)' /proc/cpuinfo
위와 같이 cpu 확인 후에도 kvm 을 사용할 수 없다며 시스템 bios를 확인하여 virtualization cpu를 사용할 수 있도록 bios에서 enable 해줍니다.

Kvm: disabled by bios -> 이와 같은 메시지가 로그 파일에서 보일 경우 bios에서 virtualization 기능이 disable 되어 있다는 뜻.

5. virtualization에 관련 패키지 설치

# yum groupinstall 'Virtualization’

설치 후 아래 명령어로 kvm 관련 모듈이 로드되었는지 확인합니다.

# lsmod |grep kvm
kvm_intel 48184 0 intel cpu 아키텍쳐 kvm kernel module
kvm 163952 1 kvm_intel -> kvm kernel module

만일 로드 되지 않았을 경우 아래 명령어로 kvm 모듈을 로드합니다.
modprobe kvm
modprobe kvm-intel

6. kvm 설치전 네트워크 설정

brctl 명령어로 guest os가 이미 nat를 이용해 네트워크 사용할 수 있도록 virtual 인터페이스가 올라와 있는 것을 확인 할 수 있습니다.
# brctl show
bridge name bridge id STP enabled interfaces 스
virbr0 8000.000000000000 yes

아래 명령어로 이미 guest os에서 nat를 통해 네트워크를 사용 할 수 있도록 iptables 세팅이 들어가 있는 것을 확인 할 수 있음.
# iptables -L -nv
# iptables -t nat -L -nv

1) bridge 네트워크 설정 파일 설정 하기
# cd /etc/sysconfig/network-scripts/
# vim ifcfg-br0
DEVICE=br0
TYPE=Bridge
BOOTPROTO=dhcp
ONBOOT=yes

2) bridge 인터페이스 시작하기 및 eth0 설정
# ifup br0

# vim /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
BRIDGE=br0
BOOTPROTO=dhcp
HWADDR=xx:xx:xx:xx:xx:xx
ONBOOT=yes

3) network 서비스 다시 시작하기
만일 NetworkManager를 network 서비스 대신 사용하고 있다면 아래와 같이 network 서비스가 사용 될 수 있도록 설정을 변경합니다.

# chkconfig NetworkManager off
# chkconfig network on
# service NetworkManager stop
# service network start

4) brctl show
# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.xxxxxxxxxxxx no eth0
virbr0 8000.000000000000 yes

5) 아래와 같이 iptables에 Guest os의 모든 트레픽이 브리지를 통해 포워딩 될 수 있드록 아래 룰을 추가합니다.
# iptables -I FORWARD -m physdev --physdev-is-bridged -j ACCEPT
# service iptables save
# service iptables restart
6) 커널 파라미터 확인
# sysctl -a | grep net.ipv4.ip_forward

net.ipv4.ip_forward = 1
만일 위와 같이 커널 파라미터 값이 1이 아닐 경우 enable 해줍니다.
# vim /etc/sysctl.conf <- 아래 값 추가
net.ipv4.ip_forward = 1
# sysctl -p





6. guest os 설치하기
1) virt-manager 사용

Installation wizard
http://www.virt-manager.org/screenshots/install.html

Virtual network wizard
http://www.virt-manager.org/screenshots/networking.html

Add hardware wizard
http://www.virt-manager.org/screenshots/addhardware.html


2) virt-install 사용
shell 모드로 설치기능을 하여 원격에서 guest os 설치할 때 유용함
# man virt-install

man 페이지에 예제와 함께 잘 문서화가 되어 있기 때문에 man 페이지 기준으로 설명함.

다음과 같이 host 서버에 접속합니다.

ssh -X root@xxx.xxx.xxx.xxx

아래 예제는 5기가 디스크 이미지(--disk path), 500M 메모리, 디폴트 네트워크(virtio para-virtualized 네트워크 드라이버http://www.linux-kvm.org/page/Virtio) vnc server 과 vnc view를 통해 설치나 Guest 서버 관리를 할 수 있게 합니다. 설치 디바이스 시디롬으로 지정(--cdrom)

# virt-install \
--connect qemu:///system \
--name demo \
--ram 500 \
--disk path=/var/lib/libvirt/images/demo.img,size=5 \
--network network=default,model=virtio \
--vnc \
--cdrom /dev/cdrom

아래 예제는 파일 디스크 이미가 아닌 lvm 파티션을 이용하여 fedora12를 pxe 모드로 설치하는 예제.
# virt-install \
--connect qemu:///system \
--name demo \
--ram 500 \
--disk path=/dev/HostVG/DemoVM \
--network network=default \
--virt-type kvm
--vnc \
--os-variant fedora12
--pxe

하드디스크 /dev/hdc와 브리지를 이용하여 guest os를 설치하는 예제

# virt-install \
--connect qemu:///system \
--name demo \
--ram 500 \
--disk path=/dev/hdc \
--network bridge=eth0 \
--arch ppc64 \
--sdl \
--location
http://download.fedora.redhat.com/pub/fedora/linux/releases/12/Fedora/i386/os/

7. kvm tuning

virtual guest의 성능향상을 위해서 para-virtualized 드라이버를 사용할 것을 권장하는 내용을 아래 웹 페이지에 찾아 볼 수 있음.
http://www.linux-kvm.org/page/Tuning_KVM

8. Benchmark

http://virt.kernelnewbies.org/XenVsKVM

http://www.xen.org/files/xensummitboston08/Deshane-XenSummit08-Slides.pdf

http://www.phoronix.com/scan.php?page=article&item=ubuntu_virt_benchmarks&num=1

http://www.phoronix.com/scan.php?page=article&item=623&num=1

9. Tech comparison.

http://virt.kernelnewbies.org/TechOverview

http://virt.kernelnewbies.org/TechComparison

10. References

Virtualization 가이드

http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5.4/pdf/Virtualization_Guide.pdf

http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5.4/html/Virtualization_Guide/index.html

http://fedoraproject.org/wiki/Getting_started_with_virtualization

Forums: 
nonots의 이미지

좋은 정보 감사합니다. 하드웨어만 갖춰지면 참고해서 테스트해 봐야겠네요.

=== 건달의 경지를 꿈꾸며 ===


=== 건달의 경지를 꿈꾸며 ===

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.