Systemctl 安装及基础操作
2023-06-13 09:16:00 时间
Systemctl 安装及基础操作
01、首先检查系统上是否安装了systemd以及当前安装的Systemd的版本是什么?
# systemd --version systemd 215 +PAM +AUDIT +SELINUX +IMA +SYSVINIT +LIBCRYPTSETUP +GCRYPT +ACL +XZ -SECCOMP -APPARMOR
从上面的例子可以清楚地看出,我们已经安装了systemd 215版本。
02.检查systemd和systemctl的二进制文件和库的安装位置。
# whereis systemd systemd: /usr/lib/systemd /etc/systemd /usr/share/systemd /usr/share/man/man1/systemd.1.gz # whereis systemctl systemctl: /usr/bin/systemctl /usr/share/man/man1/systemctl.1.gz
03.检查systemd是否正在运行。
# ps -eaf | grep [s]ystemd root 1 0 0 16:27 ? 00:00:00 /usr/lib/systemd/systemd --switched-root --system --deserialize 23 root 444 1 0 16:27 ? 00:00:00 /usr/lib/systemd/systemd-journald root 469 1 0 16:27 ? 00:00:00 /usr/lib/systemd/systemd-udevd root 555 1 0 16:27 ? 00:00:00 /usr/lib/systemd/systemd-logind dbus 556 1 0 16:27 ? 00:00:00 /bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
注意:systemd作为父守护进程运行(PID = 1)。 在上面的命令ps中使用(-e)选择所有进程,( a)选择除会话前导之外的所有进程和(-f)选择完整格式列表(即-eaf)。
另请注意上面示例中的方括号以及其他示例。 Square Bracket表达式是grep的字符类模式匹配的一部分。
04.分析systemd启动过程
# systemd-analyze Startup finished in 487ms (kernel) + 2.776s (initrd) + 20.229s (userspace) = 23.493s
05.分析每个进程在引导时花费的时间
# systemd-analyze blame 8.565s mariadb.service 7.991s webmin.service 6.095s postfix.service 4.311s httpd.service 3.926s firewalld.service 3.780s kdump.service 3.238s tuned.service 1.712s network.service 1.394s lvm2-monitor.service 1.126s systemd-logind.service ....
06.分析启动时的关键链
# systemd-analyze critical-chain The time after the unit is active or started is printed after the "@" character. The time the unit takes to start is printed after the "+" character. multi-user.target @20.222s └─mariadb.service @11.657s +8.565s └─network.target @11.168s └─network.service @9.456s +1.712s └─NetworkManager.service @8.858s +596ms └─firewalld.service @4.931s +3.926s └─basic.target @4.916s └─sockets.target @4.916s └─dbus.socket @4.916s └─sysinit.target @4.905s └─systemd-update-utmp.service @4.864s +39ms └─auditd.service @4.563s +301ms └─systemd-tmpfiles-setup.service @4.485s +69ms └─rhel-import-state.service @4.342s +142ms └─local-fs.target @4.324s └─boot.mount @4.286s +31ms └─systemd-fsck@dev-disk-by/x2duuid-79f594ad/x2da332/x2d4730/x2dbb5f/x2d85d19608096 └─dev-disk-by/x2duuid-79f594ad/x2da332/x2d4730/x2dbb5f/x2d85d196080964.device @4
重要:Systemctl接受服务(.service),挂载点(.mount),套接字(.socket)和设备(.device)作为单位。
07、列出所有可用的单位
# systemctl list-unit-files
UNIT FILE STATE proc-sys-fs-binfmt_misc.automount static dev-hugepages.mount static dev-mqueue.mount static proc-sys-fs-binfmt_misc.mount static sys-fs-fuse-connections.mount static sys-kernel-config.mount static sys-kernel-debug.mount static tmp.mount disabled brandbot.path disabled .....
08、列出所有运行单元
# systemctl list-units UNIT LOAD ACTIVE SUB DESCRIPTION proc-sys-fs-binfmt_misc.automount loaded active waiting Arbitrary Executable File Formats File Syste sys-devices-pc...0-1:0:0:0-block-sr0.device loaded active plugged VBOX_CD-ROM sys-devices-pc...:00:03.0-net-enp0s3.device loaded active plugged PRO/1000 MT Desktop Adapter sys-devices-pc...00:05.0-sound-card0.device loaded active plugged 82801AA AC97 Audio Controller sys-devices-pc...:0:0-block-sda-sda1.device loaded active plugged VBOX_HARDDISK sys-devices-pc...:0:0-block-sda-sda2.device loaded active plugged LVM PV Qzyo3l-qYaL-uRUa-Cjuk-pljo-qKtX-VgBQ8 sys-devices-pc...0-2:0:0:0-block-sda.device loaded active plugged VBOX_HARDDISK sys-devices-pl...erial8250-tty-ttyS0.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS0 sys-devices-pl...erial8250-tty-ttyS1.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS1 sys-devices-pl...erial8250-tty-ttyS2.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS2 sys-devices-pl...erial8250-tty-ttyS3.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS3 sys-devices-virtual-block-dm/x2d0.device loaded active plugged /sys/devices/virtual/block/dm-0 sys-devices-virtual-block-dm/x2d1.device loaded active plugged /sys/devices/virtual/block/dm-1 sys-module-configfs.device loaded active plugged /sys/module/configfs ...
09、列出所有失败的单元
# systemctl --failed UNIT LOAD ACTIVE SUB DESCRIPTION kdump.service loaded failed failed Crash recovery kernel arming LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, values depend on unit type. 1 loaded units listed. Pass --all to see loaded but inactive units, too. To show all installed unit files use systemctl list-unit-files.
10、检查单元(cron.service)是否启用?
# systemctl is-enabled crond.service enabled
11.检查单元或服务是否正在运行?
systemctl status firewalld.service firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled) Active: active (running) since Tue 2018-04-28 16:27:55 IST; 34min ago Main PID: 549 (firewalld) CGroup: /system.slice/firewalld.service └─549 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid Apr 28 16:27:51 tecmint systemd[1]: Starting firewalld - dynamic firewall daemon... Apr 28 16:27:55 tecmint systemd[1]: Started firewalld - dynamic firewall daemon.
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/59181.html
linuxMDpython相关文章
- python与anaconda安装(先安装了python后安装anaconda,基于python已存在的基础上安装anaconda)——逼死强迫症、超详解[通俗易懂]
- python基础系列教程——Python的安装与测试:python解释器、PyDev编辑器、pycharm编译器
- 1.vSphere快速入门与基础安装
- BookStack企业团队小型Wiki(知识库网站)基础安装与使用
- HarmonyOS实战[一]——原理概念介绍安装:基础篇
- 达芬奇是什么软件?视频调色软件Davinci中文版,达芬奇安装教程
- VMware Workstation安装(Linux内核)银河麒麟图文教程
- Redis介绍以及安装(Linux)详解数据库
- Java基础学习笔记二十四 MySQL安装图解详解编程语言
- 安装实现基于Linux的嵌入式系统安装:U盘安装法(linux嵌入式u盘)
- Ubuntu 13.04 安装步骤 – 截图
- rLinux下安装Bazaar的指南(linux安装bz)
- 让虚拟机成为Linux世界的入口(在虚拟机安装linux)
- 快速学会如何在电脑上安装MySQL数据库(电脑安装mysql数据库)
- 轻松搞定:Mac 编译安装 MySQL 教程(mac编译安装mysql)
- Linux系统安装后的基础优化-基于CentOS
- Oracle安装的先决条件:全面梳理(oracle安装先决条件)
- Oracle AIX系统安装指南(oracleaix安装)
- 实现在Windows下安装Lighttpd的方法
- 关于webLucene安装方法