MENU
  • VPS(レンタルサーバ)比較
  • ITエンジニアの転職
  • IT技術入門(Engineers.LOG)
カテゴリー
  • IT関連 (623)
    • Bootstrap (2)
    • クラウド (4)
    • サーバー技術 (185)
    • ストレージ (7)
      • NetApp (7)
    • ネットワーク技術 (91)
      • Cisco (36)
      • Juniper (18)
      • 負荷分散装置 (17)
    • パソコン関連 (92)
      • MAC (25)
      • Windows (54)
    • プログラミング (154)
      • Ansible (11)
      • C言語 (23)
      • Python (111)
        • Django (20)
    • 仮想化 (88)
      • Docker (63)
      • VMware (23)
  • VPS (200)
    • ABLENET VPS (16)
    • Amazon Lightsail(VPS) (2)
    • ConoHaVPS (37)
    • mixhostVPS (4)
    • WebARENAIndigo (16)
    • XServerVPS (34)
    • お名前.com VPS (12)
    • さくらのVPS (24)
    • カゴヤクラウドVPS (13)
    • シンVPS (7)
  • レンタルサーバー (56)
    • エックスサーバー (38)
  • 光回線 (8)
  • 技術スキルアップ開発・学習 (7)
    • Envader (2)
    • RareTECH (2)
    • Udemy (3)
もう現役20年超えましたー。経験値ならだれにも負けないエンジニア技術ブログ
インフラエンジニアの技術LOG
  • VPS(レンタルサーバ)比較
  • ITエンジニアの転職
  • IT技術入門(Engineers.LOG)
インフラエンジニアの技術LOG
  • VPS(レンタルサーバ)比較
  • ITエンジニアの転職
  • IT技術入門(Engineers.LOG)
  1. ホーム
  2. IT関連
  3. サーバー技術
  4. 【CentOS8】systemdのCPU使用率が高騰し100%になる問題解決

【CentOS8】systemdのCPU使用率が高騰し100%になる問題解決

2020 8/19
サーバー技術
2020年7月11日2020年8月19日

CentOS8で構築したWebサイトが最近なぜか重く感じるようになりました。
アクセスしても表示されるのが著しく遅いので、サーバーを確認してみるとCPUが高騰し、100%近くで張り付いている状況でした。

今回の問題を解決したのでメモをしておきます。

目次
安くて高速!高性能VPSで快適開発!
最速5分でサーバー構築
>>>こちらをチェック

エンジニア必見! 技術力を伸ばすVPS徹底比較
>>>VPS比較

「CentOS8」systemd+というユーザーがCPU使用率が高騰する問題を解決

事象は以下の状態となりますう。
topコマンドを実行した際、「syytemd+」というユーザーがCPU使用率をほとんど使用している状態となっています。

$ top

top - 21:06:50 up 63 days,  5:04,  1 user,  load average: 1.83, 1.84, 1.92
Tasks: 110 total,   1 running, 109 sleeping,   0 stopped,   0 zombie
%Cpu(s): 97.0 us,  2.0 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.7 hi,  0.3 si,  0.0 st
MiB Mem :    477.5 total,      5.4 free,    375.5 used,     96.6 buff/cache
MiB Swap:   2048.0 total,   1616.5 free,    431.5 used.     88.4 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
 2622 systemd+  20   0  306068 264112      4 S  94.4  54.0  14568:36 ei74G1
30728 root      20   0  622060  13988      0 S   4.7   2.9 305:10.66 python
 5710 root      20   0   63336   4404   3632 R   0.3   0.9   0:00.01 top
    1 root      20   0   94340  10612   8188 S   0.0   2.2   4:39.94 systemd
    2 root      20   0       0      0      0 S   0.0   0.0   0:00.95 kthreadd

上記で「systemd+」のCPU使用率が頭打ちしているので、以下の対応をしました。

暫定対応

一時的な対応として、systemctlのサービス再起動を実施しました。
このコマンドはサービスに影響がないということもあり、サービス影響に支障なく対応したい場合に使用します。

ちなみに、私のwebサーバーでは一時的に効果はありました。

$ systemctl daemon-reexec

恒久対応

恒久対応は、systemdをアップデートします。
いろいろと調べてみると、systemdのバグがあるようで、アップデートすることで改善されているようです。

以下で、「yum info」コマンドを実施した際の例となります。

$ yum info installed systemd
Failed to set locale, defaulting to C.UTF-8
Modular dependency problem:

 Problem: conflicting requests
  - nothing provides module(perl:5.26) needed by module perl-DBI:1.641:8010020191113222731:16b3ab4d-0.x86_64
Installed Packages
Name         : systemd
Version      : 239
Release      : 18.el8_1.5
Architecture : x86_64
Size         : 16 M
Source       : systemd-239-18.el8_1.5.src.rpm
Repository   : @System
From repo    : BaseOS
Summary      : System and Service Manager
URL          : http://www.freedesktop.org/wiki/Software/systemd
License      : LGPLv2+ and MIT and GPLv2+
Description  : systemd is a system and service manager that runs as PID 1 and starts
             : the rest of the system. It provides aggressive parallelization
             : capabilities, uses socket and D-Bus activation for starting services,
             : offers on-demand starting of daemons, keeps track of processes using
             : Linux control groups, maintains mount and automount points, and
             : implements an elaborate transactional dependency-based service control
             : logic. systemd supports SysV and LSB init scripts and works as a
             : replacement for sysvinit. Other parts of this package are a logging daemon,
             : utilities to control basic system configuration like the hostname,
             : date, locale, maintain a list of logged-in users, system accounts,
             : runtime directories and settings, and daemons to manage simple network
             : configuration, network time synchronization, log forwarding, and name
             : resolution.

systemdをアップデートできそうなので実施します。

$ yum update systemd

最後にOSの再起動もしておきます。

$ shutdown -r now

「systemd」アップデート後に事象改善

「systemd」アップデート後のCPU使用率ですが、以下の通り、CPUの頭打ちはなくなり、Webサーバーの動作も軽くなりました。

top - 00:23:05 up  2:49,  1 user,  load average: 0.08, 0.08, 0.02
Tasks: 122 total,   2 running, 120 sleeping,   0 stopped,   0 zombie
%Cpu(s):  1.3 us,  1.3 sy,  0.0 ni, 97.2 id,  0.0 wa,  0.2 hi,  0.0 si,  0.0 st
MiB Mem :    821.3 total,     95.7 free,    288.2 used,    437.4 buff/cache
MiB Swap:   2048.0 total,   2039.2 free,      8.8 used.    385.8 avail Mem

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
   5766 root      20   0  277312  43968  12704 S   5.0   5.2   9:00.15 python
   6550 root      20   0   67424   4952   4176 R   0.3   0.6   0:00.06 top
      1 root      20   0  176748  10776   8296 S   0.0   1.3   0:01.44 systemd
      2 root      20   0       0      0      0 S   0.0   0.0   0:00.00 kthreadd
      3 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_gp
      4 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_par+
      6 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 kworker+
      8 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 mm_perc+

今回の件とは違いますが、以下参考URLを参考にしました。
https://yomon.hatenablog.com/entry/2017/03/23/103419

systemd+CPU高騰再発

上記を実施しましたが、また再発をしたので以下を実施してみました。

$ vim /etc/systemd/resolved.conf

DNSStubListener=no

上記設定後、再起動を実施

$ service systemd-resolved restart

これでいったん様子見してみます。
参考URL:
https://itectec.com/ubuntu/ubuntu-systemd-resolve-high-cpu-usage-after-update-to-17-04/

CentOS8でsystemdでCPUが頭打ちしている方は参考にしてください。

あわせて読みたい
サーバーエンジニアへの構築手順書 サーバエンジニアにおすすめの構築手順をまとめたページです。 サーバ初心者の方。じぶんも初心者なので、そっから目線で構築した設計手順書となっています。 ご興味の...
エンジニアスキルをアップする勉強法

ITエンジニアの開発・検証・学習としてインターネット上で専用のサーバ(VPS)を利用しましょう!
実務経験はVPSで学べます。

あわせて読みたい
現役エンジニアがおすすめするVPSレンタルサーバ比較(高速SSD限定) 格安VPS比較(2025年最新版)

サーバー技術
よかったらシェアしてね!
  • URLをコピーしました!
  • URLをコピーしました!

コメント

コメントする コメントをキャンセル

email confirm*

post date*

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)



検索
カテゴリー
新着記事
  • XServerVPS アニメ風 男の子 プログラミングをしている VPSを利用している 楽しそうにしている
    XServerVPSで証明書(SSL)を取得する方法
    2025年3月24日
    XServerVPS
  • レンタルサーバ アニメ風 女の子 楽しんでパソコンをしている 目がキラキラ
    WordPressがレンタルサーバよりVPSで利用する方がおすすめの理由
    2025年3月19日
    VPS
  • VPS レンタルサーバー アニメ風 女の子 プログラミングをしている VPSを利用している 楽しそうにしている
    VPSとクラウドの違いとは?初心者向けにわかりやすく解説
    2025年3月5日
    VPS
  • シンVPS アニメ風 女の子 パソコン プログラミングをしている VPSを利用している 楽しそうにしている
    シンVPSはWindows serverを利用できない。その理由と利用できるOSは?
    2025年3月4日
    シンVPS
  • シンVPS アニメ風 女の子 パソコン プログラミングをしている VPSを利用している 楽しそうにしている
    シンVPSでゲームを利用する環境はあるのか
    2025年3月4日
    シンVPS
  • シンVPS アニメ風 女の子 パソコン プログラミングをしている VPSを利用している 楽しそうにしている
    シンVPSのサイトの表示速度は他社に比べて早いのか?
    2025年3月4日
    シンVPS
目次
目次