当前位置:网站首页>使用systemd管理服务
使用systemd管理服务
2022-07-28 14:48:00 【wild _wolf】
systemd简介
systemd简介
在Linux中,systemd是与SysV和LSB初始化脚本兼容的系统和服务管理器,开启systemd服务可以提供基于守护进程的按需启动策略。
systemd服务支持快照和系统状态恢复,维护挂载和自挂载点,使得个服务之间基于从属关系实现更为精细的逻辑控制,具有更高的并行性能。
Systemd unit概念
systemd服务的开启和监督系统是基于unit的概念,unit由一个与配置文件对应的名称和类型组成,unit通常有以下几种类型:
- Service unit:系统服务
- Target unit:一组systemd units
- Automount unit:文件系统挂载点
- Device unit:内核识别的设备文件
- Mount unit:文件系统挂载点
- Path unit:在一个文件系统中的文件或目录
- Scope unit:外部创建的进程
- Snapshot unit:systemd manager的保存状态
Systemd特性
systemd具备以下特性:
- 更快的启动速度
- 提供按需启动能力
- 采用cgroup特性跟踪和管理进程的生命周期
- 启动挂载点和自动挂载的管理
- 实现事务性依赖关系管理
- 与SysV初始化脚本兼容
- 能够对系统进行快照和恢复
使用systemd管理服务(systemctl)
管理系统服务
systemd可以通过systemctl命令来对系统服务进行运行、关闭、重启、显示、启用或禁用的操作。systemctl命令与sysvinit命令的功能相似,但是建议用systemctl来进行系统服务管理。
Systemctl和sysvinit的区别这里做一个简单对比:
Systemctl - 显示服务
若是用户需要查看当前正在运行的服务,可以通过以下命令来进行查看:
systemctl list-units --type services #若是要查看所有服务,需要在命令后添加-all参数
Systemctl - 显示服务状态
若是用户需要查看某个服务的状态,可以通过如下命令来进行查看:
systemctl status name.service
其中的命令参数说明如下:
Loaded:说明服务是否被加载,同时显示对应的绝对路径是否启用
Active:说明服务是否正在运行,并显示时间节点
Main PID:相应系统服务PID值
CGroup:相关控制组的其他信息
Systemctl - 相关操作
systemctl命令可以对系统服务进行运行、关闭、重启、显示、启用或禁用等操作,命令如下:
运行服务:systemctl start name.service
关闭服务:systemctl stop name.service
重启服务:systemctl restart name.service
启用服务:systemctl enable name.service
禁用服务:systemctl disable name.service
Systemctl - 其他操作
Systemd亦可通过systemctl命令对系统进行关机、重启、休眠等操作,具体命令如下:
关闭系统:
systemctl poweroff #关闭系统并下电
systemctl halt #关闭系统但不下电
重启系统:
systemctl reboot
系统待机:
systemctl suspend
系统休眠:
systemctl hibernate
systemctl hybrid-sleep #使系统待机并处于休眠状态
边栏推荐
- VirturalBox解决kernel driver问题
- Vs usage skills
- The price war of off screen fingerprints has resumed, and second-line manufacturers are expected to win 30% of the market this year?
- MIT pointed out that the public pre training model should not be used indiscriminately
- try...except异常处理语句(6)
- Monkey stress test
- 迟来的2021年终总结
- File and directory operations (5)
- vs动态库调试
- MATLAB不覆盖导入EXCEL
猜你喜欢

关于Simulink如何生成模型覆盖率报告

Matlab exports high-definition pictures without distortion in word compression and PDF conversion

An article about rsocket protocol

DNS domain name resolution protocol

PXE network installation

Baidu proposes a dynamic self distillation method to realize dense paragraph retrieval by combining interactive model and double tower model

2022年最火的十大测试工具,你掌握了几个

AS如何不区分大小写去进行智能提示
![【删除指定数字——leetcode]](/img/16/b40492d8414a363a3a24f00b4afd47.png)
【删除指定数字——leetcode]

详解.NET的求复杂类型集合的差集、交集、并集
随机推荐
How to obtain and embed go binary execution package information
Camera continuous shooting automatic test shell script
800V high voltage system
Among the three "difficult and miscellaneous diseases" of machine learning, causal learning is the breakthrough | Liu Li, Chongqing University
FTP file transfer protocol
Framework customization series (I) -- systemui NavigationBar slide back to launcher on the navigation bar
Matlab does not overwrite importing Excel
DNS domain name resolution protocol
How to configure Samba server
samba服务器如何配置
Daily news on July 28, 2022: Science: AI has made another breakthrough in protein design, and can design specific functional proteins
跟我学Rx编程——Concat
Vs usage skills
800V高压系统
Baidu proposes a dynamic self distillation method to realize dense paragraph retrieval by combining interactive model and double tower model
如何有效进行回顾会议(上)?
Framework customization series (VI) -- shield fallbackhome mobile phone from pop-up during startup and directly enter the launcher
Software architecture and design (II) -- Architecture Model
String (3)
Learn RX programming from me -- concat