文章目录提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
- 前言
- 一、io问题分析
- 总结
前言
在某次实验环境中,发现我的达梦数据库环境top下us跟sys的使用率都有点高,并且伴随着一些iowait情况,随后就针对本次内容,进行一个初步尝试分析
一、io问题分析
可以看到,当前环境下我的sys跟iowait都有点高,那么是什么导致的呢,我们往下分析
随后我们使用vmstat工具分析下上下文切换情况,发现in跟cs的值都很大,尤其是cs每秒上下文切换次数非常高,但是具体是什么导致的目前我们还不知道,所以我们继续分析下
[root@dmsh1 tools]# vmstat 1 5 procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 12 0 0 115000 0 1287496 0 0 1225 2976 1553 2269 20 23 51 6 0 10 0 0 117388 0 1286568 0 0 4744 16353 9712 37034 21 77 2 1 0 8 0 0 114640 0 1287908 0 0 4708 45482 9487 29766 18 70 7 6 0 11 0 0 114972 0 1287960 0 0 5908 18971 9904 35690 16 77 7 1 0 9 1 0 113908 0 1288812 0 0 6580 29369 9848 39746 21 77 2 1 0
随后我们使用pidstat 工具分析下,pidstat 用于监控全部或指定进程占用系统资源的情况,如CPU,内存、设备IO、任务切换、线程等
发现dm的sql线程的每秒自愿上下文切换跟非自愿上下文切换的值都比较大,
自愿上下文切换cswch/s也就意味着进程无法获取所需资源,常见的io、内存等系统资源不足会发生这类问题
非资源上下文切换nvcswch/s指进程由于时间片已到等原因被系统强制调度,比如大量进程都在争抢cpu就容易发生非自愿
[root@dmsh1 tools]# pidstat -w -t 1 Linux 5.18.3-1.el7.elrepo.x86_64 (dmsh1) 2022年06月13日 _x86_64_ (2 CPU) 12时50分52秒 UID TGID TID cswch/s nvcswch/s Command 12时50分53秒 0 9 - 1150.93 0.00 kworker/0:1H-kblockd 12时50分53秒 0 - 9 1150.93 0.00 |__kworker/0:1H-kblockd 12时50分53秒 0 14 - 12.04 0.00 ksoftirqd/0 12时50分53秒 0 - 14 12.04 0.00 |__ksoftirqd/0 12时50分53秒 0 15 - 62.04 0.00 rcu_preempt 12时50分53秒 0 - 15 62.04 0.00 |__rcu_preempt 12时50分53秒 0 21 - 143.52 0.00 ksoftirqd/1 12时50分53秒 0 - 21 143.52 0.00 |__ksoftirqd/1 12时50分53秒 0 45 - 571.30 0.00 kworker/1:1H-kblockd 12时50分53秒 0 - 45 571.30 0.00 |__kworker/1:1H-kblockd 12时50分53秒 0 46 - 1.85 1.85 kswapd0 12时50分53秒 0 - 46 1.85 1.85 |__kswapd0 12时50分53秒 0 376 - 4.63 0.00 irq/16-vmwgfx 12时50分53秒 0 - 376 4.63 0.00 |__irq/16-vmwgfx 12时50分53秒 0 490 - 19.44 0.00 xfsaild/dm-0 12时50分53秒 0 - 490 19.44 0.00 |__xfsaild/dm-0 12时50分53秒 0 794 - 10.19 0.00 vmtoolsd 12时50分53秒 0 - 794 10.19 0.00 |__vmtoolsd 12时50分53秒 0 - 815 0.93 0.00 |__HangDetector 12时50分53秒 0 - 1389 0.93 0.00 |__tuned 12时50分53秒 0 - 1244 0.93 0.00 |__in:imjournal 12时50分53秒 10000 1307 - 0.93 0.00 dmserver 12时50分53秒 10000 - 1307 0.93 0.00 |__dmserver 12时50分53秒 10000 - 1404 68.52 5.56 |__dm_io_thd 12时50分53秒 10000 - 1405 66.67 16.67 |__dm_io_thd 12时50分53秒 10000 - 1406 66.67 19.44 |__dm_io_thd 12时50分53秒 10000 - 1407 61.11 9.26 |__dm_io_thd 12时50分53秒 10000 - 1408 63.89 7.41 |__dm_io_thd 12时50分53秒 10000 - 1409 71.30 10.19 |__dm_io_thd 12时50分53秒 10000 - 1410 64.81 20.37 |__dm_io_thd 12时50分53秒 10000 - 1411 72.22 20.37 |__dm_io_thd 12时50分53秒 10000 - 1412 69.44 10.19 |__dm_io_thd 12时50分53秒 10000 - 1413 65.74 9.26 |__dm_io_thd 12时50分53秒 10000 - 1414 71.30 5.56 |__dm_io_thd 12时50分53秒 10000 - 1415 69.44 34.26 |__dm_io_thd 12时50分53秒 10000 - 1416 69.44 7.41 |__dm_io_thd 12时50分53秒 10000 - 1417 69.44 7.41 |__dm_io_thd 12时50分53秒 10000 - 1418 67.59 25.00 |__dm_io_thd 12时50分53秒 10000 - 1419 69.44 14.81 |__dm_io_thd 12时50分53秒 10000 - 1437 9.26 3.70 |__dmserver 12时50分53秒 10000 - 1443 6.48 76.85 |__dm_chkpnt_thd 12时50分53秒 10000 - 1444 1739.81 463.89 |__dm_redolog_thd 12时50分53秒 10000 - 1509 0.93 0.00 |__dm_tskwrk_thd 12时50分53秒 10000 - 1513 0.93 0.00 |__dm_tskwrk_thd 12时50分53秒 10000 - 1515 272.22 212.96 |__dm_purge_thd 12时50分53秒 10000 - 1516 0.93 0.00 |__dmserver 12时50分53秒 10000 - 1518 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1519 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1520 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1521 0.93 0.93 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1522 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1523 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1524 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1525 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1526 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1527 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1528 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1529 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1530 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1531 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1532 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1533 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1535 0.93 0.00 |__dm_sched_thd 12时50分53秒 10000 - 16742 764.81 1012.04 |__dm_sql_thd 12时50分53秒 10000 - 16743 845.37 1032.41 |__dm_sql_thd 12时50分53秒 10000 - 16744 778.70 1040.74 |__dm_sql_thd 12时50分53秒 10000 - 16745 872.22 963.89 |__dm_sql_thd 12时50分53秒 10000 - 16746 734.26 1174.07 |__dm_sql_thd 12时50分53秒 10000 - 16747 827.78 1156.48 |__dm_sql_thd 12时50分53秒 10000 - 16748 769.44 1089.81 |__dm_sql_thd 12时50分53秒 10000 - 16749 869.44 1404.63 |__dm_sql_thd 12时50分53秒 10000 - 16750 814.81 852.78 |__dm_sql_thd 12时50分53秒 10000 - 16751 763.89 1487.04 |__dm_sql_thd 12时50分53秒 10000 - 1438 0.93 0.00 |__dmserver 12时50分53秒 10000 - 1452 0.93 0.00 |__dm_redolog_thd 12时50分53秒 10000 - 1464 0.93 0.00 |__dm_tskwrk_thd 12时50分53秒 10000 - 1465 0.93 0.00 |__dm_tskwrk_thd 12时50分53秒 10000 - 1469 0.93 0.00 |__dm_tskwrk_thd 12时50分53秒 10000 - 1476 1.85 0.00 |__dm_purge_thd 12时50分53秒 10000 - 1477 0.93 0.00 |__dmserver 12时50分53秒 10000 - 1479 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1480 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1481 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1482 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1483 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1484 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1485 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1486 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1487 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1488 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1489 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1490 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1491 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1492 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1493 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1494 0.93 0.00 |__dm_wrkgrp_thd 12时50分53秒 10000 - 1496 0.93 1.85 |__dm_sched_thd 12时50分53秒 10000 1325 - 0.93 0.00 dmap 12时50分53秒 10000 - 1325 0.93 0.00 |__dmap 12时50分53秒 0 1583 - 1.85 0.00 sshd 12时50分53秒 0 - 1583 1.85 0.00 |__sshd 12时50分53秒 0 15347 - 3.70 0.93 kworker/0:0-events 12时50分53秒 0 - 15347 3.70 0.93 |__kworker/0:0-events 12时50分53秒 0 16225 - 10.19 0.00 kworker/u256:1-events_unbound 12时50分53秒 0 - 16225 10.19 0.00 |__kworker/u256:1-events_unbound 12时50分53秒 0 16488 - 31.48 0.93 kworker/1:1-events 12时50分53秒 0 - 16488 31.48 0.93 |__kworker/1:1-events 12时50分53秒 0 - 16728 8.33 0.93 |__java 12时50分53秒 0 - 16729 8.33 0.93 |__java 12时50分53秒 0 - 16730 10.19 0.00 |__java 12时50分53秒 0 - 16737 19.44 0.00 |__java 12时50分53秒 0 - 16752 1146.30 13.89 |__java 12时50分53秒 0 - 16753 1178.70 0.00 |__java 12时50分53秒 0 - 16754 1190.74 14.81 |__java 12时50分53秒 0 - 16755 1279.63 15.74 |__java 12时50分53秒 0 - 16756 1267.59 8.33 |__java 12时50分53秒 0 - 16757 1251.85 75.00 |__java 12时50分53秒 0 - 16758 1261.11 41.67 |__java 12时50分53秒 0 - 16759 1416.67 55.56 |__java 12时50分53秒 0 - 16760 1111.11 0.00 |__java 12时50分53秒 0 - 16761 1395.37 87.04 |__java 12时50分53秒 0 16908 - 0.93 0.00 kworker/1:3-ata_sff 12时50分53秒 0 - 16908 0.93 0.00 |__kworker/1:3-ata_sff 12时50分53秒 0 16950 - 0.93 117.59 pidstat 12时50分53秒 0 - 16950 0.93 116.67 |__pidstat
然后在进一步观察/proc/interrputs 来查看具体内容,res为重调度中断,可以看出值很大,说明还是过多任务的调度问题
[root@dmsh1 tools]# cat /proc/interrupts
CPU0 CPU1
0: 4 0 IO-APIC 2-edge timer
1: 9 0 IO-APIC 1-edge i8042
8: 0 1 IO-APIC 8-edge rtc0
9: 0 0 IO-APIC 9-fasteoi acpi
12: 0 15 IO-APIC 12-edge i8042
14: 0 0 IO-APIC 14-edge ata_piix
15: 0 8329 IO-APIC 15-edge ata_piix
16: 34454 13113 IO-APIC 16-fasteoi vmwgfx, ens34
17: 12677 4034584 IO-APIC 17-fasteoi ioc0, snd_ens1371
18: 63 0 IO-APIC 18-fasteoi ehci_hcd:usb1, uhci_hcd:usb2
19: 128092 175 IO-APIC 19-fasteoi ens33, ens37
24: 0 0 PCI-MSI 344064-edge PCIe PME, pciehp
25: 0 0 PCI-MSI 346112-edge PCIe PME, pciehp
26: 0 0 PCI-MSI 348160-edge PCIe PME, pciehp
27: 0 0 PCI-MSI 350208-edge PCIe PME, pciehp
28: 0 0 PCI-MSI 352256-edge PCIe PME, pciehp
29: 0 0 PCI-MSI 354304-edge PCIe PME, pciehp
30: 0 0 PCI-MSI 356352-edge PCIe PME, pciehp
31: 0 0 PCI-MSI 358400-edge PCIe PME, pciehp
32: 0 0 PCI-MSI 360448-edge PCIe PME, pciehp
33: 0 0 PCI-MSI 362496-edge PCIe PME, pciehp
34: 0 0 PCI-MSI 364544-edge PCIe PME, pciehp
35: 0 0 PCI-MSI 366592-edge PCIe PME, pciehp
36: 0 0 PCI-MSI 368640-edge PCIe PME, pciehp
37: 0 0 PCI-MSI 370688-edge PCIe PME, pciehp
38: 0 0 PCI-MSI 372736-edge PCIe PME, pciehp
39: 0 0 PCI-MSI 374784-edge PCIe PME, pciehp
40: 0 0 PCI-MSI 376832-edge PCIe PME, pciehp
41: 0 0 PCI-MSI 378880-edge PCIe PME, pciehp
42: 0 0 PCI-MSI 380928-edge PCIe PME, pciehp
43: 0 0 PCI-MSI 382976-edge PCIe PME, pciehp
44: 0 0 PCI-MSI 385024-edge PCIe PME, pciehp
45: 0 0 PCI-MSI 387072-edge PCIe PME, pciehp
46: 0 0 PCI-MSI 389120-edge PCIe PME, pciehp
47: 0 0 PCI-MSI 391168-edge PCIe PME, pciehp
48: 0 0 PCI-MSI 393216-edge PCIe PME, pciehp
49: 0 0 PCI-MSI 395264-edge PCIe PME, pciehp
50: 0 0 PCI-MSI 397312-edge PCIe PME, pciehp
51: 0 0 PCI-MSI 399360-edge PCIe PME, pciehp
52: 0 0 PCI-MSI 401408-edge PCIe PME, pciehp
53: 0 0 PCI-MSI 403456-edge PCIe PME, pciehp
54: 0 0 PCI-MSI 405504-edge PCIe PME, pciehp
55: 0 0 PCI-MSI 407552-edge PCIe PME, pciehp
56: 1244 0 PCI-MSI 129024-edge vmw_vmci
57: 0 0 PCI-MSI 129025-edge vmw_vmci
NMI: 0 0 Non-maskable interrupts
LOC: 3924413 4258052 Local timer interrupts
SPU: 0 0 Spurious interrupts
PMI: 0 0 Performance monitoring interrupts
IWI: 917 1641 IRQ work interrupts
RTR: 0 0 APIC ICR read retries
RES: 3961986 8852831 Rescheduling interrupts
CAL: 78741 78971 Function call interrupts
TLB: 20224 18382 TLB shootdowns
TRM: 0 0 Thermal event interrupts
THR: 0 0 Threshold APIC interrupts
DFR: 0 0 Deferred Error APIC interrupts
MCE: 0 0 Machine check exceptions
MCP: 26 27 Machine check polls
ERR: 0
MIS: 0
PIN: 0 0 Posted-interrupt notification event
NPI: 0 0 Nested posted-interrupt event
PIW: 0 0 Posted-interrupt wakeup event
随后我猜测可能是io导致的sys升高,随后我先去看了下dm数据库的写系统调用情况,这边使用到了strace命令去查看
发现,有大量的写请求,并且我也去查了下read,发现read也非常多,大多其中在文件描述符47-56左右,那么我们去看下这些文件描述符都是什么东西
[root@dmsh1 tools]# ps -ef | grep dmserver dmdba 1307 1 36 10:39 ? 00:53:38 /dm8/bin/dmserver path=/dm8/data/DAMENG/dm.ini -noconsole dmdba 1316 1 0 10:39 ? 00:00:07 /opt/dmdbms/bin/dmserver path=/opt/dmdbms/data/DAMENG/dm.ini -noconsole mount root 17744 12787 0 13:05 pts/1 00:00:00 grep --color=auto dmserver [root@dmsh1 tools]# strace -p 1307 -f 2>&1 | grep write 搜索该进程的写系统调用 [pid 1444] <... pwrite64 resumed> ) = 4608 [pid 17584] write(50, "10 273 F 365240 1 "..., 134[pid 17584] <... write resumed> ) = 134 [pid 17582] write(48, "37 273 244237 n "..., 64) = 64 [pid 17582] write(48, "36 273 26 263240 1 "..., 86 [pid 17584] write(50, "7 273 \1 341240 1 "..., 412 [pid 17582] <... write resumed> ) = 86 [pid 17586] write(52, "t 273 t 306237 16 "..., 180) = 180 [pid 17584] <... write resumed> ) = 412 [pid 17590] write(56, " 30 30 "..., 88 [pid 17590] <... write resumed> ) = 88 [pid 17584] write(50, "10 273 M 376240 1 "..., 141 [pid 1444] pwrite64(7, " n |10 337233W2323220JM1 bM20 bM"..., 2560, 154957824 [pid 17584] <... write resumed> ) = 141 [pid 1444] <... pwrite64 resumed> ) = 2560 [pid 17589] write(55, "7 273 X1 345240 1 "..., 408 [pid 17589] <... write resumed> ) = 408 [pid 17586] write(52, "n 273 t 305235 16 "..., 180 [pid 17586] <... write resumed> ) = 180 [pid 17581] write(47, "7 273 Q1 354240 1 "..., 401 [pid 17583] write(49, "7 273 R1 357240 1 "..., 402 [pid 17585] write(51, "16 273 314 y240 1 "..., 268 [pid 17583] <... write resumed> ) = 402 [pid 17585] <... write resumed> ) = 268 [pid 17588] write(54, " 30 30 "..., 88 [pid 17587] write(53, "7 273 N1 363240 1 "..., 398 [pid 17588] <... write resumed> ) = 88 [pid 17587] <... write resumed> ) = 398 [pid 17581] <... write resumed> ) = 401 [pid 1444] pwrite64(7, " 20 (17 337233W2323220JM1 cM20 cM"..., 4096, 154960384 [pid 17583] write(49, "10 273 Z 351240 1 "..., 154 [pid 1444] <... pwrite64 resumed> ) = 4096 [pid 17581] write(47, "10 273 M 376240 1 "..., 141 [pid 17589] write(55, "10 273 c 320240 1 "..., 163 [pid 17589] <... write resumed> ) = 163 [pid 17581] <... write resumed> ) = 141 [pid 17583] <... write resumed> ) = 154 [pid 17588] write(54, "21 273 252237 1 "..., 64 [pid 17586] write(52, " 30 30 "..., 88) = 88 [pid 17585] write(51, "22 273 251237 1 "..., 64 [pid 17586] write(52, "21 273 252237 1 "..., 64 [pid 17586] <... write resumed> ) = 64 [pid 17588] <... write resumed> ) = 64 [pid 17586] write(52, "f 273 ` 327240 1 "..., 160 [pid 17586] <... write resumed> ) = 160 [pid 17585] <... write resumed> ) = 64 [pid 17589] write(55, "7 273 b1 337240 1 "..., 418 [pid 17588] write(54, "f 273 l 333240 1 "..., 172 [pid 17582] write(48, " 273 233237 1 "..., 64 [pid 17582] <... write resumed> ) = 64 [pid 17589] <... write resumed> ) = 418 [pid 17584] write(50, "7 273 Y1 344240 1 "..., 409 [pid 17585] write(51, "24 273 257235 1 "..., 64 [pid 17582] write(48, "32 273 107 256240 377377377377377377377177"..., 1864) = 1864 [pid 17581] write(47, "7 273 [1 346240 1 "..., 411 [pid 17582] write(48, "33 273 240236 1 "..., 64 [pid 17581] <... write resumed> ) = 411 [pid 17582] <... write resumed> ) = 64 [pid 17581] write(47, "10 273 S 340240 1 "..., 147 [pid 17582] write(48, "35 273 246237 1 "..., 64 [pid 17581] <... write resumed> ) = 147 [pid 17582] <... write resumed> ) = 64 [pid 17581] write(47, "7 273 c1 336240 1 "..., 419 [pid 17582] write(48, "34 273 22 265240 1 "..., 82 [pid 17581] <... write resumed> ) = 419 [pid 17582] <... write resumed> ) = 82 [pid 17582] write(48, "37 273 244237 v "..., 64 [pid 17581] write(47, "10 273 ` 323240 1 "..., 160) = 160 [pid 17582] <... write resumed> ) = 64 [pid 17581] write(47, "7 273 [1 346240 1 "..., 411 [pid 17586] write(52, "20 273 253237 1 "..., 64 [pid 17581] <... write resumed> ) = 411 [pid 17588] <... write resumed> ) = 172 [pid 17587] write(53, "t 273 <


