老男人百科 > 百科 > 正文

linux kvm虚拟机(kvm虚拟机安装)

2023-05-14 08:23:35 阅读( 2472)

本次在UBuntu12.04.2系统安装KVM,随后创建虚拟机,又出现了新的问题。

这次在ubuntu12.04.2系统中安装了KVM,然后创建了一个虚拟机,新的问题出现了。

现象:

Ping不到虚拟机,ssh无法登录,console无法登录,虚拟机无法关机。电源管理似乎没有安装成功。

先来解决网络问题:

幸运的是,你可以通过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

This DNS- search local domain looks strange. Generally the default domain.

本地域在主机的/etc/hosts中配置为:

127 .0 .0 .1个本地主机。本地域dbk虚拟机将其换成这种配置:

127.0.0.1 localhost

127.0.1.1 dbkvm

重新创建虚拟机,网络就正常了。您可以在中ping或ssh。控制台问题和.

虚拟机中的网络设置dns-search被设置为defaultdomain。

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

来看一下电源管理

如果未安装电源管理,则无法通过关机来关闭主机上的虚拟机。

在创建虚拟机的选项中,您需要添加:

--addpkg=acpid

为了事后弥补,您应该登录到虚拟机并运行以下命令:

apt-get install acpid

然后处理控制台无法登录的问题。

请先停止虚拟机。

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 installs guestfish. Now, copy the file to the voltmeter's /etc/initialization directory with virtual copy input:

virt-copy-in-dv m1 ttys 0 . 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)

够了。所有问题的根源在于不正确的主机上的/etc/hosts配置。

猜你喜欢

Guessyoulike
女生初夜什么感觉(女生初夜什么感觉)

女生初夜什么感觉(女生初夜什么感觉)

hao333 5106次阅读2023-03-08 09:08
保持性能力的方法有哪些(保持心理健康的方法)
孩子过于放纵家长如何管教(孩子太过叛逆家长无法管教怎么办)
女性乳房按摩手法(乳房保养的按摩手法)

女性乳房按摩手法(乳房保养的按摩手法)

hao333 2132次阅读2023-03-24 17:54
专题页