A simple way to install Xen virtual machine in CentOS

Time:2021-1-12

1、 Xen virtual environment preparation
Method 1: after selecting Xen components during installation, the system naturally supports Xen.
Method 2: install Xen component manually when necessary.

1. Yum automatically installs Xen components

Copy code

The code is as follows:

# yum install kernel-xen xen-libs xen

2. Modify the boot list and start the system with the kernel running Xen

Copy code

The code is as follows:

# vi /boot/grub/grub.conf
default=0
title CentOS (2.6.18-194.3.1.el5xen)
root (hd0,0)
kernel /xen.gz-2.6.18-194.3.1.el5
module /vmlinuz-2.6.18-194.3.1.el5xen ro root=LABEL=/
module /initrd-2.6.18-194.3.1.el5xen.img

Description: after installing yum, grub menu is automatically installed. If not, add it manually, and there will be related kernel files under the / boot menu.

3. Boot automatically enters the kernel of Xen component.

4. View Xen startup
(1) Set Xen to boot

Copy code

The code is as follows:

# chkconfig –list |grep xend
xend 0:off 1:off 2:on 3:on 4:on 5:on 6:off
xendomains 0:off 1:off 2:off 3:on 4:on 5:on 6:off

(2) The operation of Xen (the following indicates that it has been started)

Copy code

The code is as follows:

# xm list
Name ID Mem(MiB) VCPUs State Time(s)
Domain-0 0 211 1 r—– 90.5

5. Create installation source
When installing Linux virtual system in Xen virtual machine semi virtual environment, you need to use the installation source of the system. You can use HTTP, FTP or NFS to provide Xen virtual machine for system installation. FTP is used for installation.

Copy code

The code is as follows:

# yum install -y vsftpd
# service vsftpd start
# mount /dev/cdrom /var/ftp/pub/

Note: after vsftpd is installed, anonymous access is supported.

2、 Xen virtual machine installation
1. Create virtual machine

Copy code

The code is as follows:

# virt-install –prompt
What is the name of your virtual machine? centos5
How much RAM should be allocated (in megabytes)? 256
What would you like to use as the disk (file path)? /data/ test.img </p>
#For example, / dev / lvmdata / var01
How large would you like the disk(/data/test.img) to be (in gigabytes)? 3
What is the install URL? ftp://192.168.44.141/pub/</p>
<p>Starting install…
Retrieving file .treeinfo… | 413 B 00:00
Retrieving file vmlinuz… | 2.1 MB 00:00
Retrieving file initrd.img… | 6.6 MB 00:00
Creating storage file… | 3.0 GB 00:00</p>
Name ID Mem(MiB) VCPUs State Time(s)
Domain-0 0 877 2 r—– 1781.7
centos5 12 300 1 -b—- 31.5
testos 11 300 1 -b—- 40.9

2. Enter the console of centos5 virtual host

Copy code

The code is as follows:

# xm console centos5
#CTRL +] exit virtualization console