Zen สะกด Z คือ quintessential feeling ที่ coronet ของหัวขณะ pissing in snow หลัง hold แปดชั่วโมง Xen สะกด X คือ open-source virtualization technology ที่คุณอาจ consider สำหรับ setup ของคุณ ไม่ว่าจะ home หรือ business แม้จะเหมือน KVM oriented มากกว่าตลาด corporate
เราเคยมี tutorials KVM หลายอัน ครอบคลุม introduction article, how to setup และ configure storage และ network รวมถึง bridged networking และ how to resolve conflicts กับ VirtualBox ตอนนี้ถึงเวลาเรียน Xen มากขึ้น คล้ายกันจะแสดง first steps ที่จำเป็นสำหรับได้ virtual machines installed และ running, subtle terminology, GUI และ command-line management tools, virtualization modes, various appliances และมากกว่านั้น

Xen - Introduction
Short introduction into Xen internals ต่างจาก most technologies ที่ต้องการ special kernel to boot กล่าวคือ Linux system ของคุณต้องการ separate entry ใน GRUB menu เมื่อ boot จาก context ของ kernel นี้ Xen จะ run ได้
เพิ่มเติม Xen works in layers - เรียกว่า domains most privileged domain เรียกว่า Domain0 (dom0) คือ hypervisor เอง Guest operating systems built on top of domain นี้ run ใน DomainU (domU)
เพื่อทำให้ซับซ้อนขึ้น Xen มี two modes Paravirtualization อนุญาต guests run without special calls to processor Full virtualization หรือ Hardware Assisted Virtualization (HVM) ซึ่ง depend on processor virtualization technology (Intel-VT หรือ AMD-V) เสนอ even better performance และ extended features
รายละเอียดเพิ่มเติม โปรด consult:
- Xen on Wikipedia
- Xen tutorials on howtoforge.com
Pros and cons
หลายเหตุผลที่คุณอาจอยาก Xen หนึ่ง ฟรี สอง robust และ mature มี powerful command-line syntax ที่ scriptable ทำให้ administration work breeze สำคัญที่สุด ถ้าคุณไม่มี virtualization technology enabled ใน processor คุณยังเพลิดเพลินกับ reasonable performance ได้ ไม่เหมือน KVM ที่ simply grinds to a crawl ในสถานการณ์นั้น แต่คุณจะสูญเสียบาง functionality เมื่อรัน paravirtualized จะเห็น relevant examples ภายหลัง
อีกด้านหนึ่ง Xen cumbersome กว่า VirtualBox หรือ VMware Server เช่นกัน แม้ graphical management เดียวกันใช้ได้กับ KVM และ Xen แต่ creating และ installing new virtual machines ยากกว่ากับ Xen SUSE integration ทำให้ process นี้ both easier และ more difficult พร้อมกัน อีกครั้งจะเห็น examples ภายหลัง
Xen มี fairly steep learning curve และ intimidate less knowledgeable users การผสมผสาน complex architecture, layered management และ not-so-simple language อาจ deter potential customers ที่อาจ prefer linear simplicity ของ solutions อื่นที่เสนอ entire framework ใน single package
Biggest downside คือต้องการ own kernel to boot ต่างจาก KVM ที่แค่ insert module เข้า kernel Xen ต้องมี GRUB menu entry ของตัวเอง เมื่อ boot เข้า Xen kernel คุณจะสังเกต different kernel version เมื่อ run uname command
Test platform
Xen มา pre-installed ใน SUSE flavors รวมถึง openSUSE และ SLES ตั้งแต่ version 10.3 หมายความว่า use และ setup บน distro นี้ควร fairly simple ไม่หมายความว่าไม่สามารถใช้ Xen บน systems อื่นได้ แต่อาจ encounter problems เช่น Xen tools ใน Ubuntu repositories broken ต้อง compile from source RedHat-based distros ไม่มี issues เหล่านี้ แต่ preferred virtualization technology คือ KVM
กล่าวคือ ถ้าคุณใช้ Xen อาจอยากเริ่มกับ SUSE และ possibly RedHat Ubuntu อาจ friendly แต่ setup อาจเป็น pain แม้ไม่ inconceivable
ในบทความนี้ จะแสดง setups บน SUSE 10.3 และ 11.2 ใน future articles จะใช้ RedHat-based distros เช่น CentOS และ Scientific Linux เป็น testbeds Testing shows Xen 3.X จะมี Xen 4.0 reviewed soon ซึ่ง included with openSUSE 11.4 ดังนั้นมี goodness เพิ่มเติมมา
Xen installation
Configuring Xen บน SUSE very easy เปิด Yast > Virtualization > Install Hypervisor and Tools Setup มี two stages - installation of necessary packages และ change of boot menu และ subsequent boot into Xen kernel

Xen จะ automatically configure bridged networking automatically ซึ่ง very neat เพราะไม่ได้ใน default KVM installation ให้ finish และ reboot
Basically that's it เรา ready to use Xen
Xen booted from GRUB2
โปรดสังเกต ถ้าคุณ chainloading SUSE ด้วย GRUB2 คุณจะต้อง create special entry สำหรับ Xen kernel ซึ่งอาจไม่ automatically added by OS probe script Entry ลูกต่างจาก standard boot stanzas
Without going into specifics of how GRUB2 works (อ่าน tutorial อธิบายทั้งหมด) นี่คือ section ที่ต้อง pay attention แทนที่จะใช้ standard linux, initrd entries คุณต้อง:
multiboot /boot/xen.gz
module /boot/vmlinuz-xen
module /boot/initrd-xen
Adjust exact paths ให้ match installations, devices ฯลฯ รูปภาพแสดงอย่างไรบน test machine:
Using Xen
ตอนนี้จะ start Virtual Machine Manager (VMM) ซึ่ง familiar จาก KVM tutorials และจะ create first virtual machine ของตัวเอง Warmup ใช้ GUI tools และภายหลังเรียนรู้ achieve same using Xen command line
จะแสดง two setups หนึ่งบน machine with SUSE 10 running KDE using full virtualization อีกอันบน SUSE 11 running Gnome using paravirtualization คาดหวัง mix of GUI images

VMM running
Very similar to what we already know
Create virtual machine
สามารถ create virtual machines using GUI โดย launch utility from YaST หรือ run vm-create from command line โปรดสังเกต somewhat different than VMM + KVM on Ubuntu ที่เราเห็นไม่กี่วันก่อน ที่เรามี ability create virtual machines from within management itself
Customization
เมื่อ reach summary section คุณสามารถ customize whatever you need คลิก blue title ใดๆ และ make changes ตัวอย่าง Disks section จะ normally point to virtual machine image under /var แทนคุณสามารถ create your own with dd และ place them anywhere you want และ use CD-ROM หรือ ISO images ที่คุณต้องการสำหรับ first installation นี่คือ handful of screenshots showing various options
We are ready to run
Running virtual machine
Depends on how you configured virtual machine Virt Viewer (virt-viewer) should start และ display virtual machine progress ในกรณีนี้ boot into Fedora 14 live session
Status ใน VMM:
Not bad for starters ตอนนี้คุณมี virtual machine configuration created on disk และใช้ได้ทั้ง understanding Xen syntax และ using it as template for other machines
Command line
ตอนนี้ examine Xen อีกครั้งคราวนี้ as proper CLI users ไม่มีอะไร special และถ้าเคยใช้ KVM จะพบ syntax fairly easy to follow man pages ดetailed และมี handful of good examples
จริงๆ คุณหา virtual machine templates ได้ under /etc/xen/examples Virtual machine files go under /etc/xen/vm copy them over และ create machines using xm create
นี่คือ Fedora 14 configuration ของเรา:
Important directives to pay attention to:
builder="hvm" - ถ้า processor ไม่ support virtualization คุณ won't be able to use this feature ต้อง set directive นี้เป็น linux แต่จะ lose some functionality
boot="d" - Very counter-intuitively d คือ CD-ROM first c คือ disk go figure
disk= - Specifies any kind of storage Order of devices determines how they are seen and used by virtual machine Letters r และ w denote read-only และ read/write modes
รายละเอียดเพิ่มเติม อ่าน xm man page เมื่อพร้อมใช้ configuration execute:
xm create
จะ registered as new domain ใน VMM ถ้าไม่ต้องการใช้ configuration files ระหว่าง testing สามารถ create virtual machines on the fly เช่น:
xm create /dev/null \
name=Debian \
kernel=/boot/vmlinuz-2.6-xen \
disk=file:/tmp/debian.img,sda1,w \
root=/dev/sda1 memory=256 vcpus=1
สร้าง new configuration ไม่เขียนที่ไหน hence /dev/null ใช้ privileged Xen kernel under /boot/ ที่มี drivers สำหรับ hardware ฯลฯ หรือถ้ามี smaller xenU kernel ใช้ได้ โดยเฉพาะ paravirtualization ต่อไป allocate memory, number of virtual CPUs และ storage สุดท้าย set root device สำหรับ virtual machine
ยังสามารถ install และใช้ virt-install create virtual machines virt-install run in interactive mode ถามคำถาม quite convenient 而且如果您使用 KVM 熟悉 syntax
Other things
A few more details worth mentioning ...
Paravirtualization
This one works แต่ not without some big issues ถ้า processor ไม่ support virtualization คุณอาจพบ Xen uncooperative กับบาง functions และ options ตัวอย่าง ผมไม่สามารถ boot from CD ใน paravirtualized mode 大部分时候 หรือพูดได้ว่า สามารถทำได้ หลัง lots of tweaking และ fiddling และ changes losing some functionality 在过程中 和 whatnot
This is a huge minus Web reverberating with questions และ answers regarding this 包括 crazy hacks like building your own HTTP server, mounting ISO images via loopback device, praying to Mayan gods, 和 more few of these methods being successful 或 even easy to implement เราจะ discuss this more separately 我会向您展示 how you can get going with paravirtualization despite the odds 和 explain why you don't want to do that anyway
More reading
If you're brave and want to run Xen on your Ubuntu try the Community Documentation
You may also like this very detailed Xen wiki at virtuatopia.com
Xen management tools - 我们将在单独的文章中讨论许多这些工具
openSUSE Xen page 和 how to install Xen VM Server
Finally a worthy blog on Virtualization: blog.bodhizazen.net 不只是 Xen
Conclusion
As you can see Xen is not a monster 虽然它可以是 daunting for new users somewhat complicated infrastructure can be a deterrent against using Xen 但如果您 focus 您会意识到它不是那么 dramatic Get the extra kernels, add them to your bootloader, boot into Xen, use graphical and command line tools to manage your virtual machines On SUSE Xen is included with the operating system making things easier
Compared to KVM Xen is a little more complicated to use 但您从一开始就获得 bridged networking 和没有 conflict with other technologies Paravirtualization mode parts of it that work offer better performance compared to emulation mode with KVM In full virtualization mode both solutions are quite handy and useful Most importantly I hope this tutorial has cleared some of the fog
在续集文章中 我们将学习 additional management tools for Xen 看看 standalone Xen Cloud Platform 甚至 introduce live edition 是的 Xen 可以从 live CD 运行 w00t 希望您喜欢这篇文章 See you around
Cheers.