[20260815]centos 9 sar安装.txt
--//发现安装的centos 9,没有sar命令
# sar
bash: sar: command not found...
Failed to search for file: /mnt/cdrom/BaseOS was not found
# mount /dev/sr0 /mnt/cdrom/ -o ro
# sar
bash: sar: command not found...
Install package 'sysstat' to provide command 'sar'? [N/y] n
--//需要安装sysstat包。
# dnf install --setopt=tsflags=test -y sysstat
29cbaseos 2.2 MB/s | 2.3 kB 00:00
29cappstream 2.7 MB/s | 2.8 kB 00:00
Dependencies resolved.
===================================================================================
Package Architecture Version Repository Size
===================================================================================
Installing:
sysstat x86_64 12.5.4-11.el9 henry_appstream 480 k
Installing dependencies:
lm_sensors-libs x86_64 3.6.0-10.el9 henry_appstream 42 k
Transaction Summary
===================================================================================
Install 2 Packages
Total size: 522 k
Installed size: 1.6 M
DNF will only download packages, install gpg keys, and check the transaction.
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Complete!
--//执行安装任务:
# dnf install -y sysstat
Last metadata expiration check: 0:04:20 ago on Sun 16 Aug 2026 11:35:00 AM CST.
Dependencies resolved.
===============================================================================
Package Architecture Version Repository Size
===============================================================================
Installing:
sysstat x86_64 12.5.4-11.el9 henry_appstream 480 k
Installing dependencies:
lm_sensors-libs x86_64 3.6.0-10.el9 henry_appstream 42 k
Transaction Summary
===============================================================================
Install 2 Packages
Total size: 522 k
Installed size: 1.6 M
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : lm_sensors-libs-3.6.0-10.el9.x86_64 1/2
Installing : sysstat-12.5.4-11.el9.x86_64 2/2
Running scriptlet: sysstat-12.5.4-11.el9.x86_64 2/2
Created symlink /etc/systemd/system/multi-user.target.wants/sysstat.service → /usr/lib/systemd/system/sysstat.service.
Created symlink /etc/systemd/system/sysstat.service.wants/sysstat-collect.timer → /usr/lib/systemd/system/sysstat-collect.timer.
Created symlink /etc/systemd/system/sysstat.service.wants/sysstat-summary.timer → /usr/lib/systemd/system/sysstat-summary.timer.
Verifying : lm_sensors-libs-3.6.0-10.el9.x86_64 1/2
Verifying : sysstat-12.5.4-11.el9.x86_64 2/2
Installed:
lm_sensors-libs-3.6.0-10.el9.x86_64 sysstat-12.5.4-11.el9.x86_64
Complete!
# systemctl status sysstat
○ sysstat.service - Resets System Activity Logs
Loaded: loaded (/usr/lib/systemd/system/sysstat.service; enabled; preset: enabled)
Active: inactive (dead)
# systemctl enable --now sysstat
--//简单测试:
# sar -u 1 5
Linux 5.14.0-704.el9.x86_64 (centos9) 08/16/2026 _x86_64_ (4 CPU)
11:45:15 AM CPU %user %nice %system %iowait %steal %idle
11:45:16 AM all 0.00 0.00 0.00 0.00 0.00 100.00
11:45:18 AM all 0.00 0.00 0.48 0.00 0.00 99.52
11:45:19 AM all 0.00 0.00 0.25 0.00 0.00 99.75
11:45:20 AM all 0.00 0.00 0.00 0.00 0.00 100.00
11:45:21 AM all 0.00 0.00 0.25 0.00 0.00 99.75
Average: all 0.00 0.00 0.20 0.00 0.00 99.80
--//检查配置:
# grep -v "^#" /etc/sysconfig/sysstat | sed -e "/^$/d"
HISTORY=28
COMPRESSAFTER=31
SADC_OPTIONS=" -S DISK"
SA_DIR=/var/log/sa
ZIP="xz"
DELAY_RANGE=0
UMASK=0022
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-3180181/ ,如需转载,请注明出处,否则将追究法律责任。