KVM故障调试经验
来源:互联网 发布:全景通系统源码 编辑:程序博客网 时间:2024/05/17 08:55
本次在UBuntu12.04.2系统安装KVM,随后创建虚拟机,又出现了新的问题。
现象:
ping不通虚拟机,ssh登录不上,console方式登录不上, 虚拟机无法shutdown,貌似电源管理也没有安装成功。
先来解决网络问题:
还好可以通过virt-cat来检查虚拟机内部的文件。
先关闭虚拟机
virsh destroy vm1
然后检查网卡设置文件:
root@dbkvm:~# virt-cat -d vm1 /etc/network/interfaces# This file describes the network interfaces available on your system# and how to activate them. For more information, see interfaces(5).# The loopback network interfaceauto loiface lo inet loopback# The primary network interfaceauto eth0iface eth0 inet static address 192.168.1.51 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.1 # dns-* options are implemented by the resolvconf package, if installed dns-nameservers 8.8.8.8 dns-search localdomain
这个dns-search localdomain看上去很奇怪。一般是defaultdomain.
localdomain是因为host机器的/etc/hosts中配置成了
127.0.0.1 localhost.localdomain dbkvm
将其换成这种配置:
127.0.0.1localhost127.0.1.1dbkvm
再创建虚拟机,网络正常了。可以ping通,可以ssh登录。 console问题还有。
虚拟机里面的网络设置dns-search 被设置成了defaultdomain.
因此推测是hosts文件的配置错误,导致虚拟机中网卡设置的dns-search错误,导致无法连接网络,因此不能在创建过程中从网络下载安装openssh-server.
来看一下电源管理
如果不安装电源管理,就不能在host主机通过shutdown关闭虚拟机。
在创建vm的选项中需要补上:
--addpkg=acpid
事后弥补就要登录到虚拟机中,然后运行命令:
apt-get install acpid
再来处理console不能登录的问题。(注意,Ubuntu 13.10此法还有问题,会卡在virsh console命令中,而且用virsh edit修改后的xml文件的部分丢失)
先停止虚拟机。
virsh stop vm1
准备一个文件ttyS0.conf, 内容如下:
# ttyS0.conf - getty# This service maintains a getty on ttyS0 from the point the system is# started until it is shut down again.start on stopped rc RUNLEVEL=[2345]stop on runlevel [!2345]respawn
安装guestfish程序, 这会安装一些常用的virt工具,比如virt-edit等,安装时回答no.
apt-get install guestfish
还要安装
apt-get install libguestfs-tools
安装的时候,,要回答yes, 否则virt-edit命令使用会报错.
如果回答了no, 以后要运行下面的命令重新配置:
update-guestfs-appliance
现在用virt-copy-in将文件复制到vm的/etc/init目录中:
virt-copy-in -d vm1 ttyS0.conf /etc/init
然后调用virsh edit vm1 来编辑vm1的配置文件,添加下面的内容:
<devices> ... <serial type='pty'> <source path='/dev/pts/2'/> <target port='0'/> </serial> <console type='pty' tty='/dev/pts/2'> <source path='/dev/pts/2'/> <target port='0'/> </console></devices>
最后试用一下:
virsh start vm1Domain vm1 startedroot@dbkvm:~/kvm_scripts# virsh console vm1Connected to domain vm1Escape character is ^]Ubuntu 12.04.2 LTS vm1 ttyS0vm1 login: rootPassword: Last login: Thu May 2 09:21:03 UTC 2013 from 192.168.1.4 on pts/1Welcome to Ubuntu 12.04.2 LTS (GNU/Linux 3.2.0-41-virtual x86_64)
所有问题的根源都出在那个不正确的host机器上的/etc/hosts配置。
- KVM故障调试经验
- centos7 kvm网卡故障
- kvm 虚拟机调试
- 利用KVM调试内核
- 利用KVM调试内核
- 使用kvm的一例故障
- 调试经验
- 调试经验
- 调试经验
- W5100故障调试
- 相机调试故障排查
- windbg调试kvm windows虚机
- windbg调试kvm windows虚机
- KVM 页故障处理 包括EPT 和 影子页表
- 20150206 调试终端LDO 故障
- 日志记录,调试, 故障排除
- 排查DHCP服务器故障的经验
- Elasticsearch经验之-GitHub故障处理
- sysfs 文件系统
- 前/中/后缀表达式的转换
- JUnitReport的使用 .
- 日志的操作
- hibernate一对多关联关系配置经验
- KVM故障调试经验
- javaSe学习前奏
- ExtJs(一)
- 放弃 或 坚持
- 如何从零开始开发一款嵌入式产品
- Python正则表达式练习
- JUnit简述 .
- 电子元件笔记
- Memory(-Leak) and Exception Trace (CRT and COM Leaks)