主頁 >  其他 > 關于 Linux中系統調優的一些筆記

關于 Linux中系統調優的一些筆記

2021-10-25 08:47:50 其他

寫在前面


  • 推送的的郵件里看到有大佬講的公共課,聽了之后這里整理學習筆記,
  • 因為是公開課,所以講的很淺,沒接觸過,這里做為了解,長長見識,

博文內容包括
系統調優原理概述
如何檢測系統的性能瓶頸
如何進行內核引數調優
如何限制服務的資源占用
自定義tuned調優配置集

我突然又明白,死亡是聰明的兄長,我們可以放心地把自己托付給他,他會知道在我們有所準備的適當時刻前來,我也突然懂得,原來痛苦、失望和悲愁不是為了惹惱我們,使我們氣餒或者無地自容;它們的存在,是為了使我們心智成熟,臻于完善,—赫爾曼·黑塞《彼得·卡門青》


零、系統調優原理概述:

通過調整系統設定來提高計算機資源的利用率資料吞吐量用戶體驗的程序,消除或減輕系統中的排隊現象

分析系統性能的方法:

分析利用率、飽和、錯誤 (Utilization, Saturation and Errors (USE))和系統資源
資源 Resource服務器中的硬體資源(CPU、記憶體、網路、 磁盤和控制器)
利用率 Utilization資源提供服務的平均時間(70%)
飽和度 Saturation資源承擔額外作業量的能力,這類作業通常 排隊(佇列長度)
錯誤 Errors錯誤事件數量

執行系統變更的步驟:

執行系統變更的步驟
設定基線:在調優中,執行性能測驗,收集指標
執行變更:在系統上執行變更,建議查閱相應官方檔案
驗證變更有效性:執行變更后,重新運行測驗,比較一些關鍵指標
取消變更并與基線對比:如有需要,可以取消變更并回傳到基線狀態
應用最終更改:應用并記錄最終變更

一、如何檢測系統的性能瓶頸

1、檢測系統當前運行負載:vmstat、mpstat、iostat、top 等

裝包,一般不需要

yum install -y sysstat

sysstat包含監測系統性能及效率的一組工具,這些工具對于我們收集系統性能資料,比如 CPU 使用率、硬碟和網路吞吐資料,這些資料的收集和分析,有利于我們判斷系統是否正常運行,是提高系統運行效率、安全運行服務器的得力助手,

vmstat 記憶體子系統監控

┌──[root@liruilongs.github.io]-[~]
└─$ vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 1  0      0 3228884   2076 594152    0    0    10     6  102  152  0  0 100  0  0
┌──[root@liruilongs.github.io]-[~]
└─$ vmstat 1
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 1  0      0 3228852   2076 594184    0    0    10     6  102  152  0  0 100  0  0  # 平均值
 0  0      0 3228852   2076 594184    0    0     0     0  197  289  0  1 99  0  0
 0  0      0 3228852   2076 594184    0    0     0     0  192  290  0  0 100  0  0
 1  0      0 3228852   2076 594184    0    0     0     0  180  285  0  0 100  0  0
 0  0      0 3228852   2076 594184    0    0     0     0  174  276  1  0 99  0  0
 0  0      0 3228852   2076 594184    0    0     0     0  173  267  0  0 100  0  0
 0  0      0 3228852   2076 594184    0    0     0     0  176  268  0  0 100  0  0
 0  0      0 3228852   2076 594184    0    0     0     0  173  274  0  0 100  0  0
^C
┌──[root@liruilongs.github.io]-[~]
└─$

mpstat CUP子系統監控

┌──[root@liruilongs.github.io]-[~]
└─$ mpstat 1
Linux 3.10.0-693.el7.x86_64 (liruilongs.github.io)      10/23/2021      _x86_64_        (2 CPU)

01:41:22 AM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
01:41:23 AM  all    0.52    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00   99.48
01:41:24 AM  all    0.00    0.00    0.51    0.00    0.00    0.00    0.00    0.00    0.00   99.49
01:41:25 AM  all    0.00    0.00    0.00    0.00    0.00    0.52    0.00    0.00    0.00   99.48
01:41:26 AM  all    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
01:41:27 AM  all    0.00    0.00    0.52    0.00    0.00    0.00    0.00    0.00    0.00   99.48
01:41:28 AM  all    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
01:41:29 AM  all    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
^C
Average:     all    0.07    0.00    0.15    0.00    0.00    0.07    0.00    0.00    0.00   99.71
┌──[root@liruilongs.github.io]-[~]
└─$ mpstat 1 3
Linux 3.10.0-693.el7.x86_64 (liruilongs.github.io)      10/23/2021      _x86_64_        (2 CPU)

01:42:06 AM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
01:42:07 AM  all    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
01:42:08 AM  all    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
01:42:09 AM  all    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
Average:     all    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
┌──[root@liruilongs.github.io]-[~]
└─$

iostat IO子系統監控

┌──[root@liruilongs.github.io]-[~]
└─$ iostat 1 3
Linux 3.10.0-693.el7.x86_64 (liruilongs.github.io)      10/23/2021      _x86_64_        (2 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.21    0.00    0.24    0.05    0.00   99.50

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sda               0.56        19.86        12.15     387999     237243

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.00    0.00    0.00    0.52    0.00   99.48

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sda               1.00         8.00         0.00          8          0

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.00    0.00    0.00    0.00    0.00  100.00

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sda               0.00         0.00         0.00          0          0

┌──[root@liruilongs.github.io]-[~]
└─$

top 綜合情況監控

top - 01:46:43 up  5:29,  1 user,  load average: 0.01, 0.02, 0.05
Tasks: 151 total,   1 running, 150 sleeping,   0 stopped,   0 zombie
%Cpu0  :  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu1  :  0.3 us,  0.0 sy,  0.0 ni, 99.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  4030172 total,  3227596 free,   205988 used,   596588 buff/cache
KiB Swap: 10485756 total, 10485756 free,        0 used.  3531292 avail Mem

   PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
   844 etcd      20   0 10.308g  22996  11100 S   2.7  0.6  11:10.71 etcd
   572 root      20   0  220312   5208   3508 S   0.3  0.1   0:06.03 rsyslogd
   592 root      20   0  298868   6260   4916 S   0.3  0.2   1:32.71 vmtoolsd
     1 root      20   0  125408   3836   2440 S   0.0  0.1   0:09.03 systemd
     2 root      20   0       0      0      0 S   0.0  0.0   0:00.07 kthreadd
     3 root      20   0       0      0      0 S   0.0  0.0   0:00.61 ksoftirqd/0
     5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:0H
     7 root      rt   0       0      0      0 S   0.0  0.0   0:00.27 migration/0
     8 root      20   0       0      0      0 S   0.0  0.0   0:00.00 rcu_bh
     9 root      20   0       0      0      0 S   0.0  0.0   0:05.72 rcu_sched
    10 root      rt   0       0      0      0 S   0.0  0.0   0:01.25 watchdog/0
    11 root      rt   0       0      0      0 S   0.0  0.0   0:01.15 watchdog/1
    12 root      rt   0       0      0      0 S   0.0  0.0   0:00.17 migration/1
    13 root      20   0       0      0      0 S   0.0  0.0   0:00.54 ksoftirqd/1
    15 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/1:0H
    17 root      20   0       0      0      0 S   0.0  0.0   0:00.05 kdevtmpfs
    18 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 netns
    19 root      20   0       0      0      0 S   0.0  0.0   0:00.03 khungtaskd
    20 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 writeback
    21 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kintegrityd
    22 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 bioset
    23 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kblockd
  • load average: 0.01 不能超過 0.7
  • 需要除以 cpu核數 ;數字1

2、檢測系統歷史運行負載:sar

┌──[root@liruilongs.github.io]-[/usr/lib/systemd/system]
└─$ pwd
/usr/lib/systemd/system
┌──[root@liruilongs.github.io]-[/usr/lib/systemd/system]
└─$ cat sysstat.service
# /usr/lib/systemd/system/sysstat.service
# (C) 2012 Peter Schiffer (pschiffe <at> redhat.com)
#
# sysstat-10.1.5 systemd unit file:
#        Insert a dummy record in current daily data file.
#        This indicates that the counters have restarted from 0.

[Unit]
Description=Resets System Activity Logs

[Service]
Type=oneshot
RemainAfterExit=yes
User=root
ExecStart=/usr/lib64/sa/sa1 --boot

[Install]
WantedBy=multi-user.target

┌──[root@liruilongs.github.io]-[/usr/lib/systemd/system]
└─$ systemctl status  sysstat.service
● sysstat.service - Resets System Activity Logs
   Loaded: loaded (/usr/lib/systemd/system/sysstat.service; enabled; vendor preset: enabled)
   Active: active (exited) since Wed 2021-10-13 01:53:41 CST; 1 weeks 3 days ago
 Main PID: 584 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/sysstat.service

Oct 13 01:53:41 liruilongs.github.io systemd[1]: Starting Resets System Activity Logs...
Oct 13 01:53:41 liruilongs.github.io systemd[1]: Started Resets System Activity Logs.

紅帽8沒有,需要自己開啟,紅帽7有

┌──[root@liruilongs.github.io]-[/]
└─$ cd /var/log/sa
┌──[root@liruilongs.github.io]-[/var/log/sa]
└─$ ls
sa01  sa03  sa04  sa05  sa06  sa08  sa09  sa13  sa14  sa23  sa24  sa30  sar03

CPU 監控資訊

┌──[root@liruilongs.github.io]-[/var/log/sa]
└─$ sar -f sa24 -p # CPU 監控資訊
Linux 3.10.0-693.el7.x86_64 (liruilongs.github.io)      10/24/2021      _x86_64_        (2 CPU)

08:14:46 AM       LINUX RESTART

08:20:03 AM     CPU     %user     %nice   %system   %iowait    %steal     %idle
09:40:01 AM     all      1.44      0.00      1.72      0.21      0.00     96.64
09:50:01 AM     all      0.80      0.00      1.51      0.01      0.00     97.69
10:00:01 AM     all      0.81      0.00      1.56      0.00      0.00     97.63
10:10:01 AM     all      0.74      0.00      1.40      0.02      0.00     97.83
10:20:01 AM     all      0.65      0.00      1.26      0.00      0.00     98.08
10:30:01 AM     all      0.78      0.02      1.50      0.04      0.00     97.67
10:40:01 AM     all      3.24      0.00      5.65      0.01      0.00     91.11
Average:        all      1.18      0.00      2.10      0.03      0.00     96.69

負載資訊

┌──[root@liruilongs.github.io]-[/var/log/sa]
└─$ sar -f sa24 -q #  負載資訊
Linux 3.10.0-693.el7.x86_64 (liruilongs.github.io)      10/24/2021      _x86_64_        (2 CPU)

08:14:46 AM       LINUX RESTART

08:20:03 AM   runq-sz  plist-sz   ldavg-1   ldavg-5  ldavg-15   blocked
09:40:01 AM         0       215      0.06      0.40      0.42         0
09:50:01 AM         0       215      0.41      0.21      0.28         0
10:00:01 AM         1       215      0.27      0.13      0.20         0
10:10:01 AM         1       216      0.03      0.08      0.14         0
10:20:01 AM         0       216      0.00      0.04      0.10         0
10:30:01 AM         1       217      0.00      0.03      0.06         0
10:40:01 AM         0       215      0.07      0.16      0.14         0
Average:            0       216      0.12      0.15      0.19         0

記憶體資訊

┌──[root@liruilongs.github.io]-[/var/log/sa]
└─$ sar -f sa24 -r #  記憶體資訊
Linux 3.10.0-693.el7.x86_64 (liruilongs.github.io)      10/24/2021      _x86_64_        (2 CPU)

08:14:46 AM       LINUX RESTART

08:20:03 AM kbmemfree kbmemused  %memused kbbuffers  kbcached  kbcommit   %commit  kbactive   kbinact   kbdirty
09:40:01 AM   3472808    557364     13.83      2076    266132    832840      5.74    157400    244716         8
09:50:01 AM   3470960    559212     13.88      2076    266516    832840      5.74    158004    244652         4
10:00:01 AM   3466736    563436     13.98      2076    270432    832972      5.74    158272    248436         0
10:10:01 AM   3465552    564620     14.01      2076    270856    833480      5.74    159624    247772         0
10:20:01 AM   3465732    564440     14.01      2076    271172    833584      5.74    159720    248028         0
10:30:01 AM   3457092    573080     14.22      2076    272904    833772      5.74    161872    247732         0
10:40:01 AM   3458440    571732     14.19      2076    271864    833032      5.74    160824    247256         0
Average:      3465331    564841     14.02      2076    269982    833217      5.74    159388    246942         2

網卡資訊

┌──[root@liruilongs.github.io]-[/var/log/sa]
└─$ sar -f sa24 -n DEV #  網卡資訊
Linux 3.10.0-693.el7.x86_64 (liruilongs.github.io)      10/24/2021      _x86_64_        (2 CPU)

08:14:46 AM       LINUX RESTART

08:20:03 AM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
09:40:01 AM br-4b3da203747c      0.00      0.00      0.00      0.00      0.00      0.00      0.00
09:40:01 AM     ens32      0.34      0.37      0.04      0.33      0.00      0.00      0.00
09:40:01 AM        lo      0.13      0.13      0.01      0.01      0.00      0.00      0.00
09:40:01 AM   docker0      0.00      0.00      0.00      0.00      0.00      0.00      0.00
09:50:01 AM br-4b3da203747c      0.00      0.00      0.00      0.00      0.00      0.00      0.00
09:50:01 AM     ens32      1.19      0.78      0.10      0.36      0.00      0.00      0.00
09:50:01 AM        lo      0.13      0.13      0.01      0.01      0.00      0.00      0.00
09:50:01 AM   docker0      0.00      0.00      0.00      0.00      0.00      0.00      0.00
10:00:01 AM br-4b3da203747c      0.00      0.00      0.00      0.00      0.00      0.00      0.00
10:00:01 AM     ens32      0.20      0.13      0.02      0.01      0.00      0.00      0.00
10:00:01 AM        lo      0.13      0.13      0.01      0.01      0.00      0.00      0.00
10:00:01 AM   docker0      0.00      0.00      0.00      0.00      0.00      0.00      0.00
10:10:01 AM br-4b3da203747c      0.00      0.00      0.00      0.00      0.00      0.00      0.00
10:10:01 AM     ens32      0.49      0.50      0.04      0.54      0.00      0.00      0.00
10:10:01 AM        lo      0.13      0.13      0.01      0.01      0.00      0.00      0.00
10:10:01 AM   docker0      0.00      0.00      0.00      0.00      0.00      0.00      0.00
10:20:01 AM br-4b3da203747c      0.00      0.00      0.00      0.00      0.00      0.00      0.00
10:20:01 AM     ens32      0.17      0.11      0.01      0.01      0.00      0.00      0.00
10:20:01 AM        lo      0.13      0.13      0.01      0.01      0.00      0.00      0.00
10:20:01 AM   docker0      0.00      0.00      0.00      0.00      0.00      0.00      0.00
10:30:01 AM br-4b3da203747c      0.00      0.00      0.00      0.00      0.00      0.00      0.00
10:30:01 AM     ens32      0.04      0.03      0.00      0.00      0.00      0.00      0.00
10:30:01 AM        lo      0.13      0.13      0.01      0.01      0.00      0.00      0.00
10:30:01 AM   docker0      0.00      0.00      0.00      0.00      0.00      0.00      0.00
10:40:01 AM br-4b3da203747c      0.00      0.00      0.00      0.00      0.00      0.00      0.00
10:40:01 AM     ens32      0.08      0.06      0.01      0.00      0.00      0.00      0.00
10:40:01 AM        lo      0.13      0.13      0.01      0.01      0.00      0.00      0.00
10:40:01 AM   docker0      0.00      0.00      0.00      0.00      0.00      0.00      0.00

Average:        IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
Average:    br-4b3da203747c      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:        ens32      0.36      0.28      0.03      0.17      0.00      0.00      0.00
Average:           lo      0.13      0.13      0.01      0.01      0.00      0.00      0.00
Average:      docker0      0.00      0.00      0.00      0.00      0.00      0.00      0.00
┌──[root@liruilongs.github.io]-[/var/log/sa]
└─$

3、通過 Performance Co-Pilot(PCP) 收集性能資料

安裝相關包

┌──[root@liruilongs.github.io]-[/usr/lib/systemd/system]
└─$ yum -y install pcp
┌──[root@liruilongs.github.io]-[/usr/lib/systemd/system]
└─$ yum install pcp-gui -y

啟動相關服務

┌──[root@liruilongs.github.io]-[/usr/lib/systemd/system]
└─$ systemctl enable --now pmcd # 啟動監控服務
Created symlink from /etc/systemd/system/multi-user.target.wants/pmcd.service to /usr/lib/systemd/system/pmcd.service.
┌──[root@liruilongs.github.io]-[/usr/lib/systemd/system]
└─$ systemctl enable --now pmlogger # 啟動存資料的資料庫
Created symlink from /etc/systemd/system/multi-user.target.wants/pmlogger.service to /usr/lib/systemd/system/pmlogger.service.
┌──[root@liruilongs.github.io]-[/usr/lib/systemd/system]

通過pmchart,pminfo,pmval讀取系統當前及歷史運行資料

查看所有的監控內容

┌──[root@liruilongs.github.io]-[~]  
└─$ pminfo
jbd2.njournals
jbd2.transaction.count
jbd2.transaction.requested
......
┌──[root@liruilongs.github.io]-[~]
└─$ pminfo | wc -l
2052

查看所有的監控引數詳細資訊

┌──[root@liruilongs.github.io]-[~]
└─$ pminfo -dt proc.nprocs #引數詳細資訊

proc.nprocs [instantaneous number of processes]
    Data Type: 32-bit unsigned int  InDom: PM_INDOM_NULL 0xffffffff
    Semantics: instant  Units: none
┌──[root@liruilongs.github.io]-[~]
└─$ pminfo  proc.nprocs #行程監控
proc.nprocs

監控行程資訊 pmval proc.nprocs

┌──[root@liruilongs.github.io]-[~]
└─$ pmval  proc.nprocs #行程監控

metric:    proc.nprocs
host:      liruilongs.github.io
semantics: instantaneous value
units:     none
samples:   all
        158
        158
        158
        158
        158
        158
^C

監控剩余記憶體的量 pmval -t 2 mem.freemem

┌──[root@liruilongs.github.io]-[~]
└─$ pmval  -t 2 mem.freemem # 剩余記憶體資訊

metric:    mem.freemem
host:      liruilongs.github.io
semantics: instantaneous value
units:     Kbyte
samples:   all
              3471612
              3471636
              3471636
              3471636
              3471636
^C
┌──[root@liruilongs.github.io]-[~]
└─$

查看監控日志

┌──[root@liruilongs.github.io]-[~]
└─$ pminfo | grep mem.freemem
mem.freemem
┌──[root@liruilongs.github.io]-[~]
└─$ cd /var/log/pcp
┌──[root@liruilongs.github.io]-[/var/log/pcp]
└─$ ls
NOTICES  pmcd  pmie  pmlogger  pmproxy
┌──[root@liruilongs.github.io]-[/var/log/pcp]
└─$ cd pmlogger/
┌──[root@liruilongs.github.io]-[/var/log/pcp/pmlogger]
└─$ ls
liruilongs.github.io  pmlogger_check.log.prev  pmlogger_daily-K.log.prev  pmlogger_daily.stamp
┌──[root@liruilongs.github.io]-[/var/log/pcp/pmlogger]
└─$ cd liruilongs.github.io/
┌──[root@liruilongs.github.io]-[/var/log/pcp/pmlogger/liruilongs.github.io]
└─$ ls
20211023.02.05.0.xz     20211023.02.30-00.0.xz     20211023.02.30.0.xz     20211024.08.16.0      Latest
20211023.02.05.index    20211023.02.30-00.index    20211023.02.30.index    20211024.08.16.index  pmlogger.log
20211023.02.05.meta.xz  20211023.02.30-00.meta.xz  20211023.02.30.meta.xz  20211024.08.16.meta   pmlogger.log.prior
┌──[root@liruilongs.github.io]-[/var/log/pcp/pmlogger/liruilongs.github.io]
└─$ pmval -a 20211024.08.16.0 mem.freemem  # 查看監控日志 每秒

metric:    mem.freemem
archive:   20211024.08.16.0
host:      liruilongs.github.io
start:     Sun Oct 24 08:17:06 2021
end:       Sun Oct 24 10:02:06 2021
semantics: instantaneous value
units:     Kbyte
samples:   6301
interval:  1.00 sec
08:17:06.095  No values available
08:17:07.095  No values available
08:17:08.095              3651184
08:17:09.095              3651184
08:17:10.095              3651184
08:17:11.095              3651184
08:17:12.095              3651184
08:17:13.095              3651184
08:17:14.095              3651184
08:17:15.095              3651184
08:17:16.095              3651184
08:17:17.095              3651184
08:17:18.095              3651184
08:17:19.095              3651184
08:17:20.095              3651184
08:17:21.095              3651184
08:17:22.095              3651184
08:17:23.095              3651184
08:17:24.095              3651184
08:17:25.095              3651184
08:17:26.095              3651184
......

加時間粒度

┌──[root@liruilongs.github.io]-[/var/log/pcp/pmlogger/liruilongs.github.io]
└─$ pmval -a 20211024.08.16.0 -t 500 mem.freemem  # 加時間粒度

metric:    mem.freemem
archive:   20211024.08.16.0
host:      liruilongs.github.io
start:     Sun Oct 24 08:17:06 2021
end:       Sun Oct 24 10:08:06 2021
semantics: instantaneous value
units:     Kbyte
samples:   14
interval:  500.00 sec
08:17:06.095  No values available
08:25:26.095              3488128
08:33:46.095              3488128
08:42:06.095              3488128
08:50:26.095              3488128
08:58:46.095              3488128
09:07:06.095              3488128
09:15:26.095              3488128
09:23:46.095              3488128
09:32:06.095              3488128
09:40:26.095              3472784
09:48:46.095              3472024
09:57:06.095              3467052
10:05:26.095              3466276
┌──[root@liruilongs.github.io]-[/var/log/pcp/pmlogger/liruilongs.github.io]
└─$

二、如何進行內核引數調優

/proc & /sys

/proc 存放記憶體中資料,每次重啟就沒了,

┌──[root@liruilongs.github.io]-[/]
└─$ cd proc/
┌──[root@liruilongs.github.io]-[/proc]
└─$ ls
1      16836  241  269  284  3    313  362  45   647   853        crypto       keys        pagetypeinfo   tty
10     16842  242  270  285  300  314  363  469  649   856        devices      key-users   partitions     uptime
1041   16843  250  271  286  301  315  364  47   66    857        diskstats    kmsg        sched_debug    version
1043   16850  251  272  287  302  316  365  5    6671  861        dma          kpagecount  schedstat      vmallocinfo
1045   16862  253  273  288  303  317  366  506  7     864        driver       kpageflags  scsi           vmstat
1050   17     254  274  289  304  318  367  509  7603  8922       execdomains  loadavg     self           zoneinfo
1051   18     255  275  290  305  319  368  570  7604  9          fb           locks       slabinfo
1054   19     256  276  291  306  32   369  581  7606  98         filesystems  mdstat      softirqs
1055   2      262  277  292  307  320  370  583  8     acpi       fs           meminfo     stat
1056   20     263  278  293  308  321  371  585  8095  buddyinfo  interrupts   misc        swaps
11     21     264  279  294  309  322  372  594  8158  bus        iomem        modules     sys
12     22     265  280  295  31   33   373  595  8159  cgroups    ioports      mounts      sysrq-trigger
13     23     266  281  296  310  34   42   596  8160  cmdline    irq          mpt         sysvipc
15     24     267  282  298  311  348  44   627  8161  consoles   kallsyms     mtrr        timer_list
16006  240    268  283  299  312  361  441  642  8162  cpuinfo    kcore        net         timer_stats
┌──[root@liruilongs.github.io]-[/proc]
└─$ pwd
/proc
┌──[root@liruilongs.github.io]-[/proc]
└─$ cd sys
┌──[root@liruilongs.github.io]-[/proc/sys]
└─$ ls
abi  crypto  debug  dev  fs  kernel  net  user  vm

記憶體調優目錄

┌──[root@liruilongs.github.io]-[/proc/sys]
└─$ cd vm # 記憶體調優目錄
┌──[root@liruilongs.github.io]-[/proc/sys/vm]
└─$ ls
admin_reserve_kbytes       hugepages_treat_as_movable  mmap_min_addr             overcommit_memory
block_dump                 hugetlb_shm_group           mmap_rnd_bits             overcommit_ratio
compact_memory             laptop_mode                 mmap_rnd_compat_bits      page-cluster
dirty_background_bytes     legacy_va_layout            nr_hugepages              panic_on_oom
dirty_background_ratio     lowmem_reserve_ratio        nr_hugepages_mempolicy    percpu_pagelist_fraction
dirty_bytes                max_map_count               nr_overcommit_hugepages   stat_interval
dirty_expire_centisecs     memory_failure_early_kill   nr_pdflush_threads        swappiness
dirty_ratio                memory_failure_recovery     numa_zonelist_order       user_reserve_kbytes
dirty_writeback_centisecs  min_free_kbytes             oom_dump_tasks            vfs_cache_pressure
drop_caches                min_slab_ratio              oom_kill_allocating_task  zone_reclaim_mode
extfrag_threshold          min_unmapped_ratio          overcommit_kbytes
┌──[root@liruilongs.github.io]-[/proc/sys/vm]
└─$

查看內核引數:cat & sysctl -a

┌──[root@liruilongs.github.io]-[/proc/sys/vm]
└─$ sysctl -a  # 查看所有調優引數
abi.vsyscall32 = 1
crypto.fips_enabled = 0
debug.exception-trace = 1
debug.kprobes-optimization = 1
debug.panic_on_rcu_stall = 0
dev.hpet.max-user-freq = 64
dev.mac_hid.mouse_button2_keycode = 97
dev.mac_hid.mouse_button3_keycode = 100
dev.mac_hid.mouse_button_emulation = 0
dev.parport.default.spintime = 500
dev.parport.default.timeslice = 200
dev.raid.speed_limit_max = 200000
dev.raid.speed_limit_min = 1000
dev.scsi.logging_level = 0
fs.aio-max-nr = 65536
fs.aio-nr = 0
..............

根據變數找對應檔案引數

┌──[root@liruilongs.github.io]-[/proc/sys/vm]
└─$ sysctl -a | grep net.ipv4.ip_forward
net.ipv4.ip_forward = 1
net.ipv4.ip_forward_use_pmtu = 0
sysctl: reading key "net.ipv6.conf.all.stable_secret"
sysctl: reading key "net.ipv6.conf.br-4b3da203747c.stable_secret"
sysctl: reading key "net.ipv6.conf.default.stable_secret"
sysctl: reading key "net.ipv6.conf.docker0.stable_secret"
sysctl: reading key "net.ipv6.conf.ens32.stable_secret"
sysctl: reading key "net.ipv6.conf.lo.stable_secret"
┌──[root@liruilongs.github.io]-[/proc/sys/vm]
└─$ cd ../net/ipv
ipv4/ ipv6/
┌──[root@liruilongs.github.io]-[/proc/sys/vm]
└─$ cd ../net/ipv4/
┌──[root@liruilongs.github.io]-[/proc/sys/net/ipv4]
└─$ cat ip_forward
1

調整內核引數:echo & sysctl

設定調優引數:臨時調整

┌──[root@liruilongs.github.io]-[/proc/sys/vm]
└─$ cat swappiness
30
┌──[root@liruilongs.github.io]-[/proc/sys/vm]
└─$ echo 40 > swappiness  ## 臨時調整
┌──[root@liruilongs.github.io]-[/proc/sys/vm]
└─$ cat swappiness
40

設定調優引數:永久調整

┌──[root@liruilongs.github.io]-[/proc/sys/vm]
└─$ cat /etc/sysc
sysconfig/   sysctl.conf  sysctl.d/
┌──[root@liruilongs.github.io]-[/proc/sys/vm]
└─$ cat /etc/sysctl.conf
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
net.ipv4.ip_forward = 1
┌──[root@liruilongs.github.io]-[/proc/sys/vm]
└─$ echo "vm.swappiness = 20" >>  /etc/sysctl.conf  ## 永久調整
┌──[root@liruilongs.github.io]-[/proc/sys/vm]
└─$ cat /etc/sysctl.conf
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
net.ipv4.ip_forward = 1
vm.swappiness = 20
┌──[root@liruilongs.github.io]-[/proc/sys/vm]
└─$ sysctl -p
net.ipv4.ip_forward = 1
vm.swappiness = 20
┌──[root@liruilongs.github.io]-[/proc/sys/vm]
└─$

內核調優之清理快取

如何使用幫助調整內核引數

┌──[root@liruilongs.github.io]-[/proc/sys/vm]
└─$ man -K drop_caches
--Man-- next: proc(5) [ view (return) | skip (Ctrl-D) | quit (Ctrl-C) ]
清理快取
在這里插入圖片描述
在這里插入圖片描述
┌──[root@liruilongs.github.io]-[/proc/sys/vm]
└─$ cat drop_caches  #快取處理
0
┌──[root@liruilongs.github.io]-[/proc/sys/vm]
└─$ man -K drop_caches
No manual entry for drop_caches
┌──[root@liruilongs.github.io]-[/proc/sys/vm]
└─$ man -K drop_caches
No manual entry for drop_caches
┌──[root@liruilongs.github.io]-[/proc/sys/vm]
└─$ man -K ip_forward
┌──[root@liruilongs.github.io]-[/proc/sys/vm]
└─$ free -m
              total        used        free      shared  buff/cache   available
Mem:           3935         212        3357          16         366        3440
Swap:         10239           0       10239
┌──[root@liruilongs.github.io]-[/proc/sys/vm]
└─$ echo 3 > /proc/sys/vm/drop_caches
┌──[root@liruilongs.github.io]-[/proc/sys/vm]
└─$ free -m
              total        used        free      shared  buff/cache   available
Mem:           3935         200        3575          16         159        3504
Swap:         10239           0       10239
┌──[root@liruilongs.github.io]-[/proc/sys/vm]
└─$

調整內核模塊引數:lsmod、modinfo、modprobe

加載的內核模塊串列 lsmod

┌──[root@liruilongs.github.io]-[/proc/sys/vm]
└─$ lsmod               # 大小 呼叫次數
Module                  Size  Used by
binfmt_misc            17468  1
xt_conntrack           12760  2
ipt_MASQUERADE         12678  2
nf_nat_masquerade_ipv4    13412  1 ipt_MASQUERADE
nf_conntrack_netlink    40449  0
nfnetlink              14696  2 nf_conntrack_netlink
xt_addrtype            12676  2
iptable_filter         12810  1
iptable_nat            12875  1
nf_conntrack_ipv4      15053  3
nf_defrag_ipv4         12729  1 nf_conntrack_ipv4
,,,,,
,,,,,,
crct10dif_common       12595  3 crct10dif_pclmul,crct10dif_generic,crc_t10dif
crc32c_intel           22079  1
ahci                   34042  0
drm                   370825  2 ttm,drm_kms_helper
libahci                31992  1 ahci
mptspi                 22542  2
ata_piix               35038  0
scsi_transport_spi     30732  1 mptspi
mptscsih               40150  1 mptspi
libata                238896  5 ahci,pata_acpi,libahci,ata_generic,ata_piix
e1000                 137500  0
serio_raw              13413  0
mptbase               105960  2 mptspi,mptscsih
i2c_core               40756  3 drm,i2c_piix4,drm_kms_helper
┌──[root@liruilongs.github.io]-[/proc/sys/vm]
└─$

查看內核模塊引數 modinfo

┌──[root@liruilongs.github.io]-[/proc/sys/vm]
└─$ modinfo kvm # 查看內核模塊引數
filename:       /lib/modules/3.10.0-693.el7.x86_64/kernel/arch/x86/kvm/kvm.ko.xz
license:        GPL
author:         Qumranet
rhelversion:    7.4
srcversion:     FA3AAB0FB1DD5C7B9D69811
depends:        irqbypass
intree:         Y
vermagic:       3.10.0-693.el7.x86_64 SMP mod_unload modversions
signer:         CentOS Linux kernel signing key
sig_key:        DA:18:7D:CA:7D:BE:53:AB:05:BD:13:BD:0C:4E:21:F4:22:B6:A4:9C
sig_hashalgo:   sha256
parm:           ignore_msrs:bool
parm:           min_timer_period_us:uint
parm:           kvmclock_periodic_sync:bool
parm:           tsc_tolerance_ppm:uint
parm:           lapic_timer_advance_ns:uint
parm:           vector_hashing:bool
parm:           halt_poll_ns:uint
parm:           halt_poll_ns_grow:uint
parm:           halt_poll_ns_shrink:uint
┌──[root@liruilongs.github.io]-[/proc/sys/vm]
└─$

內核模塊調優之嵌套虛擬化設定

┌──[root@liruilongs.github.io]-[/proc/sys/vm]
└─$ modinfo kvm
filename:       /lib/modules/3.10.0-693.el7.x86_64/kernel/arch/x86/kvm/kvm.ko.xz
license:        GPL
author:         Qumranet
rhelversion:    7.4
srcversion:     FA3AAB0FB1DD5C7B9D69811
depends:        irqbypass
intree:         Y
vermagic:       3.10.0-693.el7.x86_64 SMP mod_unload modversions
signer:         CentOS Linux kernel signing key
sig_key:        DA:18:7D:CA:7D:BE:53:AB:05:BD:13:BD:0C:4E:21:F4:22:B6:A4:9C
sig_hashalgo:   sha256
parm:           ignore_msrs:bool
parm:           min_timer_period_us:uint
parm:           kvmclock_periodic_sync:bool
parm:           tsc_tolerance_ppm:uint
parm:           lapic_timer_advance_ns:uint
parm:           vector_hashing:bool
parm:           halt_poll_ns:uint
parm:           halt_poll_ns_grow:uint
parm:           halt_poll_ns_shrink:uint
┌──[root@liruilongs.github.io]-[/proc/sys/vm]
└─$ modinfo kvm | grep  ignore_msrs # 設定允許嵌套虛擬化
parm:           ignore_msrs:bool
┌──[root@liruilongs.github.io]-[/etc/modprobe.d]
└─$ echo "options kvm ignore_msrs=1" >> /etc/modprobe.d/kvm.conf  ##從起機器

如何限制服務的資源占用

資源消耗分為用戶和服務,消耗:CPU,記憶體和 I/O

經典的限制通過 pam_limit 模塊配合 /etc/security/limits.conf 實作(用戶)

用戶登錄會加載pam_limit模塊,pam_limit模塊讀取組態檔 /etc/security/limits.conf限制用戶資源的占用

┌──[root@liruilongs.github.io]-[/etc/modprobe.d]
└─$ cat /etc/security/limits.conf
# /etc/security/limits.conf
#
#This file sets the resource limits for the users logged in via PAM.
#It does not affect resource limits of the system services.
#
#Also note that configuration files in /etc/security/limits.d directory,
#which are read in alphabetical order, override the settings in this
#file in case the domain is the same or more specific.
#That means for example that setting a limit for wildcard domain here
#can be overriden with a wildcard setting in a config file in the
#subdirectory, but a user specific setting here can be overriden only
#with a user specific setting in the subdirectory.
#
#Each line describes a limit for a user in the form:
#
#<domain>        <type>  <item>  <value>
#
#Where:
#<domain> can be:
#        - a user name
#        - a group name, with @group syntax
#        - the wildcard *, for default entry
#        - the wildcard %, can be also used with %group syntax,
#                 for maxlogin limit
#
#<type> can have the two values:
#        - "soft" for enforcing the soft limits
#        - "hard" for enforcing hard limits
#
#<item> can be one of the following:
#        - core - limits the core file size (KB) 核心檔案大小
#        - data - max data size (KB)
#        - fsize - maximum filesize (KB)
#        - memlock - max locked-in-memory address space (KB)
#        - nofile - max number of open file descriptors # 訪問檔案數量
#        - rss - max resident set size (KB)
#        - stack - max stack size (KB)
#        - cpu - max CPU time (MIN)  # cup時間
#        - nproc - max number of processes
#        - as - address space limit (KB)
#        - maxlogins - max number of logins for this user #最多的登錄數
#        - maxsyslogins - max number of logins on the system
#        - priority - the priority to run user process with
#        - locks - max number of file locks the user can hold
#        - sigpending - max number of pending signals
#        - msgqueue - max memory used by POSIX message queues (bytes)
#        - nice - max nice priority allowed to raise to values: [-20, 19]
#        - rtprio - max realtime priority
#
#<domain>      <type>  <item>         <value>
#

#*               soft    core            0
#*               hard    rss             10000
#@student        hard    nproc           20
#@faculty        soft    nproc           20
#@faculty        hard    nproc           50
#ftp             hard    nproc           0
#@student        -       maxlogins       4

# End of file

限制服務的資源之限制用戶通過ssh的登錄數

┌──[root@liruilongs.github.io]-[/etc/modprobe.d]
└─$vim /etc/security/limits.conf
student       hard       maxlogins       4

也可以通過 cgroup 實作資源的限制(服務)

┌──[root@liruilongs.github.io]-[/etc/modprobe.d]
└─$ md5sum /dev/urandom & #啟動一個行程 cpu100%
[1] 38162
┌──[root@liruilongs.github.io]-[/etc/modprobe.d]
└─$ top
top - 13:37:42 up  4:10,  1 user,  load average: 1.03, 0.80, 0.43
Tasks: 158 total,   2 running, 156 sleeping,   0 stopped,   0 zombie
%Cpu(s):  2.0 us, 53.9 sy,  0.0 ni, 43.3 id,  0.0 wa,  0.0 hi,  0.8 si,  0.0 st
KiB Mem :  4030172 total,  3637840 free,   207252 used,   185080 buff/cache
KiB Swap: 10485756 total, 10485756 free,        0 used.  3575580 avail Mem

   PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
   861 etcd      20   0 10.254g  22572  11092 S   9.7  0.6  22:07.49 etcd
     9 root      20   0       0      0      0 S   1.7  0.0   0:28.00 rcu_sched
   595 root      20   0  298868   6260   4916 S   1.6  0.2   2:27.63 vmtoolsd
   371 root      20   0       0      0      0 S   0.4  0.0   1:23.11 xfsaild/sda1
     1 root      20   0   51688   3960   2624 S   0.4  0.1   0:31.08 systemd
 36765 root      20   0       0      0      0 S   0.2  0.0   0:03.13 kworker/1:0
   583 root      20   0   21616   1284    972 S   0.2  0.0   0:09.59 irqbalance
   857 root      20   0  573468  16760   6020 S   0.2  0.4   0:14.24 tuned
    13 root      20   0       0      0      0 S   0.2  0.0   0:06.16 ksoftirqd/1
   864 root      20   0 1015116  42652  13740 S   0.1  1.1   0:22.33 containerd
   853 root      20   0  228220   5128   3240 S   0.1  0.1   0:09.13 httpd
   594 root      20   0  224504  12424   3348 S   0.1  0.3   0:08.61 rsyslogd
   649 chrony    20   0  117704   1772   1312 S   0.1  0.0   0:03.47 chronyd
  7604 root      20   0  151984   5352   4088 R   0.1  0.1   0:05.89 sshd
 38166 root      20   0  161908   2264   1556 R   0.1  0.1   0:00.10 top
  1055 root      20   0   81744   3132   2168 S   0.0  0.1   0:10.09 pmdalinux
  8095 root      20   0       0      0      0 S   0.0  0.0   0:01.54 kworker/u256:0
    11 root      rt   0       0      0      0 S   0.0  0.0   0:02.17 watchdog/1
  1051 root      20   0   81628   2700   1912 S   0.0  0.1   0:03.07 pmdaproc
     2 root      20   0       0      0      0 S   0.0  0.0   0:00.09 kthreadd
     3 root      20   0       0      0      0 S   0.0  0.0   0:01.56 ksoftirqd/0
     5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:0H
     7 root      rt   0       0      0      0 S   0.0  0.0   0:01.08 migration/0
[1]+  Terminated              md5sum /dev/urandom
┌──[root@liruilongs.github.io]-[/etc/modprobe.d]
└─$

在這里插入圖片描述

現在我們把這個寫成一個服務,然后通過cgroup做簡單限制,

┌──[root@liruilongs.github.io]-[~]
└─$ vim /etc/systemd/system/md5sum.service
┌──[root@liruilongs.github.io]-[~]
└─$ cat /etc/systemd/system/md5sum.service
[Unit]
Description=MD5 Demo

[Service]
CPUQuota=40%
ExecStart=/usr/bin/md5sum /dev/urandom

[Install]
WantedBy=multi-user.target
┌──[root@liruilongs.github.io]-[~]
└─$
┌──[root@liruilongs.github.io]-[~]
└─$ systemctl daemon-reload
┌──[root@liruilongs.github.io]-[~]
└─$ systemctl start md5sum.service
┌──[root@liruilongs.github.io]-[~]
└─$ top
top - 19:12:14 up  9:44,  1 user,  load average: 0.29, 0.20, 0.11
Tasks: 159 total,   2 running, 157 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.5 us, 20.3 sy,  0.0 ni, 78.8 id,  0.0 wa,  0.0 hi,  0.4 si,  0.0 st
KiB Mem :  4030172 total,  3606960 free,   209832 used,   213380 buff/cache
KiB Swap: 10485756 total, 10485756 free,        0 used.  3558764 avail Mem

   PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
 59598 root      20   0  107920    612    516 R  39.7  0.0   0:02.54 md5sum  ##CPU限制為40%
   861 etcd      20   0 10.254g  22572  11092 S   6.3  0.6  51:24.88 etcd
 59601 root      20   0  161908   2268   1560 R   1.0  0.1   0:00.08 top
   595 root      20   0  298868   6260   4916 S   0.7  0.2   5:35.80 vmtoolsd
     1 root      20   0   51688   4000   2648 S   0.3  0.1   1:15.99 systemd
     9 root      20   0       0      0      0 S   0.3  0.0   0:50.90 rcu_sched
   371 root      20   0       0      0      0 S   0.3  0.0   3:02.41 xfsaild/sda1
  6671 root      20   0 1309148  66444  25620 S   0.3  1.6   0:48.35 dockerd
     2 root      20   0       0      0      0 S   0.0  0.0   0:00.13 kthreadd
     3 root      20   0       0      0      0 S   0.0  0.0   0:04.25 ksoftirqd/0
     5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:0H
     7 root      rt   0       0      0      0 S   0.0  0.0   0:02.39 migration/0
     8 root      20   0       0      0      0 S   0.0  0.0   0:00.00 rcu_bh
    10 root      rt   0       0      0      0 S   0.0  0.0   0:03.13 watchdog/0
    11 root      rt   0       0      0      0 S   0.0  0.0   0:04.80 watchdog/1
    12 root      rt   0       0      0      0 S   0.0  0.0   0:02.72 migration/1
    13 root      20   0       0      0      0 S   0.0  0.0   0:11.18 ksoftirqd/1
    15 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/1:0H
    17 root      20   0       0      0      0 S   0.0  0.0   0:00.11 kdevtmpfs
    18 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 netns
    19 root      20   0       0      0      0 S   0.0  0.0   0:00.08 khungtaskd
    20 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 writeback
    21 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kintegrityd
┌──[root@liruilongs.github.io]-[~]
└─$

這個具體小伙伴可以看看這篇博客: https://blog.csdn.net/sanhewuyang/article/details/120735766

關于cgroup引數設定可以使用幫助檔案

┌──[root@liruilongs.github.io]-[~]
└─$ man -k systemd
┌──[root@liruilongs.github.io]-[~]
└─$ man systemd.resource-control
┌──[root@liruilongs.github.io]-[~]
└─$

為 systemd unit 實作資源限制

這個老師沒講,以后研究下,應該也和cgroup有關

自定義tuned調優配置集

tuned 實作系統傻瓜化和集成化調優,作業系統預裝多個調優場景配置集,這是一道RHCAS的考試題

查看調優策略

┌──[root@liruilongs.github.io]-[~]
└─$ tuned-adm list
Available profiles:
- balanced                    - General non-specialized tuned profile
- desktop                     - Optimize for the desktop use-case
- latency-performance         - Optimize for deterministic performance at the cost of increased power consumption
- network-latency             - Optimize for deterministic performance at the cost of increased power consumption, focused on low latency network performance
- network-throughput          - Optimize for streaming network throughput, generally only necessary on older CPUs or 40G+ networks
- powersave                   - Optimize for low power consumption
- throughput-performance      - Broadly applicable tuning that provides excellent performance across a variety of common server workloads
- virtual-guest               - Optimize for running inside a virtual guest
- virtual-host                - Optimize for running KVM guests
Current active profile: virtual-guest
┌──[root@liruilongs.github.io]-[~]
└─$ tuned-adm recommend  # 查看推薦的策略
virtual-guest
┌──[root@liruilongs.github.io]-[~]
└─$ tuned-adm profile virtual-guest

調優策略位置

┌──[root@liruilongs.github.io]-[~]
└─$ cd /usr/lib/tuned/;ls ## 調優引數
balanced   latency-performance  powersave               virtual-guest
desktop    network-latency      recommend.conf          virtual-host
functions  network-throughput   throughput-performance
┌──[root@liruilongs.github.io]-[/usr/lib/tuned]
└─$ cd virtual-guest/
┌──[root@liruilongs.github.io]-[/usr/lib/tuned/virtual-guest]
└─$ ls
tuned.conf
┌──[root@liruilongs.github.io]-[/usr/lib/tuned/virtual-guest]
└─$ cat tuned.conf
#
# tuned configuration
#

[main]
summary=Optimize for running inside a virtual guest
include=throughput-performance

[sysctl]
# If a workload mostly uses anonymous memory and it hits this limit, the entire
# working set is buffered for I/O, and any more write buffering would require
# swapping, so it's time to throttle writes until I/O can catch up.  Workloads
# that mostly use file mappings may be able to use even higher values.
#
# The generator of dirty data starts writeback at this percentage (system default
# is 20%)
vm.dirty_ratio = 30

# Filesystem I/O is usually much more efficient than swapping, so try to keep
# swapping low.  It's usually safe to go even lower than this on systems with
# server-grade storage.
vm.swappiness = 30
┌──[root@liruilongs.github.io]-[/usr/lib/tuned/virtual-guest]
└─$

在/etc/tuned目錄中編輯自定義tuned profile,配置集中的條目可以相互參考,并通過各種plugin自定義
獲取 yum倉庫的tuned profile

┌──[root@liruilongs.github.io]-[/usr/lib/tuned/virtual-guest]
└─$ yum list | grep tuned
tuned.noarch                             2.8.0-5.el7                   @anaconda
tuned.noarch                             2.11.0-11.el7_9               updates
tuned-gtk.noarch                         2.11.0-11.el7_9               updates
tuned-profiles-atomic.noarch             2.11.0-11.el7_9               updates
tuned-profiles-compat.noarch             2.11.0-11.el7_9               updates
tuned-profiles-cpu-partitioning.noarch   2.11.0-11.el7_9               updates
tuned-profiles-mssql.noarch              2.11.0-11.el7_9               updates
tuned-profiles-oracle.noarch             2.11.0-11.el7_9               updates
tuned-utils.noarch                       2.11.0-11.el7_9               updates
tuned-utils-systemtap.noarch             2.11.0-11.el7_9               updates
┌──[root@liruilongs.github.io]-[/usr/lib/tuned/virtual-guest]
└─$ yum -y install tuned-profiles-oracle.noarch
....
┌──[root@liruilongs.github.io]-[/usr/lib/tuned/virtual-guest]
└─$ tuned-adm list
Available profiles:
- balanced                    - General non-specialized tuned profile
- desktop                     - Optimize for the desktop use-case
- hpc-compute                 - Optimize for HPC compute workloads
- latency-performance         - Optimize for deterministic performance at the cost of increased power consumption
- network-latency             - Optimize for deterministic performance at the cost of increased power consumption, focused on low latency network performance
- network-throughput          - Optimize for streaming network throughput, generally only necessary on older CPUs or 40G+ networks
- oracle                      - Optimize for Oracle RDBMS
- powersave                   - Optimize for low power consumption
- throughput-performance      - Broadly applicable tuning that provides excellent performance across a variety of common server workloads
- virtual-guest               - Optimize for running inside a virtual guest
- virtual-host                - Optimize for running KVM guests
Current active profile: virtual-guest
┌──[root@liruilongs.github.io]-[/usr/lib/tuned/virtual-guest]
└─$

通過SystemTap配置內核模塊進行系統底層分析:

嗯,這部分有些復雜,有些包需要訂閱,先記錄下,以后有機會學習

通過SystemTap配置內核模塊進行系統底層分析:
SystemTap 可以簡易的探索測量 kernel 中任意部件
Kernel開發者通過kprobe在kernel功能前后加入測驗代碼
SystemTap需要gcc,kernel-debuginfo,kernel-devel軟體支持
stap命令將*.stp腳本檔案編譯為kernel模塊,通過staprun命令運行

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/335354.html

標籤:其他

上一篇:【大資料】??搞定Hadoop集群??Hadoop運行模式-完全分布式

下一篇:在VMware上如何創建虛擬機以及安裝linux作業系統

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 網閘典型架構簡述

    網閘架構一般分為兩種:三主機的三系統架構網閘和雙主機的2+1架構網閘。 三主機架構分別為內端機、外端機和仲裁機。三機無論從軟體和硬體上均各自獨立。首先從硬體上來看,三機都用各自獨立的主板、記憶體及存盤設備。從軟體上來看,三機有各自獨立的作業系統。這樣能達到完全的三機獨立。對于“2+1”系統,“2”分為 ......

    uj5u.com 2020-09-10 02:00:44 more
  • 如何從xshell上傳檔案到centos linux虛擬機里

    如何從xshell上傳檔案到centos linux虛擬機里及:虛擬機CentOs下執行 yum -y install lrzsz命令,出現錯誤:鏡像無法找到軟體包 前言 一、安裝lrzsz步驟 二、上傳檔案 三、遇到的問題及解決方案 總結 前言 提示:其實很簡單,往虛擬機上安裝一個上傳檔案的工具 ......

    uj5u.com 2020-09-10 02:00:47 more
  • 一、SQLMAP入門

    一、SQLMAP入門 1、判斷是否存在注入 sqlmap.py -u 網址/id=1 id=1不可缺少。當注入點后面的引數大于兩個時。需要加雙引號, sqlmap.py -u "網址/id=1&uid=1" 2、判斷文本中的請求是否存在注入 從文本中加載http請求,SQLMAP可以從一個文本檔案中 ......

    uj5u.com 2020-09-10 02:00:50 more
  • Metasploit 簡單使用教程

    metasploit 簡單使用教程 浩先生, 2020-08-28 16:18:25 分類專欄: kail 網路安全 linux 文章標簽: linux資訊安全 編輯 著作權 metasploit 使用教程 前言 一、Metasploit是什么? 二、準備作業 三、具體步驟 前言 Msfconsole ......

    uj5u.com 2020-09-10 02:00:53 more
  • 游戲逆向之驅動層與用戶層通訊

    驅動層代碼: #pragma once #include <ntifs.h> #define add_code CTL_CODE(FILE_DEVICE_UNKNOWN,0x800,METHOD_BUFFERED,FILE_ANY_ACCESS) /* 更多游戲逆向視頻www.yxfzedu.com ......

    uj5u.com 2020-09-10 02:00:56 more
  • 北斗電力時鐘(北斗授時服務器)讓網路資料更精準

    北斗電力時鐘(北斗授時服務器)讓網路資料更精準 北斗電力時鐘(北斗授時服務器)讓網路資料更精準 京準電子科技官微——ahjzsz 近幾年,資訊技術的得了快速發展,互聯網在逐漸普及,其在人們生活和生產中都得到了廣泛應用,并且取得了不錯的應用效果。計算機網路資訊在電力系統中的應用,一方面使電力系統的運行 ......

    uj5u.com 2020-09-10 02:01:03 more
  • 【CTF】CTFHub 技能樹 彩蛋 writeup

    ?碎碎念 CTFHub:https://www.ctfhub.com/ 筆者入門CTF時時剛開始刷的是bugku的舊平臺,后來才有了CTFHub。 感覺不論是網頁UI設計,還是題目質量,賽事跟蹤,工具軟體都做得很不錯。 而且因為獨到的金幣制度的確讓人有一種想去刷題賺金幣的感覺。 個人還是非常喜歡這個 ......

    uj5u.com 2020-09-10 02:04:05 more
  • 02windows基礎操作

    我學到了一下幾點 Windows系統目錄結構與滲透的作用 常見Windows的服務詳解 Windows埠詳解 常用的Windows注冊表詳解 hacker DOS命令詳解(net user / type /md /rd/ dir /cd /net use copy、批處理 等) 利用dos命令制作 ......

    uj5u.com 2020-09-10 02:04:18 more
  • 03.Linux基礎操作

    我學到了以下幾點 01Linux系統介紹02系統安裝,密碼啊破解03Linux常用命令04LAMP 01LINUX windows: win03 8 12 16 19 配置不繁瑣 Linux:redhat,centos(紅帽社區版),Ubuntu server,suse unix:金融機構,證券,銀 ......

    uj5u.com 2020-09-10 02:04:30 more
  • 05HTML

    01HTML介紹 02頭部標簽講解03基礎標簽講解04表單標簽講解 HTML前段語言 js1.了解代碼2.根據代碼 懂得挖掘漏洞 (POST注入/XSS漏洞上傳)3.黑帽seo 白帽seo 客戶網站被黑帽植入劫持代碼如何處理4.熟悉html表單 <html><head><title>TDK標題,描述 ......

    uj5u.com 2020-09-10 02:04:36 more
最新发布
  • 2023年最新微信小程式抓包教程

    01 開門見山 隔一個月發一篇文章,不過分。 首先回顧一下《微信系結手機號資料庫被脫庫事件》,我也是第一時間得知了這個訊息,然后跟蹤了整件事情的經過。下面是這起事件的相關截圖以及近日流出的一萬條資料樣本: 個人認為這件事也沒什么,還不如關注一下之前45億快遞資料查詢渠道疑似在近日復活的訊息。 訊息是 ......

    uj5u.com 2023-04-20 08:48:24 more
  • web3 產品介紹:metamask 錢包 使用最多的瀏覽器插件錢包

    Metamask錢包是一種基于區塊鏈技術的數字貨幣錢包,它允許用戶在安全、便捷的環境下管理自己的加密資產。Metamask錢包是以太坊生態系統中最流行的錢包之一,它具有易于使用、安全性高和功能強大等優點。 本文將詳細介紹Metamask錢包的功能和使用方法。 一、 Metamask錢包的功能 數字資 ......

    uj5u.com 2023-04-20 08:47:46 more
  • vulnhub_Earth

    前言 靶機地址->>>vulnhub_Earth 攻擊機ip:192.168.20.121 靶機ip:192.168.20.122 參考文章 https://www.cnblogs.com/Jing-X/archive/2022/04/03/16097695.html https://www.cnb ......

    uj5u.com 2023-04-20 07:46:20 more
  • 從4k到42k,軟體測驗工程師的漲薪史,給我看哭了

    清明節一過,盲猜大家已經無心上班,在數著日子準備過五一,但一想到銀行卡里的余額……瞬間心情就不美麗了。最近,2023年高校畢業生就業調查顯示,本科畢業月平均起薪為5825元。調查一出,便有很多同學表示自己又被平均了。看著這一資料,不免讓人想到前不久中國青年報的一項調查:近六成大學生認為畢業10年內會 ......

    uj5u.com 2023-04-20 07:44:00 more
  • 最新版本 Stable Diffusion 開源 AI 繪畫工具之中文自動提詞篇

    🎈 標簽生成器 由于輸入正向提示詞 prompt 和反向提示詞 negative prompt 都是使用英文,所以對學習母語的我們非常不友好 使用網址:https://tinygeeker.github.io/p/ai-prompt-generator 這個網址是為了讓大家在使用 AI 繪畫的時候 ......

    uj5u.com 2023-04-20 07:43:36 more
  • 漫談前端自動化測驗演進之路及測驗工具分析

    隨著前端技術的不斷發展和應用程式的日益復雜,前端自動化測驗也在不斷演進。隨著 Web 應用程式變得越來越復雜,自動化測驗的需求也越來越高。如今,自動化測驗已經成為 Web 應用程式開發程序中不可或缺的一部分,它們可以幫助開發人員更快地發現和修復錯誤,提高應用程式的性能和可靠性。 ......

    uj5u.com 2023-04-20 07:43:16 more
  • CANN開發實踐:4個DVPP記憶體問題的典型案例解讀

    摘要:由于DVPP媒體資料處理功能對存放輸入、輸出資料的記憶體有更高的要求(例如,記憶體首地址128位元組對齊),因此需呼叫專用的記憶體申請介面,那么本期就分享幾個關于DVPP記憶體問題的典型案例,并給出原因分析及解決方法。 本文分享自華為云社區《FAQ_DVPP記憶體問題案例》,作者:昇騰CANN。 DVPP ......

    uj5u.com 2023-04-20 07:43:03 more
  • msf學習

    msf學習 以kali自帶的msf為例 一、msf核心模塊與功能 msf模塊都放在/usr/share/metasploit-framework/modules目錄下 1、auxiliary 輔助模塊,輔助滲透(埠掃描、登錄密碼爆破、漏洞驗證等) 2、encoders 編碼器模塊,主要包含各種編碼 ......

    uj5u.com 2023-04-20 07:42:59 more
  • Halcon軟體安裝與界面簡介

    1. 下載Halcon17版本到到本地 2. 雙擊安裝包后 3. 步驟如下 1.2 Halcon軟體安裝 界面分為四大塊 1. Halcon的五個助手 1) 影像采集助手:與相機連接,設定相機引數,采集影像 2) 標定助手:九點標定或是其它的標定,生成標定檔案及內參外參,可以將像素單位轉換為長度單位 ......

    uj5u.com 2023-04-20 07:42:17 more
  • 在MacOS下使用Unity3D開發游戲

    第一次發博客,先發一下我的游戲開發環境吧。 去年2月份買了一臺MacBookPro2021 M1pro(以下簡稱mbp),這一年來一直在用mbp開發游戲。我大致分享一下我的開發工具以及使用體驗。 1、Unity 官網鏈接: https://unity.cn/releases 我一般使用的Apple ......

    uj5u.com 2023-04-20 07:40:19 more