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

[1036]Linux启动时间分析

时间:2023-01-16 10:06:54浏览次数:59  
标签: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://blog.51cto.com/u_11529070/6010050

相关文章

  • linux中的-和--参数linux中的-和--参数
    linux中的-和--参数 在linux中,利用man查看某个命令的使用手册的时候,该命令参数通常会有-和--两种情况。通常而言,-说明参数是字符形式,后面接的是单字母命令。而--说明参数是......
  • [Guide]Linux Install Guide: Installer Method
    [Guide]LinuxInstallGuide:InstallerMethodQuotePost by torzdf » MonAug19,20193:56pmInstallingFaceswaponLinuxisabreeze.TheLinuxinst......
  • Linux && CentOS7
    Linux&&CentOS7.6虚拟1.VMware虚拟机1.1如何安装VMware​ 官方链接:www.vmware.com​ VMware是用于在Linux或WindowsPC上运行虚拟机的行业标准桌面管理程......
  • linux grep/sed/awk
    1.sed基础逻辑按照行处理行匹配处理逻辑-编辑/显示行不匹配处理逻辑-显示2.sed语法sed[选项][sed内置命令自负][输入文件]2.1选项(-开头)-n取消默认......
  • linux kernel 和 设备树的匹配
    stext()--->__enable_mmu()--->__turn_mmu_on()--->__mmap_switched()--->start_kernel()--->setup_arch()--->setup_machine_fdt()--->of_flat_dt_match_ma......
  • 交叉编译 linux x86_64 aarch64 Android8
    https://github.com/TanNang/tls-proxy#uthashcd/tmpgitclonehttps://github.com/troydhanson/uthash#base64cd/tmpgitclonehttps://github.com/aklomp/bas......
  • linux学习笔记
    如何创建ubanto网上的教程已经很多了我使用virtualbox自己创建了一个虚拟机中文包安装遇到了语言问题,安装的时候默认语言没有中文找到了一个中文语言包教程......
  • Linux下进程占用内存了解
    转自:https://zhuanlan.zhihu.com/p/4703150891.介绍通过以下命令:cat/proc/pid/status即可查看所占用内存情况,C++中通过getpid()函数即可打印进程的pid,类型为pid_t,......
  • 洛谷 P1036 选数
    原题链接题解:#include"iostream"#include"algorithm"#definelllonglongusingnamespacestd;llsum=0;boolprime(llx){intn=2;for(;x%n!=0;n++)......
  • 尚硅谷Linux通关2022
    Linux-v10.0-01天-课堂笔记学习目标能够知道什么是Linux系统以及它的应用场景能够独立完成安装VMware虚拟机和网络配置能够独立完成安装CentOS以及远程终端SecureCRT......