首页 > 系统相关 >[1036]Linux启动时间分析

[1036]Linux启动时间分析

时间:2023-01-12 18:45:25浏览次数:36  
标签:systemd service 启动 after character time Linux analyze 1036

简述

今天有同事咨询:项目上有台服务器操作系统启动时间较长,如何分析?

果然,好问题都来自实践。

经过查找,对于所有基于systemd的系统,可以使用systemd-analyze来分析系统启动时间。查看man手册,systemd-analyze blame和 systemd-analyze critical-chain可以有效分析

 systemd-analyze blame: 
     This command prints a list of all running units, ordered by the time they took to initialize. This information may be used to  optimize boot-up times.
    
 systemd-analyze critical-chain:
     This command prints a tree of the time-critical chain of units (for each of the specified UNITs or for the default target otherwise). 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.

样例分析

服务器1

配置:四路X86服务器

操作系统:CentOS Linux release 8.5.2111

#  systemd-analyze blame|head -n 15
         50.902s unbound-anchor.service
         21.032s mysql-monitor-agent.service
         15.143s DmServiceDMSERVER.service
         15.137s DmAPService.service
         10.305s kdump.service
          8.214s systemd-udev-settle.service
          6.170s NetworkManager-wait-online.service
          6.032s mysql-monitor-server.service
          4.536s mysqld.service
          2.194s dnf-makecache.service
          2.117s tuned.service
          1.328s dracut-initqueue.service
          1.226s lvm2-monitor.service
           813ms [email protected]
           672ms lvm2-pvscan@8:3.service
           
           
# systemd-analyze critical-chain unbound-anchor.service
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.

unbound-anchor.service +50.902s
└─basic.target @9.108s
  └─sockets.target @9.108s
    └─spice-vdagentd.socket @9.108s
      └─sysinit.target @9.105s
        └─systemd-update-utmp.service @9.100s +5ms
          └─auditd.service @9.053s +45ms
            └─systemd-tmpfiles-setup.service @9.024s +24ms
              └─import-state.service @9.010s +13ms
                └─local-fs.target @9.009s
                  └─boot.mount @8.956s +53ms
                    └─systemd-fsck@dev-disk-by\x2duuid-e2c118b0\x2dc161\x2d4599\x2dacfe\x2dd574ba48cb64.service >
                      └─local-fs-pre.target @8.923s
                        └─lvm2-monitor.service @245ms +1.226s
                          └─dm-event.socket @234ms
                            └─-.mount
                              └─system.slice
                                └─-.slice
           

服务器2

配置:四路X86服务器

操作系统:CentOS Linux release 7.9.2009 (Core)

# systemd-analyze blame|head -n 15
    1min 41.449s network.service
         50.468s unbound-anchor.service
         38.996s initial-setup.service
         27.898s kdump.service
          6.214s NetworkManager-wait-online.service
          4.439s systemd-udev-settle.service
          3.237s tuned.service
          2.922s dev-mapper-centos\x2droot.device
          1.715s lvm2-pvscan@8:3.service
          1.112s containerd.service
          1.005s docker.socket
          1.004s lvm2-monitor.service
           859ms dracut-initqueue.service
           814ms postfix.service
           756ms fwupd.service

# systemd-analyze critical-chain network.service
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.

network.service +1min 41.449s
└─network-pre.target @7.418s

服务器3

配置:2路 Phytium服务器

操作系统:Kylin Linux Advanced Server release V10 (Sword)

# systemd-analyze blame|head -n 15
19.884s NetworkManager-wait-online.service
14.006s rasdaemon.service
 6.587s dracut-initqueue.service
 3.324s kdump.service
 2.607s plymouth-quit-wait.service
 1.930s network.service
 1.525s tuned.service
 1.475s lvm2-monitor.service
  995ms pmcd.service
  791ms hdd.mount
  637ms lvm2-pvscan@8:3.service
  574ms initrd-switch-root.service
  560ms systemd-sysctl.service
  540ms dracut-pre-pivot.service
  510ms udisks2.service
  
# systemd-analyze critical-chain NetworkManager-wait-online.service
The time when unit became active or started is printed after the "@" character.
The time the unit took to start is printed after the "+" character.

NetworkManager-wait-online.service +19.884s
└─NetworkManager.service @4.107s +66ms
  └─network-pre.target @4.104s

服务器4

配置:2路 鲲鹏服务器

操作系统:NFS Server release 3.1 (RTM4-A1)

# systemd-analyze blame|head -n 15
         47.635s systemd-fsck-root.service
         26.005s NetworkManager-wait-online.service
          8.968s plymouth-quit-wait.service
          2.028s lvm2-pvscan@8:3.service
          1.709s docker.service
          1.650s fwupd.service
          1.081s postfix.service
          1.038s systemd-udev-settle.service
           935ms lvm2-monitor.service
           877ms dev-mapper-nfs\x2d\x2d3.1\x2droot.device
           614ms tuned.service
           590ms bolt.service
           505ms rdma.service
           496ms containerd.service
           427ms network.service

# systemd-analyze critical-chain systemd-fsck-root.service
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.

systemd-fsck-root.service +47.635s
└─systemd-readahead-replay.service @1.257s +39ms
  └─system.slice
    └─-.slice

标签:systemd,service,启动,after,character,time,Linux,analyze,1036
From: https://www.cnblogs.com/jinanxiaolaohu/p/17047642.html

相关文章

  • linux发展史及软件配置
    linux岗位需求#1.岗位需求自动化运维,容器运维,DBA,IDC运维(不建议)ps:linux岗位会的越多给的越多linux工作本质linux简要发展史#1.发展1991年,芬兰林......
  • Linux基础13 打包压缩 gzip, zip, tar
    压缩打包 windows下我们接触最多的压缩文件就是.rar格式,但Linux有自己所特有的压缩工具。 一般linux上的压缩包windows上可以使用 如果希望windows和Linux互相能使用的压......
  • 【图文教程】云服务器上,Linux安装VSFTPD组件及遇到的问题
    服务器做迁移,从AXX云迁移到Txx云上,迁移的话,需要把图片服务器也迁移过去。之前使用的是VSFTPD这次也还用这个吧。这里就记录下FTP服务器安装及遇到的问题。1:安装VSFTP组件使......
  • Android:如何在后台启动Activity
     通常我用这段代码开始一个活动:Intenti=newIntent(context,MyActivity.class);i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);context.startActivity(i);......
  • Linux内核为什么会发生soft lockup?【转】
    转自:https://blog.csdn.net/21cnbao/article/details/108250786提到softlockup,大家都不会陌生:BUG: soft lockup - CPU#3 stuck for 23s! [kworker/3:0:32]......
  • 【图文教程】云服务器上,Linux安装VSFTPD组件及遇到的问题
    服务器做迁移,从AXX云迁移到Txx云上,迁移的话,需要把图片服务器也迁移过去。之前使用的是VSFTPD这次也还用这个吧。这里就记录下FTP服务器安装及遇到的问题。1:安装VSFTP组件......
  • 使用UltraISO制作U盘CentOS启动盘
    1、下载安装UltraISO,下载地址:https://cn.ultraiso.net/xiazai.html2、准备centos系统镜像,下载地址:https://mirrors.aliyun.com/centos/7.9.2009/isos/x86_64/3、打开UltraI......
  • linux安装向日葵
    安装向日葵1、安装下载好的rpm包#rpm-ivhsunloginclient-11.0.0.36662.x86_64.rpm如果说依赖错误那就在悬后加上,加上--nodeps-force跳过依赖检测强制安装2、查看是否安装......
  • linux搭建web服务
    ​​​​1、检查环境getenforce                         #查看seLinux运行状态Enforcing                         ......
  • Linux (WSL) Files in Windows 10 | 如何传输文件在linux的window subsystem
    问题:访问基于linux的window的子系统,进行文件传输,如果采用winscp有点麻烦解决方法一:命令explorer.exe.如图:  解决方法二:也可以直接根据ubantu版本在文......