欢迎登陆真网站,您的到来是我们的荣幸。 登陆 注册 忘记密码? ☆设为首页 △加入收藏
欢迎加入真幸福QQ群
电脑知识: 基础知识 网络技术 操作系统 办公软件 电脑维修 电脑安全 windows7 windows8 windows10 服务器教程 平板电脑 视频播放教程 网络应用 互联网 工具软件 浏览器教程 QQ技巧 输入法教程 影视制作 YY教程 wps教程 word教程 Excel教程 PowerPoint
云南西双版纳特产小花糯玉米真空包装


linux三个特殊权限setuid、setgid和stick bit
Windows和linux系统文件合并命令
Windows 2003下编辑组策略对象上的安全设置方法
Apache配置基于加密的认证https加密证书访问
Win7任务管理器出错已被系统管理员停用该怎么办
显示windows7系统3D效果的快捷键是什么?
Windows7系统如何设置关闭视觉效果?
如何取消服务器/主机空间目录脚本的执行权限
解决iisapp命令不能使用的方法
Windows7如何设置不让孩子玩游戏?
UBuntu系统安装KVM创建虚拟机遭遇故障
【 来源:网络 】【 点击:1 】 【 发布时间:2017_03_03 08:59:59 】

 现象:

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 interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface 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.1   localhost
127.0.1.1   dbkvm

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

虚拟机里面的网络设置dns-search 被设置成了defaultdomain。

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

来看一下电源管理

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

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

--addpkg=acpid

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

apt-get install acpid

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

先停止虚拟机。

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程序:

apt-get install guestfish

现在用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 vm1
Domain vm1 started
root@dbkvm:~/kvm_scripts# virsh console vm1
Connected to domain vm1
Escape character is ^]
Ubuntu 12.04.2 LTS vm1 ttyS0
vm1 login: root
Password:
Last login: Thu May  2 09:21:03 UTC 2013 from 192.168.1.4 on pts/1
Welcome to Ubuntu 12.04.2 LTS (GNU/Linux 3.2.0-41-virtual x86_64)

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

本网站由川南居提供技术支持,fkzxf版权所有 浙ICP备12031891号
淳安分站 淳安分站