Centos 虚拟化之 XEN (二)

2019-10-06  本文已影响0人  dreamscd

  昨天看到了虚拟机的引导界面,好开心,后面又留了好多的问题,这主要是因为时间的关系,不然的话这个过程,我想应该可以写一部小说了。
  下面来说说昨天留下的问题

1. xl

   什么是xl呢?
简单来说它是xen提供说用户的一套工具,使用户可以和xen Hypervisor交互,要不只有一个孤零零的Hypervisor在哪我们也没有办法用啊。(大牛除外,他可以自己写一套)
先看一下官方的

xl-----------------------Xen Project management tool, based on LibXenlight

DESCRIPTION
The xl program is the new tool for managing Xen guest domains. The program can be used to create, pause, and shutdown domains. It can also be used to list current domains, enable or pin VCPUs, and attach or detach virtual block devices.

The basic structure of every xl command is almost always:

    xl subcommand [OPTIONS] domain-id

Where subcommand is one of the subcommands listed below, domain-id is the numeric domain id, or the domain name (which will be internally translated to domain id), and OPTIONS are subcommand specific options. There are a few exceptions to this rule in the cases where the subcommand in question acts on all domains, the entire machine, or directly on the Xen hypervisor. Those exceptions will be clear for each of those subcommands.

现在我们来说第一个命令:

  一旦我们安装好了xen,这个命令就能看到dom0

[root@localhost ~]# xl list
Name                                        ID   Mem VCPUs  State   Time(s)
Domain-0                                     0  1024     2     r-----     100.6

ID:这个具有唯一性,很多的操作可以用名字dom(代表虚拟机),也可以用ID号,有一个特殊的ID,就是0,这是xen中的第一个dom,也是特权dom
State:
     r : running
     b: block(阻塞)
     p: pause(暂停): 类似与睡眠.
     s: stop
     c: crash(崩溃)
     d: dying, 正在关闭的过程中.

为什么要说这个呢?因为只有这个才是最好,最全的命令信息
你要知道xl有什么子命令就xl help,所有支持的子命令都有了,要知道一个子命令如何使用,如:create就 xl help create,关于创建子命令的信息也有了。
好了来看一个xl help

删除大部分命令,留下实验中可能会用的子命令
xl list of subcommands:
 list                List information about all/some domains 
                          虚拟机列表
 create              Create a domain from config file <filename>
                          根据一个config文件创建虚拟机
 destroy             Terminate a domain immediately 
                          终止一个虚拟机
 pause               Pause execution of a domain
                          暂停
 shutdown            Issue a shutdown signal to a domain
                          向虚拟机发出关闭信号
 reboot              Issue a reboot signal to a domain
                         向虚拟机发出重启信号
 console             Attach to domain's console
                          连到虚拟机的控制台上
 vncviewer           Attach to domain's VNC server.
                          连到虚拟机的vnc上
 save                Save a domain state to restore later
                          快照
 restore             Restore a domain from a saved state
                          快照恢复
 top                 Monitor a host and the domains in real time
                          xl的top

这么多命令差不多了

2. 配置文件

其实吧,管理xen除了xl这个工具栈,还一个libvirt系的,这样就又不得不说说libvirt是什么了。

就说这么多,要讲清这个东东,至少是一个万字的篇幅。收,我们的目标是图标界面,对了libvirt使用的配置文件和xl是不一样的,它使用的xml的配置文件,但最起码不用手写了是吧。
安装开始

[root@localhost ~]# yum install libvirt

Install  1 Package (+57 Dependent packages)

Total download size: 15 M
Installed size: 42 M
Is this ok [y/d/N]: 
好多的包,Y 继续
Complete!

好,来看一下安装的包
libvirt-client.x86_64 0:4.5.0-23.el7
提供了virsh
libvirt-daemon.x86_64 0:4.5.0-23.el7
提供了libvirtd
怎么没有我们期待的virt-manager呢?没有就装嘛

[root@localhost ~]# yum install virt-manager
Install  1 Package  (+76 Dependent packages)
Upgrade             (  2 Dependent packages)

Total download size: 43 M
Is this ok [y/d/N]: y
Complete!
这个过程安装了太多的包,libx的、Xorg的、太多太多,如果在生产环境中我想是不会有人这么玩的,我们可以将virt-manager安装到一台管理机上,再远程管理比较合适

启动

[rootelocalhost "]# virt-manager
[rootelocalhost "]#
(virt-manager:18916):Gtk-WARNING **::cannot open display:

这是理所当然的,我的这台xen服务器上没有安装桌面环境,难道还要安装一个桌面?
xshell+xmanager隆重上场
先在我的物理机(IP: 192.168.2.99)上启动Xmanager - Passive

[root@localhost ~]# export DISPLAY=192.168.2.99:0.0
[rootelocalhost "]# virt-manager
virt-manager-start.png

看到图形了,是不是好开森,等等,怎么提示连不上xen,我那个去,又什么情况
看libvirt的架构图,好的看来是libvirtd没有开

[root@localhost ~]# systemctl start libvirtd
[rootelocalhost "]# virt-manager
virt-manager-start-withlib.png

还是连不上,什么情况,难道电脑抽风了。。。

我都不知道我是怎么这儿的,上xen的yum源看看,果然有libvirt
安装试试

[root@localhost ~]# yum --enablerepo=centos-virt-xen-48 install libvirt
Install             (  1 Dependent package)
Upgrade  1 Package  (+22 Dependent packages)

Total download size: 7.4 M
Is this ok [y/d/N]: y
Complete!

可以安装,试试,不要忘记了重启服务

[root@localhost ~]# systemctl restart libvirtd
[rootelocalhost "]# virt-manager
virt-manager-1.png

没有报错,完美,看来对于xen管理使用的libvirt要使用专门的才行,redhat我恨你!!!
下面就看图


virt-manager-1.png virt-manager-2.png virt-manager-3.png virt-manager-4.png virt-manager-5.png virt-manager-6.png virt-manager-7.png virt-manager-8.png virt-manager-9.png virt-manager-10.png

是不是 熟悉的配方,熟悉的味道。

上一篇说的:

这一篇上的:

这都涉及到 X Window 的问题
下一篇再来说

今天写文的时候发现一个小问题


win-mng.png
mng-ip1.png

在这个情况下,会出现


mng-ip2.png

这是在ssh连接时不能接受服务器的key也不能输入密码

[root@localhost ~]# virt-manager --no-fork
mng-ip3.png
上一篇 下一篇

猜你喜欢

热点阅读