Installation and basic operation of Xen virtual machine in CentOS

Time:2020-10-7

Since rhel6 version, red hat does not support Xen in its original version, but goes to KVM instead. Although KVM claims to support full virtualization of HVM technology, KVM started late after all, far less mature than Xen technology. When running multiple instances, system crashes often occur. Of course, KVM can be more efficient in the future. Therefore, there are only two ways to install Xen. One is to download the source code and compile it by yourself. However, this method consumes too much energy, so it is ignored. The other is to use a third-party software source for installation. The Internet has a large number of third-party sources and open-source organizations provide compiled source code. The xenmade easy open source project provides us with the installation of xen4 in rhel6 / centos6. This paper uses the third-party installation source provided by Xen made easy project website, which is convenient and fast.

Environment 1
Hardware: HP DL360 G6 (e5520,16g, 2 * 146gb)
System version: centos-6.6-x86_ 64- minimal.iso

2. System initialization

Copy code

The code is as follows:

wget //blog.linuxeye.com/lnmp-full.tar.gz
tar xzf lnmp-full.tar.gz
cd lnmp
/ install.sh #All choose No
Chkconfig iptables off ා turn off iptables

3. Install bridge utils

Copy code

The code is as follows:

yum -y install bridge-utils

4. Installation crc.id.au Installation source

Copy code

The code is as follows:

yum -y install http://au1.mirror.crc.id.au/repo/el6/x86_64/kernel-xen-release-6-7.noarch.rpm

5. Install Xen virtualization

Copy code

The code is as follows:

yum -y install xen
ls -l /boot/xen.gz
lrwxrwxrwx 1 root root 12 Dec 1 18:42 /boot/xen.gz -> xen-4.2.5.gz

6. Install Xen kernel

Copy code

The code is as follows:

yum -y install kernel-xen

Note: kernel Xen installation depends on kernel Xen firmware. Since these two packages are relatively large, it is recommended to download them locally and use Yum – y localinstall kernel Xen * to complete the installation

Copy code

The code is as follows:

cat /boot/grub/ grub.conf #As shown in the figure below, boot with Xen kernel next time

201653110035633.gif (888×651)

Chkconfig xend on ා after restarting the system, it is found that the xend server is not configured to boot automatically

7. Configure the network card to bridge mode
Create a new file / etc / sysconfig / network scripts / ifcfg-xenbr0, and keep the following contents:

Copy code

The code is as follows:

DEVICE=xenbr0
TYPE=Bridge
ONBOOT=yes
DELAY=0
NM_CONTROLLED=no
BOOTPROTO=static
IPADDR=192.168.3.20
NETMASK=255.255.255.0
GATEWAY=192.168.3.1

Modify / etc / sysconfig / network scripts / ifcfg-eth0 to keep the following contents:

Copy code

The code is as follows:

DEVICE=eth0
HWADDR=F4:CE:46:85:64:34
TYPE=Ethernet
UUID=c27373b9-a698-4ac8-9afe-a4dee87f5704
ONBOOT=yes
BRIDGE=xenbr0
NM_CONTROLLED=no
Service network restart ා

Restart the server 8
Restart the system and enter the Xen kernel Linux. The test is as follows:
201653110112552.gif (895×843)

9. Install virtualization management toolset

Copy code

The code is as follows:

yum -y install libvirt

Libvirt provides a hypervisor agnostic API to safely manage guest operating systems running on the host. Libvirt itself is not a tool, it is an API that can build tools to manage guest operating systems. Libvirt itself is built on an abstract concept. It provides a common API for common functions implemented by supported hypervisors. Libvirt was originally designed as a Management API for Xen, and was later extended to support multiple hypervisors.

Copy code

The code is as follows:

service libvirtd start
yum -y install python-virtinst

Contains a python module that uses libvirt to start and install the operating system version inside the virtual machine (such as commands: virt install, virt clone)

10. Configure the operating system installation source
Mount centos-6.6-x86 at 192.168.3.10:81_ 64- minimal.iso And copy the file to centos6.6 in the root directory of Apache website, so that it can be accessed on 192.168.3.20 http://192.168.3.10 : 81 / centos6.6 access to installation image
Note: there is a missing line in the image file. Treeinfo, which causes the kernel not to be found when installing the system. Keep the middle segment as follows:

Copy code

The code is as follows:

[images-xen]
kernel = images/pxeboot/vmlinuz
initrd = images/pxeboot/initrd.img

11. Character interface installation CentOS

Copy code

The code is as follows:

mkdir -p /data/xen
virt-install -n vm21 -r 2048 –vcpus=2 –nographic –disk path=/data/xen/vm21.img,size=20 \
-l http://192.168.3.10:81/centos6.6/ –bridge=xenbr0,model=virtio

Virt install command parameters:
-N — name = client virtual machine name
-R — ram = memory allocated by client virtual machine
-U — UUID = client UUID
–Vcpus = 2 number of vcpus of client
-V — HVM full virtualization
-P — paravirt semi virtualization
-L — location = localdir installation source
–VNC using VNC
-C — CDROM = CD drive installation path
-S — file size = uses the size of the disk image in GB
-F — file = file used as disk image
–Disk = use different options to use installation media as disks

12. Clone image

Copy code

The code is as follows:

virt-clone -o vm21 -n vm22 -f /data/xen/vm22.img

Recommended Today

JS function

1. Ordinary function Grammar: Function function name (){ Statement block } 2. Functions with parameters Grammar: Function function name (parameter list){ Statement block } 3. Function with return value Grammar: Function function name (parameter list){ Statement block; Return value; } Allow a variable to accept the return value after calling the function Var variable name […]