Environment:
Virtual Server:
CentOS 1, 5.4
192.168.10.6
VM:
CentOS5.4
192.168.10.8
The Virtual Server XEN is installed using yum, and the virtual host is installed using virt-install.
Steps:
1. To facilitate the operation, replace the default yum source of the system with the source of HKUST, which is faster in China.
Cd/etc/yum. repos. d
Mv CentOS-Base.repo CentOS-Base.repo.save
Wget http://centos.ustc.edu.cn/CentOS-Base.repo.5
Mv CentOS-Base.repo.5 CentOS-Base.repo
2. confirm that the current XEN is not installed in the system and install XEN through yum.
Yum clean all
Yum grouplist // If the Virtualization is in Available Groups, but not in Installed Groups, the XEN is not Installed in the system.
Yum groupinstall Virtualization-y
3. After the installation is complete, modify grub to enable it to start with the xen kernel.
Vi/etc/grub. conf
# Boot =/dev/sda
Default = 0
Timeout = 5
Splashimage = (hd0, 0)/boot/grub/splash.xpm.gz
Hiddenmenu
Title CentOS (2.6.18-164.11.1.el5xen)
Root (hd0, 0)
Kernel/boot/xen.gz-2.6.18-164.11.1.el5
Module/boot/vmlinuz-2.6.18-164.11.1.el5xen ro root = LABEL =/
Module/boot/initrd-2.6.18-164.11.1.el5xen.img
Title CentOS (2.6.18-164. el5PAE)
Root (hd0, 0)
Kernel/boot/vmlinuz-2.6.18-164.el5PAE ro root = LABEL =/
Initrd/boot/initrd-2.6.18-164.el5PAE.img
In grub. conf, it will probably look like this. You need to manually change it to default = 1 and change it to 0, that is, enable CentOS (2.6.18-164.11.1.el5xen) to start it by default.
Save and exit and restart the system.
4. start preparations for installing the VM:
Create Disk
Dd if =/dev/zero of =/app/xendata/gaso1disk bs = 25600 seek = 1024 k count = 0 // create a 25 GB disk space
Mkfs-t ext3/app/xendata/gaso1disk // format to ext3
Copy the system image and store it locally/app/gasoimages/centos5.iso
Mount the system image to a directory (/tmp)
Mount-o loop/app/gasoimages/centos5.iso/tmp
Start nfs service
Service nfs start
Edit nfs Directory Permissions
Vi/etc/exports
/Tmp 192.168.10. * (ro) // Add such a row
Save and exit, and output the Mount directory again
Exportfs-rv
5. Start to install the VM.
Virt-install-n gasotest-r 2048 -- vcpus = 2-f/app/xendata/gaso1disk -- nographics-l/tmp
-N specifies the Virtual Host Name
-R specifies the memory size used by the VM, which is 2 GB.
-- Vcpus = 2 specify the number of CPUs used by the VM
-F specifies the disk space files used by the VM
-- Nographics: specifies that the GUI is not enabled for VM installation.
-L specifies the location where the image is installed on the VM. Here, it indicates that/tmp is not actually effective. It should be directed to the nfs just created, but it doesn't matter, you can re-specify it during installation.
Select language> NFS Host Name: 192.168.10.6; NFS Directory:/tmp> select ipv4. Set the IP address to 192.168.10.8/255.255.255.0. Enter the gateway name, if you want to install a dns instance, you can choose to install it in text or vnc.
Now, the installation of the VM is almost complete.
6. Some XEN commands for controlling virtual hosts:
Xm list // view all running Virtual Hosts, where Domain0 is the host machine of the XEN Server
Xm shutdown gasotest // close the VM you just created. The name of the VM is the name of the VM. You can also disable it by id.
Xm create gasotest // enable the VM gasotest
Xm create gasotest-c // This-c parameter can be tracked by calling the console.
Note:
1. the configuration file of the created VM is/etc/xen/gasotest. a configuration file with the same name will be generated under/etc/xen, you can modify the parameters of the VM.
2. Add the VM to boot automatically:
Chkconfig -- add xendomains
Ln-s/etc/xen/gasotest/etc/xen/auto/gasotest // The domain in the auto directory will be automatically started upon startup, of course, the premise is to first add the xendomains service to the startup.