如下三个命令也同样适用于RHEL8.0
systemd-analyze time
systemd-analyze blame
systemd-analyze critical-chain
怎么分析RHEL7中 启动慢的问题?
环境
- Red Hat Enterprise Linux 7
- systemd
问题
RHEL 7 is taking long time to boot. How can I find out which services are taking long time to start?
决议
systemd-analyze
command can be utilized to find out information about how much each service took to start, please see Diagnostics steps for examples:
诊断步骤
systemd-analyze time
can provide overall information about how long took system to start
Raw
[root@server ~]# systemd-analyze time
Startup finished in 629ms (kernel) + 930ms (initrd) + 6.098s (userspace) = 7.658s
To find out, how much time each unit took to start, run systemd-analyze blame
Raw
[root@server ~]# systemd-analyze blame
4.048s network.service
1.298s firewalld.service
1.071s kdump.service
824ms tuned.service
592ms lvm2-pvscan@252:2.service
555ms postfix.service
522ms lvm2-monitor.service
257ms boot.mount
203ms systemd-logind.service
125ms rhel-dmesg.service
...
At certain steps, the boot cannot proceed until all dependencies for unit are satisfied. To see units at these critical points run systemd-analyze critical-chain
Raw
[root@servert ~]# 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 @6.089s
└─postfix.service @5.018s +555ms
└─network.target @5.015s
└─network.service @961ms +4.048s
└─basic.target @960ms
└─paths.target @959ms
└─brandbot.path @959ms
└─sysinit.target @954ms
└─systemd-update-utmp.service @946ms +7ms
└─auditd.service @896ms +48ms
└─systemd-tmpfiles-setup.service @865ms +27ms
└─rhel-import-state.service @816ms +45ms
└─local-fs.target @813ms
└─lvm2-monitor.service @288ms +522ms
└─lvm2-lvmetad.service @330ms
└─lvm2-lvmetad.socket @287ms
└─-.mount
└─system.slice
└─-.slice