📅  最后修改于: 2023-12-03 14:58:50.625000             🧑  作者: Mango
在虚拟化环境中,libvirtd 作为一个守护进程,负责管理虚拟机的创建、启动、停止、删除等任务。在常规场景中,我们需要确认 libvirtd 是否正在运行,来保证虚拟机的正常运行。
我们可以使用以下命令确认 libvirtd 是否正在运行:
sudo systemctl status libvirtd
如果 libvirtd 正在运行,我们将看到以下输出:
● libvirtd.service - Virtualization daemon
Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2021-11-23 10:01:28 CST; 33min ago
Docs: man:libvirtd(8)
https://libvirt.org
Main PID: 1966 (libvirtd)
Tasks: 23 (limit: 32768)
Memory: 150.5M
CGroup: /system.slice/libvirtd.service
├─1966 /usr/sbin/libvirtd
├─1985 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
└─15051 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
Nov 23 10:01:28 localhost.localdomain systemd[1]: Starting Virtualization daemon...
Nov 23 10:01:28 localhost.localdomain libvirtd[1966]: libvirt version: 7.6.0
Nov 23 10:01:28 localhost.localdomain libvirtd[1966]: hostname: localhost.localdomain
Nov 23 10:01:28 localhost.localdomain libvirtd[1966]: Server ID: 75bc1d0f-4621-4411-9c21-788edb8c202d
Nov 23 10:01:28 localhost.localdomain libvirtd[1966]: Service object: 0x5595e92321d0, ref=0
Nov 23 10:01:28 localhost.localdomain libvirtd[1966]: Initializing Xen support
Nov 23 10:01:28 localhost.localdomain kernel: Initializing XFRM netlink socket
Nov 23 10:01:28 localhost.localdomain libvirtd[1966]: Initializing cgroup subsys: memory
Nov 23 10:01:28 localhost.localdomain libvirtd[1966]: Initializing cgroup subsys: blkio
Nov 23 10:01:28 localhost.localdomain systemd[1]: Started Virtualization daemon.
如果 libvirtd 不在运行状态,我们将看到以下输出:
● libvirtd.service - Virtualization daemon
Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:libvirtd(8)
https://libvirt.org
我们可以使用以下命令启动 libvirtd 进程:
sudo systemctl start libvirtd
我们可以使用以下命令停止 libvirtd 进程:
sudo systemctl stop libvirtd
我们可以使用以下命令重新启动 libvirtd 进程:
sudo systemctl restart libvirtd
我们可以使用以下命令使 libvirtd 进程自启动:
sudo systemctl enable libvirtd
我们可以使用以下命令禁止 libvirtd 进程自启动:
sudo systemctl disable libvirtd
以上内容共计介绍了 libvirtd 守护进程的状态检测、启动、停止、重新启动、自启动、禁止自启动等操作。