博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HOW TO INSTALL XEN HYPERVISOR ON DEBIAN 9 “STRETCH” AND DEBIAN 8 “JESSIE” LINUX SYSTEMS
阅读量:6709 次
发布时间:2019-06-25

本文共 9442 字,大约阅读时间需要 31 分钟。

hot3.png

In this article, we will discuss the installation of Xen hypervisor server on Linux systems (Debian Family “Debian 9 “Stretch” and Debian 8 “Jessie” /Ubuntu 14.04, and higher”). The following steps worked on Debian 9 “stretch” and the result was installing xen 4.8 on Debian 9. For Debian 8 “Jessie” the only difference you’ll find is the version of Xen hypervisor which will be Xen 4.4 or 4.6, but As I’m not specifying the versions of xen on my commands, the following commands will work find on Debian 9/8 and may be Ubuntu 16.04/14.04 Linux systems.

The Xen Project hypervisor is an open-source , which makes it possible to run many instances of an operating system or indeed different operating systems in parallel on a single machine (or host). The Xen Project hypervisor is the only type-1 hypervisor that is available as open source. It is used as the basis for a number of different commercial and open source applications, such as: server virtualization, Infrastructure as a Service (IaaS), desktop virtualization, security applications, embedded and hardware appliances. The Xen Project hypervisor is powering the largest clouds in production today.

Requirements:

There are no requirements for installing Xen hypervisor, but only some general points to take into consideration:

  • Install Xen on 64 bit Linux systems, 32 bit it too old these days
  • Disk partition layout is very important since this will have an impact on the disk configurations available to the guests. 

  • Ensure that your Linux machine has suitable amount of ram for guests vms.

Let’s Install Xen hypervisor through the following steps:

Step 1: Install Xen and Xen-Tools

The installation is very direct and simple, but first I prefer to use the root account not sudo, run the following command “or you’ll use sudo in each command”:

$ sudo su -

Now, run the following commands to install the two needed packages xen and xen-tools:

# apt-get update# apt-get -y install xen-hypervisor-4.8-amd64 xen-tools

This will install all the additional packages needed by the xen hypervisor on Debian 9. For Debian 8 you may not find xen 4.8 available in your repository, just install the available version 4.4 or higher.

Step 2: Configure Grub to Switch the Boot Order

Before do any other configuration to the installed xen hypervisor, you must configure the grub to switch the boot order. This very important as in some cases after you reboot your machine doesn’t come back and lose all your work, run the following command to switch the boot order:

# dpkg-divert --divert /etc/grub.d/08_linux_xen --rename /etc/grub.d/20_linux_xenAdding 'local diversion of /etc/grub.d/20_linux_xen to /etc/grub.d/08_linux_xen'

Now, update the grub to apply your changes, run the following command:

# update-grubIncluding Xen overrides from /etc/default/grub.d/xen.cfgWARNING: GRUB_DEFAULT changed to boot into Xen by default! Edit /etc/default/grub.d/xen.cfg to avoid this warning.Generating grub configuration file ...Found linux image: /boot/vmlinuz-4.9.0-3-amd64Found initrd image: /boot/initrd.img-4.9.0-3-amd64Found linux image: /boot/vmlinuz-4.9.0-3-amd64Found initrd image: /boot/initrd.img-4.9.0-3-amd64Found linux image: /boot/vmlinuz-4.9.0-3-amd64Found initrd image: /boot/initrd.img-4.9.0-3-amd64done

Now, run this command to check the the grub boot order is correct, the first line should be ” 0 menuentry ‘Debian GNU/Linux, with Xen hypervisor’ ”

# grep -i "menuentry '" /boot/grub/grub.cfg|sed -r "s|--class .*$||g"|nl -v 0 0 menuentry 'Debian GNU/Linux, with Xen hypervisor'  1 menuentry 'Debian GNU/Linux, with Xen 4.8-amd64 and Linux 4.9.0-3-amd64'  2 menuentry 'Debian GNU/Linux, with Xen 4.8-amd64 and Linux 4.9.0-3-amd64 (recovery mode)'  3 menuentry 'Debian GNU/Linux, with Xen 4.8-amd64.efi and Linux 4.9.0-3-amd64'  4 menuentry 'Debian GNU/Linux, with Xen 4.8-amd64.efi and Linux 4.9.0-3-amd64 (recovery mode)'  5 menuentry 'Debian GNU/Linux'  6 menuentry 'Debian GNU/Linux, with Linux 4.9.0-3-amd64'  7 menuentry 'Debian GNU/Linux, with Linux 4.9.0-3-amd64 (recovery mode)'

Perfect!, the boot order is set to the xen hypervisor. Now, reboot your Linux machine:

# reboot

Step 3: Checks and Configuration Tweaks

Now, I suppose that your Machine started normally after the last reboot. To check that Xen successfully installed and UP run the following commands:

# xl infohost : octopusrelease : 4.9.0-3-amd64version : #1 SMP Debian 4.9.30-2+deb9u2 (2017-06-26)machine : x86_64nr_cpus : 8max_cpu_id : 7nr_nodes : 1cores_per_socket : 4threads_per_core : 2cpu_mhz : 3600hw_caps : b7ebfbff:77faf3ff:2c100800:00000121:0000000f:009c6fbf:00000000:00000100virt_caps : hvm hvm_directiototal_memory : 65329free_memory : 128sharing_freed_memory : 0sharing_used_memory : 0outstanding_claims : 0free_cpus : 0xen_major : 4xen_minor : 8xen_extra : .1xen_version : 4.8.1xen_caps : xen-3.0-x86_64 xen-3.0-x86_32p hvm-3.0-x86_32 hvm-3.0-x86_32p hvm-3.0-x86_64 xen_scheduler : creditxen_pagesize : 4096platform_params : virt_start=0xffff800000000000xen_changeset : xen_commandline : placeholdercc_compiler : gcc (Debian 6.3.0-16) 6.3.0 20170425cc_compile_by : ian.jacksoncc_compile_domain : eu.citrix.comcc_compile_date : Tue May 2 14:06:04 UTC 2017build_id : 0b619fa14fca0e6ca76f2a8b52eba64d60aa37dexend_config_format : 4

Again, our xen server is up, the above command is very important as it shows more details about the server’s specs. I highlighted the important details in brown. I’m using 64 bit OS, 8 VCPU, and total 64 GB of ram.

Now, we list the running guest xen vms, yes we’ll find only dom0 as we didn’t create any guests, run the following command:

# xl listName     ID   Mem    VCPUs State  Time(s)Domain-0 0    64357  8     r----- 6.8

As you see, our domain 0 is using all the available ram “64 GB in our case” and uses all cpus. This amount of memory and cpu are shared among dom0 and all domU (guests). Here’s comes our configuration tweaks. We need to tweak the memory and cpu assigned to dom0 and force dom0 to use dedicated amount of RAM and certain number of CPU for better performance:

Step 3.1: Configure Domain 0 Memory AND CPUs

By default on a Xen system the majority of the hosts memory is assigned to dom0 on boot and dom0’s size is dynamically modified (“ballooned”) automatically in order to accommodate new guests which are started. However on a system which is dedicated to running Xen guests it is better to instead give dom0 some static amount of RAM and to disable ballooning.

By default all CPUs are shared among dom0 and all domU (guests). It may broke dom0 responsibility if guests consume too much CPU time. To avoid this, it is possible to grant one (or more) processor core to dom0 and also pin it to dom0.

Here we will assign 4 GB of ram to dom0 and one CPU. The following commands will do this task:

# echo 'GRUB_CMDLINE_XEN="dom0_mem=4096M,max:4096M dom0_max_vcpus=1 dom0_vcpus_pin"' >> /etc/default/grub

This command updates grub configuration, and assign dedicated resources to dom0, yes we have to update grub and reboot the machine but this will be after the next modification.

Now, edit/create /etc/xen/xend-config.sxp to configure the toolstack to match by changing/adding the following settings:

(dom0-min-mem 4096)(enable-dom0-ballooning no)(dom0-cpus 1)

Find the above lines and change their values to the above values. If /etc/xen/xend-config.sxp not exists do not panic, just create it and add the above three lines to it.

Now, update the grub to apply your changes, run the following command:

# update-grubIncluding Xen overrides from /etc/default/grub.d/xen.cfgWARNING: GRUB_DEFAULT changed to boot into Xen by default! Edit /etc/default/grub.d/xen.cfg to avoid this warning.Generating grub configuration file ...Found linux image: /boot/vmlinuz-4.9.0-3-amd64Found initrd image: /boot/initrd.img-4.9.0-3-amd64Found linux image: /boot/vmlinuz-4.9.0-3-amd64Found initrd image: /boot/initrd.img-4.9.0-3-amd64Found linux image: /boot/vmlinuz-4.9.0-3-amd64Found initrd image: /boot/initrd.img-4.9.0-3-amd64done

Perfect!, the boot order is set to the xen hypervisor. Now, reboot your Linux machine:

# reboot

Now, I suppose that your Machine started normally after the last reboot. To check that Xen correctly configured, run the following commands:

# xl listName     ID   Mem   VCPUs  State   Time(s)Domain-0 0    4096  1      r-----  3.6

As you see, now dom0 uses 4GB and one dedicated cpu. To continue reading this article, check the next page

Step 4: Configure Xen-Tools

Soon will be completed.

Summary

I hope this article is good enough for you.

See you in other articles.

 

When attempting to create a XEN driven virtual machine on my dedicated server this morning I stumbled accross the following error:

01

02

03

04

05

06

07

08

09

10

11

Networking Information

----------------------

IP Address 1   : 192.168.1.200 [MAC: 00:16:3E:21:97:56]

 

Error:  No recognised installation type.

 

Logfile produced at:

         /var/log/xen-tools/test.my.flat.log

Assertion that either --dir, --lvm, or --dir are given failed.

This is probably a bug, please report it. at /usr/bin/xen-create-image line 4383.

END failed--call queue aborted at /usr/bin/xen-create-image line 990.

Well it was annyoing because I already used to create virtual machines yesterday. Luckily I found a solution for this issue quickly. Simply edit /etc/xen-tools/xen-tools.conf and uncomment dir = /home/xen .

For now it works again flawlessly.

转载于:https://my.oschina.net/shootercn/blog/1786218

你可能感兴趣的文章
几个关于tableView的问题解决方式整合
查看>>
gulp 常用插件汇总
查看>>
在linux下玩转usb摄像头
查看>>
RequiredFieldValidator----验证控件不起作用
查看>>
服务器端发送邮件签名采用Data URI scheme包含图片
查看>>
什么是DSCP,如何使用DSCP标记搭配ROS策略
查看>>
JPQL设置自增长、只读、文本类型等的注解
查看>>
【.net 深呼吸】自定义应用程序配置节
查看>>
【POI】对于POI无法处理超大xls等文件,官方解决方法【已解决】【多线程提升速率待定】...
查看>>
<html>
查看>>
SQL 查询逻辑处理顺序
查看>>
Android实训案例(七)——四大组件之中的一个Service初步了解,实现通话录音功能,抽调接口...
查看>>
Springmvc 中org.springframework.http.converter.json.MappingJackson2HttpMessageConverter依赖jackson包...
查看>>
[转载]从业务运维转到产品经理,我摸爬滚打的产品之路
查看>>
JDK工具jstatd用法详解(转)
查看>>
剑指offer47 不用加减乘除做加法
查看>>
为什么WEB-INF外的jsp无法根据cookie享受国际化
查看>>
Hbase 技术细节笔记(上)
查看>>
Java线程池详解
查看>>
深度学习入门篇--手把手教你用 TensorFlow 训练模型
查看>>