UBuntu系统安装KVM创建虚拟机遭遇故障

  现象

  ping不通虚拟机ssh登录不上console方式登录不上 虚拟机无法shutdown貌似电源管理也没有安装成功

  先来解决网络问题

  还好可以通过virtcat来检查虚拟机内部的文件

  先关闭虚拟机

  virsh destroy vm

  然后检查网卡设置文件

  root@dbkvm:~# virtcat d vm /etc/network/interfaces# This file describes the network interfaces available on your system# and how to activate them For more information see interfaces()# The loopback network interfaceauto loiface lo inet loopback# The primary network interfaceauto ethiface eth inet staticaddress netmask network broadcast gateway # dns* options are implemented by the resolvconf package if installeddnsnameservers dnssearch localdomain

  这个dnssearch localdomain看上去很奇怪一般是defaultdomain

  localdomain是因为host机器的/etc/hosts中配置成了

   localhostlocaldomain dbkvm

  将其换成这种配置

   localhost dbkvm

  再创建虚拟机网络正常了可以ping通可以ssh登录 console问题还有

  虚拟机里面的网络设置dnssearch 被设置成了defaultdomain

  因此推测是hosts文件的配置错误导致虚拟机中网卡设置的dnssearch错误导致无法连接网络因此不能在创建过程中从网络下载安装opensshserver

  来看一下电源管理

  如果不安装电源管理就不能在host主机通过shutdown关闭虚拟机

  在创建vm的选项中需要补上

  addpkg=acpid

  事后弥补就要登录到虚拟机中然后运行命令

  aptget install acpid

  再来处理console不能登录的问题

  先停止虚拟机

  virsh stop vm

  准备一个文件ttySconf 内容如下

  # ttySconf getty# This service maintains a getty on ttyS from the point the system is# started until it is shut down againstart on stopped rc RUNLEVEL=[]stop on runlevel [!]respawn

  安装guestfish程序

  aptget install guestfish

  现在用virtcopyin将文件复制到vm的/etc/init目录中

  virtcopyin d vm ttySconf /etc/init

  然后调用virsh edit vm 来编辑vm的配置文件添加下面的内容

  <devices><serial type=pty><source path=/dev/pts//><target port=/></serial><console type=pty tty=/dev/pts/><source path=/dev/pts//><target port=/></console></devices>

  最后试用一下

  virsh start vmDomain vm startedroot@dbkvm:~/kvm_scripts# virsh console vmConnected to domain vmEscape character is ^]Ubuntu LTS vm ttySvm login: rootPassword:Last login: Thu May :: UTC from on pts/Welcome to Ubuntu LTS (GNU/Linux virtual x_)

  可以了所有问题的根源都出在那个不正确的host机器上的/etc/hosts配置

而消极的人则在每个机会都看到某种忧患。

UBuntu系统安装KVM创建虚拟机遭遇故障

相关文章:

你感兴趣的文章:

标签云: