考试首页 | 考试用书 | 培训课程 | 模拟考场 | 考试论坛  
  当前位置:Linux认证 > 红帽认证 > 红帽认证辅导 > 文章内容
  

RHCE7认证学习笔记:使用虚拟化系统KVM

来源:Linux社區 [ 2016年2月14日 ] 【

查看虚拟机的更多信息: 
[root@linuxidc ~]# virsh domainfo rhel7
error: unknown command: 'domainfo'
[root@linuxidc ~]# virsh dominfo rhel7
Id:            7
Name:          rhel7
UUID:          7c096b6b-1d56-4405-86e4-509f612b13aa
OS Type:        hvm
State:          running
CPU(s):        1
CPU time:      107.3s
Max memory:    524288 KiB
Used memory:    524288 KiB
Persistent:    yes
Autostart:      disable
Managed save:  no
Security model: selinux
Security DOI:  0
Security label: system_u:system_r:svirt_t:s0:c608,c777 (enforcing)

停止运行的虚拟机:

[root@linuxidc ~]# virsh stop rhel7
[root@linuxidc ~]# #virsh shutdown rhel7
[root@linuxidc ~]# #virsh destroy rhel7

开启一个虚拟机:
[root@linuxidc ~]# #virsh start rhel7

删除一个虚拟机:

[root@linuxidc ~]# #virsh destroy rhel7
[root@linuxidc ~]# #virsh undefine rhel7

[root@linuxidc ~]# #rm -rf /var/lib/libvirt/images/mydisk1.img
[root@linuxidc ~]# #virsh pool-refresh default

KVM主机从console口进入虚拟机:

首先,修改虚拟机的内核:
[root@localhost ~]# grubby --update-kernel=ALL --args="console=ttyS0"

重启虚拟机,从KVM host主机console虚拟机:

[root@linuxidc ~]# virsh console rhel7

[root@linuxidc ~]# virsh console rhel7
Connected to domain rhel7
Escape character is ^]
Red Hat Enterprise Linux Server 7.0 (Maipo)
Kernel 3.10.0-123.el7.x86_64 on an x86_64
localhost login: root
Password:

    紧急情况的处理,当KVM主机失去了与虚拟主机的所有连接(/etc/fstab,ssh配置等),并且也没有设置任何console连接,那么可以按照以下的办法处理:
    首先在KVM主机上关闭虚拟机:

virsh destroy rhel7    查找存储文件位置:

[root@linuxidc ~]# virsh dumpxml rhel7 | grep "source file="
     

将虚拟机的存储文件映射到KVM主机环境:

kpartx -av /var/lib/libvirt/images/mydisk1.img

挂载boot到KVM的mnt目录:
mount /dev/mapper/loop0p1 /mnt

然后编辑/mnt/boot/grub2/grub.cfg文件,在包含有/vmlinuz的那行添加console=ttyS0

卸载mnt目录:

umount /mnt

解除映射:

kpartx -dv /var/lib/libvirt/images/mydisk1.img

重启虚拟机:
virsh start RHEL7

重启完成后,就可以console进入虚拟机:
virsh console rhel7

首页 1 2 3 4 尾页
本文纠错】【告诉好友】【打印此文】【返回顶部
将考试网添加到收藏夹 | 每次上网自动访问考试网 | 复制本页地址,传给QQ/MSN上的好友 | 申请链接 | 意见留言 TOP
关于本站  网站声明  广告服务  联系方式  站内导航  考试论坛
Copyright © 2007-2013 中华考试网(Examw.com) All Rights Reserved