Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and configure a Xen virtual machine in CentOS

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to install and configure the Xen virtual machine in CentOS". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to install and configure the Xen virtual machine in CentOS.

Note 1: in this experimental environment, the real machine CentOS 5.832 bit, virtual machine CentOS 5.232 bit, real machine IP: 192.168.100.117

Note 2: be sure to write down the MAC address of the real machine before the experiment, so as not to be able to use the Internet later. My MAC here is 00:1D:7D:CD:D7:74.

The first step is to view hardware support

1. Paravirtualized hardware requirements

The code is as follows:

[root@xen ~] # cat / proc/cpuinfo | grep flags

Flags: fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm

Pbe nx lm constant_tsc pni monitor ds_cpl est tm2 cid cx16 xtpr lahf_lm

If the pae character appears, it means that paravirtualization is supported; we are using the paravirtualization experiment this time.

two。 Fully virtualized hardware requirement

Since I don't have the hardware to support, roughly speaking, the query command is the same as above.

Pae vmx is required for Inter's CPU and pae svm for AMD's CPU.

Step 2 install Xen core software

Be careful to close selinux and disable netmanager first

Add in / etc/sysconfig/network-script/ifcfg-eth0

The code is as follows:

NM_CONTROLLED=no

1. Basic installation and testing

The code is as follows:

[root@xen ~] # yum install xen* kernel-xen*

[root@xen ~] # vi / boot/grub/menu.lst

Default=0

Timeout=5

Splashimage= (hd0,0) / grub/splash.xpm.gz

Hiddenmenu

Title CentOS (2.6.18-308.4.1.el5xen)

Root (hd0,0)

Kernel / xen.gz-2.6.18-308.4.1.el5

Module / vmlinuz-2.6.18-308.4.1.el5xen ro root=LABEL=/ rhgb quiet

Module / initrd-2.6.18-308.4.1.el5xen.img

Title CentOS (2.6.18-308.4.1.el5)

Root (hd0,0)

Kernel / vmlinuz-2.6.18-308.4.1.el5 ro root=LABEL=/ rhgb quiet

Initrd / initrd-2.6.18-308.4.1.el5.img

See the el5xen kernel version of the system above? Change default to 0 to start with it.

Then, restart the server

The code is as follows:

[root@xen] # shutdown-r now

Once booted, reconfirm whether it is started with the Xen kernel

The code is as follows:

[root@xen ~] # uname-r

2.6.18-308.4.1.el5xen

[root@xen ~] # chkconfig-- list | grep xen

Xend 0: off 1: off 2: enable 3: enable 4: enable 5: enable 6: close

Xendomains 0: off 1: close 2: close 3: enable 4: enable 5: enable 6: close

[root@xen ~] # pstree-p | grep xen

| |-xenbus (14) |

| | `- xenwatch (13) |

| |-xenconsoled (2860)-{xenconsoled} (2861) |

| |-xend (2856)-xend (2858)-+-{xend} (28 62) |

| |-{xend} (2866) |

| |-{xend} (2867) |

| |-{xend} (3086) |

| | `- {xend} (3087) |

| |-xenstored (2852) |

[root@xen ~] # xm list

Name ID Mem (MiB) VCPUs State Time (s)

Domain-0 0 1763 2 r-37.1

If the color and bold parts of the above steps are similar to mine, it means that the startup is successful!

2. The software structure of Xen

/ usr/sbin/xend xend startup script, written by my favorite python

/ usr/sbin/xm commands for managing xen, enter xm help to query usage

/ etc/xen/xend-config.sxp this is the xend configuration file, generally do not need to move

/ etc/xen/ contains several configuration templates for domain-U, and xmexample.hvm can be used as a complete virtual template.

/ etc/xen/auto system automatically starts a certain domain-U when it is powered on. The following example usage:

[root@xen ~] # cd / etc/xen/auto/

[root@xen auto] # ln-s.. / xmexample.hvm.

In this way, xmexample will be started when the system is started, but don't use it so directly.

/ etc/xen/scripts includes virtual device startup, network startup, etc.

Step 3 install the virtual system

1. First create a directory to put the virtual system (the directory is self-determined)

The code is as follows:

[root@xen auto] # cd / var

[root@xen var] # mkdir vps

We use the directory / var/vps here.

two。 Then make an empty image file to put in the system.

The code is as follows:

[root@xen var] # dd if=/dev/zero of=/var/vps/vps1.img bs=1M count=8000

Count is the size; waiter, give me 8G space.

3. Install vsftp and mount the system in the CD drive to the ftp directory

The code is as follows:

[root@xen ~] # yum install vsftpd

[root@xen ~] # service vsftpd start

Such an anonymous FTP can be used to download and mount the CD-ROM drive.

[root@xen ~] # mount / dev/cdrom / var/ftp/pub/

Test whether the mount is successful and access it from the browser.

Ftp://192.168.100.117/pub/

E2fsck's blog http://www.e2fsck.org

You can see the contents of the CD, which means it's a success.

4. Go to the / var/vps directory to establish a virtual machine

The code is as follows:

[root@xen ~] # cd / var/vps/

[root@xen vps] # virt-install-prompt

What is the name of your virtual machine? Vps1 # enter a name

How much RAM should be allocated (in megabytes)? 415 # memory size

What would you like to use as the disk (file path)? / var/vps/vps1.img # storage location, write the address after of above

What is the install URL? Ftp://192.168.100.117/pub/ # where are the installation files

Then there is the TEXT installation mode

The code is as follows:

Welcome to CentOS +-Choose a Language +-+

| | |

| | What language would you like to use |

| | during the inst |

Allation process? |

| | |

| | Catalan ^ |

| | Chinese (Simplified): | |

| | Chinese (Traditional) # | |

| | Croatian: |

| | Czech: |

| | Danish: |

| | Dutch: |

| | English v |

| | |

| | +-+ |

| | OK |

| | +-+ |

| | |

| | |

+-+

/ between elements | selects | next screen

Text mode installation is not difficult, if there is a problem, search the Internet

After installation, restart and appear:

The code is as follows:

CentOS release 5.2 (Final)

Kernel 2.6.18-92.el5xen on an i686

Localhost.localdomain login: root

Password:

[root@localhost ~] #

Enter the account number and password and go in.

The exit button is the same as telnet's: CTRL +]

5. Manage Xen virtual machines

View the general information of virtual machines in the current system

The code is as follows:

[root@xen vps] # xm list

Name ID Mem (MiB) VCPUs State Time (s)

Domain-0 0 1599 2 r-421.9

Vps1 2 415 1-bMurmuri-24.9

By the way, there are six states of State above:

R-run, b-block (not running or sleep state), p-pause (possibly xm pause performed), s-shutdown, c-crash, d-dying

View the load of the virtual machine

The code is as follows:

[root@xen vps] # xm top

Shut down the virtual machine

The code is as follows:

[root@xen vps] # xm shutdown vps1

Enter the virtual machine

The code is as follows:

[root@xen vps] # xm console vps1

Start the virtual machine

The code is as follows:

[root@xen vps] # xm create vps1

Add vps1 to the real machine boot self-boot

The code is as follows:

[root@xen xen] # ln-s / etc/xen/vps1 / etc/xen/auto/vps1

Input other parameters into xm help

6. Xen virtual machine replication

Shut down the virtual machine first

The code is as follows:

[root@xen xen] # xm shutdown vps1

Copy the image files and configuration files of the virtual machine

The code is as follows:

[root@xen xen] # cp / var/vps/vps1.img / var/vps/vps2.img

[root@xen xen] # cp / etc/xen/vps1 / etc/xen/vps2

Modify the configuration file of the new replication virtual machine

The code is as follows:

[root@xen xen] # vi / etc/xen/vps2

The original content is:

The code is as follows:

Name = "vps1"

Uuid = "1f251cca-5ea2-49fb-95e6-3b08359e6d33"

Maxmem = 415

Memory = 415

Vcpus = 1

Bootloader = "/ usr/bin/pygrub"

On_poweroff = "destroy"

On_reboot = "restart"

On_crash = "restart"

Disk = ["tap:aio:/var/vps/vps1.img,xvda,w"]

Vif = ["mac=00:16:3e:44:09:ca,bridge=xenbr0,script=vif-bridge"]

After modification, it is:

The code is as follows:

Name = "vps2"

Uuid = "1f251cca-5ea2-49fb-95e6-3b08359e6d34"

Maxmem = 415

Memory = 415

Vcpus = 1

Bootloader = "/ usr/bin/pygrub"

On_poweroff = "destroy"

On_reboot = "restart"

On_crash = "restart"

Disk = ["tap:aio:/var/vps/vps2.img,xvda,w"]

Vif = ["mac=00:16:3e:44:09:cb,bridge=xenbr0,script=vif-bridge"]

Note: make sure that name, uuid and mac are unique, and then change the disk path.

Then boot and enter the new virtual machine

The code is as follows:

[root@xen xen] # xm create-c vps2

Modify hostname and IP

The code is as follows:

[root@localhost ~] # vi / etc/hosts

[root@localhost ~] # vi / etc/sysconfig/network

The above two are relatively simple, so I won't talk about them.

The code is as follows:

[root@localhost ~] # hostname vps2

[root@localhost ~] # vi / etc/sysconfig/network-scripts/ifcfg-eth0

# Xen Virtual Ethernet

DEVICE=eth0

BOOTPROTO=static

HWADDR=00:16:3E:44:09:CB # it's best to change it to the MAC address in the modified configuration file above

ONBOOT=yes

IPADDR=192.168.100.167

NETMASK=255.255.255.0

NETWORK=192.168.100.0

GATEWAY=192.168.100.1

Thank you for reading, the above is the content of "how to install and configure Xen virtual machine in CentOS". After the study of this article, I believe you have a deeper understanding of how to install and configure Xen virtual machine in CentOS. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report