How to install and use Xen in Centos5.5

Source: Internet
Author: User
Centos5.5 installation and use of XenXen is a mainstream virtual machine with minimal performance loss (but does not support windows). It can run on x86 systems and is porting to x86_64, IA64, and PPC. Porting to other platforms is technically feasible and may be implemented in the future. 1. Installation supports Xen...
Centos 5.5 installation and use of Xen is a mainstream virtual machine with minimal performance loss (but does not support windows). It can run on x86 systems and is porting to x86_64, IA64, and PPC. Porting to other platforms is technically feasible and may be implemented in the future.
1. install the Linux kernel supporting Xen and Xen1yum-y install xen kernel-xen-lib virt-manager python-kernel instkernel-xen: The Linux core www.2cto.com Xen that can run xen: The main xen suite, including configuration files, startup scripts, and some function libraries xen-libs: The function library required by Xen python-connector INST: provides the terminal-installed software virt-manager: used to manage xen in a graphical interface
2. modify the default xen kernel to start 1vi/boot/grub. confdefault = 0 restart system 1reboot check kernel 1 uname-r2 output 2.6.18-238.9.1.el5xen check whether xen starts 1xm list2 output: Domain-0
3. when operating system is installed in xen, three sources are supported: NFS: nfs: host IP: Directory www.2cto.com WWW: http: // host IP/directory FTP: ftp: // host IP address/directory we use the WWW method (this method is very convenient. the installation source can be a web environment that contains the installation file that can be accessed ): make the installation source (Mount the optical drive to/mnt/cdrom) 1 mkdir-p/mnt/cdrom2mount/dev/cdrom/mnt/cdrom install httpd (if not installed) 1yum-y install httpd modify httpd default directory 1vi/etc/httpd/conf/httpd. conf: change DocumentRoot "/var/www/html" to DocumentRoot "/mnt/cdrom" Change 1sed-I's # DocumentRoot "/var/www/html" # DocumentRoot "/mnt/cdrom" # '/etc/httpd/conf/httpd. conf2sed-I's # # # '/Etc/httpd/conf/httpd. conf restart httpd1service httpd restart to create the main disk of the client 1 mkdir-p/data/vm2dd if =/dev/zero of =/data/vm/web_001.img bs = 2 k seek = 4096 k count = 1 create a client to swap disk 1dd if =/dev/zero of =/data/vm/swap. img bs = 2 k seek = 512 k count = 1 install the operating system 12.16-install-n web_001-r 512 -- vcpus = 1 -- nographic-f/data/vm/web_001.img-l http://192.168.9.220 Www.2cto.com #-n: specifies the name of the VM followed by the name. configure the name under/etc/xen. #-r: specifies the size of the allocated memory. it must be at least 256 MB ?? Why? /Div> # -- vcpus: How many CPUs are allocated #-f: the new disk file is followed! # -- Nographics: Do not use graphical installation; #-p: Semi-virtualization #-s: hard disk space of the virtual machine #-l: install the source later. Written as: # NFS: nfs: host IP: Directory # WWW: http: // host IP/directory # FTP: ftp: // host IP address/Directory. after installing the system according to the system prompt, view the virtual machine list on the real machine. the list output by 1xm list contains the newly created web_001 virtual machine. 4. attaches the relevant operation command ls/etc/xen # xen configuration file directory xm list # view the status of each domain xm shutdown web_001 # Disable the VM xm console web_001 web_001 to connect to the web_001 console, to connect to the VM, you can press ctrl +] to switch to the host. # if an IP address is configured, you can use the ssh-l username IP address to connect to xm create web_001 and start web_0015. how to automatically start the virtual machine 1ln-s/etc/xen/web_001/etc/xen/auto/web_001 # Copy the configuration file directly to/etc/xen/auto/ 1 www.2cto.com cp-r/etc/xen/web_001/etc/xen/auto/6. XM command: xm create vm1 # where vm1 is the virtual machine configuration file, located in/etc/xen/vm/vm1 xm create-c vm1 # If you need to start the console, you can run the command xm list # to list all the VM xm consoles. # Display xm reboot on the console of a virtual machine | shutdown # You can restart and disable the virtual machine xm destroy with the id of domid. # Destroy the VM xm console fc5 with the id of domid # log on to the running virtual operating system xm save from the terminal or console # Store the status of the running virtual operating system xm restore # Wake up xm pause # Stop the running virtual operating system xm unpause # Activate the stopped virtual operating system xm mem-set # Adjust the memory occupied by the virtual platform/virtual operating system xm shutdown the Name or DomID of the virtual operating system # Disable the virtual system xm destroy # Stop a virtual system immediately (important); xm vcpu-set # Adjust the number of virtual CPUs of the virtual platform and virtual operating system xm top or xentop # view the running status of the virtual system xm save VM1 VM1.chk # stop the domain and save its current state into a file called VM1.chk xm restore VM1.chk # resume execution of this domain
7. XEN vm copy close running vm 1xm shutdown web_001 copy vm image file and configuration file 1cp/data/vm/web_001.img/data/vm/web_002.img2cp/etc/xen/web_001/etc/ xen/web_002 modify the configuration file 1vi/etc/xen/web_002 of the newly copied virtual machine as follows: 01 name = "web_001" 02 www.2cto.com uuid = "courier" 03 maxmem = 51204 memory = 51205 vcpus = 106 bootloader = "/usr/bin/pygrub" 07on_poweroff = "destroy" 08on_reboot = ""restart" 09on_crash = "restart" 10 disk = ["tap: aio:/data/vm/web_001.img, xvda, w "] 11vif = [" mac = 00: 16: 36: 64: 98: f1, bridge = xenbr0, script = vif-bridge "] The modified content is: 01 name = "web_002" 02 uuid = "bytes" 03 maxmem = 51204 memory = 51205 vcpus = 106 bootloader = "/usr/bin/pygrub" 07 www.2cto.com on_poweroff = "destroy" 08on_reboot = "restart" 09on_crash = "restart" 10 disk = ["tap: aio:/data/vm/web_002.img, xvda, w "] 11vif = [" mac = 00: 16: 36: 64: 98: f5, bridge = xenbr0, script = vif-bridge "] * Ensure the uniqueness of name, uuid, mac, and disk path
Start and enter the newly copied VM 1xm create-c web_002 modify host name 1vi/etc/hosts change web_001 to web_0021vi/etc/sysconfig/network change web_001 to web_002 modify IP01vi/etc/ sysconfig/network-scripts/ifcfg-eth002 # Xen Virtual Ethernet03DEVICE = eth004BOOTPROTO = static05BROADCAST = 192.168.9.25506HWADDR = 00: 16: 36: 64: 98: f507 www.2cto.com IPADDR = 192.168.9.22208NETMASK = 255.255.0000009network = 192.168.9.010ONBOOT = yesQ: bs = 2 k seek = 4096 k count = 1 parameter meaning bs = 2 k: set the size of the read/write block to 2 kseek = 4096 k: Skip 4096 k blocks from the beginning of the output file and then start copying (usually only valid when the output file is a disk or tape) count = 1: copy only one block (the block size is equal to the number of bytes specified by bs) by Snowman
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.