14_systemd
systermd
-
大多数现代Linux发行版都使用systermd(systerm management daemon)作为默认的初始系统和服务管理器.systermd是Linux初始化系统管理、日志记录、启动管理器等等。systermd是第一个进程,它会接管并继续挂载主机文件系统和启动服务。
![img]()
在进程列表中,为了向后兼容,列表把systermd显示为init。所以systermd在引导时初始化系统。
与按顺序启动服务的旧的init相比,systermd平行启动服务,这是初始化系统的更加有效和快速的方法。
观察系统启动所用时间:
systemd-analyze
Service Management(systemd,systemctl)
-
让我们继续看看如何使用systemctl管理服务:
举个例子,我想查看nginx服务器的状态,使用:
systemctl status nginx.service假如nginx被关闭了。
systemctl start nginx #停止服务请使用stop systemctl restart nginx要使配置生效可使用restart或者reload:
systemctl reload nginx systemctl reload-or-restart nginx要使服务在boot阶段启动,使用enable命令:
systemctl enable nginx #禁止使用 disable查看服务是否在boot阶段启动,使用is-enabled:
systemctl is-enabled nginx要防止服务自动或手动启动,请使用mask命令:
systemctl mask nginx # 取消屏蔽命令 unmask该命令将服务单元设置为完全不可启动。
要查看systemd知道的所有systemd启动的(包括不活动的)单元的列表,请使用list-units命令 + --all选项:
systemctl list-units --all

浙公网安备 33010602011771号