Target unit:用于模拟实现“运行级别”,文件扩展名为.target,可以理解Target 就是一个 Unit 组,包含许多相关的 Unit
Device unit:用于定义内核识别的设备,文件扩展名为.device
Mount unit:用于定义文件系统挂载点,文件扩展名为.mount
Socket unit:用于标识进程间通信用的socket文件,文件扩展名为.socket
1 2 3 4 5 6 7
┌──[root@liruilongs.github.io]-[~] └─$ systemctl status cockpit.socket #CocKpit驾驶舱 和SSH类似,用于远程控制,类似于阿里云的控制台。为初级管理员提供基本操作,通过web端的控制台,访问地址:服务器IP:9090 ● cockpit.socket - Cockpit Web Service Socket Loaded: loaded (/usr/lib/systemd/system/cockpit.socket; disabled; vendor preset: disabled) Active: inactive (dead) Docs: man:cockpit-ws(8) Listen: [::]:9090 (Stream)
Snapshot unit:管理系统快照,文件扩展名为.snapshot
Swap unit:用于标识swap设备,文件扩展名为.swap
Automount unit:文件系统的自动挂载点,文件扩展名为.automount
Path unit:用于根据文件系统上特定对象的变化来启动其他服务,文件扩展名为.path
Timer unit:用于管理计划任务,文件扩展名为.timer
1 2 3 4 5 6 7 8 9 10 11 12
┌──[root@liruilongs.github.io]-[~] └─$ systemctl status systemd-tmpfiles-clean.timer #用于定时清理 `/tmp`,`/var/tmp`之类的临时文件 ● systemd-tmpfiles-clean.timer - Daily Cleanup of Temporary Directories Loaded: loaded (/usr/lib/systemd/system/systemd-tmpfiles-clean.timer; static; vendor preset: disabl> Active: active (waiting) since Sun 2022-04-03 11:24:00 CST; 1h 48min ago Trigger: Mon 2022-04-04 11:39:07 CST; 22h left Docs: man:tmpfiles.d(5) man:systemd-tmpfiles(8)
Apr 03 11:24:00 liruilongs.github.io systemd[1]: Started Daily Cleanup of Temporary Directories. ┌──[root@liruilongs.github.io]-[~] └─$
Slice unit:用于资源管理,文件扩展名为.slice
1.查看units列表信息
列出loaded(配置文件以加载)的units
1 2 3 4 5
┌──[root@liruilongs.github.io]-[~] └─$ systemctl list-units UNIT LOAD ACTIVE SUB DESCRIPTION proc-sys-fs-binfmt_misc.automount loaded active waiting Arbitrary Executable File> .............
┌──[root@liruilongs.github.io]-[~] └─$ systemctl list-units -i timer 0 loaded units listed. Pass --all to see loaded but inactive units, too. To show all installed unit files use 'systemctl list-unit-files'. ┌──[root@liruilongs.github.io]-[~] └─$ systemctl list-unit-files -t timer UNIT FILE STATE dnf-makecache.timer enabled #yaml仓库定时更新 fstrim.timer disabled systemd-tmpfiles-clean.timer static # 临时文件清理 unbound-anchor.timer enabled
4 unit files listed. ┌──[root@liruilongs.github.io]-[~] └─$
┌──[root@liruilongs.github.io]-[~] └─$ systemctl list-units -t service UNIT LOAD ACTIVE SUB DESCRIPTION auditd.service loaded active running Security Auditing Service
列出类型为service,状态为active和inactive 的unit
1 2
┌──[root@liruilongs.github.io]-[~] └─$ systemctl list-units --type service --all
查看失败的服务
1 2 3 4 5
┌──[root@liruilongs.github.io]-[~] └─$ systemctl --failed -t service UNIT LOAD ACTIVE SUB DESCRIPTION ● kdump.service loaded failed failed Crash recovery kernel arming .....
# /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf # Note: This dropin only works with kubeadm and kubelet v1.11+ [Service] Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --pod-manifest-path=/etc/kubernetes/kube Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml" # This is a file that "kubeadm init" and "kubeadm join" generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env # This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use # the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file. EnvironmentFile=-/etc/sysconfig/kubelet ExecStart= ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS$KUBELET_CONFIG_ARGS$KUBELET_KUBEADM_ARGS$KUBELET_EXTRA_ARGS
┌──[root@liruilongs.github.io]-[~] └─$ systemctl mask httpd Created symlink /etc/systemd/system/httpd.service → /dev/null. ┌──[root@liruilongs.github.io]-[~] └─$ systemctl start httpd Failed to start httpd.service: Unit httpd.service is masked. ┌──[root@liruilongs.github.io]-[~] └─$ systemctl status httpd | head -2 ● httpd.service Loaded: masked (Reason: Unit httpd.service is masked.)