error: failed to connect to the hypervisor error: Failed to connect socket to '/var/run/libvirt/

Posted hy007x

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了error: failed to connect to the hypervisor error: Failed to connect socket to '/var/run/libvirt/相关的知识,希望对你有一定的参考价值。

服务器版本:CentOS Linux release 7.4

Linux lb 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

 参考:https://www.cnblogs.com/yogurtwu/p/9988974.html

注:在翻了很多baidu和google相关文章后,逐步排查,根据手动执行libvirtd命令出现的报错信息才查到解决方法。一路坑。

 

对装有kvm虚拟机的服务器执行了安装libguestfs-tools后,发现出现了故障。

执行virsh list命令后会报以下错误:

技术图片

virsh list
error: failed to connect to the hypervisor
error: Failed to connect socket to ‘/var/run/libvirt/libvirt-sock‘: No such file or directory

 

执行systemctl status libvirtd后报错:

技术图片
● libvirtd.service - Virtualization daemon
Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
Active: failed (Result: start-limit) since Tue 2019-03-19 16:44:52 CST; 49min ago
Docs: man:libvirtd(8)
https://libvirt.org
Process: 21280 ExecStart=/usr/sbin/libvirtd $LIBVIRTD_ARGS (code=exited, status=3)
Main PID: 21280 (code=exited, status=3)
Tasks: 2 (limit: 32768)
CGroup: /system.slice/libvirtd.service
├─1007 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper
└─1008 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper

Mar 19 16:44:52 develop systemd[1]: Failed to start Virtualization daemon.
Mar 19 16:44:52 develop systemd[1]: Unit libvirtd.service entered failed state.
Mar 19 16:44:52 develop systemd[1]: libvirtd.service failed.
Mar 19 16:44:52 develop systemd[1]: libvirtd.service holdoff time over, scheduling restart.
Mar 19 16:44:52 develop systemd[1]: Stopped Virtualization daemon.
Mar 19 16:44:52 develop systemd[1]: start request repeated too quickly for libvirtd.service
Mar 19 16:44:52 develop systemd[1]: Failed to start Virtualization daemon.
Mar 19 16:44:52 develop systemd[1]: Unit libvirtd.service entered failed state.
Mar 19 16:44:52 develop systemd[1]: libvirtd.service failed.

 

执行systemctl restart libvirtd后报错:

技术图片

Job for libvirtd.service failed because start of the service was attempted too often. See "systemctl status libvirtd.service" and "journalctl -xe" for details.
To force a start use "systemctl reset-failed libvirtd.service" followed by "systemctl start libvirtd.service" again.

 

原因:

因为依赖安装了某些包(比如libguestfs-tools)后,跟着KVM相关的软件也跟着升级,但是CentOS7.4无法运行这个版本的libvirt,最简单粗暴的做法就是移除该模块,重启libvirtd。

 

解决办法:

mv /usr/lib64/libvirt/storage-backend/libvirt_storage_backend_rbd.so /usr/lib64/libvirt/storage-backend/libvirt_storage_backend_rbd.so-bak

systemctl restart libvirtd

再次执行virsh list,正常了:

技术图片

技术图片

 

以上是关于error: failed to connect to the hypervisor error: Failed to connect socket to '/var/run/libvirt/的主要内容,如果未能解决你的问题,请参考以下文章

android 中Network error IOException: failed to connect to /127.0.0.1 (port 1433): connect failed: ECO

Error -27796: Failed to connect to server "ip地址": [10060] Connection timed out

Action.c(28): Error -27796: Failed to connect to server "xxxx": [10060] Connection timed o

开机出现提示“Error:Failed to connect to driver2"是啥意思?

cURL Error:Failed connect to *****.com:80; Connection timed out

ArcGis中出现Failed to connect to database.An underlying database error occured.没有注册类。该怎么办