日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

CentOS故障排除详解(2): 进程相关

發(fā)布時間:2023/12/20 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 CentOS故障排除详解(2): 进程相关 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.


在這篇文章中, 將會了解到如何使用ps/vmstat/top等命令確認(rèn)進程相關(guān)信息, 以及使用iotop/iostat/lsof確認(rèn)當(dāng)前信息,以及如何使用systemd在centos下進行服務(wù)的管理。

顯示內(nèi)存信息

命令解釋
free -b以byte單位顯示內(nèi)存信息
free -k以Kbyte單位顯示內(nèi)存信息
free -m以Mbyte單位顯示內(nèi)存信息
free -g以Gbyte單位顯示內(nèi)存信息

顯示swap信息(free)

[root@liumiaocn ~]# free -mtotal used free shared buff/cache available Mem: 977 712 72 2 193 76 Swap: 2047 646 1401 [root@liumiaocn ~]#

顯示swap信息(文件)

[root@liumiaocn ~]# cat /proc/swaps Filename Type Size Used Priority /dev/dm-1 partition 2097148 660212 -1 [root@liumiaocn ~]#

/proc/sys/vm/swappiness

[root@liumiaocn ~]# cat /proc/sys/vm/swappiness 30 [root@liumiaocn ~]# 此值為0-100范圍,30的意思是當(dāng)內(nèi)存70%被使用后,swap內(nèi)存開始使用

swap其他命令

除此之外,還有sysctl -w vm.swappiness=X/swapoff -a/swapon -a等命令可以用于swap相關(guān)操作

vmstat

vmstat也可以用于查看內(nèi)存相關(guān)信息,比如vmstat -a

[root@liumiaocn ~]# vmstat procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----r b swpd free buff cache si so bi bo in cs us sy id wa st3 0 656988 60880 0 213068 255 257 1672 817 279 552 4 2 94 1 0 [root@liumiaocn ~]# 項目說明
siThis column shows the value swapped in from disk
soThis column shows the value swapped out to disk
biThis column shows the value sent to block devices
boThis column shows the value received from block devices
usThis column shows the user time
syThis column shows the system time
idThis column shows the idle time

vmstat 1 2

以1秒為間隔,進行兩次vmstat操作后退出

[root@liumiaocn ~]# vmstat 1 2 procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----r b swpd free buff cache si so bi bo in cs us sy id wa st3 0 659108 83376 0 198864 249 251 1630 797 275 548 3 2 94 1 01 0 659084 83376 0 198888 4 0 4 0 133 411 0 0 100 0 0 [root@liumiaocn ~]#

vmstat 1

以1秒為間隔,一直作vmstat操作

vmstat -t 1 2

以1秒為間隔,進行兩次vmstat操作后退出, 會列出兩次命令執(zhí)行時的時間信息

[root@liumiaocn ~]# vmstat -t 1 2 procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- -----timestamp-----r b swpd free buff cache si so bi bo in cs us sy id wa st EST4 0 656952 80324 0 199540 245 247 1603 784 273 545 3 2 94 1 0 2017-01-22 19:11:050 0 656948 80324 0 199528 0 0 0 0 107 353 0 0 100 0 0 2017-01-22 19:11:06 [root@liumiaocn ~]#

vmstat -S M 1 2

以MB為單位顯示結(jié)果信息

[root@liumiaocn ~]# vmstat -S M 1 2 procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----r b swpd free buff cache si so bi bo in cs us sy id wa st6 0 639 75 0 195 0 0 1578 772 270 543 3 2 94 1 01 0 639 75 0 195 0 0 4 0 116 377 1 1 98 0 0 [root@liumiaocn ~]# vmstat 1 2 procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----r b swpd free buff cache si so bi bo in cs us sy id wa st3 0 654568 77408 0 199792 242 242 1576 771 270 542 3 2 94 1 00 0 654564 77408 0 199792 0 0 0 0 123 373 0 1 99 0 0 [root@liumiaocn ~]#

top命令

top命令時用來檢查系統(tǒng)RAM和CPU信息的標(biāo)準(zhǔn)命令。

top -u admin

顯示出admin用戶所有的信息

top -n 2

兩次循環(huán)之后推出top命令

iotop

iotop命令可以用來監(jiān)視磁盤I/O,最小安裝不包含該命令,所以需要用如下命令進行安裝

yum install iotop 命令說明
iotop顯示磁盤I/O相關(guān)信息
iotop -o僅顯示活動中的磁盤I/O的相關(guān)信息

iostat

iostat像vmstat一樣,只不過iostat是用于CPU以及磁盤I/O相關(guān)信息確認(rèn)

[root@liumiaocn ~]# iostat Linux 3.10.0-327.el7.x86_64 (liumiaocn) 01/22/2017 _x86_64_ (1 CPU)avg-cpu: %user %nice %system %iowait %steal %idle2.89 0.01 1.51 0.45 0.00 95.14Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn sda 35.87 1068.79 475.86 8833449 3932944 scd0 0.00 0.01 0.00 44 0 dm-0 24.45 863.54 269.25 7137068 2225343 dm-1 102.71 204.56 206.36 1690640 1705540 dm-2 18.11 264.64 187.13 2187192 1546636 dm-3 10.58 204.14 27.12 1687240 224155[root@liumiaocn ~]#

iostat -c 1

每隔1秒輸出cpu相關(guān)信息

[root@liumiaocn ~]# iostat -c 1 Linux 3.10.0-327.el7.x86_64 (liumiaocn) 01/22/2017 _x86_64_ (1 CPU)avg-cpu: %user %nice %system %iowait %steal %idle2.83 0.01 1.48 0.44 0.00 95.24avg-cpu: %user %nice %system %iowait %steal %idle0.00 0.00 1.02 0.00 0.00 98.98avg-cpu: %user %nice %system %iowait %steal %idle1.03 0.00 0.00 0.00 0.00 98.97 ...

iostat 1

每1秒輸出一次信息

iostat -t 1

每1秒輸出一次信息,同時輸出時間信息

lsof

lsof = list open file。 一般用于故障排除時已知某一端口被使用,順藤摸瓜找到使用此端口的進程時非常有效

uptime

用以確認(rèn)系統(tǒng)啟動的時間

systemd相關(guān)

命令說明
systemctl status service確認(rèn)
systemctl start service啟動
systemctl stop service停止
systemctl enable service有效
systemctl disable service無效
systemd-cgtop按照使用量列出cgroup信息
systemd-cgls列出cgroup信息
systemctl list-units --type service列出service
systemctl list-units --type mounttype mount
systemctl list-dependencies .service依賴

參考文檔

The Red Hat Enterprise Linux 7 System Administrators guide:
https://access.redhat.com/documentation/enUS/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/chapManaging_Services_with_systemd.html
The Swappiness Wikipedia page:
http://en.wikipedia.org/wiki/Swappiness
The vmstat command Wikipedia page:
http://en.wikipedia.org/wiki/Vmstat
The iostat command Wikipedia page:
http://en.wikipedia.org/wiki/Iostat
The lsof command Wikipedia page:
http://en.wikipedia.org/wiki/Lsof
The kill command Wikipedia page:
http://en.wikipedia.org/wiki/Kill_(command)
The pkill command Wikipedia page:
http://en.wikipedia.org/wiki/Pkill
SysVinit to Systemd Cheatsheet:
https://fedoraproject.org/wiki/SysVinit_to_Systemd_Cheatsheet
The Orphans Wikipedia page:
http://en.wikipedia.org/wiki/Orphan_process

總結(jié)

以上是生活随笔為你收集整理的CentOS故障排除详解(2): 进程相关的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。