构建Xen实例之创建Dom0

Dom0的作用:
管理底层IO(是真正对底层硬件做支持的),负责虚拟实例的管理。

1. 配置Xen yum源

[root@rebekk ~]# cat /etc/yum.repos.d/xen48.repo
[xen48]
name=Xen4.8 on Aliyun
baseurl=https://mirrors.aliyun.com/centos/7/virt/x86_64/xen-48/
gpgcheck=0
enabled=1

# 下面这个命令主要目的是生成重要脚本/usr/bin/grub-bootxen.sh
[root@rebekk ~]# yum install centos-release-xen-common -y

# 用rpm命令可以看一下它生成了什么
[root@rebekk ~]# rpm -ql centos-release-xen-common
/etc/yum.repos.d/CentOS-Xen-dependencies.repo
/usr/bin/grub-bootxen.sh

# 看一下它生成的源是什么样子
[root@localhost yum.repos.d]# cat /etc/yum.repos.d/CentOS-Xen-dependencies.repo
# Include select packages from epel:
# - xossiro: For xen-vixen sidecar creation script
[centos-virt-xen-epel]
name=Extra Packages from EPEL for Xen - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/$releasever/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-$releasever&arch=$basearch
failovermethod=priority
enabled=1
includepkgs=xorriso
gpgcheck=1
gpgkey=https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-$releasever

# 接下来将enable=1改成0,以免影响下载速度

2. 升级安装包并安装Xen

[root@rebekk ~]# yum update
[root@rebekk ~]# yum install xen

3. 修改Grub引导文件,并指定Dom0启动内核参数

[root@rebekk ~]# vim /etc/default/grub

GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
GRUB_CMDLINE_XEN_DEFAULT="dom0_mem=1024M,max:1024M dom0_max_vcpus=2 dom0_vcpus_pin=true cpuinfo com1=115200,8n1 console=com1,tty loglvl=all guest_loglvl=all"
GRUB_CMDLINE_LINUX_XEN_REPLACE_DEFAULT="console=hvc0 earlyprintk=xen nomodeset"

4. 启动Dom0

# 运行脚本编译内核
[root@rebekk ~]# bash $(which grub-bootxen.sh)
GRUB_CMDLINE_XEN_DEFAULT already set in /etc/default/grub, not touching
GRUB_CMDLINE_LINUX_XEN_REPLACE_DEFAULT already set in /etc/default/grub, not touching
Regenerating grub2 config
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.9.215-36.el7.x86_64
Found initrd image: /boot/initramfs-4.9.215-36.el7.x86_64.img
Found linux image: /boot/vmlinuz-4.9.215-36.el7.x86_64
Found initrd image: /boot/initramfs-4.9.215-36.el7.x86_64.img
Found linux image: /boot/vmlinuz-4.9.215-36.el7.x86_64
Found initrd image: /boot/initramfs-4.9.215-36.el7.x86_64.img
Found linux image: /boot/vmlinuz-4.9.215-36.el7.x86_64
Found initrd image: /boot/initramfs-4.9.215-36.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-957.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-957.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-379b7e7190f942cfaf325ab6cddbe36b
Found initrd image: /boot/initramfs-0-rescue-379b7e7190f942cfaf325ab6cddbe36b.img
done
Setting Xen as the default

[root@rebekk ~]# reboot

5. 查看结果

# 查看现在的内核信息
[root@rebekk ~]# uname -a
Linux rebekk 4.9.215-36.el7.x86_64 #1 SMP Mon Mar 2 11:42:52 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
[root@rebekk ~]# uname -r
4.9.215-36.el7.x86_64
[root@rebekk ~]# xl list
Name                                        ID   Mem VCPUs	State	Time(s)
Domain-0                                     0  1024     2     r-----      51.4

# 通过xl info命令可以查看底层硬件平台(Xen Hypervisor)的一些信息,如总内存(total_memory)、空闲内存(free_memory)等
[root@rebekk ~]# xl info
host                   : rebekk
release                : 4.9.215-36.el7.x86_64
version                : #1 SMP Mon Mar 2 11:42:52 UTC 2020
machine                : x86_64
nr_cpus                : 1
max_cpu_id             : 127
nr_nodes               : 1
cores_per_socket       : 1
threads_per_core       : 1
cpu_mhz                : 3599
hw_caps                : 078bfbff:f7fa3223:2c100800:00000121:0000000f:009c27ab:00000000:00000100
virt_caps              : hvm
total_memory           : 2047
free_memory            : 998
sharing_freed_memory   : 0
sharing_used_memory    : 0
outstanding_claims     : 0
free_cpus              : 0
xen_major              : 4
xen_minor              : 8
xen_extra              : .5.86.g8db85532
xen_version            : 4.8.5.86.g8db85532
xen_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          : credit
xen_pagesize           : 4096
platform_params        : virt_start=0xffff800000000000
xen_changeset          : 
xen_commandline        : placeholder dom0_mem=1024M,max:1024M dom0_max_vcpus=2 dom0_vcpus_pin=true cpuinfo com1=115200,8n1 console=com1,tty loglvl=all guest_loglvl=all
cc_compiler            : gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39)
cc_compile_by          : mockbuild
cc_compile_domain      : centos.org
cc_compile_date        : Thu Dec 12 15:10:22 UTC 2019
build_id               : 758b32738223bc21223741bec488a75ce4f823ab
xend_config_format     : 4
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值