一、启动虚拟机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. Vim/Vi实用技巧(第二版)

    Vim/Vi实用技巧 1.导入文件 :r [文件名] #导入到当前编辑的文件中 如 :r /etc/inittab 文件上部为/etc/services文件,下部为/etc/inittab文件 2.执 ...

  2. how tomcat works 五 servlet容器 上

    servlet容器是用来处理请求servlet资源,并为Web客户端填充response对象的模块.在上一篇文章(也就是书的第四章)我们设计了SimpleContainer类,让他实现Containe ...

  3. 2016/1/9:深度剖析安卓Framebuffer设备驱动

    忙了几天,今天在公司居然没什么活干 ,所以早上就用公司的电脑写写之前在公司编写framebuffer的使用心得体会总结,这也算是一点开发经验,不过我还没写全,精华部分还是自己藏着吧.直到下午才开始有点 ...

  4. Gradle 1.12用户指南翻译——第二十七章. Ear 插件

    其他章节的翻译请参见: http://blog.csdn.net/column/details/gradle-translation.html 翻译项目请关注Github上的地址: https://g ...

  5. Android服务器——使用TomCat实现软件的版本检测,升级,以及下载更新进度!

    Android服务器--使用TomCat实现软件的版本检测,升级,以及下载更新进度! 算下来,TomCat服务器已经写了很长一段时间了,一直说拿他来搞点事 情,也一直没做,今天刚好有空,交流群还有人请 ...

  6. Linux Framebuffer驱动剖析之一—软件需求

    嵌入式企鹅圈将以本文作为2015年的终结篇,以回应第一篇<Linux字符设备驱动剖析>.嵌入式企鹅圈一直专注于嵌入式Linux和物联网IOT两方面的原创技术分享,稍后会发布嵌入式企鹅圈的2 ...

  7. 8 个实用的 Bootstrap 3 案例教程

    Bootstrap 3发布各大设计论坛议论纷纷.这次Bootstrap 3最大的特点就是--扁平化.下面就是一些早期的Bootstrap 3例子,不过亲们注意咯,因为大部分最早期的测试案例,可能用到一 ...

  8. mongodb3.6 (五)net 客户端访问mongodb设置超时时间踩过的“坑”

    前言 在上一篇文章中,我们有提到net访问mongodb连接超时默认为30秒,这个时间在实际项目中肯定是太长的.而MongoClientSettings 也确是提供了超时属性,如下图: 可实际使用中, ...

  9. 如何将程序集安装到全局程序集缓存GAC

    针对一些类库项目或用户控件项目(一般来说,这类项目最后编译生成的是一个或多个dll文件),在程序开发完成后,有时需要将开发的程序集(dll文件)安装部署到GAC(全局程序集缓存)中,以便其他的程序也可 ...

  10. apache压力测试工具的apache bench和JMeter的安装

    Apache压力测试工具的安装 1,apache bench的安装 apache  bench工具集成在http的软件包内,可以直接安装apache就可以. 当有些时候,我们不需要用到所有的软件包,我 ...