How to analyse slow boot in RHEL7?

本文介绍如何使用systemd-analyze命令组(包括time、blame和critical-chain)来诊断和优化RHEL7系统的启动时间,通过具体示例展示了如何找出启动过程中耗时较长的服务。

https://access.redhat.com/solutions/2478981

转帖者注:

如下三个命令也同样适用于RHEL8.0

systemd-analyze time
systemd-analyze blame
 systemd-analyze critical-chain

怎么分析RHEL7中 启动慢的问题?

 SOLUTION IN PROGRESS - 已更新 2016年八月3日16:21 - 

English 

环境

  • 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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值