我正在尝试估计在 32 位 CentOS 6.2 上运行的应用程序的 IOPS 要求。我开始在一台带有 SATA 磁盘的机器上进行一些测量,我对 sar 测量的 IOPS 和 tps 之间的差异感到非常困惑。
根据维基百科SATA 磁盘应该执行 75-100 IOPS。ioping 实用程序似乎为随机访问测试确认了这一点:
# ./ioping -R /dev/sda
--- /dev/sda (device 931.0 Gb) ioping statistics ---
279 requests completed in 3.0 s, 92 iops, 371.3 kb/s
min/avg/max/mdev = 2.7 ms / 10.8 ms / 130.8 ms / 7.9 ms
Run Code Online (Sandbox Code Playgroud)
但是 sar 产生的 tps 值要高得多(/dev/sda):
# iostat 1
avg-cpu: %user %nice %system %iowait %steal %idle
0.17 0.00 2.02 14.86 0.00 …
Run Code Online (Sandbox Code Playgroud) 我刚刚sysstat
在 Manjaro 上安装了这个包。sar
第一次运行 时,我看到:
Cannot open /var/log/sa/sa21: No such file or directory
Please check if data collecting is enabled
Run Code Online (Sandbox Code Playgroud)
如何查看是否开启了数据采集功能?
如果不是,我将如何启用它?
sar 联机帮助页说:
pgpgin/s - 系统每秒从磁盘调入的千字节总数。
pgpgout/s - 系统每秒调出到磁盘的千字节总数。
fault/s - 系统每秒发生的页面错误数(主要 + 次要)。这不是产生 I/O 的页面错误的计数,因为有些页面错误可以在没有 I/O 的情况下解决。
majflt/s - 系统每秒发生的主要错误数,这些错误需要从磁盘加载内存页面
这是否衡量掉期活动?它指的是什么分页?从磁盘获取数据被认为是分页?
另外,我已经读到 majflt/s 的大而恒定的值并不好。为什么?
例子 :
萨尔-B 12:00:08 AM pgpgin/s pgpgout/s fault/s majflt/s 12:10:05 上午 207.55 2522.76 5109.80 0.01 12:20:07 上午 303.83 274.64 4446.52 0.00 12:30:05 上午 53.85 251.81 4183.98 0.00 12:40:05 上午 43.19 234.05 4181.53 0.00 12:50:06 上午 88.89 265.46 4311.81 0.00 01:00:09 上午 64.60 232.72 4239.05 0.00 01:10:07 上午 69.71 216.89 4523.03 0.00 01:20:06 上午 81.37 250.02 4359.93 …
我的服务器上的负载非常高,即使似乎没有太多磁盘活动并且 CPU 处于空闲状态。使用 sar,我可以看到运行队列已满,但是有什么方法可以查看运行队列中的内容吗?
我定期从服务器上的每日 cron 收到此消息。(我不是每天都收到这条消息。)
/etc/cron.daily/sysstat:
Invalid system activity file: /var/log/sysstat//sa28
Run Code Online (Sandbox Code Playgroud)
这是我服务器上的一些基本信息:
Ubuntu 12.04.2 LTS
Linux server 3.8.4-x86_64-linode31 #1 SMP Mon Mar 25 16:00:34 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux
Run Code Online (Sandbox Code Playgroud)
以下是相关目录列表:
/var/log/sysstat$ ls -lai
total 44
6601 drwxr-xr-x 2 root root 4096 Apr 29 06:48 .
6550 drwxr-xr-x 13 root root 4096 Apr 29 06:48 ..
16 -rw-r--r-- 1 root root 384 Apr 22 00:00 sa21
510 -rw-r--r-- 1 root root 384 Apr 23 00:00 sa22
524 -rw-r--r-- 1 root root 384 …
Run Code Online (Sandbox Code Playgroud) 我被要求调查今天早上发生的高 CPU 使用率警报。我使用sar -p
并看到当时出现的高CPU使用率
接下来我曾经ps -eo pcpu,pid,user,args | sort -r -k1 | less
列出了这个时间前 10 名的内存猪
现在我如何找出早上那个特定时间导致瓶颈的进程。我是一名 Java 开发人员,而不是 Linux 专家。
甚至有可能吗?
我们sar
在 Ubuntu 服务器上工作,但在服务器上做了一些工作,现在它停止记录到当天的日志文件。
sar -b 5 5
Run Code Online (Sandbox Code Playgroud)
这说明还sar
活着,并且有监控数据,但是
ubuntu@testing:/var/log/sysstat$ sar
Run Code Online (Sandbox Code Playgroud)
输出:
Linux 5.4.0-1063-azure (server) 02/22/22 _x86_64_ (4 CPU)
10:22:05 LINUX RESTART (4 CPU)
10:22:46 LINUX RESTART (4 CPU)
10:24:25 LINUX RESTART (4 CPU)
16:34:04 LINUX RESTART (4 CPU)
Run Code Online (Sandbox Code Playgroud)
cron 和sysstat
配置没有改变。
*/1 * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 1
Run Code Online (Sandbox Code Playgroud)
为什么统计数据没有添加到日志中?
我有一个负载很小的 CentOS-5 服务器。“sar”命令的典型输出如下所示:
02:20:01 PM CPU %user %nice %system %iowait %steal %idle
02:30:01 PM all 0.63 0.00 1.23 0.31 0.00 97.84
02:40:01 PM all 0.92 0.32 1.34 0.45 0.00 96.97
02:50:01 PM all 0.76 0.00 0.93 0.77 0.00 97.54
03:00:01 PM all 0.41 0.00 0.72 0.15 0.00 98.72
03:10:01 PM all 0.78 0.32 1.49 1.83 0.00 95.58
03:20:01 PM all 0.27 0.00 0.50 0.62 0.00 98.61
Run Code Online (Sandbox Code Playgroud)
但是,我观察到每天晚上 4 点 10 分,CPU 使用率非常高。除了一个月中的几天外,这种情况几乎每天晚上都会发生。“sar”命令显示如下:
03:00:01 AM all 0.10 0.00 0.10 0.11 0.00 …
Run Code Online (Sandbox Code Playgroud) 这些free
命令以两种形式提供可用内存量:完全可用内存(Mem
行)和用于缓存和缓冲区的一次性内存(-/+ buffers/cache
行):
-bash-3.2$ free -m
total used free shared buffers cached
Mem: 16057 15173 884 0 17 2520
-/+ buffers/cache: 12635 3422
Swap: 12287 4937 7350
Run Code Online (Sandbox Code Playgroud)
在此示例中,不包括缓冲区和缓存的可用内存为 884 MB,包括缓冲区和缓存的可用内存为 3422 MB。
如何在 中获得第二个测量值(可用内存,包括缓冲区和缓存)sar
?
我的数据库服务器具有以下数据设备的 sar 输出:
[postgres@dbsrv07 ~]$ LC_ALL=POSIX sar -d |egrep "await|dev253-2"
00:00:01 DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util
00:10:01 dev253-2 2721.27 18357.23 20291.52 14.20 613.68 225.51 0.15 40.60
00:20:01 dev253-2 1345.04 574.92 10685.38 8.37 290.65 215.99 0.06 8.61
00:30:01 dev253-2 801.39 193.53 6364.92 8.18 87.49 109.34 0.07 5.95
00:40:01 dev253-2 832.95 195.70 6617.82 8.18 89.30 107.20 0.07 5.87
00:50:01 dev253-2 835.58 162.90 6644.64 8.15 85.35 102.14 0.06 5.24
01:00:01 dev253-2 847.99 232.36 6722.90 8.20 89.91 106.03 0.07 5.64 …
Run Code Online (Sandbox Code Playgroud) 我正在寻找对“sar -n SOCK”输出的 totsck 列的解释
09:44:06 PM totsck tcpsck udpsck rawsck ip-frag tcp-tw
09:44:09 PM 580 18 5 0 0 1
09:44:10 PM 580 18 5 0 0 0
09:44:11 PM 580 18 5 0 0 0
Average: 580 18 5 0 0 1
Run Code Online (Sandbox Code Playgroud)
这显然不是 tcp/udp/raw 套接字的总和。我遇到的唯一其他解释是它是 sockets plus
sysctl fs.file-nr
Run Code Online (Sandbox Code Playgroud)
但在我的测试盒上
fs.file-nr = 5632 0 803168
Run Code Online (Sandbox Code Playgroud)
非常感谢精确的解释。
谢谢
编辑 2:所以显然 totsck 相当于
cat /proc/net/sockstat
Run Code Online (Sandbox Code Playgroud)
这就引出了一个问题,那里算什么。我找到了这个,但最后它只建议询问编写那段特定内核代码的人。
编辑(用于域套接字记帐):
[root@fedora16 fs]# netstat --protocol unix| wc -l
413
[root@fedora16 fs]# sar …
Run Code Online (Sandbox Code Playgroud) sar ×11
linux ×7
performance ×3
cpu-usage ×2
arch-linux ×1
centos ×1
hard-drive ×1
io ×1
iops ×1
memory ×1
memory-usage ×1
process ×1
queue ×1
socket ×1
ubuntu ×1
ubuntu-12.04 ×1