Xen: Linux™Introduction to kernel virtualization technology

Source: Internet
Author: User
Xen: Linux & #8482; kernel virtualization technology overview-Linux general technology-Linux programming and kernel information. For details, refer to the following section. Xen is applicable to Linux™A virtualization technology of the kernel allows you to install and test new upgrades like in an existing environment without worrying about damaging the original system. I will show you how to use Fedora Core to install Xen. However, after installation, all programs run the same in any release version of Xen. Learn about virtualization on Linux, know the benefits of having a sandbox for testing new software, and practice running multiple virtual machines on the same Linux machine.
With the improvement of existing software and bug fixing, the Open Source world will never change. To keep the software updated, you may have to work as a full-time job. One of the most difficult problems with upgrading software is that you never really know whether the application can still work after the upgrade is complete. Most software packaging systems have the rollback function, but this function is not enough. Ideally, you should test these new upgrades, and try them in an environment that does not destroy anything.

Just like a child playing, you want to have a sandbox of your own, where you can do anything at will.

Applications and systems on the same hardware are usually isolated by Virtualization (or sandbox. From hardware simulation to Full Hardware virtualization, Linux supports many different forms of virtualization. In the ever-increasing list of Virtualization Technologies, Xen is one of the most striking recently developed by the University of Cambridge. Xen deserves your attention because it has unprecedented performance and security.

First knowledge of Xen
Xen was developed as a research project at the University of Cambridge and has been greatly promoted in the open-source community. Xen is a semi-virtualization (paravirtualizing) VMM (Virtual Machine Monitor). This indicates that the operating system must be modified selectively to call the system hypervisor, however, you do not need to modify the applications running on the operating system. While other virtualization systems such as VMWare are fully virtualized (they do not have to modify the operating system in use), they still need to translate real-time machine code, which affects performance.




(400) {this. resized = true; this. width = 400; this. alt = 'click here to open new window';} "onmouseover =" if (this. resized) this. style. cursor = 'hand'; "onclick =" window. open ('HTTP: // tech.ccidnet.com/pub/attachment/2005/4/410885.gif'); ">

Because Xen needs to modify the operating system, you cannot directly run the current Linux kernel in the Xen System Administrator unless it has been transplanted to the Xen architecture. However, if the current system can use a new Linux kernel that has been transplanted to the Xen architecture, you can run the existing system without modification.

Figure 1. Simple Xen Architecture


Get Xen
You can obtain the source code from the Xen project homepage (refer to the link in the references section). However, if you are using a Linux release version, you may be able to obtain the Xen through the software package upgrade or installation. These mainstream Release versions include Xen:

Fedora Core
SUSE Linux
Debian
You can obtain the e-builds used in the Gentoo's bugzilla experiment.
Check your release version-if it is not in this list, you may only use the source code directly. Except the installation process is specific to the release version, all work in Xen is the same on any release version.
Use Fedora Core
I have a ora Core 3 installation that can be used. To keep this article concise, I will discuss how to install and run the system on Fedora Core.

Although the software package was developed only recently, Fedora is already used by a large number of Xen users. Since many people try to use Xen on Fedora, you may be able to get a lot of online help.

Install Xen
To help you get started and use Quick Start, this section highlights the key points of Quick Start Guide in the references section. Since Xen updates are being integrated into Fedora, the Quick Start Guide is likely to change over time and wiki is expected to maintain updates to these changes.

First, perform the simplest Server installation for the base machine. This basic machine is your system administrator program and will not run any server applications. You can install the required software package on the Xen server running on this machine. Therefore, you do not need to install the application you want to run.

After the system starts running, you should update it to the latest development version (rawhide) of Fedora ). To complete this task, traverse the elements in the/etc/yum. repos. d/directory and change all elements except the fedora-devel.repo to enabled = 0; change the fedora-devel.repo to enabled = 1.

After the yum repository (repository) is created, you need to update the machine to rawhide so that you can start to use the latest release Xen.

Listing 1. Update FC3 to rawhide and install the Xen package

Yum update

Yum install x en kernel-xen0 kernel-xenU



Then, create a virtual file system to be used.

Listing 2. Format and create an Xen Server File System

Mkdir-p/xen/base
Dd if =/dev/zero of =/root/base. img bs = 1 M count = 1 seek = 1024
Mkfs. ext3/root/base. img
Mount-o loop/root/base. img/xen/base



After formatting and mounting the Xen Server File System, the next step is to install necessary software packages to run certain programs on these software packages. To run a Web server on the Xen server, you should install a set of Web-server software packages. (Warning: this will take some time! You can run yum first and then go out for a walk .)

Listing 3. Installing the Xen Server Software Package

Yum -- installroot =/xen/base-y groupinstall web-server \
-- Enablerepo = base -- disablerepo = development



(Now we should take a walk .)

All required software packages have been installed, but you should check a simple fstab file, which will tell the Xen server that they will obtain the root device sda1, use the device as the root. The root device is actually a virtual device from the system administrator, but your server does not know this.

Listing 4. Xen server fstab file

/Dev/sda1/ext3defas1 S1 1
None/dev/ptsdevpts gid = 5, mode = 6200 0
None/dev/shm tmpfs defaults0 0
None/proc defaults0 0
None/sys sysfs defaults0 0



Write this file to/xen/base/etc/fstab. If it is not a standard Fedora installation, no fstab will be created for you. It is expected that future versions of Fedora will include tools to solve this problem.

Finally, you should do some processing to make the system run correctly. Currently, Xen still has problems when using initrd. Therefore, if you want to start the system, you need to create some device code for yourself. Then, to make the program run smoothly, deleting the TLS library will be helpful because they are currently in serious conflict with Xen. After completing this step, you can uninstall the file system.

Listing 5. The final process for starting running

For I in console null zero; do MAKEDEV-d/xen/base/dev-x $ I; done

Mv/lib/tls. disabled
Mv/xen/base/lib/tls/xeb/base/lib/tls. disabled

Umount/xen/base/



Run Xen
Since the customer system has been carefully established manually, now you can actually restart the machine and start using the Xen kernel. You may see much more print output than usual, and you will also see terrible messages about the TLS Library (the library you deleted in the previous section that causes problems.

Xen requires that the configuration file be prepared for each running server. Although you can create a unique dynamic configuration file for all servers, we recommend that you create two static configuration files, one for each. As you can see, the disk tag tells the server that your file image is an sda1 device. It also specifies the xenU kernel you are using and the memory that the server client will obtain.

Listing 6. Xen server configuration file
/Etc/xen/base
Kernel = "/boot/vmlinuz-2.6.10-1.1141_FC4xenU"
Memory = 64
Name = "BaseServer"
Bytes = 1
Disk = ['file:/root/base. img, sda1, W']
Root = "/dev/sda1 ro"

/Etc/xen/test
Kernel = "/boot/vmlinuz-2.6.10-1.1141_FC4xenU"
Memory = 64
Name = "TestServer"
Bytes = 1
Disk = ['file:/root/test. img, sda1, W']
Root = "/dev/sda1 ro"



To start and run the server, run the command xend start to start the Xen service, and then run the command xm create base to create the BaseServer through the basic configuration file. After completing these steps, you will be directed to the Xen customer system and you will see that the system has been started. At any time, if you want to jump out of the customer's system console, press Ctrl-] to return directly to the System Administrator console.

Use Xen
Now you have used some time to edit the configuration and created a system that runs two Xen servers. What should I do next after all these hard work is completed?

Now you have two copies of a system that run the same kernel and are virtualized on the same machine. If BaseServer represents the stable environment in which you want to run the Web Service normally, TestServer represents the latest software update provided by Fedora rawhide. You can upgrade the TestServer system at will and try all new software updates. When you think it is stable enough, you can run TestServer as a BaseServer.

Set BaseServer
When BaseServer is running, it is a good time to modify the configuration of the httpd service to be running. You should remove the ssl. conf file from the/etc/httpd/conf. d/directory to disable ssl. Otherwise, you will need to generate a certificate for the server. In addition, you may need to add an apache user to the system.

The Xen System Administrator has automatically provided a virtual network device that can be used. If you can run dhcp on this device, you only need to run dhclient eth0 and the BaseServer will get the IP address.

Set TestServer
After setting the BaseServer configuration, run poweroff on the BaseServer console to disable the instance. If you have logged out of the BaseServer, you can use the xm console BaseServer to re-enter it.

Now, copy the basic image through cp/root/base. img/root/test. img to obtain copies of the same file system. When xm create-c test is run, it runs the same server as BaseServer, but its name is TestServer. Log on to TestServer, enable rawhide support as you did in the Xen installation section, and then run yum update.

The TestServer instance has the same configuration as BaseServer, but you have upgraded to the latest package required by Fedora rawhide. Here, you can check whether the Web site is still available.

What else does Xen have?
I hope these brief descriptions and simple examples can help you install and run Xen so that you can try it. To help you quickly get familiar with Xen, I did not describe how to use features such as LVM and snapshots, nor did I describe how to migrate Xen servers from one machine to another. However, since you have learned some of the advantages of Xen, please refer to the following references and learn more about how to use it.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.