用systemd-analyze分析Linux系統(tǒng)的啟動性能
systemd-analyze是一個分析啟動性能的工具,用于分析啟動時服務(wù)時間消耗。默認顯示啟動是內(nèi)核和用戶空間的消耗時間:
Startupfinishedin818ms(kernel)+6.240s(initrd)+32.979s(userspace)=40.038s
和使用systemd-analyzetime命令的效果一樣。
(1)查看詳細的每個服務(wù)消耗的啟動時間
通過systemd-analyzeblame命令查看詳細的每個服務(wù)消耗的啟動時間:
[root@localhost~]#systemd-analyzeblame
30.852siscsi.service
16.994skdump.service
10.871sboot.mount
...
103mssystemd-sysctl.service
101msdatapool.mount
(2)查看嚴重消耗時間的服務(wù)樹狀表
systemd-analyzecritical-chain命令打印嚴重消耗時間的服務(wù)樹狀表,按照啟動消耗的時間進行排序,時間消耗越多,越排到前面。@之后是服務(wù)激活或者啟動的時間,+號之后是服務(wù)啟動消耗的時間。個人理解@是從系統(tǒng)引導(dǎo)到服務(wù)啟動起來的時間,是一個相對時間消耗,+是服務(wù)啟動消耗的時間,是一個絕對時間消耗。
[root@localhost~]#systemd-analyzecritical-chain
Thetimeaftertheunitisactiveorstartedisprintedafterthe"@"character.
Thetimetheunittakestostartisprintedafterthe"+"character.
multi-user.target@32.976s
└─kdump.service@15.981s+16.994s
└─network.target@15.980s
└─NetworkManager.service@15.069s+54ms
└─firewalld.service@14.532s+535ms
└─basic.target@14.532s
└─sockets.target@14.532s
└─dbus.socket@14.532s
└─sysinit.target@14.527s
└─systemd-update-utmp.service@14.524s+2ms
└─systemd-tmpfiles-setup.service@14.456s+67ms
└─local-fs.target@14.447s
└─boot.mount@3.575s+10.871s
└─systemd-fsck@dev-disk-by\x2duuid-8c77568b\x2d7e51\x2d4e32\x2dbbdf\x2ddc12ff737bbf.service@3.348s+226ms
└─systemd-fsck-root.service@1.237s+152ms
└─systemd-readahead-replay.service@1.073s+25ms
(3)打印分析圖及其他命令
systemd-analyzeplot打印一個svg格式的服務(wù)消耗時間表,通過瀏覽器可以以圖形的方式展示,非常直觀:
[root@localhost~]#systemd-analyzeplot>plot.svg

其他參數(shù):
systemd-analyzedot用分隔符產(chǎn)生當前服務(wù)
systemd-analyzedump以友好方式顯示當前服務(wù)狀態(tài)
6systemd文件類型及存放位置
systemd配置文件被稱為unit單元,根據(jù)類型不同,以不同的擴展名結(jié)尾。
.service系統(tǒng)服務(wù);
.target一組系統(tǒng)服務(wù);
.automount自動掛載點;
.device能被內(nèi)核識別的設(shè)備;
.mount掛載點;
.path文件系統(tǒng)的文件或者目錄;
.scope外部創(chuàng)建的進程;
.slice一組分層次管理的系統(tǒng)進程;
.snapshot系統(tǒng)服務(wù)狀態(tài)管理;
.socket進程間通訊套接字;
.swap定義swap文件或者設(shè)備;
.timer定義定時器。
版權(quán)聲明:本站文章來源標注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學習參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。