启动libvirtd服务时,由于网络初始化失败导致异常的解决方法
问题现象描述
启动libvirtd服务时,操作命令及其回显如下:
[root@bogon libvirt-4.5.0]# service libvirtd restart Redirecting to /bin/systemctl restart libvirtd.service [root@bogon libvirt-4.5.0]# virsh version error: failed to connect to the hypervisor error: Failed to connect socket to '/var/run/libvirt/libvirt-sock': No such file or directory [root@bogon libvirt-4.5.0]# systemctl status libvirtd.service ● libvirtd.service - Virtualization daemon Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled) Active: inactive (dead) since Mon 2019-08-12 19:18:53 HKT; 39s ago Docs: man:libvirtd(8) https://libvirt.org
关键过程、根本原因分析
通过以下命令的返回查看根因。
systemctl status libvirtd.service
怀疑是网络初始化失败引起的。
● libvirtd.service - Virtualization daemon Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled) Active: inactive (dead) since Mon 2019-08-12 19:18:53 HKT; 39s ago Docs: man:libvirtd(8) https://libvirt.org Process: 86914 ExecStart=/usr/sbin/libvirtd $LIBVIRTD_ARGS (code=exited, status=0/SUCCESS) Main PID: 86914 (code=exited, status=0/SUCCESS) Tasks: 2 (limit: 32768) CGroup: /system.slice/libvirtd.service ├─11836 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper └─11837 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper Aug 12 19:18:53 bogon systemd[1]: Started Virtualization daemon. Aug 12 19:18:53 bogon libvirtd[86914]: 2019-08-12 11:18:53.095+0000: 86930: info : libvirt version: 4.5.0, package: 10.el7 (CentOS BuildSystem <http://bugs.centos.org>, 2018-11-03-08:45:3...ys.centos.org) Aug 12 19:18:53 bogon libvirtd[86914]: 2019-08-12 11:18:53.095+0000: 86930: info : hostname: bogon Aug 12 19:18:53 bogon libvirtd[86914]: 2019-08-12 11:18:53.095+0000: 86930: error : virNetworkObjAssignDefLocked:589 : operation failed: network 'default' already exists with uuid 7442d10...3-fc2e6122b69b Aug 12 19:18:53 bogon dnsmasq[11836]: read /etc/hosts - 2 addresses Aug 12 19:18:53 bogon dnsmasq[11836]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses Aug 12 19:18:53 bogon dnsmasq-dhcp[11836]: read /var/lib/libvirt/dnsmasq/default.hostsfile Aug 12 19:18:53 bogon libvirtd[86914]: 2019-08-12 11:18:53.269+0000: 86930: error : netcfStateInitialize:95 : internal error: failed to initialize netcf Aug 12 19:18:53 bogon libvirtd[86914]: 2019-08-12 11:18:53.269+0000: 86930: error : virStateInitialize:667 : Initialization of netcf state driver failed: internal error: failed to initialize netcf Aug 12 19:18:53 bogon libvirtd[86914]: 2019-08-12 11:18:53.269+0000: 86930: error : daemonRunStateInit:806 : Driver state initialization failed Hint: Some lines were ellipsized, use -l to show in full.
结论、解决方案及效果
通过重启网络服务可以解决此问题。
- 重启网络服务。
service network restart
预期结果:
Restarting network (via systemctl): [ OK ]
- 重启libvirtd服务。
service libvirtd restart
预期结果:
Redirecting to /bin/systemctl restart libvirtd.service
- 查看libvirt库的版本和其他相关信息。
virsh version
预期结果示例:Compiled against library: libvirt 4.5.0 Using library: libvirt 4.5.0 Using API: QEMU 4.5.0 Running hypervisor: QEMU 4.0.0
父主题: KVM虚拟化