LinuxレポートResource temporarily unavailable問題解決レコードについて


目次
 
イベントレコード
ソリューション

イベントレコード


今日、テスト環境でrootユーザーからinmgrユーザーにアプリケーションを移行する必要があるため、inmgrユーザーを作成して直接移行しました.5分後にアプリケーションに直接OOM異常が発生し、インターネットで確認すると、新しいユーザーLinuxシステムがユーザーの最大プロセス数を制限します.アプリケーションがプロセス数を満たすと、どのコマンドを実行してもレポートされます.
/bin/bash: Resource temporarily unavailable。

新規ユーザのプロセス数制限は、一般に1024または2048である.

ソリューション


このサーバを例にとります.
  • rootユーザーを使用してログインし、/etc/security/limits.d/:
    [root@VM_3_220_centos ~]$ cd /etc/security/limits.d/
    [root@VM_3_220_centos limits.d]$ ll
    total 8
    -rw-r--r-- 1 root root 195 Aug 29  2017 20-nproc.conf
    -rw-r--r-- 1 root root  60 Apr 21  2016 80-nofile.conf
  • に入ります.
  • 編集20-nproc.conf:
    [root@VM_3_220_centos limits.d]$ vim 20-nproc.conf 
     
  • 以下の情報を追加する:
    inmgr      soft    nproc     60000
    追加後のファイル内容は:
    # Default limit for number of user's processes to prevent
    # accidental fork bombs.
    # See rhbz #432903 for reasoning.
    
    *          soft    nproc     4096
    root       soft    nproc     unlimited
    inmgr      soft    nproc     60000
  • であるべきである.
  • /etc/security/limits.confを編集し、以下の内容を追加します:
    inmgr soft nproc 60000
    inmgr hard nproc 65535
    inmgr soft nofile 60000
    inmgr hard bofile 65535
    編集後のファイルの内容は:
    # End of file
    * soft nofile 100001
    * hard nofile 100002
    root soft nofile 100001
    root hard nofile 100002
    inmgr soft nproc 65535
    inmgr hard nproc 65535
    inmgr soft nofile 60000
    inmgr hard nofile 65535
    nproc:max number of processesnofileを表します:max number of open file descriptorshard/soft:softは警告値で、hardは本当の意味のバルブ値で、超えるとエラーが報告されます.
  • は再びinmgrユーザーに切り替えられ、ulimit -a:
    [inmgr@VM_3_220_centos ~]$ ulimit -a
    core file size          (blocks, -c) 0
    data seg size           (kbytes, -d) unlimited
    scheduling priority             (-e) 0
    file size               (blocks, -f) unlimited
    pending signals                 (-i) 7271
    max locked memory       (kbytes, -l) 64
    max memory size         (kbytes, -m) unlimited
    open files                      (-n) 65535
    pipe size            (512 bytes, -p) 8
    POSIX message queues     (bytes, -q) 819200
    real-time priority              (-r) 0
    stack size              (kbytes, -s) 8192
    cpu time               (seconds, -t) unlimited
    max user processes              (-u) 65535
    virtual memory          (kbytes, -v) unlimited
    file locks                      (-x) unlimited
    を実行すると、最大プロセス数が65535に変更されたことがわかります.アプリケーションを再起動してもOOM異常は発生しません.