一、启动虚拟机Connection reset by peer

# virsh start vmhost1error: Failed to start domain vmhost1error: Unable to read from monitor: Connection reset by peer

在虚拟机运行过程中关闭宿主服务器就有可能导致这种情况出现,由于宿主服务器中的kvm虚拟机控制器与安装在kvm中的虚拟机会话被异常重置,所以我们可以如下解决:

# virsh managedsave-remove vmhost1# virsh start vmhost1

如果启动查看/var/log/libvirt/qemu/vmhost1.log下log还报如下错误:

Cannot set up guest memory 'pc.ram': Cannot allocate memory

这个问题可能是分配给vmhost1分配的内存过大(甚至超过的物理主机的内存大小),或者可能是宿主机没有足够的内存分配给此虚拟机,导致无法启动!

二、重Define虚拟机时无/usr/bin/kvm

error: Failed to define domain from hostname.xmlerror: Cannot find QEMU binary /usr/bin/kvm: No such file or directory

解决方法:

# ln -s /usr/libexec/qemu-kvm /usr/bin/kvm

三、error: internal error process exited while connecting to monitor

# virsh start vmhost1  
error: Failed to start domain vmhost1error: internal error process exited while connecting to monitor: kvm: -drive file=/dev/sp1368155439693/v1368544020461,if=none,id=drive-virtio-disk0,format=qcow2: could not open disk image /dev/sp1368155439693/v1368544020461: Invalid argument

分析:镜像格式错误,用qemu-img info 检查镜像和xml配置文件中指定的type是否一致!

四、Unable to load library 'virt': libvirt.so

Unable to load library 'virt': libvirt.so: cannot open shared object file: No such file or directoryLinux下解决:      ln -s /usr/lib/libvirt.so.0   /usr/lib/libvirt.so

windows下解决:
     将libvirt-0.dll改名为virt.dll

五、error: Refusing to undefine while domain managed save image exists

# virsh undefine vmhost1error: Refusing to undefine while domain managed save image existshttp://www.redhat.com/archives/libvir-list/2011-July/msg01219.html

解决方法:virsh undefine $domain  --managed-save

六、启动libvirtd进程出错

# /usr/local/sbin/libvirtd -d -l --config /usr/local/etc/libvirt/libvirtd.conf (编译安装的启动方式)
error:/usr/local/sbin/libvirtd: initialization failed
try to install libpcap-devel RPM and rebuild libvirt  http://comments.gmane.org/gmane.comp.emulators.libvirt/58218apt-get install libpcap-dev
上面的方法好像都没有效果,但是尝试了http://wiki.libvirt.org/page/The_daemon_cannot_be_started说的,把配置文件里的
listen_tls = 0注释取消(更奇怪的问题,在我的客户端链接不对)

七、启动虚拟机报错

# virsh start vmhost1error: Failed to start domain vmhost1error: internal error process exited while connecting to monitor: Could not access KVM kernel module: No such file or directoryfailed to initialize KVM: No such file or directoryNo accelerator found!

上面的提示信息就是因为QEMU在初始化阶段因为无法找到kvm内核模块。

# modprobe kvm   #载入指定的模块

重启电脑,进入bios界面,设置advance选项里面的virtualization标签为Enabled

通过命令 lsmod | grep kvm    #显示已载入的模块

八、虚拟机迁移

# virsh migrate --live 1 qemu+tcp://192.168.0.121 --p2p --tunnelled --unsafe error: operation failed: Failed to connect to remote libvirt URI qemu+tcp://192.168.0.121(在URI后面加上/system,‘system’相当于root用户的访问权限)

#virsh migrate --live 2 qemu+tcp://192.168.0.121/system --p2p --tunnelled
error: Unsafe migration: Migration may lead to data corruption if disks use cache != none(加上--unsafe参数)#virsh migrate --live 2 qemu+tcp://192.168.0.121/system --p2p --tunnelled --unsafe error: Timed out during operation: cannot acquire state change lock (启动虚拟机有时也会遇此错误),需要重启libvirtd进程

九、virsh

error: Failed to connect socket to '/var/run/libvirt/libvirt-sock': Connection refused(libvirtd 进程没有启动,libvirtd是一个监听客户端请求的进程)# virsh -c qemu:///system listerror: Failed to connect socket to '/var/run/libvirt/libvirt-sock': Permission denied
error: failed to connect to the hypervisor
(当前用户没有权限,修改/etc/libvirt/libvirtd.conf,unix_sock_rw_perms = 0777,使所有用户都有权限读写)

注意:如果查询的结果中包含有vmx,那么就可以证明服务器是支持虚拟化的

安装包

yum -y groupinstall "Virtualization" "Virtualization Client" "Virtualization Platform"

modprobe kvm

lsmod |grep kvm

ln -sv /usr/libexec/qemu-kvm /usr/bin/

service libvirtd start

chkconfig --level 2345 libvirtd on

chkconfig libvirtd  --list

配置网卡桥接

virsh iface-bridge eth0 br0

安装

virt-install --connect  qemu:///system --virt-type kvm --name rhel6 --ram=1024  --disk path=/var/lib/libvirt/images/rhel6.img,size=8,sparse --os-type=linux --accelerate -c /sdb1/CentOS-6.6-x86_64-bin-DVD.iso --network bridge=br0,model=virtio --vnc  --vncport=5991 --vnclisten=0.0.0.0 --force

--vncport 端口可以自己改,不指定的话自动获取

--boot network,cdrom,menu=on  这个是启动顺序可以不用加

当出现下面提示的时候用vnc客户端连接即可(端口:5991)

netstat -tnlp |grep kvm

tcp        0      0 0.0.0.0:5991                0.0.0.0:*                   LISTEN      3006/qemu-kvm

开始安装......

创建域......                                                                     |    0 B     00:00

无法打开显示:

运行 'virt-viewer --help' 来查看可用命令行选项的完整列表

域安装仍在进行。您可以重新连接

到控制台以便完成安装进程。

注意: 如果安装完成后,ifconfig只能看到本地回环网卡,到/etc/sysconfig/network-scripts/目录下将ifcfg-eth0的ONBOOT改为yes,然后启动网卡即可。

virsh uri: 查看当前主机上hypervisor的连接路径;

virsh connect:

virsh define: 创建一个虚拟机,根据事先定义的xml格式的配置文件;创建以后不会自动启动;

virsh create: 创建,创建完成后会自动启动;

virsh undefine: 删除

virsh list  --all 查看

virsh destroy  rhel6  删除rhel6

virt-install --os-variant list

virsh start rhel66  开启rhel66 或 virsh create /etc/libvirt/qemu/rhel66.xml

virsh shutdown rhel66

virsh reboot rhel66

virsh console rhel66

virsh suspend rhel66  挂起

virsh resume  rhel66 恢复挂起

/etc/libvirt/qemu/  虚拟机xml配置文件目录

virsh edit rhel66   编辑xml配置文件,vi编辑的不会立即生效

解决virsh shutdown无法关闭KVM虚拟机,以下操作都在客户机,不是宿主机

yum -y install  acpid

service acpid restart

chkconfig --level 2345 acpid on

chkconfig acpid --list

解决KVM中宿主机通过console无法连接客户机,以下操作都在客户机,不是宿主机

1、添加ttyS0的安全许可,允许root登录:

echo "ttyS0" >> /etc/securetty

2、在/etc/grub.conf文件中为内核添加参数:

console=ttyS0

这步要注意:

console=ttyS0一定要放在kernel这行中(大约在第16行),不能单独一行,即console=ttyS0是kernel的一个参数,不是单独的

3、在/etc/inittab中添加agetty:

S0:12345:respawn:/sbin/agetty ttyS0 115200

4、重启客户机:

reboot

kvm虚拟机的重命名

1、查看所有的kvm虚拟机

virsh list --all

Id    名称                         状态

----------------------------------------------------

-     rhel6                        关闭

2、重命名kvm虚拟机最好是将虚拟机先关机,然后再导出其xml文件

cd /etc/libvirt/qemu

virsh dumpxml rhel6 > CentOS02.xml

3、为了让重命名后的虚拟机名字与磁盘文件名一致、我们可以先将之前的磁盘文件命名成CentOS02.img

cd /var/lib/libvirt/images

mv rhel6.1.img CentOS02.img

4、编辑CentOS02.xml文件,修改<name>标签对以及磁盘文件,这里我们将磁盘文件修改成CentOS02.img

<domain type='kvm'>

<name>CentOS02</name>

......

...省略......

......

<disk type='file' device='disk'>

<driver name='qemu' type='raw' cache='none'/>

<source file='/var/lib/libvirt/images/CentOS02.img'/>

5、使用virsh undefine命令删除之前的虚拟机,根据新的xml文件定义新的kvm虚拟机

virsh undefine  rhel6 ////删除rhel6虚拟机

virsh define /etc/libvirt/qemu/CentOS02.xml    //重新定义新的kvm虚拟机

6、最后我们可以再次使用virsh list --all命令查看,结果如下所示

Id    名称                         状态

----------------------------------------------------

-     CentOS02                       关闭

经过如上方法重命名的kvm机直接启动使用即可,不会影响udev动态管理设备的文件。和之前的虚拟机相比、仅仅就是名字变了而已。

设置步骤如下:

  1、以联想t420为例,开机后按F2进入bios设置;

  2、选择Security选项;

  3、选择Virtualization,回车进入;

  4、按+键修改俩个选项为enabled;

  5、按F10,输入y保存退出即可。

kvm常见故障及解决的更多相关文章

  1. mysql主从复制常见故障解决

    一.主从复制常见故障 1.从库已存在数据库,主库建立同名库导致从库同步失败.报错如下: mysql> show slave status\G*************************** ...

  2. 【集群实战】NFS服务常见故障排查和解决方法

    NFS,全名叫Network File System,中文叫网络文件系统,是Linux.UNIX系统的分布式文件系统的一个组成部分,可实现在不同网络上共享远程文件系统. NFS由Sun公司开发,目前已 ...

  3. Weblogic常见故障常:JDBC Connection Pools(转)

    WebLogic Server中数据库连接池是一个经常出问题的地方,总结一下出问题的原因和解决办法. 一.数据库连接泄漏 此类问题一般都是由于开发人员没有正确关闭数据库连接造成的.比如使用完Conne ...

  4. 理解 OpenStack + Ceph (7): Ceph 的基本操作和常见故障排除方法

    本系列文章会深入研究 Ceph 以及 Ceph 和 OpenStack 的集成: (1)安装和部署 (2)Ceph RBD 接口和工具 (3)Ceph 物理和逻辑结构 (4)Ceph 的基础数据结构 ...

  5. [转] Linux运维常见故障排查和处理的技巧汇总

    作为linux运维,多多少少会碰见这样那样的问题或故障,从中总结经验,查找问题,汇总并分析故障的原因,这是一个Linux运维工程师良好的习惯.每一次技术的突破,都经历着苦闷,伴随着快乐,可我们还是执着 ...

  6. Weblogic常见故障常:JDBC Connection Pools【转】

    WebLogic Server中数据库连接池是一个经常出问题的地方,总结一下出问题的原因和解决办法. 一.数据库连接泄漏 此类问题一般都是由于开发人员没有正确关闭数据库连接造成的.比如使用完Conne ...

  7. vsftp客户连接常见故障现象

    ftp客户连接常见故障现象现象0:> ftp: connect :连接被拒绝原因: 服务没启动解决: # chkconfig vsftpd on<Enter> 现象1:500 OOP ...

  8. Linux运维常见故障排查和处理的33个技巧汇总

    作为linux运维,多多少少会碰见这样那样的问题或故障,从中总结经验,查找问题,汇总并分析故障的原因,这是一个Linux运维工程师良好的习惯.每一次技术的突破,都经历着苦闷,伴随着快乐,可我们还是执着 ...

  9. CentOS Grub、BASH 故障、解决方法

    简介: Grub 常见的两种故障:Grub.conf 文件丢失.MBR 损坏 ( 不管恢复怎么样,还是先备份好吧 ) 一.Grub.conf 文件丢失 shell > rm -rf /boot/ ...

随机推荐

  1. 【嵌入式开发】C语言 指针数组 多维数组

    . 作者 : 万境绝尘 转载请注明出处 : http://blog.csdn.net/shulianghan/article/details/21402047 . 1. 地址算数运算示例 指针算数运算 ...

  2. 一个简单的多机器人编队算法实现--PID

    用PID进行领航跟随法机器人编队控制 课题2:多机器人编队控制研究对象:两轮差动的移动机器人或车式移动机器人研究内容:平坦地形,编队的保持和避障,以及避障和队形切换算法等:起伏地形,还要考虑地形情况对 ...

  3. 解决ADT大量出现"Unexpected value from nativeGetEnabledTags: 0"的问题

    在过滤器中输入下面的代码即可:(此方法搜索于网略) ^(?!.*(nativeGetEnabledTags)).*$ 

  4. 第一个Polymer应用 - (1)创建APP结构

    原文链接: Step 1: Creating the app structure翻译日期: 2014年7月5日翻译人员: 铁锚在本节中,将使用一些预先构建好的Polymer元素来创建基本的应用程序结构 ...

  5. 苹果新的编程语言 Swift 语言进阶(九)--方法和下标

    一.方法 方法是与特定类型相关的函数.与属性一样,方法也包括实例方法和类型方法. 类.结构.枚举都能定义实例方法,用来封装或实现给定类型的一个实例相关的功能或特定任务. 类.结构.枚举也能定义与类型本 ...

  6. How to download the installation package by ZOL Downer

    How to download the installation package by ZOL Downer Ma Genfeng (Guangdong Unitoll Services incorp ...

  7. IndexedDB,FileSystem- 前端数据库,文件管理系统

    "我们不再需要下载并且安装软件.一个简单的web浏览器和一个可供使用的互联网就足以让我们在任何时间, 任何地点, 还有任何平台上使用任何web应用程序." web应用很酷, 但是相 ...

  8. JVM terminated. Exit code=8096

    http://www-01.ibm.com/support/docview.wss?uid=swg21303648 Technote (troubleshooting) Problem(Abstrac ...

  9. JavaScript设计模式之一Interface接口

    如何用面向对象的思想来写JavaScript,对于初学者应该是比较难的,我们经常用的JQuery其实也是用面向对象的思想去封装的,今天我们来看看如何在Javascript中用Interface,在C# ...

  10. 交换机设置IP

    二成交换机所有端口在默认情况下都是属于vlan1的 代表整个交换机 你只需要设置vlan1的ip地址就行了 进入交换机配置界面后 命令如下:enableconfigure terminalinterf ...