当前位置:网站首页>使用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 #使系统待机并处于休眠状态
边栏推荐
- Youdao cloud notes remove the bottom advertisement
- Matlab does not overwrite importing Excel
- 如何通过adb打开和关闭飞行模式
- Framework定制系列(一)-----SystemUI NavigationBar导航栏上滑返回Launcher
- Rongyun real-time community solution
- QT refresh UI interface problem
- Deutsche Telekom denied strengthening its cooperation with Huawei and said it had reduced its cooperation with Huawei in the past three years
- 3. Basic constants and macro definitions
- Qt刷新UI界面问题
- 软件架构与设计(四)-----数据流架构
猜你喜欢

Docker容器实现MySQL主从复制

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

Easyexcel complex header export (one to many)

An article about rsocket protocol

How as makes intelligent prompts regardless of case

如何有效进行回顾会议(上)?

Software architecture and design (VIII) -- distributed architecture

虚拟机之NAT模式下设置静态IP

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

Explain the difference set, intersection set and union set of complex type set in detail.Net
随机推荐
软件架构与设计(五)-----以数据为中心的架构
1200 times faster! MIT develops a new generation of drug research and development AI, and suspends the old model
数据实时反馈技术
数牍 X Rust,那些不得不说的事
2022年最火的十大测试工具,你掌握了几个
shell编程规范与变量
FTP文件传输协议
File and directory operations (5)
软件架构与设计(十)-----架构技术
A wave of operation to solve the error problem of Laya scene editor
28.55亿元!青岛芯恩增资完成:兴橙集电成第一大股东,持股57.10%
4. Main program and cumulative interrupt processing routine implementation code
Summary and arrangement of postgraduate entrance examination information of 985 colleges and universities nationwide
flowable工作流所有业务概念
设置结构体字节对齐
FTP file transfer protocol
Framework定制系列(十)-----SystemUI定制状态栏statusbar和导航栏navigationbar教程
Some operations of bit operation
Framework定制系列(六)-----屏蔽FallbackHome手机启动中弹窗直接进入Launcher
An article about rsocket protocol